- Timestamp:
- Nov 7, 2017, 7:34:56 AM (7 years ago)
- Branches:
- ForceAnnealing_with_BondGraph_continued_betteresults
- Children:
- 10b1ef
- Parents:
- 0f9726
- git-author:
- Frederik Heber <frederik.heber@…> (08/03/17 10:47:26)
- git-committer:
- Frederik Heber <frederik.heber@…> (11/07/17 07:34:56)
- Location:
- src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MoleculeAction/ForceAnnealingAction.cpp
r0f9726 r38ac25 71 71 return Action::failure; 72 72 } 73 74 size_t CurrentStep = WorldTime::getInstance().getTime(); 75 if (CurrentStep == 0) { 76 ELOG(1, "WorldTime must be at least at step 1 already, use step-world-time if necessary."); 77 return Action::failure; 78 } 79 73 80 // first, we need to sort the mixin according to their ids (as selected atoms are sorted 74 81 // according to their arbitrary address in memory) … … 76 83 77 84 // create undo state for all selected atoms (undo info) 78 std::vector<AtomicInfo> UndoInfo; 79 UndoInfo.reserve(set.size()); 80 { 81 for (World::AtomSelectionConstIterator iter = World::getInstance().beginAtomSelection(); 82 iter != World::getInstance().endAtomSelection(); 83 ++iter) 84 UndoInfo.push_back(AtomicInfo(*(iter->second))); 85 std::vector< std::vector<AtomicInfo> > UndoInfo(2); 86 for (int i=0;i<2;++i) { 87 UndoInfo[i].reserve(set.size()); 88 { 89 for (World::AtomSelectionConstIterator iter = World::getInstance().beginAtomSelection(); 90 iter != World::getInstance().endAtomSelection(); 91 ++iter) 92 UndoInfo[i].push_back(AtomicInfo(*(iter->second), CurrentStep-i)); 93 } 85 94 } 86 95 … … 93 102 params.MaxDistance.get(), 94 103 params.DampingFactor.get()); 95 size_t CurrentStep = WorldTime::getInstance().getTime();96 if (CurrentStep == 0) {97 ELOG(1, "WorldTime must be at least at step 1 already, use step-world-time if necessary.");98 return Action::failure;99 }100 104 101 105 // parse forces into last step (assuming we stepped on already) … … 113 117 STATUS("Successfully optimized structure by one step."); 114 118 115 std::vector<AtomicInfo> RedoInfo; 116 RedoInfo.reserve(set.size()); 117 { 118 for (World::AtomSelectionConstIterator iter = World::getInstance().beginAtomSelection(); 119 iter != World::getInstance().endAtomSelection(); 120 ++iter) 121 RedoInfo.push_back(AtomicInfo(*(iter->second))); 119 std::vector< std::vector<AtomicInfo> > RedoInfo(2); 120 for (int i=0;i<2;++i) { 121 RedoInfo[i].reserve(set.size()); 122 { 123 for (World::AtomSelectionConstIterator iter = World::getInstance().beginAtomSelection(); 124 iter != World::getInstance().endAtomSelection(); 125 ++iter) 126 RedoInfo[i].push_back(AtomicInfo(*(iter->second), CurrentStep-i)); 127 } 122 128 } 129 123 130 MoleculeForceAnnealingState *UndoState = 124 131 new MoleculeForceAnnealingState(UndoInfo, RedoInfo, params); … … 130 137 MoleculeForceAnnealingState *state = 131 138 assert_cast<MoleculeForceAnnealingState*>(_state.get()); 139 const size_t CurrentStep = WorldTime::getInstance().getTime(); 132 140 133 141 // set stored old state 134 SetAtomsFromAtomicInfo(state->UndoInfo); 142 for (int i=0;i<2;++i) 143 SetAtomsFromAtomicInfo(state->UndoInfo[i], CurrentStep-i); 135 144 136 145 return ActionState::ptr(_state); … … 140 149 MoleculeForceAnnealingState *state = 141 150 assert_cast<MoleculeForceAnnealingState*>(_state.get()); 151 const size_t CurrentStep = WorldTime::getInstance().getTime(); 142 152 143 153 // set stored new state 144 SetAtomsFromAtomicInfo(state->RedoInfo); 154 for (int i=0;i<2;++i) 155 SetAtomsFromAtomicInfo(state->RedoInfo[i], CurrentStep-i); 145 156 146 157 return ActionState::ptr(_state); -
src/Actions/MoleculeAction/ForceAnnealingAction.def
r0f9726 r38ac25 32 32 (DummyValidator<bool>()) 33 33 34 #define statetypes (std::vector< AtomicInfo>)(std::vector<AtomicInfo>)34 #define statetypes (std::vector< std::vector<AtomicInfo> >)(std::vector< std::vector<AtomicInfo> >) 35 35 #define statereferences (UndoInfo)(RedoInfo) 36 36 -
src/Actions/UndoRedoHelpers.cpp
r0f9726 r38ac25 145 145 } 146 146 147 void MoleCuilder::SetAtomsFromAtomicInfo(const std::vector<AtomicInfo> &_movedatoms) 147 void MoleCuilder::SetAtomsFromAtomicInfo( 148 const std::vector<AtomicInfo> &_movedatoms, 149 const unsigned int _step) 148 150 { 149 151 BOOST_FOREACH( const AtomicInfo &_atominfo, _movedatoms) { … … 153 155 "MoleCuilder::SetAtomsFromAtomicInfo() - cannot find atom with id " 154 156 +toString(id)+" in the world."); 155 _atominfo.setAtom( *_atom );157 _atominfo.setAtom( *_atom, _step ); 156 158 } 157 159 } -
src/Actions/UndoRedoHelpers.hpp
r0f9726 r38ac25 19 19 #include "Atom/AtomicInfo.hpp" 20 20 #include "Bond/BondInfo.hpp" 21 #include "WorldTime.hpp" 21 22 22 23 namespace MoleCuilder { … … 61 62 * 62 63 * @param movedatoms vector of atomicInfo 64 * @param _step set state information for given world time 63 65 */ 64 void SetAtomsFromAtomicInfo(const std::vector<AtomicInfo> &_movedatoms); 66 void SetAtomsFromAtomicInfo( 67 const std::vector<AtomicInfo> &_movedatoms, 68 const unsigned int _step = WorldTime::getTime()); 65 69 66 70 /** Selects all atoms inside the given vector -
src/Atom/AtomicInfo.cpp
r0f9726 r38ac25 58 58 {} 59 59 60 AtomicInfo::AtomicInfo(const atom &_atom ) :61 Position(_atom.getPosition ()),60 AtomicInfo::AtomicInfo(const atom &_atom, unsigned int _step) : 61 Position(_atom.getPositionAtStep(_step)), 62 62 Type(_atom.getType()), 63 63 charge(_atom.getCharge()), 64 Velocity(_atom.getAtomicVelocity ()),65 Force(_atom.getAtomicForce ()),64 Velocity(_atom.getAtomicVelocityAtStep(_step)), 65 Force(_atom.getAtomicForceAtStep(_step)), 66 66 FatherId(_atom.father->getId()), 67 67 MolId(0), … … 101 101 102 102 103 bool AtomicInfo::setAtom(atom &_atom ) const103 bool AtomicInfo::setAtom(atom &_atom, const unsigned int _step) const 104 104 { 105 _atom.setPosition (Position);105 _atom.setPositionAtStep(_step, Position); 106 106 _atom.setType(Type); 107 107 _atom.setCharge(charge); 108 _atom.setAtomicVelocity (Velocity);109 _atom.setAtomicForce (Force);108 _atom.setAtomicVelocityAtStep(_step, Velocity); 109 _atom.setAtomicForceAtStep(_step, Force); 110 110 111 111 // set old id -
src/Atom/AtomicInfo.hpp
r0f9726 r38ac25 20 20 21 21 #include "Bond/BondInfo.hpp" 22 #include "WorldTime.hpp" 22 23 23 24 class atom; … … 31 32 public: 32 33 AtomicInfo(); 33 AtomicInfo(const atom &_atom );34 AtomicInfo(const atom &_atom, const unsigned int _step = WorldTime::getTime()); 34 35 AtomicInfo(const AtomicInfo &_atominfo); 35 36 ~AtomicInfo(); 36 37 37 bool setAtom(atom &_atom ) const;38 bool setAtom(atom &_atom, const unsigned int _step = WorldTime::getTime()) const; 38 39 atomId_t getId() const; 39 40
Note:
See TracChangeset
for help on using the changeset viewer.