- Timestamp:
- Apr 23, 2021, 8:31:23 PM (5 years ago)
- 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)
- Location:
- src
- Files:
-
- 6 edited
- 4 moved
-
Actions/GlobalListOfActions.hpp (modified) (1 diff)
-
Actions/Makefile.am (modified) (3 diffs)
-
Actions/MoleculeAction/SaveEnergiesAction.cpp (moved) (moved from src/Actions/MoleculeAction/SaveTemperatureAction.cpp ) (6 diffs)
-
Actions/MoleculeAction/SaveEnergiesAction.def (moved) (moved from src/Actions/MoleculeAction/SaveTemperatureAction.def ) (3 diffs)
-
Actions/MoleculeAction/SaveEnergiesAction.hpp (moved) (moved from src/Actions/MoleculeAction/SaveTemperatureAction.hpp ) (2 diffs)
-
Atom/AtomSet.hpp (modified) (4 diffs)
-
Atom/atom_atominfo.cpp (modified) (1 diff)
-
Atom/atom_atominfo.hpp (modified) (1 diff)
-
Dynamics/OutputEnergies.hpp (moved) (moved from src/Dynamics/OutputTemperature.hpp ) (3 diffs)
-
Makefile.am (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/GlobalListOfActions.hpp
rcbbb6a rd40189 96 96 (MoleculeSaveBonds) \ 97 97 (MoleculeSaveSelectedMolecules) \ 98 (MoleculeSave Temperature) \98 (MoleculeSaveEnergies) \ 99 99 (MoleculeStretchBond) \ 100 100 (MoleculeTranslate) \ -
src/Actions/Makefile.am
rcbbb6a rd40189 351 351 Actions/MoleculeAction/SaveAdjacencyAction.cpp \ 352 352 Actions/MoleculeAction/SaveBondsAction.cpp \ 353 Actions/MoleculeAction/Save TemperatureAction.cpp \353 Actions/MoleculeAction/SaveEnergiesAction.cpp \ 354 354 Actions/MoleculeAction/StretchBondAction.cpp \ 355 355 Actions/MoleculeAction/TranslateAction.cpp \ … … 370 370 Actions/MoleculeAction/SaveAdjacencyAction.hpp \ 371 371 Actions/MoleculeAction/SaveBondsAction.hpp \ 372 Actions/MoleculeAction/Save TemperatureAction.hpp \372 Actions/MoleculeAction/SaveEnergiesAction.hpp \ 373 373 Actions/MoleculeAction/StretchBondAction.hpp \ 374 374 Actions/MoleculeAction/TranslateAction.hpp \ … … 389 389 Actions/MoleculeAction/SaveAdjacencyAction.def \ 390 390 Actions/MoleculeAction/SaveBondsAction.def \ 391 Actions/MoleculeAction/Save TemperatureAction.def \391 Actions/MoleculeAction/SaveEnergiesAction.def \ 392 392 Actions/MoleculeAction/StretchBondAction.def \ 393 393 Actions/MoleculeAction/TranslateAction.def \ -
src/Actions/MoleculeAction/SaveEnergiesAction.cpp
rcbbb6a rd40189 3 3 * Description: creates and alters molecular systems 4 4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved. 5 * Copyright (C) 2019 Frederik Heber 5 6 * 6 7 * … … 22 23 23 24 /* 24 * Save TemperatureAction.cpp25 * SaveEnergiesAction.cpp 25 26 * 26 27 * Created on: May 10, 2010 … … 39 40 #include "CodePatterns/Log.hpp" 40 41 #include "CodePatterns/Verbose.hpp" 41 #include "Dynamics/Output Temperature.hpp"42 #include "Dynamics/OutputEnergies.hpp" 42 43 #include "molecule.hpp" 43 44 #include "World.hpp" … … 48 49 #include <vector> 49 50 50 #include "Actions/MoleculeAction/Save TemperatureAction.hpp"51 #include "Actions/MoleculeAction/SaveEnergiesAction.hpp" 51 52 52 53 using namespace MoleCuilder; 53 54 54 55 // and construct the stuff 55 #include "Save TemperatureAction.def"56 #include "SaveEnergiesAction.def" 56 57 #include "Action_impl_pre.hpp" 57 58 /** =========== define the function ====================== */ 58 ActionState::ptr MoleculeSave TemperatureAction::performCall() {59 LOG(1, "Storing temperatures in " << params. temperaturefile.get() << ".");59 ActionState::ptr MoleculeSaveEnergiesAction::performCall() { 60 LOG(1, "Storing temperatures in " << params.energiesfile.get() << "."); 60 61 ofstream output; 61 output.open(params. temperaturefile.get().string().c_str(), ios::trunc);62 output.open(params.energiesfile.get().string().c_str(), ios::trunc); 62 63 AtomSetMixin<std::vector<const atom *> > set = 63 64 const_cast<const World &>(World::getInstance()).getSelectedAtoms(); 64 65 const size_t MDSteps = set.getMaxTrajectorySize(); 65 Output Temperature<std::vector<const atom *> > writer(set);66 OutputEnergies<std::vector<const atom *> > writer(set); 66 67 if (output.fail() || !writer((ofstream * const) &output, 0, MDSteps)) { 67 68 STATUS("File could not be written."); … … 73 74 } 74 75 75 ActionState::ptr MoleculeSave TemperatureAction::performUndo(ActionState::ptr _state) {76 // MoleculeSave TemperatureState *state = assert_cast<MoleculeSaveTemperatureState*>(_state.get());76 ActionState::ptr MoleculeSaveEnergiesAction::performUndo(ActionState::ptr _state) { 77 // MoleculeSaveEnergiesState *state = assert_cast<MoleculeSaveEnergiesState*>(_state.get()); 77 78 78 79 // string newName = state->mol->getName(); … … 82 83 } 83 84 84 ActionState::ptr MoleculeSave TemperatureAction::performRedo(ActionState::ptr _state){85 ActionState::ptr MoleculeSaveEnergiesAction::performRedo(ActionState::ptr _state){ 85 86 // Undo and redo have to do the same for this action 86 87 return performUndo(_state); 87 88 } 88 89 89 bool MoleculeSave TemperatureAction::canUndo() {90 bool MoleculeSaveEnergiesAction::canUndo() { 90 91 return false; 91 92 } 92 93 93 bool MoleculeSave TemperatureAction::shouldUndo() {94 bool MoleculeSaveEnergiesAction::shouldUndo() { 94 95 return false; 95 96 } -
src/Actions/MoleculeAction/SaveEnergiesAction.def
rcbbb6a rd40189 1 1 /* 2 * Save TemperatureAction.def2 * SaveEnergiesAction.def 3 3 * 4 4 * Created on: Aug 26, 2010 … … 14 14 // "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value 15 15 #define paramtypes (boost::filesystem::path) 16 #define paramtokens ("save- temperature")17 #define paramdescriptions ("name of the temperaturefile to write to")16 #define paramtokens ("save-energies") 17 #define paramdescriptions ("name of the energies file to write to") 18 18 #undef paramdefaults 19 #define paramreferences ( temperaturefile)19 #define paramreferences (energiesfile) 20 20 #define paramvalids \ 21 21 (!FilePresentValidator()) … … 28 28 #define MENUNAME "molecule" 29 29 #define MENUPOSITION 12 30 #define ACTIONNAME Save Temperature31 #define TOKEN "save- temperature"30 #define ACTIONNAME SaveEnergies 31 #define TOKEN "save-energies" 32 32 33 33 34 34 // finally the information stored in the ActionTrait specialization 35 #define DESCRIPTION "save the temperatureper time step to file"35 #define DESCRIPTION "save several energies (kinetic, momentum, mean force) per time step to file" 36 36 #undef SHORTFORM -
src/Actions/MoleculeAction/SaveEnergiesAction.hpp
rcbbb6a rd40189 1 1 /* 2 * Save TemperatureAction.hpp2 * SaveEnergiesAction.hpp 3 3 * 4 4 * Created on: May 10, 2010 … … 17 17 #include "Actions/Action.hpp" 18 18 19 #include "Save TemperatureAction.def"19 #include "SaveEnergiesAction.def" 20 20 #include "Action_impl_header.hpp" 21 21 -
src/Atom/AtomSet.hpp
rcbbb6a rd40189 77 77 double totalMass() const; 78 78 double totalTemperatureAtStep(unsigned int step) const; 79 Vector totalForceAtStep(unsigned int step) const; 79 80 Vector totalMomentumAtStep(unsigned int step) const; 81 Vector totalAbsoluteMomentumAtStep(unsigned int step) const; 82 Vector totalAbsoluteForceAtStep(unsigned int step) const; 80 83 81 84 size_t getMaxTrajectorySize() const; … … 111 114 112 115 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> 113 139 struct valueMax { 114 140 valueMax(T (AtomInfo::*_f)() const,T startValue) : … … 145 171 T (AtomInfo::*f)(unsigned int) const; 146 172 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; 147 198 }; 148 199 }; … … 208 259 class iterator_type, 209 260 class const_iterator_type> 261 inline 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 265 template <class container_type, 266 class iterator_type, 267 class const_iterator_type> 268 inline 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 272 template <class container_type, 273 class iterator_type, 274 class const_iterator_type> 275 inline 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 279 template <class container_type, 280 class iterator_type, 281 class const_iterator_type> 210 282 inline void AtomSetMixin<container_type,iterator_type,const_iterator_type>::sortByIds(){ 211 283 std::sort(this->begin(), this->end(), -
src/Atom/atom_atominfo.cpp
rcbbb6a rd40189 475 475 } 476 476 477 Vector AtomInfo::getAcceleration(const unsigned int _step) const 478 { 479 return getMass() * getAtomicForceAtStep(_step); 480 } 481 477 482 /** Decrease the trajectory if given \a MaxSteps is smaller. 478 483 * Does nothing if \a MaxSteps is larger than current size. -
src/Atom/atom_atominfo.hpp
rcbbb6a rd40189 299 299 double getKineticEnergy(const unsigned int step) const; 300 300 Vector getMomentum(const unsigned int step) const; 301 Vector getAcceleration(const unsigned int _step) const; 301 302 double getMass() const; 302 303 double getCharge() const { -
src/Dynamics/OutputEnergies.hpp
rcbbb6a rd40189 1 1 /* 2 * Output Temperature.hpp2 * OutputEnergies.hpp 3 3 * 4 4 * Created on: Feb 23, 2011 … … 17 17 18 18 template <class T> 19 class Output Temperature19 class OutputEnergies 20 20 { 21 21 public: 22 Output Temperature(AtomSetMixin<T> &_atoms) :22 OutputEnergies(AtomSetMixin<T> &_atoms) : 23 23 atoms(_atoms) 24 24 {} 25 ~Output Temperature()25 ~OutputEnergies() 26 26 {} 27 27 … … 37 37 { 38 38 double temperature; 39 Vector force, abs_force; 40 Vector momentum, abs_momentum; 39 41 // test stream 40 42 if (output == NULL) 41 43 return false; 42 44 else 43 *output << "# Step Temperature [K] Temperature [a.u.]" << endl; 45 *output << "# Step" 46 << "\tTemperature [K]" 47 << "\tTemperature [a.u.]" 48 << "\tMomentum" 49 << "\tAbolute Momentum" 50 << "\tForce" 51 << "\tAbsolute Force" 52 << endl; 44 53 for (int step=startstep;step < endstep; step++) { // loop over all time steps 45 54 temperature = atoms.totalTemperatureAtStep(step); 46 *output << step << "\t" << temperature*AtomicEnergyToKelvin << "\t" << temperature << endl; 55 momentum = atoms.totalMomentumAtStep(step); 56 force = atoms.totalForceAtStep(step); 57 abs_momentum = atoms.totalAbsoluteMomentumAtStep(step); 58 abs_force = atoms.totalAbsoluteForceAtStep(step); 59 *output << step 60 << "\t" << temperature*AtomicEnergyToKelvin 61 << "\t" << temperature 62 << "\t" << momentum.Norm() 63 << "\t" << abs_momentum.Norm() 64 << "\t" << force.Norm() 65 << "\t" << abs_force.Norm() 66 << endl; 47 67 } 48 68 return true; -
src/Makefile.am
rcbbb6a rd40189 119 119 Dynamics/LinearInterpolationBetweenSteps.hpp \ 120 120 Dynamics/MinimiseConstrainedPotential.hpp \ 121 Dynamics/Output Temperature.hpp \121 Dynamics/OutputEnergies.hpp \ 122 122 Dynamics/VerletForceIntegration.hpp 123 123
Note:
See TracChangeset
for help on using the changeset viewer.
