45#include "optimization/BoxObjectiveFunction.hpp"
47#include "math/CholeskyDecomposition.hpp"
51 BoxObjectiveFunction::BoxObjectiveFunction(
SimInfo* info,
54 forceMan_(forceMan), thermo(info) {
55 shake_ =
new Shake(info_);
57 if (info_->usesFluctuatingCharges()) {
58 if (info_->getNFluctuatingCharges() > 0) {
61 bool cr = info_->getSimParams()
62 ->getFluctuatingChargeParameters()
63 ->getConstrainRegions();
64 fqConstraints_->setConstrainRegions(cr);
72 if (setCoor(x) == 0) {
73 shake_->constraintR();
74 forceMan_->calcForces();
75 if (hasFlucQ_) fqConstraints_->applyConstraints();
76 shake_->constraintF();
77 return thermo.getPotential();
80 return std::numeric_limits<RealType>::infinity();
87 if (setCoor(x) == 0) {
88 shake_->constraintR();
89 forceMan_->calcForces();
90 if (hasFlucQ_) fqConstraints_->applyConstraints();
91 shake_->constraintF();
95 for (
int j = 0; j < 6; j++)
96 grad[j] = std::numeric_limits<RealType>::infinity();
103 if (setCoor(x) == 0) {
104 shake_->constraintR();
105 forceMan_->calcForces();
106 if (hasFlucQ_) fqConstraints_->applyConstraints();
107 shake_->constraintF();
109 return thermo.getPotential();
114 for (
int j = 0; j < 6; j++)
115 grad[j] = std::numeric_limits<RealType>::infinity();
116 return std::numeric_limits<RealType>::infinity();
124 SimInfo::MoleculeIterator miter;
133 eta.setupVoigtTensor(x[0], x[1], x[2], x[3] / 2., x[4] / 2., x[5] / 2.);
136 if (eta.frobeniusNorm() > 0.7) {
145 while (norm > 1.0e-10) {
146 y = eta - eps * eps / 2.0;
148 norm = test.frobeniusNorm();
157 posO = refPos_[index++];
159 delta = deformation_ * posO - posN;
163 Mat3x3d Hmat = deformation_ * refHmat_;
183 pressureTensor *= Constants::elasticConvert;
185 Mat3x3d tao = idm * (pressureTensor * idm);
188 lstress = tao.toVoigtTensor();
189 RealType V = thermo.getVolume();
191 for (
int j = 0; j < 6; j++) {
192 grad[j] = V * lstress[j];
198 SimInfo::MoleculeIterator miter;
203 V0_ = snap->getVolume();
208 refPos_.push_back(mol->
getCom());
RealType valueAndGradient(DynamicVector< RealType > &grad, const DynamicVector< RealType > &x)
method to overload to compute grad_f, the first derivative
RealType value(const DynamicVector< RealType > &x)
method to overload to compute the objective function value in x
void gradient(DynamicVector< RealType > &grad, const DynamicVector< RealType > &x)
method to overload to compute grad_f, the first derivative of
Dynamically-sized vector class.
ForceManager is responsible for calculating both the short range (bonded) interactions and long range...
void moveCom(const Vector3d &delta)
Moves the center of this molecule.
Vector3d getCom()
Returns the current center of mass position of this molecule.
void negate()
Negates the value of this matrix in place.
One of the heavy-weight classes of OpenMD, SimInfo maintains objects and variables relating to the cu...
Molecule * beginMolecule(MoleculeIterator &i)
Returns the first molecule in this SimInfo and intialize the iterator.
Molecule * nextMolecule(MoleculeIterator &i)
Returns the next avaliable Molecule based on the iterator.
SnapshotManager * getSnapshotManager()
Returns the snapshot manager.
The Snapshot class is a repository storing dynamic data during a Simulation.
Mat3x3d getHmat()
Returns the H-Matrix.
void setHmat(const Mat3x3d &m)
Sets the H-Matrix.
Snapshot * getCurrentSnapshot()
Returns the pointer of current snapshot.
SquareMatrix3< Real > inverse() const
Sets the value of this matrix to the inverse of itself.
Real determinant() const
Returns the determinant of this matrix.
static SquareMatrix< Real, Dim > identity()
Mat3x3d getPressureTensor()
gives the pressure tensor in amu*fs^-2*Ang^-1
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.