Changeset 6145577
- Timestamp:
- Apr 10, 2018, 6:43:12 AM (7 years ago)
- Branches:
- AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Enhanced_StructuralOptimization_continued, Exclude_Hydrogens_annealWithBondGraph, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, PythonUI_with_named_parameters, StoppableMakroAction, TremoloParser_IncreasedPrecision
- Children:
- c87d6e
- Parents:
- 8c6b68
- git-author:
- Frederik Heber <frederik.heber@…> (08/03/17 10:47:26)
- git-committer:
- Frederik Heber <frederik.heber@…> (04/10/18 06:43:12)
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MoleculeAction/ForceAnnealingAction.cpp
r8c6b68 r6145577 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
r8c6b68 r6145577 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
r8c6b68 r6145577 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
r8c6b68 r6145577 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
r8c6b68 r6145577 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
r8c6b68 r6145577 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 -
tests/regression/Molecules/ForceAnnealing/post/test-undo.conf
r8c6b68 r6145577 82 82 Ion_Type2_2 8.532785963 4.158586027 3.535886037 0 1.000000e-01 0.000000e+00 0.000000e+00 # molecule nr 9 83 83 Ion_Type2_3 7.283585982 3.275186040 3.535886037 0 1.000000e-01 0.000000e+00 0.000000e+00 # molecule nr 10 84 85 Ion_Type1_1 9.782085945 2.645886050 2.645886050 0 # molecule nr 0 86 Ion_Type1_2 9.782085945 2.645886050 4.425886024 0 # molecule nr 1 87 Ion_Type1_3 10.672039608 3.904536878 3.535886037 0 # molecule nr 2 88 Ion_Type1_4 8.532785963 4.787886018 2.645886050 0 # molecule nr 3 89 Ion_Type1_5 8.532785963 4.787886018 4.425886024 0 # molecule nr 4 90 Ion_Type1_6 6.393632318 3.904536877 3.535886037 0 # molecule nr 5 91 Ion_Type1_7 7.283585982 2.645886050 2.645886050 0 # molecule nr 6 92 Ion_Type1_8 7.283585982 2.645886050 4.425886024 0 # molecule nr 7 93 Ion_Type2_1 9.782085945 3.275186040 3.535886037 0 # molecule nr 8 94 Ion_Type2_2 8.532785963 4.158586027 3.535886037 0 # molecule nr 9 95 Ion_Type2_3 7.283585982 3.275186040 3.535886037 0 # molecule nr 10 -
tests/regression/Molecules/ForceAnnealing/testsuite-molecules-force-annealing.at
r8c6b68 r6145577 33 33 AT_SETUP([Molecules - Force Annealing with Undo]) 34 34 AT_KEYWORDS([molecules force-annealing undo]) 35 AT_XFAIL_IF([/bin/true])36 35 37 36 file=test.conf
Note:
See TracChangeset
for help on using the changeset viewer.