| 48 |
|
#include "optimization/StatusFunction.hpp" |
| 49 |
|
#include "optimization/OptimizationFactory.hpp" |
| 50 |
|
|
| 51 |
– |
|
| 52 |
– |
|
| 51 |
|
#ifdef IS_MPI |
| 52 |
|
#include <mpi.h> |
| 53 |
|
#endif |
| 55 |
|
using namespace QuantLib; |
| 56 |
|
namespace OpenMD { |
| 57 |
|
|
| 58 |
< |
FluctuatingChargePropagator::FluctuatingChargePropagator(SimInfo* info, |
| 59 |
< |
ForceManager* fm) : |
| 62 |
< |
info_(info), forceMan_(fm), hasFlucQ_(false) { |
| 58 |
> |
FluctuatingChargePropagator::FluctuatingChargePropagator(SimInfo* info) : |
| 59 |
> |
info_(info), hasFlucQ_(false), forceMan_(NULL) { |
| 60 |
|
|
| 61 |
+ |
Globals* simParams = info_->getSimParams(); |
| 62 |
+ |
fqParams_ = simParams->getFluctuatingChargeParameters(); |
| 63 |
+ |
} |
| 64 |
+ |
|
| 65 |
+ |
void FluctuatingChargePropagator::setForceManager(ForceManager* forceMan) { |
| 66 |
+ |
forceMan_ = forceMan; |
| 67 |
+ |
} |
| 68 |
+ |
|
| 69 |
+ |
void FluctuatingChargePropagator::initialize() { |
| 70 |
+ |
|
| 71 |
|
if (info_->usesFluctuatingCharges()) { |
| 72 |
|
if (info_->getNFluctuatingCharges() > 0) { |
| 66 |
– |
|
| 73 |
|
hasFlucQ_ = true; |
| 74 |
< |
Globals* simParams = info_->getSimParams(); |
| 69 |
< |
fqParams_ = simParams->getFluctuatingChargeParameters(); |
| 70 |
< |
|
| 74 |
> |
fqConstraints_ = new FluctuatingChargeConstraints(info_); |
| 75 |
|
} |
| 76 |
|
} |
| 73 |
– |
} |
| 77 |
|
|
| 75 |
– |
void FluctuatingChargePropagator::initialize() { |
| 76 |
– |
|
| 78 |
|
if (!hasFlucQ_) return; |
| 79 |
|
|
| 80 |
|
SimInfo::MoleculeIterator i; |
| 90 |
|
atom->setFlucQVel(0.0); |
| 91 |
|
} |
| 92 |
|
} |
| 92 |
– |
|
| 93 |
– |
std::cerr << "doing a minimization\n"; |
| 93 |
|
|
| 94 |
|
fqConstraints_ = new FluctuatingChargeConstraints(info_); |
| 95 |
|
FluctuatingChargeObjectiveFunction flucQobjf(info_, forceMan_, fqConstraints_); |
| 98 |
|
EndCriteria endCriteria(1000, 100, 1e-5, 1e-5, 1e-5); |
| 99 |
|
OptimizationMethod* minim = OptimizationFactory::getInstance()->createOptimization("SD", info_); |
| 100 |
|
|
| 101 |
< |
minim->minimize(problem, endCriteria); |
| 101 |
> |
DumpStatusFunction dsf(info_); // we want a dump file written every iteration |
| 102 |
|
|
| 103 |
+ |
minim->minimize(problem, endCriteria); |
| 104 |
|
} |
| 105 |
|
|
| 106 |
– |
|
| 106 |
|
void FluctuatingChargePropagator::applyConstraints() { |
| 107 |
|
if (!hasFlucQ_) return; |
| 109 |
– |
|
| 108 |
|
fqConstraints_->applyConstraints(); |
| 109 |
|
} |
| 110 |
|
} |