source: src/analysis_bonds.cpp@ f2bb0f

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since f2bb0f was 9879f6, checked in by Frederik Heber <heber@…>, 15 years ago

Huge Refactoring due to class molecule now being an STL container.

  • molecule::start and molecule::end were dropped. Hence, the usual construct Walker = start while (Walker->next != end) {

Walker = walker->next
...

}
was changed to
for (molecule::iterator iter = begin(); iter != end(); ++iter) {

...

}
and (*iter) used instead of Walker.

  • Two build errors remain (beside some more in folder Actions, Patterns and unittest) in molecule_pointcloud.cpp and molecule.cpp
  • lists.cpp was deleted as specialization of atom* was not needed anymore
  • link, unlink, add, remove, removewithoutcheck all are not needed for atoms anymore, just for bonds (where first, last entries remain in molecule)
  • CreateFatherLookupTable() was put back into class molecule.
  • molecule::InternalPointer is now an iterator
  • class PointCloud: GoToPrevious() and GetTerminalPoint() were dropped as not needed.
  • some new STL functions in class molecule: size(), empty(), erase(), find() and insert()
  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*
2 * analysis_bonds.cpp
3 *
4 * Created on: Nov 7, 2009
5 * Author: heber
6 */
7
8#include "analysis_bonds.hpp"
9#include "atom.hpp"
10#include "bond.hpp"
11#include "log.hpp"
12#include "molecule.hpp"
13
14/** Calculates the min, mean and maximum bond counts for the given molecule.
15 * \param *mol molecule with atoms and atom::ListOfBonds
16 * \param &Min minimum count on return
17 * \param &Mean mean count on return
18 * \param &Max maximum count on return
19 */
20void GetMaxMinMeanBondCount(const molecule * const mol, double &Min, double &Mean, double &Max)
21{
22 Min = 2e+6;
23 Max = -2e+5;
24 Mean = 0.;
25
26 int AtomCount = 0;
27 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
28 const int count = (*iter)->ListOfBonds.size();
29 if (Max < count)
30 Max = count;
31 if (Min > count)
32 Min = count;
33 Mean += count;
34 AtomCount++;
35 }
36 if (((int)Mean % 2) != 0)
37 eLog() << Verbose(1) << "Something is wrong with the bond structure, the number of bonds is not even!" << endl;
38 Mean /= (double)AtomCount;
39};
40
41/** Calculates the min and max bond distance of all atoms of two given elements.
42 * \param *mol molecule with atoms
43 * \param *type1 one element
44 * \param *type2 other element
45 * \param &Min minimum distance on return, 0 if no bond between the two elements
46 * \param &Mean mean distance (i.e. sum of distance for matching element pairs, divided by number) on return, 0 if no bond between the two elements
47 * \param &Max maximum distance on return, 0 if no bond between the two elements
48 */
49void MinMeanMaxBondDistanceBetweenElements(const molecule *mol, element *type1, element *type2, double &Min, double &Mean, double &Max)
50{
51 Min = 2e+6;
52 Mean = 0.;
53 Max = -2e+6;
54
55 int AtomNo = 0;
56 for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
57 if ((*iter)->type == type1)
58 for (BondList::const_iterator BondRunner = (*iter)->ListOfBonds.begin(); BondRunner != (*iter)->ListOfBonds.end(); BondRunner++)
59 if ((*BondRunner)->GetOtherAtom((*iter))->type == type2) {
60 const double distance = (*BondRunner)->GetDistanceSquared();
61 if (Min > distance)
62 Min = distance;
63 if (Max < distance)
64 Max = distance;
65 Mean += sqrt(distance);
66 AtomNo++;
67 }
68 }
69 if (Max < 0) {
70 Max = Min = 0.;
71 } else {
72 Max = sqrt(Max);
73 Min = sqrt(Min);
74 Mean = Mean/(double)AtomNo;
75 }
76};
Note: See TracBrowser for help on using the repository browser.