Changeset d1df9b for src/molecules.cpp


Ignore:
Timestamp:
Jul 10, 2009, 9:01:40 PM (16 years ago)
Author:
Frederik Heber <heber@…>
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:
205ccd
Parents:
6cb412
git-author:
Frederik Heber <heber@…> (07/10/09 20:21:12)
git-committer:
Frederik Heber <heber@…> (07/10/09 21:01:40)
Message:

new class ConfigFileBuffer and new overloaded function ParseForParaneter() based on this buffer

  • the problem is that we need to use molecuilder for the periodic translating of atoms in a xzy file. However, molecuilder resorts them per element. This destroty the id mapping needed for the DBOND file. The storing was corrected, but also the loading relies on this order.
  • To solve this, we have to pull off quite something: Parse file into buffer, resort the Ion_Type ones (via a map only), load atoms and then put them into the molecule in the original order!
  • Hence, in config::Load we also have a LinearList (map<int, atom*>) in order to add the atoms after the scanning in their original order into the molecule.
  • class ConfigFileBuffer parses a config file line-wise into a buffer and allows for resorting (via a map) of lines containing key_word Ion_Type.
  • BUGFIX: molecule::Output...() were writing the wrong elements, as they were numbered during the output and not before in ascending order! (I.e. if the first atom is Si, but there is also H present, then this Si would become Ion_Type1_1 instead of Ion_Type2_1, because the elements are still sorted by their Z value, hence Ion_Type1 is H!)

This is basically tested and seems to work properly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/molecules.cpp

    r6cb412 rd1df9b  
    14711471        atom *walker = NULL;
    14721472        int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS];
    1473         int CurrentMaxElement = 0;
    14741473        CountElements();
    14751474
     
    14851484    while (walker->next != end) { // go through every atom of this element
    14861485      walker = walker->next;
    1487       if (ElementNo[walker->type->Z] == 0) // new element
    1488         ElementNo[walker->type->Z] = ++CurrentMaxElement;
     1486      ElementNo[walker->type->Z] = 1;
     1487    }
     1488    int current=1;
     1489    for (int i=0;i<MAX_ELEMENTS;++i) {
     1490      if (ElementNo[i] == 1)
     1491        ElementNo[i] = current++;
     1492    }
     1493    walker = start;
     1494    while (walker->next != end) { // go through every atom of this element
     1495      walker = walker->next;
    14891496      AtomNo[walker->type->Z]++;
    14901497      walker->Output(ElementNo[walker->type->Z], AtomNo[walker->type->Z], out); // removed due to trajectories
     
    15011508        atom *walker = NULL;
    15021509  int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS];
    1503   int CurrentMaxElement = 0;
    15041510        CountElements();
    15051511
     
    15171523                    ElementNo[i] = 0;
    15181524                  }
    1519       walker = start;
     1525    walker = start;
     1526    while (walker->next != end) { // go through every atom of this element
     1527      walker = walker->next;
     1528      ElementNo[walker->type->Z] = 1;
     1529    }
     1530    int current=1;
     1531    for (int i=0;i<MAX_ELEMENTS;++i) {
     1532      if (ElementNo[i] == 1)
     1533        ElementNo[i] = current++;
     1534    }
     1535    walker = start;
    15201536      while (walker->next != end) { // go through every atom of this element
    15211537        walker = walker->next;
    1522         if (ElementNo[walker->type->Z] == 0) // new element
    1523           ElementNo[walker->type->Z] = ++CurrentMaxElement;
    15241538        AtomNo[walker->type->Z]++;
    15251539        *out << "Ion_Type" << ElementNo[walker->type->Z] << "_" << AtomNo[walker->type->Z] << "\t"      << fixed << setprecision(9) << showpoint;
Note: See TracChangeset for help on using the changeset viewer.