Ignore:
Timestamp:
Apr 23, 2021, 8:31:23 PM (5 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Candidate_v1.7.0, stable
Children:
61cc0f
Parents:
cbbb6a
git-author:
Frederik Heber <frederik.heber@…> (04/28/19 22:01:20)
git-committer:
Frederik Heber <frederik.heber@…> (04/23/21 20:31:23)
Message:

OutputTemperature -> OutputEnergies, SaveTemperature -> SaveEnergies.

  • added force and momentum calculation.
  • TESTS: adapted test.ekin test file and integration/MolecularDynamics tests.
  • DOCU: Adapted userguide for changed action.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Atom/AtomSet.hpp

    rcbbb6a rd40189  
    7777  double totalMass() const;
    7878  double totalTemperatureAtStep(unsigned int step) const;
     79  Vector totalForceAtStep(unsigned int step) const;
    7980  Vector totalMomentumAtStep(unsigned int step) const;
     81  Vector totalAbsoluteMomentumAtStep(unsigned int step) const;
     82  Vector totalAbsoluteForceAtStep(unsigned int step) const;
    8083
    8184  size_t getMaxTrajectorySize() const;
     
    111114
    112115  template<class T>
     116  struct absValueSum {
     117    absValueSum(T (AtomInfo::*_f)() const,T startValue) :
     118      f(_f),
     119      value(startValue)
     120    {}
     121    T operator+(const AtomInfo *atom){
     122      temp = (atom->*f)();
     123      for (int i=0;i<NDIM;++i)
     124        temp[i] = fabs(temp[i]);
     125      return value + temp;
     126    }
     127    T operator=(T _value){
     128      value = _value;
     129      for (int i=0;i<NDIM;++i)
     130        value[i] = fabs(value[i]);
     131      return value;
     132    }
     133    T (AtomInfo::*f)() const;
     134    T value;
     135    T temp;
     136  };
     137
     138  template<class T>
    113139  struct valueMax {
    114140    valueMax(T (AtomInfo::*_f)() const,T startValue) :
     
    145171    T (AtomInfo::*f)(unsigned int) const;
    146172    T value;
     173  };
     174
     175  template<class T>
     176  struct stepAbsValueSum {
     177    stepAbsValueSum(unsigned int _step, T (AtomInfo::*_f)(unsigned int) const,T startValue) :
     178      step(_step),
     179      f(_f),
     180      value(startValue)
     181    {}
     182    T operator+(const AtomInfo *atom){
     183      temp = (atom->*f)(step);
     184      for (int i=0;i<NDIM;++i)
     185        temp[i] = fabs(temp[i]);
     186      return value + temp;
     187    }
     188    T operator=(T _value){
     189      value = _value;
     190      for (int i=0;i<NDIM;++i)
     191        value[i] = fabs(value[i]);
     192      return value;
     193    }
     194    unsigned int step;
     195    T (AtomInfo::*f)(unsigned int) const;
     196    T value;
     197    T temp;
    147198  };
    148199};
     
    208259          class iterator_type,
    209260          class const_iterator_type>
     261inline Vector AtomSetMixin<container_type,iterator_type,const_iterator_type>::totalAbsoluteMomentumAtStep(unsigned int step) const{
     262  return accumulate(this->begin(),this->end(),stepAbsValueSum<Vector>(step,&AtomInfo::getMomentum,Vector())).value;
     263}
     264
     265template <class container_type,
     266          class iterator_type,
     267          class const_iterator_type>
     268inline Vector AtomSetMixin<container_type,iterator_type,const_iterator_type>::totalForceAtStep(unsigned int step) const{
     269  return accumulate(this->begin(),this->end(),stepValueSum<Vector>(step,&AtomInfo::getAcceleration,Vector())).value;
     270}
     271
     272template <class container_type,
     273          class iterator_type,
     274          class const_iterator_type>
     275inline Vector AtomSetMixin<container_type,iterator_type,const_iterator_type>::totalAbsoluteForceAtStep(unsigned int step) const{
     276  return accumulate(this->begin(),this->end(),stepAbsValueSum<Vector>(step,&AtomInfo::getAcceleration,Vector())).value;
     277}
     278
     279template <class container_type,
     280          class iterator_type,
     281          class const_iterator_type>
    210282inline void AtomSetMixin<container_type,iterator_type,const_iterator_type>::sortByIds(){
    211283  std::sort(this->begin(), this->end(),
Note: See TracChangeset for help on using the changeset viewer.