Changeset 825d33 for src/Dynamics/BondVectors.cpp
- Timestamp:
- Apr 10, 2018, 6:43:30 AM (7 years ago)
- Branches:
- AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Exclude_Hydrogens_annealWithBondGraph, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, PythonUI_with_named_parameters, StoppableMakroAction, TremoloParser_IncreasedPrecision
- Children:
- c1c6cb
- Parents:
- 9861d0
- git-author:
- Frederik Heber <frederik.heber@…> (06/29/17 14:53:38)
- git-committer:
- Frederik Heber <frederik.heber@…> (04/10/18 06:43:30)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Dynamics/BondVectors.cpp
r9861d0 r825d33 39 39 40 40 #include <algorithm> 41 #include <functional> 41 42 #include <iterator> 43 #include <numeric> 42 44 43 45 #include "CodePatterns/Assert.hpp" … … 46 48 #include "Atom/atom.hpp" 47 49 #include "Bond/bond.hpp" 50 #include "Helpers/defs.hpp" 48 51 49 52 void BondVectors::recalculateBondVectorsAtStep( … … 107 110 return BondVectors; 108 111 } 112 113 BondVectors::weights_t BondVectors::getWeightsForAtomAtStep( 114 const atom &_walker, 115 const size_t &_step) const 116 { 117 const std::vector<Vector> BondVectors = 118 getAtomsBondVectorsAtStep(_walker, _step); 119 120 weights_t weights; 121 for (std::vector<Vector>::const_iterator iter = BondVectors.begin(); 122 iter != BondVectors.end(); ++iter) { 123 std::vector<double> scps; 124 scps.reserve(BondVectors.size()); 125 std::transform( 126 BondVectors.begin(), BondVectors.end(), 127 std::back_inserter(scps), 128 boost::bind(static_cast< double (*)(double) >(&fabs), 129 boost::bind(&Vector::ScalarProduct, boost::cref(*iter), _1)) 130 ); 131 const double scp_sum = std::accumulate(scps.begin(), scps.end(), 0.); 132 ASSERT( (scp_sum-1.) > -MYEPSILON, 133 "ForceAnnealing() - sum of weights must be equal or larger one but is " 134 +toString(scp_sum)); 135 weights.push_back( 1./scp_sum ); 136 } 137 LOG(4, "DEBUG: Weights for atom #" << _walker.getId() << ": " << weights); 138 139 // for testing we check whether all weighted scalar products now come out as 1. 140 #ifndef NDEBUG 141 for (std::vector<Vector>::const_iterator iter = BondVectors.begin(); 142 iter != BondVectors.end(); ++iter) { 143 std::vector<double> scps; 144 scps.reserve(BondVectors.size()); 145 std::transform( 146 BondVectors.begin(), BondVectors.end(), 147 weights.begin(), 148 std::back_inserter(scps), 149 boost::bind(static_cast< double (*)(double) >(&fabs), 150 boost::bind(std::multiplies<double>(), 151 boost::bind(&Vector::ScalarProduct, boost::cref(*iter), _1), 152 _2)) 153 ); 154 const double scp_sum = std::accumulate(scps.begin(), scps.end(), 0.); 155 ASSERT( fabs(scp_sum - 1.) < MYEPSILON, 156 "ForceAnnealing::operator() - for BondVector "+toString(*iter) 157 +" we have weighted scalar product of "+toString(scp_sum)+" != 1."); 158 } 159 #endif 160 return weights; 161 }
Note:
See TracChangeset
for help on using the changeset viewer.