Changeset 389cc8
- Timestamp:
- Jul 21, 2010, 1:09:30 PM (15 years ago)
- Branches:
- 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
- Children:
- 574ddc1
- Parents:
- 6f43ab
- Location:
- src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/config.cpp
r6f43ab r389cc8 1031 1031 { 1032 1032 bool result = true; 1033 // bring MaxTypes up to date1034 mol->CountElements();1035 1033 const Matrix &domain = World::getInstance().getDomain().getM(); 1036 1034 ofstream * const output = new ofstream(filename, ios::out); … … 1138 1136 *output << "IsAngstroem\t" << config::IsAngstroem << "\t# 0 - Bohr, 1 - Angstroem" << endl; 1139 1137 *output << "RelativeCoord\t" << config::RelativeCoord << "\t# whether ion coordinates are relative (1) or absolute (0)" << endl; 1140 *output << "MaxTypes\t" << mol-> ElementCount<< "\t# maximum number of different ion types" << endl;1138 *output << "MaxTypes\t" << mol->getElementCount() << "\t# maximum number of different ion types" << endl; 1141 1139 *output << endl; 1142 1140 result = result && mol->Checkout(output); … … 1533 1531 mol->SetNameFromFilename(ConfigFileName); 1534 1532 molecules->SimpleMultiMerge(mol, src, N); 1535 mol->doCountAtoms();1536 mol->CountElements();1537 1533 //mol->CalculateOrbitals(*this); 1538 1534 delete[](src); -
src/molecule.cpp
r6f43ab r389cc8 49 49 molecule::molecule(const periodentafel * const teil) : 50 50 Observable("molecule"), 51 elemente(teil), MDSteps(0), BondCount(0), ElementCount(0),NoNonHydrogen(0), NoNonBonds(0),51 elemente(teil), MDSteps(0), BondCount(0), NoNonHydrogen(0), NoNonBonds(0), 52 52 NoCyclicBonds(0), BondDistance(0.), ActiveFlag(false), IndexNr(-1), 53 formula(this,boost::bind(&molecule::calcFormula,this),"formula"),54 53 AtomCount(this,boost::bind(&molecule::doCountAtoms,this),"AtomCount"), last_atom(0), InternalPointer(atoms.begin()) 55 54 { 56 55 57 // other stuff58 for(int i=MAX_ELEMENTS;i--;)59 ElementsInMolecule[i] = 0;60 56 strcpy(name,World::getInstance().getDefaultName().c_str()); 61 57 }; … … 102 98 103 99 const std::string molecule::getFormula(){ 104 return *formula;100 return formula.toString(); 105 101 } 106 102 … … 118 114 } 119 115 return sstr.str(); 116 } 117 118 unsigned int molecule::getElementCount(){ 119 return formula.getElementCount(); 120 } 121 122 bool molecule::hasElement(const element *element) const{ 123 return formula.hasElement(element); 124 } 125 126 bool molecule::hasElement(atomicNumber_t Z) const{ 127 return formula.hasElement(Z); 128 } 129 130 bool molecule::hasElement(const string &shorthand) const{ 131 return formula.hasElement(shorthand); 120 132 } 121 133 … … 210 222 pointer->sort = &pointer->nr; 211 223 if (pointer->type != NULL) { 212 if (ElementsInMolecule[pointer->type->Z] == 0) 213 ElementCount++; 214 ElementsInMolecule[pointer->type->Z]++; // increase number of elements 224 formula += pointer->type; 215 225 if (pointer->type->Z != 1) 216 226 NoNonHydrogen++; … … 651 661 652 662 // copy values 653 copy->CountElements();654 663 if (hasBondStructure()) { // if adjaceny list is present 655 664 copy->BondDistance = BondDistance; … … 774 783 ASSERT(pointer, "Null pointer passed to molecule::RemoveAtom()."); 775 784 OBSERVE; 776 if (ElementsInMolecule[pointer->type->Z] != 0) { // this would indicate an error 777 ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element 778 } else 779 DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->getName() << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl); 780 if (ElementsInMolecule[pointer->type->Z] == 0) // was last atom of this element? 781 ElementCount--; 785 formula-=pointer->type; 782 786 RemoveBonds(pointer); 783 787 erase(pointer); … … 793 797 if (pointer == NULL) 794 798 return false; 795 if (ElementsInMolecule[pointer->type->Z] != 0) // this would indicate an error 796 ElementsInMolecule[pointer->type->Z]--; // decrease number of atom of this element 797 else 798 DoeLog(1) && (eLog()<< Verbose(1) << "Atom " << pointer->getName() << " is of element " << pointer->type->Z << " but the entry in the table of the molecule is 0!" << endl); 799 if (ElementsInMolecule[pointer->type->Z] == 0) // was last atom of this element? 800 ElementCount--; 799 formula-=pointer->type; 801 800 erase(pointer); 802 801 return true; … … 871 870 { 872 871 int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS]; 873 CountElements();874 872 875 873 for (int i=0;i<MAX_ELEMENTS;++i) { … … 898 896 { 899 897 int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS]; 900 CountElements();901 898 902 899 if (output == NULL) { … … 940 937 bool molecule::Checkout(ofstream * const output) const 941 938 { 942 return elemente->Checkout(output, ElementsInMolecule);939 return formula.checkOut(output); 943 940 }; 944 941 … … 998 995 }; 999 996 1000 /** Brings molecule::ElementCount and molecule::ElementsInMolecule up-to-date.1001 */1002 void molecule::CountElements()1003 {1004 for(int i=MAX_ELEMENTS;i--;)1005 ElementsInMolecule[i] = 0;1006 ElementCount = 0;1007 1008 SetIndexedArrayForEachAtomTo ( ElementsInMolecule, &element::Z, &Increment, 1);1009 1010 for(int i=MAX_ELEMENTS;i--;)1011 ElementCount += (ElementsInMolecule[i] != 0 ? 1 : 0);1012 };1013 1014 997 /** Determines whether two molecules actually contain the same atoms and coordination. 1015 998 * \param *out output stream for debugging … … 1030 1013 /// first count both their atoms and elements and update lists thereby ... 1031 1014 //Log() << Verbose(0) << "Counting atoms, updating list" << endl; 1032 CountElements();1033 OtherMolecule->CountElements();1034 1015 1035 1016 /// ... and compare: … … 1041 1022 } else Log() << Verbose(4) << "AtomCounts match: " << getAtomCount() << " == " << OtherMolecule->getAtomCount() << endl; 1042 1023 } 1043 /// -# ElementCount1024 /// -# Formula 1044 1025 if (result) { 1045 if ( ElementCount != OtherMolecule->ElementCount) {1046 DoLog(4) && (Log() << Verbose(4) << " ElementCount don't match: " << ElementCount << " == " << OtherMolecule->ElementCount<< endl);1026 if (formula != OtherMolecule->formula) { 1027 DoLog(4) && (Log() << Verbose(4) << "Formulas don't match: " << formula << " == " << OtherMolecule->formula << endl); 1047 1028 result = false; 1048 } else Log() << Verbose(4) << "ElementCount match: " << ElementCount << " == " << OtherMolecule->ElementCount << endl; 1049 } 1050 /// -# ElementsInMolecule 1051 if (result) { 1052 for (flag=MAX_ELEMENTS;flag--;) { 1053 //Log() << Verbose(5) << "Element " << flag << ": " << ElementsInMolecule[flag] << " <-> " << OtherMolecule->ElementsInMolecule[flag] << "." << endl; 1054 if (ElementsInMolecule[flag] != OtherMolecule->ElementsInMolecule[flag]) 1055 break; 1056 } 1057 if (flag < MAX_ELEMENTS) { 1058 DoLog(4) && (Log() << Verbose(4) << "ElementsInMolecule don't match." << endl); 1059 result = false; 1060 } else Log() << Verbose(4) << "ElementsInMolecule match." << endl; 1029 } else Log() << Verbose(4) << "Formulas match: " << formula << " == " << OtherMolecule->formula << endl; 1061 1030 } 1062 1031 /// then determine and compare center of gravity for each molecule ... -
src/molecule.hpp
r6f43ab r389cc8 28 28 #include "Patterns/ObservedIterator.hpp" 29 29 #include "Patterns/Cacheable.hpp" 30 #include "Formula.hpp" 30 31 31 32 #include "Descriptors/MoleculeDescriptor_impl.hpp" … … 97 98 //int AtomCount; //!< number of atoms, brought up-to-date by CountAtoms() 98 99 int BondCount; //!< number of atoms, brought up-to-date by CountBonds() 99 int ElementCount; //!< how many unique elements are therein100 int ElementsInMolecule[MAX_ELEMENTS]; //!< list whether element (sorted by atomic number) is alread present or not101 100 mutable int NoNonHydrogen; //!< number of non-hydrogen atoms in molecule 102 101 mutable int NoNonBonds; //!< number of non-hydrogen bonds in molecule … … 109 108 110 109 private: 111 Cacheable<string>formula;110 Formula formula; 112 111 Cacheable<int> AtomCount; 113 112 moleculeId_t id; … … 137 136 const std::string getFormula(); 138 137 std::string calcFormula(); 138 unsigned int getElementCount(); 139 bool hasElement(const element*) const; 140 bool hasElement(atomicNumber_t) const; 141 bool hasElement(const std::string&) const; 142 139 143 140 144 iterator begin(); … … 254 258 255 259 /// Count and change present atoms' coordination. 256 void CountElements();257 260 bool CenterInBox(); 258 261 bool BoundInBox(); -
src/molecule_dynamics.cpp
r6f43ab r389cc8 560 560 ForceMatrix Force; 561 561 562 CountElements(); // make sure ElementsInMolecule is up to date563 564 562 const int AtomCount = getAtomCount(); 565 563 // check file -
src/moleculelist.cpp
r6f43ab r389cc8 597 597 periodentafel::const_iterator elemIter; 598 598 for(elemIter=periode->begin();elemIter!=periode->end();++elemIter){ 599 if ((*ListRunner)-> ElementsInMolecule[(*elemIter).first]) { // if this element got atoms599 if ((*ListRunner)->hasElement((*elemIter).first)) { // if this element got atoms 600 600 for(molecule::iterator atomIter = (*ListRunner)->begin(); atomIter !=(*ListRunner)->end();++atomIter){ 601 601 if ((*atomIter)->type->getNumber() == (*elemIter).first) { … … 689 689 690 690 // also calculate necessary orbitals 691 (*ListRunner)->CountElements(); // this is a bugfix, atoms should shoulds actually be added correctly to this fragment692 691 //(*ListRunner)->CalculateOrbitals(*World::getInstance().getConfig); 693 692 -
src/periodentafel.cpp
r6f43ab r389cc8 205 205 for(const_iterator iter=elements.begin(); iter !=elements.end();++iter){ 206 206 result = result && (*iter).second->Output(output); 207 }208 return result;209 } else210 return false;211 };212 213 /** Prints period table to given stream.214 * \param *output output stream215 * \param *checkliste elements table for this molecule216 */217 bool periodentafel::Checkout(ostream * const output, const int * const checkliste) const218 {219 bool result = true;220 int No = 1;221 222 if (output != NULL) {223 *output << "# Ion type data (PP = PseudoPotential, Z = atomic number)" << endl;224 *output << "#Ion_TypeNr.\tAmount\tZ\tRGauss\tL_Max(PP)L_Loc(PP)IonMass\t# chemical name, symbol" << endl;225 for(const_iterator iter=elements.begin(); iter!=elements.end();++iter){226 if (((*iter).first < MAX_ELEMENTS) && (checkliste[(*iter).first])) {227 (*iter).second->No = No;228 result = result && (*iter).second->Checkout(output, No++, checkliste[(*iter).first]);229 }230 207 } 231 208 return result; -
src/periodentafel.hpp
r6f43ab r389cc8 57 57 reverse_iterator rend(); 58 58 bool Output(std::ostream * const output) const; 59 bool Checkout(std::ostream * const output, const int * const checkliste) const;60 59 bool LoadPeriodentafel(const char * const path); 61 60 bool StorePeriodentafel(const char * const path) const;
Note:
See TracChangeset
for help on using the changeset viewer.