Changeset e6a2ef
- Timestamp:
- Mar 24, 2017, 10:12:23 AM (8 years ago)
- Branches:
- FitPartialCharges_GlobalError
- Children:
- fa2c89
- Parents:
- a3d08c
- git-author:
- Frederik Heber <heber@…> (10/10/16 12:34:32)
- git-committer:
- Frederik Heber <heber@…> (03/24/17 10:12:23)
- Location:
- src/Potentials
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Potentials/PartialNucleiChargeFitter.cpp
ra3d08c re6a2ef 305 305 } 306 306 307 double PartialNucleiChargeFitter::operator()() 307 VectorContent PartialNucleiChargeFitter::calculateResiduum() 308 { 309 constructMatrix(); 310 311 // calculate residual vector 312 VectorContent residuum = (*PotentialFromCharges) * (*PartialCharges) - SampledPotential; 313 314 return residuum; 315 } 316 317 void PartialNucleiChargeFitter::prepareCharges(const size_t _size) 308 318 { 309 319 // prepare PartialCharges … … 312 322 PartialCharges = NULL; 313 323 } 314 PartialCharges = new VectorContent(positions.size()); 324 PartialCharges = new VectorContent(_size); 325 } 326 327 double PartialNucleiChargeFitter::operator()() 328 { 329 prepareCharges(positions.size()); 315 330 316 331 // set up over-determined system's problem matrix A for Ax=b … … 327 342 LOG(2, "DEBUG: Norm of right-hand side is " << SampledPotential.Norm()); 328 343 329 // need to reconstruct matrix as it was overwritten by SVD 330 constructMatrix(); 331 332 // calculate residual vector 333 VectorContent residuum = (*PotentialFromCharges) * (*PartialCharges) - SampledPotential; 344 // calculate residuum (forces matrix reconstruction) 345 VectorContent residuum = calculateResiduum(); 334 346 335 347 #ifndef NDEBUG … … 367 379 368 380 return residuum.Norm(); 381 } 382 383 bool PartialNucleiChargeFitter::setCharges(const charges_t &_charges) 384 { 385 // check sizes 386 if (positions.size() != _charges.size()) { 387 return false; 388 } 389 // (re-)allocate memory 390 prepareCharges(positions.size()); 391 // and place charges in vector 392 for(size_t i=0;i<_charges.size();++i) 393 (*PartialCharges)[i] = _charges[i]; 394 395 return true; 369 396 } 370 397 -
src/Potentials/PartialNucleiChargeFitter.hpp
ra3d08c re6a2ef 105 105 charges_t getSolutionAsCharges_t() const; 106 106 107 /** Helper function to construct the discretized Coulomb operator for the 108 * nuclei charges. 109 * 110 */ 107 111 void writeMatrix(); 112 113 /** Setter for solution as charges_t 114 * 115 * \param _charges solution vector x as type charges_t 116 * \return false - if charges does not match in size with internal positions 117 */ 118 bool setCharges(const charges_t &_charges); 119 120 /** Calculates the residuum for the currently set charges. 121 * 122 * \return residual for every charge 123 */ 124 VectorContent calculateResiduum(); 108 125 109 126 private: … … 132 149 const Vector &grid_position) const; 133 150 151 /** Helper function to allocate memory for charges. 152 * 153 * \param _size size to allocate 154 */ 155 void prepareCharges(const size_t _size); 156 134 157 private: 135 158 //!> grid dimensions per axis for internal use
Note:
See TracChangeset
for help on using the changeset viewer.