Changeset b03d7d
- Timestamp:
- May 23, 2017, 8:58:02 PM (8 years ago)
- Branches:
- ForceAnnealing_tocheck
- Children:
- 175543
- Parents:
- 9190e6
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/MoleculeAction/ForceAnnealingAction.cpp
r9190e6 rb03d7d 93 93 set, 94 94 true, 95 params.steps.get()); 95 params.steps.get(), 96 params.MaxDistance.get()); 96 97 // parse forces into next step 97 98 if (!params.forcesfile.get().string().empty()) { -
src/Actions/MoleculeAction/ForceAnnealingAction.def
r9190e6 rb03d7d 16 16 // ValueStorage by the token "Z" -> first column: int, Z, "Z" 17 17 // "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value 18 #define paramtypes (boost::filesystem::path)(unsigned int)(bool) 19 #define paramtokens ("forces-file")("steps")("output-every-step") 20 #define paramdescriptions ("file containing")("fixed number of optimization steps to be performed")("whether WorldTime should be increased and output written after every step, useful if optimization might hang") 21 #define paramdefaults (PARAM_DEFAULT(""))(NOPARAM_DEFAULT)(PARAM_DEFAULT("0")) 22 #define paramreferences (forcesfile)(steps)(DoOutput) 18 #define paramtypes (boost::filesystem::path)(unsigned int)(bool)(int) 19 #define paramtokens ("forces-file")("steps")("output-every-step")("max-distance") 20 #define paramdescriptions ("file containing")("fixed number of optimization steps to be performed")("whether WorldTime should be increased and output written after every step, useful if optimization might hang")("maximum distance to which bond graph is taken into account") 21 #define paramdefaults (PARAM_DEFAULT(""))(NOPARAM_DEFAULT)(PARAM_DEFAULT("0"))(PARAM_DEFAULT(0)) 22 #define paramreferences (forcesfile)(steps)(DoOutput)(MaxDistance) 23 23 #define paramvalids \ 24 24 (DummyValidator< boost::filesystem::path >()) \ 25 25 (NotZeroValidator< unsigned int >()) \ 26 (DummyValidator<bool>()) 26 (DummyValidator<bool>()) \ 27 (DummyValidator< int >()) 27 28 28 29 #define statetypes (std::vector<AtomicInfo>)(std::vector<AtomicInfo>) -
src/Dynamics/ForceAnnealing.hpp
r9190e6 rb03d7d 20 20 #include "CodePatterns/Log.hpp" 21 21 #include "CodePatterns/Verbose.hpp" 22 #include "Descriptors/AtomIdDescriptor.hpp" 22 23 #include "Dynamics/AtomicForceManipulator.hpp" 23 24 #include "Fragmentation/ForceMatrix.hpp" … … 38 39 * step width (we cannot perform a line search, as we have no control over the 39 40 * calculation of the forces). 41 * 42 * However, we do use the bond graph, i.e. if a single atom needs to be shifted 43 * to the left, then the whole molecule left of it is shifted, too. This is 44 * controlled by the \a max_distance parameter. 40 45 */ 41 46 template <class T> … … 51 56 * \param _IsAngstroem whether length units are in angstroem or bohr radii 52 57 * \param _maxSteps number of optimization steps to perform 58 * \param _max_distance up to this bond order is bond graph taken into account. 53 59 */ 54 60 ForceAnnealing( 55 61 AtomSetMixin<T> &_atoms, 56 62 bool _IsAngstroem, 57 const size_t _maxSteps) : 63 const size_t _maxSteps, 64 const int _max_distance) : 58 65 AtomicForceManipulator<T>(_atoms, 1., _IsAngstroem), 59 maxSteps(_maxSteps) 66 maxSteps(_maxSteps), 67 max_distance(_max_distance), 68 damping_factor(0.5) 60 69 {} 61 70 /** Destructor of class ForceAnnealing. … … 130 139 LOG(3, "DEBUG: Update would be " << PositionUpdate); 131 140 132 // add update to central atom133 const atomId_t atomid = (*iter)->getId();134 if (GatheredUpdates.count(atomid)) {135 GatheredUpdates[atomid] += PositionUpdate;136 } else137 GatheredUpdates.insert( std::make_pair(atomid, PositionUpdate) );141 // // add update to central atom 142 // const atomId_t atomid = (*iter)->getId(); 143 // if (GatheredUpdates.count(atomid)) { 144 // GatheredUpdates[atomid] += PositionUpdate; 145 // } else 146 // GatheredUpdates.insert( std::make_pair(atomid, PositionUpdate) ); 138 147 139 148 // We assume that a force is local, i.e. a bond is too short yet and hence … … 145 154 146 155 /// get all nodes from bonds in the direction of the current force 147 const size_t max_distance = 4;148 const double damping_factor = 0.9;149 156 150 157 // remove edges facing in the wrong direction … … 184 191 "ForceAnnealing() - could not find distance to an atom."); 185 192 const double factor = pow(damping_factor, diter->second); 193 LOG(3, "DEBUG: Update for atom #" << *setiter << " will be " 194 << factor << "*" << PositionUpdate); 186 195 if (GatheredUpdates.count((*setiter))) { 187 196 GatheredUpdates[(*setiter)] += factor*PositionUpdate; … … 199 208 maxComponents[i] = currentGradient[i]; 200 209 201 // are we in initial step? Then don't check against velocity202 if ((currentStep > 1) && (!(*iter)->getAtomicVelocity().IsZero()))203 // update with currentDelta tells us how the current gradient relates to204 // the last one: If it has become larger, reduce currentDelta205 if ((PositionUpdate.ScalarProduct((*iter)->getAtomicVelocity()) < 0)206 && (currentDeltat > MinimumDeltat)) {207 currentDeltat = .5*currentDeltat;208 LOG(2, "DEBUG: Upgrade in other direction: " << PositionUpdate.NormSquared()209 << " > " << (*iter)->getAtomicVelocity().NormSquared()210 << ", decreasing deltat: " << currentDeltat);211 PositionUpdate = currentDeltat * currentGradient;212 }213 214 // finally set new values215 (*iter)->setPosition(currentPosition + PositionUpdate);216 (*iter)->setAtomicVelocity(PositionUpdate);217 //std::cout << "Id of atom is " << (*iter)->getId() << std::endl;218 // (*iter)->VelocityVerletUpdateU((*iter)->getId(), NextStep-1, Deltat, IsAngstroem);219 220 210 // reset force vector for next step except on final one 221 211 if (currentStep != maxSteps) 222 212 (*iter)->setAtomicForce(zeroVec); 213 } 214 // apply the gathered updates 215 for (std::map<atomId_t, Vector>::const_iterator iter = GatheredUpdates.begin(); 216 iter != GatheredUpdates.end(); ++iter) { 217 const atomId_t &atomid = iter->first; 218 const Vector &update = iter->second; 219 atom* const walker = World::getInstance().getAtom(AtomById(atomid)); 220 ASSERT( walker != NULL, 221 "ForceAnnealing() - walker with id "+toString(atomid)+" has suddenly disappeared."); 222 walker->setPosition( walker->getPosition() + update ); 223 walker->setAtomicVelocity(update); 224 LOG(3, "DEBUG: Applying update " << update << " to atom " << *walker); 223 225 } 224 226 … … 255 257 //!> minimum deltat for internal while loop (adaptive step width) 256 258 static double MinimumDeltat; 259 //!> contains the maximum bond graph distance up to which shifts of a single atom are spread 260 const int max_distance; 261 //!> the shifted is dampened by this factor with the power of the bond graph distance to the shift causing atom 262 const double damping_factor; 257 263 }; 258 264
Note:
See TracChangeset
for help on using the changeset viewer.