Changeset 882a8a for src


Ignore:
Timestamp:
Aug 26, 2010, 11:02:41 AM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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:
e8a21f
Parents:
487ebb
Message:

made the atom::OutputTrajectories() method use an enumeration of elements instead of lookup table

Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/atom.cpp

    r487ebb r882a8a  
    218218  * \return true - \a *out present, false - \a *out is NULL
    219219 */
    220 bool atom::OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const
     220bool atom::OutputTrajectory(ofstream * const out, const enumeration<const element*> &elementLookup, int *AtomNo, const int step) const
    221221{
    222222  AtomNo[getType()->getAtomicNumber()]++;
    223223  if (out != NULL) {
    224     *out << "Ion_Type" << ElementNo[getType()->getAtomicNumber()] << "_" << AtomNo[getType()->getAtomicNumber()] << "\t"  << fixed << setprecision(9) << showpoint;
     224    const element *elemental = getType();
     225    ASSERT(elementLookup.there.find(elemental)!=elementLookup.there.end(),"Type of this atom was not in the formula upon enumeration");
     226    *out << "Ion_Type" << elementLookup.there.find(elemental)->second << "_" << AtomNo[getType()->getAtomicNumber()] << "\t"  << fixed << setprecision(9) << showpoint;
    225227    *out << Trajectory.R.at(step)[0] << "\t" << Trajectory.R.at(step)[1] << "\t" << Trajectory.R.at(step)[2];
    226228    *out << "\t" << FixedIon;
  • src/atom.hpp

    r487ebb r882a8a  
    5555  bool OutputArrayIndexed(ostream * const out,const enumeration<const element*>&, int *AtomNo, const char *comment = NULL) const;
    5656  bool OutputXYZLine(ofstream *out) const;
    57   bool OutputTrajectory(ofstream * const out, const int *ElementNo, int *AtomNo, const int step) const;
     57  bool OutputTrajectory(ofstream * const out, const enumeration<const element*>&, int *AtomNo, const int step) const;
    5858  bool OutputTrajectoryXYZ(ofstream * const out, const int step) const;
    5959  void OutputMPQCLine(ostream * const out, const Vector *center) const;
  • src/molecule.cpp

    r487ebb r882a8a  
    893893bool molecule::OutputTrajectories(ofstream * const output)
    894894{
    895   int ElementNo[MAX_ELEMENTS], AtomNo[MAX_ELEMENTS];
    896 
    897895  if (output == NULL) {
    898896    return false;
     
    904902        *output << "# ====== MD step " << step << " =========" << endl;
    905903      }
    906       for (int i=0;i<MAX_ELEMENTS;++i) {
    907         AtomNo[i] = 0;
    908         ElementNo[i] = 0;
    909       }
    910       for(molecule::iterator iter = begin(); iter != end(); ++iter) {
    911         ElementNo[(*iter)->getType()->getAtomicNumber()] = 1;
    912       }
    913       int current=1;
    914       for (int i=0;i<MAX_ELEMENTS;++i) {
    915         if (ElementNo[i] == 1)
    916           ElementNo[i] = current++;
    917       }
    918       ActOnAllAtoms( &atom::OutputTrajectory, output, (const int *)ElementNo, AtomNo, (const int)step );
     904      int AtomNo[MAX_ELEMENTS];
     905      memset(AtomNo,0,(MAX_ELEMENTS-1)*sizeof(*AtomNo));
     906      enumeration<const element*> elementLookup = formula.enumerateElements();
     907      for_each(atoms.begin(),atoms.end(),boost::bind(&atom::OutputTrajectory,_1,output,elementLookup, AtomNo, (const int)step));
    919908    }
    920909    return true;
Note: See TracChangeset for help on using the changeset viewer.