Changeset 5e99bc


Ignore:
Timestamp:
Aug 25, 2010, 1:37:01 PM (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:
1f8337
Parents:
e95a59
git-author:
Tillmann Crueger <crueger@…> (08/25/10 13:22:11)
git-committer:
Tillmann Crueger <crueger@…> (08/25/10 13:37:01)
Message:

Added a method to the AtomSetMixin that allows calculating the total moment of arbitrary sets of Atoms

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AtomSet.hpp

    re95a59 r5e99bc  
    5959  template<class Function>
    6060  void transformNodes(Function f);
    61   double totalTemperatureAtStep(unsigned int i) const;
    6261  double totalMass() const;
     62  double totalTemperatureAtStep(unsigned int step) const;
     63  Vector totalMomentumAtStep(unsigned int step) const;
    6364
    6465private:
     
    7475  template<class T>
    7576  struct valueSum {
    76     valueSum(T (atom::*_f)() const) :
     77    valueSum(T (atom::*_f)() const,T startValue) :
    7778      f(_f),
    78       value(0)
     79      value(startValue)
    7980    {}
    8081    T operator+(atom *atom){
    8182      return value + (atom->*f)();
    8283    }
    83     T operator=(double _value){
     84    T operator=(T _value){
    8485      value = _value;
    8586      return value;
     
    9192  template<class T>
    9293  struct stepValueSum {
    93     stepValueSum(unsigned int _step, T (atom::*_f)(unsigned int) const) :
     94    stepValueSum(unsigned int _step, T (atom::*_f)(unsigned int) const,T startValue) :
    9495      step(_step),
    9596      f(_f),
    96       value(0)
     97      value(startValue)
    9798    {}
    9899    T operator+(atom *atom){
    99100      return value + (atom->*f)(step);
    100101    }
    101     T operator=(double _value){
     102    T operator=(T _value){
    102103      value = _value;
    103104      return value;
     
    125126
    126127template<class Set>
    127 inline double AtomSetMixin<Set>::totalTemperatureAtStep(unsigned int step) const{
    128   return accumulate(this->begin(),this->end(),stepValueSum<double>(step,&atom::getKineticEnergy)).value;
     128inline double AtomSetMixin<Set>::totalMass() const{
     129  return accumulate(this->begin(),this->end(),valueSum<double>(&atom::getMass,0)).value;
    129130}
    130131
    131132template<class Set>
    132 inline double AtomSetMixin<Set>::totalMass() const{
    133   return accumulate(this->begin(),this->end(),valueSum<double>(&atom::getMass)).value;
     133inline double AtomSetMixin<Set>::totalTemperatureAtStep(unsigned int step) const{
     134  return accumulate(this->begin(),this->end(),stepValueSum<double>(step,&atom::getKineticEnergy,0)).value;
     135}
     136
     137template<class Set>
     138inline Vector AtomSetMixin<Set>::totalMomentumAtStep(unsigned int step) const{
     139  return accumulate(this->begin(),this->end(),stepValueSum<Vector>(step,&atom::getMomentum,Vector())).value;
    134140}
    135141
Note: See TracChangeset for help on using the changeset viewer.