Changeset 9bb6e3 for src/Potentials
- Timestamp:
 - Oct 10, 2016, 1:14:41 PM (9 years ago)
 - Branches:
 - Fix_FitPartialCharges
 - Children:
 - 9c02a8
 - Parents:
 - 489b9c
 - Location:
 - src/Potentials
 - Files:
 - 
      
- 2 edited
 
- 
          
  PartialNucleiChargeFitter.cpp (modified) (5 diffs)
 - 
          
  PartialNucleiChargeFitter.hpp (modified) (2 diffs)
 
 
Legend:
- Unmodified
 - Added
 - Removed
 
- 
      
src/Potentials/PartialNucleiChargeFitter.cpp
r489b9c r9bb6e3 309 309 VectorContent PartialNucleiChargeFitter::calculateResiduum() 310 310 { 311 // need to reconstruct matrix as it was overwritten by SVD 312 if (PotentialFromCharges == NULL) 313 constructMatrix(); 311 constructMatrix(); 314 312 315 313 // calculate residual vector … … 319 317 } 320 318 321 double PartialNucleiChargeFitter::operator()()319 void PartialNucleiChargeFitter::prepareCharges(const size_t _size) 322 320 { 323 321 // prepare PartialCharges … … 326 324 PartialCharges = NULL; 327 325 } 328 PartialCharges = new VectorContent(positions.size()); 326 PartialCharges = new VectorContent(_size); 327 } 328 329 double PartialNucleiChargeFitter::operator()() 330 { 331 prepareCharges(positions.size()); 329 332 330 333 // set up over-determined system's problem matrix A for Ax=b … … 341 344 LOG(2, "DEBUG: Norm of right-hand side is " << SampledPotential.Norm()); 342 345 343 // calculate residuum (force matrix reconstruction) 344 delete PotentialFromCharges; 346 // calculate residuum (forces matrix reconstruction) 345 347 VectorContent residuum = calculateResiduum(); 346 348 … … 379 381 380 382 return residuum.Norm(); 383 } 384 385 bool PartialNucleiChargeFitter::setCharges(const charges_t &_charges) 386 { 387 // check sizes 388 if (positions.size() != _charges.size()) { 389 return false; 390 } 391 // (re-)allocate memory 392 prepareCharges(positions.size()); 393 // and place charges in vector 394 for(size_t i=0;i<_charges.size();++i) 395 (*PartialCharges)[i] = _charges[i]; 396 397 return true; 381 398 } 382 399  - 
      
src/Potentials/PartialNucleiChargeFitter.hpp
r489b9c r9bb6e3 114 114 * 115 115 * \param _charges solution vector x as type charges_t 116 * \return false - if charges does not match in size with internal positions 116 117 */ 117 void setCharges(const charges_t &_charges) const;118 bool setCharges(const charges_t &_charges); 118 119 119 120 /** Calculates the residuum for the currently set charges. … … 148 149 const Vector &grid_position) const; 149 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 150 157 private: 151 158 //!> grid dimensions per axis for internal use  
  Note:
 See   TracChangeset
 for help on using the changeset viewer.
  