59#include "brains/Register.hpp"
62#include "brains/Thermo.hpp"
63#include "brains/Velocitizer.hpp"
64#include "constraints/Shake.hpp"
66#include "flucq/FluctuatingChargeConstraints.hpp"
67#include "flucq/FluctuatingChargeDamped.hpp"
72#include "optimization/BoxObjectiveFunction.hpp"
75#include "optimization/OptimizationFactory.hpp"
87template<
typename Real>
88class Vector6 :
public Vector<Real, 6> {
90 using ElemType = Real;
91 using ElemPoinerType = Real*;
93 Vector6() :
Vector<Real, 6>() {}
96 inline Vector6(RealType v0, RealType v1, RealType v2, RealType v3,
97 RealType v4, RealType v5) {
106 inline Vector6(Real* array) :
Vector<Real, 6>(array) {}
111 if (
this == &v) {
return *
this; }
117using Vector6d = Vector6<RealType>;
119RealType slope(
const std::vector<RealType>& x,
const std::vector<RealType>& y) {
125 const size_t n = x.size();
126 const RealType s_x = std::accumulate(x.begin(), x.end(), 0.0);
127 const RealType s_y = std::accumulate(y.begin(), y.end(), 0.0);
128 const RealType s_xx = std::inner_product(x.begin(), x.end(), x.begin(), 0.0);
129 const RealType s_xy = std::inner_product(x.begin(), x.end(), y.begin(), 0.0);
130 const RealType a = (n * s_xy - s_x * s_y) / (n * s_xx - s_x * s_x);
134void quadraticFit(
const std::vector<RealType>& x,
135 const std::vector<RealType>& y, RealType& a, RealType& b,
137 RealType s00 = RealType(x.size());
138 RealType s10(0.0), s20(0.0), s30(0.0), s40(0.0);
139 RealType s01(0.0), s11(0.0), s21(0.0);
141 for (
size_t i = 0; i < x.size(); i++) {
149 s21 += pow(x[i], 2) * y[i];
153 RealType D = (s40 * (s20 * s00 - s10 * s10) - s30 * (s30 * s00 - s10 * s20) +
154 s20 * (s30 * s10 - s20 * s20));
156 a = (s21 * (s20 * s00 - s10 * s10) - s11 * (s30 * s00 - s10 * s20) +
157 s01 * (s30 * s10 - s20 * s20)) /
160 b = (s40 * (s11 * s00 - s01 * s10) - s30 * (s21 * s00 - s01 * s20) +
161 s20 * (s21 * s10 - s11 * s20)) /
164 c = (s40 * (s20 * s01 - s10 * s11) - s30 * (s30 * s01 - s10 * s21) +
165 s20 * (s30 * s11 - s20 * s21)) /
173 std::cout << left << title <<
" (" << units <<
"):" << std::endl;
174 std::cout << std::endl;
177 std::cout << right << setw(12) << M(0, 0) <<
" ";
178 std::cout << right << setw(12) << M(0, 1) <<
" ";
179 std::cout << right << setw(12) << M(0, 2) <<
" ";
180 std::cout << right << setw(12) << M(0, 3) <<
" ";
181 std::cout << right << setw(12) << M(0, 4) <<
" ";
182 std::cout << right << setw(12) << M(0, 5);
183 std::cout << std::endl;
186 std::cout << right << setw(12) << M(1, 0) <<
" ";
187 std::cout << right << setw(12) << M(1, 1) <<
" ";
188 std::cout << right << setw(12) << M(1, 2) <<
" ";
189 std::cout << right << setw(12) << M(1, 3) <<
" ";
190 std::cout << right << setw(12) << M(1, 4) <<
" ";
191 std::cout << right << setw(12) << M(1, 5);
192 std::cout << std::endl;
195 std::cout << right << setw(12) << M(2, 0) <<
" ";
196 std::cout << right << setw(12) << M(2, 1) <<
" ";
197 std::cout << right << setw(12) << M(2, 2) <<
" ";
198 std::cout << right << setw(12) << M(2, 3) <<
" ";
199 std::cout << right << setw(12) << M(2, 4) <<
" ";
200 std::cout << right << setw(12) << M(2, 5);
201 std::cout << std::endl;
204 std::cout << right << setw(12) << M(3, 0) <<
" ";
205 std::cout << right << setw(12) << M(3, 1) <<
" ";
206 std::cout << right << setw(12) << M(3, 2) <<
" ";
207 std::cout << right << setw(12) << M(3, 3) <<
" ";
208 std::cout << right << setw(12) << M(3, 4) <<
" ";
209 std::cout << right << setw(12) << M(3, 5);
210 std::cout << std::endl;
213 std::cout << right << setw(12) << M(4, 0) <<
" ";
214 std::cout << right << setw(12) << M(4, 1) <<
" ";
215 std::cout << right << setw(12) << M(4, 2) <<
" ";
216 std::cout << right << setw(12) << M(4, 3) <<
" ";
217 std::cout << right << setw(12) << M(4, 4) <<
" ";
218 std::cout << right << setw(12) << M(4, 5);
219 std::cout << std::endl;
222 std::cout << right << setw(12) << M(5, 0) <<
" ";
223 std::cout << right << setw(12) << M(5, 1) <<
" ";
224 std::cout << right << setw(12) << M(5, 2) <<
" ";
225 std::cout << right << setw(12) << M(5, 3) <<
" ";
226 std::cout << right << setw(12) << M(5, 4) <<
" ";
227 std::cout << right << setw(12) << M(5, 5);
228 std::cout << std::endl;
229 std::cout << std::endl;
232void writeBoxGeometries(Mat3x3d org, Mat3x3d opt, std::string title1,
233 std::string title2, std::string units) {
234 std::cout << left << title1 <<
" (" << units <<
"):" << std::endl;
235 std::cout << std::endl;
237 std::cout << right << setw(12) << org(0, 0) <<
" ";
238 std::cout << right << setw(12) << org(0, 1) <<
" ";
239 std::cout << right << setw(12) << org(0, 2) <<
" ";
240 std::cout << std::endl;
242 std::cout << right << setw(12) << org(1, 0) <<
" ";
243 std::cout << right << setw(12) << org(1, 1) <<
" ";
244 std::cout << right << setw(12) << org(1, 2) <<
" ";
245 std::cout << std::endl;
247 std::cout << right << setw(12) << org(2, 0) <<
" ";
248 std::cout << right << setw(12) << org(2, 1) <<
" ";
249 std::cout << right << setw(12) << org(2, 2) <<
" ";
250 std::cout << std::endl;
251 std::cout << std::endl;
252 std::cout << left << title2 <<
" (" << units <<
"):" << std::endl;
253 std::cout << std::endl;
255 std::cout << right << setw(12) << opt(0, 0) <<
" ";
256 std::cout << right << setw(12) << opt(0, 1) <<
" ";
257 std::cout << right << setw(12) << opt(0, 2) <<
" ";
258 std::cout << std::endl;
260 std::cout << right << setw(12) << opt(1, 0) <<
" ";
261 std::cout << right << setw(12) << opt(1, 1) <<
" ";
262 std::cout << right << setw(12) << opt(1, 2) <<
" ";
263 std::cout << std::endl;
265 std::cout << right << setw(12) << opt(2, 0) <<
" ";
266 std::cout << right << setw(12) << opt(2, 1) <<
" ";
267 std::cout << right << setw(12) << opt(2, 2) <<
" ";
268 std::cout << std::endl;
269 std::cout << std::endl;
274 RealType C11 = C(0, 0);
275 RealType C22 = C(1, 1);
276 RealType C33 = C(2, 2);
277 RealType C12 = C(0, 1);
278 RealType C23 = C(1, 2);
279 RealType C31 = C(2, 0);
280 RealType C44 = C(3, 3);
281 RealType C55 = C(4, 4);
282 RealType C66 = C(5, 5);
284 RealType S11 = S(0, 0);
285 RealType S22 = S(1, 1);
286 RealType S33 = S(2, 2);
287 RealType S12 = S(0, 1);
288 RealType S23 = S(1, 2);
289 RealType S31 = S(2, 0);
290 RealType S44 = S(3, 3);
291 RealType S55 = S(4, 4);
292 RealType S66 = S(5, 5);
316 RealType Kv = ((C11 + C22 + C33) + 2.0 * (C12 + C23 + C31)) / 9.0;
318 RealType Kr = 1.0 / ((S11 + S22 + S33) + 2.0 * (S12 + S23 + S31));
321 ((C11 + C22 + C33) - (C12 + C23 + C31) + 3.0 * (C44 + C55 + C66)) / 15.0;
323 RealType Gr = 15.0 / (4.0 * (S11 + S22 + S33) - 4.0 * (S12 + S23 + S31) +
324 3.0 * (S44 + S55 + S66));
326 RealType Kh = (Kv + Kr) / 2.0;
328 RealType Gh = (Gv + Gr) / 2.0;
330 RealType Au = 5.0 * (Gv / Gr) + (Kv / Kr) - 6.0;
332 RealType muv = (1.0 - 3.0 * Gv / (3.0 * Kv + Gv)) / 2.0;
333 RealType mur = (1.0 - 3.0 * Gr / (3.0 * Kr + Gr)) / 2.0;
334 RealType muh = (1.0 - 3.0 * Gh / (3.0 * Kh + Gh)) / 2.0;
336 RealType Ev = 1.0 / (1.0 / (3.0 * Gv) + 1.0 / (9.0 * Kv));
337 RealType Er = 1.0 / (1.0 / (3.0 * Gr) + 1.0 / (9.0 * Kr));
338 RealType Eh = 1.0 / (1.0 / (3.0 * Gh) + 1.0 / (9.0 * Kh));
340 std::cout <<
" " << setw(12) <<
"Voigt"
341 <<
" " << setw(12) <<
"Reuss"
342 <<
" " << setw(12) <<
"Hill\n";
343 std::cout <<
"Bulk modulus: " << setw(12) << Kv <<
" "
344 << setw(12) << Kr <<
" " << setw(12) << Kh <<
" (GPa)\n";
346 std::cout <<
"Shear modulus: " << setw(12) << Gv <<
" "
347 << setw(12) << Gr <<
" " << setw(12) << Gh <<
" (GPa)\n";
349 std::cout <<
"Young\'s modulus (isotropic): " << setw(12) << Ev <<
" "
350 << setw(12) << Er <<
" " << setw(12) << Eh <<
" (GPa)\n";
352 std::cout <<
"Poisson\'s Ratio: " << setw(12) << muv <<
" "
353 << setw(12) << mur <<
" " << setw(12) << muh <<
"\n";
355 std::cout <<
"Universal elastic Anisotropy: " << setw(12) << Au <<
"\n";
382int main(
int argc,
char* argv[]) {
384 std::string inputFileName;
385 std::string outputFileName;
390 if (cmdline_parser(argc, argv, &args_info) != 0) {
400 inputFileName = args_info.
inputs[0];
402 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
403 "No input file name was specified on the command line");
404 painCave.severity = OPENMD_ERROR;
405 painCave.isFatal = 1;
422 if (!method.compare(
"energy")) {
448 std::vector<Vector6d> eStrains;
451 eStrains.push_back(Vector6d(1., 0., 0., 0., 0., 0.));
452 eStrains.push_back(Vector6d(0., 1., 0., 0., 0., 0.));
453 eStrains.push_back(Vector6d(0., 0., 1., 0., 0., 0.));
454 eStrains.push_back(Vector6d(0., 0., 0., 2., 0., 0.));
455 eStrains.push_back(Vector6d(0., 0., 0., 0., 2., 0.));
456 eStrains.push_back(Vector6d(0., 0., 0., 0., 0., 2.));
457 eStrains.push_back(Vector6d(1., 1., 0., 0., 0., 0.));
458 eStrains.push_back(Vector6d(1., 0., 1., 0., 0., 0.));
459 eStrains.push_back(Vector6d(1., 0., 0., 2., 0., 0.));
460 eStrains.push_back(Vector6d(1., 0., 0., 0., 2., 0.));
461 eStrains.push_back(Vector6d(1., 0., 0., 0., 0., 2.));
462 eStrains.push_back(Vector6d(0., 1., 1., 0., 0., 0.));
463 eStrains.push_back(Vector6d(0., 1., 0., 2., 0., 0.));
464 eStrains.push_back(Vector6d(0., 1., 0., 0., 2., 0.));
465 eStrains.push_back(Vector6d(0., 1., 0., 0., 0., 2.));
466 eStrains.push_back(Vector6d(0., 0., 1., 2., 0., 0.));
467 eStrains.push_back(Vector6d(0., 0., 1., 0., 2., 0.));
468 eStrains.push_back(Vector6d(0., 0., 1., 0., 0., 2.));
469 eStrains.push_back(Vector6d(0., 0., 0., 2., 2., 0.));
470 eStrains.push_back(Vector6d(0., 0., 0., 2., 0., 2.));
471 eStrains.push_back(Vector6d(0., 0., 0., 0., 2., 2.));
497 std::vector<Vector6d> sStrains;
498 sStrains.push_back(Vector6d(1., 2., 3., 4., 5., 6.));
499 sStrains.push_back(Vector6d(-2., 1., 4., -3., 6., -5.));
500 sStrains.push_back(Vector6d(3., -5., -1., 6., 2., -4.));
501 sStrains.push_back(Vector6d(-4., -6., 5., 1., -3., 2.));
502 sStrains.push_back(Vector6d(5., 4., 6., -2., -1., -3.));
503 sStrains.push_back(Vector6d(-6., 3., -2., 5., -4., 1.));
505 std::vector<Vector6d> strainBasis;
507 if (!method.compare(
"energy")) {
508 strainBasis = eStrains;
510 strainBasis = sStrains;
517 RealType mat[36][21] = {
518 {1, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
519 {0, 1, 0, 0, 0, 0, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
520 {0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0},
521 {0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 4, 5, 6, 0, 0, 0},
522 {0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 4, 0, 5, 6, 0},
523 {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 4, 0, 5, 6},
524 {-2, 1, 4, -3, 6, -5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
525 {0, -2, 0, 0, 0, 0, 1, 4, -3, 6, -5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
526 {0, 0, -2, 0, 0, 0, 0, 1, 0, 0, 0, 4, -3, 6, -5, 0, 0, 0, 0, 0, 0},
527 {0, 0, 0, -2, 0, 0, 0, 0, 1, 0, 0, 0, 4, 0, 0, -3, 6, -5, 0, 0, 0},
528 {0, 0, 0, 0, -2, 0, 0, 0, 0, 1, 0, 0, 0, 4, 0, 0, -3, 0, 6, -5, 0},
529 {0, 0, 0, 0, 0, -2, 0, 0, 0, 0, 1, 0, 0, 0, 4, 0, 0, -3, 0, 6, -5},
530 {3, -5, -1, 6, 2, -4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
531 {0, 3, 0, 0, 0, 0, -5, -1, 6, 2, -4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
532 {0, 0, 3, 0, 0, 0, 0, -5, 0, 0, 0, -1, 6, 2, -4, 0, 0, 0, 0, 0, 0},
533 {0, 0, 0, 3, 0, 0, 0, 0, -5, 0, 0, 0, -1, 0, 0, 6, 2, -4, 0, 0, 0},
534 {0, 0, 0, 0, 3, 0, 0, 0, 0, -5, 0, 0, 0, -1, 0, 0, 6, 0, 2, -4, 0},
535 {0, 0, 0, 0, 0, 3, 0, 0, 0, 0, -5, 0, 0, 0, -1, 0, 0, 6, 0, 2, -4},
536 {-4, -6, 5, 1, -3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
537 {0, -4, 0, 0, 0, 0, -6, 5, 1, -3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
538 {0, 0, -4, 0, 0, 0, 0, -6, 0, 0, 0, 5, 1, -3, 2, 0, 0, 0, 0, 0, 0},
539 {0, 0, 0, -4, 0, 0, 0, 0, -6, 0, 0, 0, 5, 0, 0, 1, -3, 2, 0, 0, 0},
540 {0, 0, 0, 0, -4, 0, 0, 0, 0, -6, 0, 0, 0, 5, 0, 0, 1, 0, -3, 2, 0},
541 {0, 0, 0, 0, 0, -4, 0, 0, 0, 0, -6, 0, 0, 0, 5, 0, 0, 1, 0, -3, 2},
542 {5, 4, 6, -2, -1, -3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
543 {0, 5, 0, 0, 0, 0, 4, 6, -2, -1, -3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
544 {0, 0, 5, 0, 0, 0, 0, 4, 0, 0, 0, 6, -2, -1, -3, 0, 0, 0, 0, 0, 0},
545 {0, 0, 0, 5, 0, 0, 0, 0, 4, 0, 0, 0, 6, 0, 0, -2, -1, -3, 0, 0, 0},
546 {0, 0, 0, 0, 5, 0, 0, 0, 0, 4, 0, 0, 0, 6, 0, 0, -2, 0, -1, -3, 0},
547 {0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 4, 0, 0, 0, 6, 0, 0, -2, 0, -1, -3},
548 {-6, 3, -2, 5, -4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
549 {0, -6, 0, 0, 0, 0, 3, -2, 5, -4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
550 {0, 0, -6, 0, 0, 0, 0, 3, 0, 0, 0, -2, 5, -4, 1, 0, 0, 0, 0, 0, 0},
551 {0, 0, 0, -6, 0, 0, 0, 0, 3, 0, 0, 0, -2, 0, 0, 5, -4, 1, 0, 0, 0},
552 {0, 0, 0, 0, -6, 0, 0, 0, 0, 3, 0, 0, 0, -2, 0, 0, 5, 0, -4, 1, 0},
553 {0, 0, 0, 0, 0, -6, 0, 0, 0, 0, 3, 0, 0, 0, -2, 0, 0, 5, 0, -4, 1}};
563 Globals* simParams = info->getSimParams();
566 std::unique_ptr<Velocitizer> veloSet {std::make_unique<Velocitizer>(info)};
571 bool hasFlucQ =
false;
574 if (info->usesFluctuatingCharges()) {
577 flucQ->setForceManager(forceMan);
586 veloSet->removeComDrift();
589 std::cout <<
"Doing box optimization\n\n";
601 snprintf(painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
602 "Optimization Factory can not create %s OptimizationMethod\n",
603 miniPars->getMethod().c_str());
604 painCave.isFatal = 1;
612 Problem problem(boxObjf, noConstraint, dsf, initCoords);
614 int maxIter = miniPars->getMaxIterations();
615 int mssIter = miniPars->getMaxStationaryStateIterations();
616 RealType rEps = miniPars->getRootEpsilon();
617 RealType fEps = miniPars->getFunctionEpsilon();
618 RealType gnEps = miniPars->getGradientNormEpsilon();
619 RealType initialStepSize = miniPars->getInitialStepSize();
621 EndCriteria endCriteria(maxIter, mssIter, rEps, fEps, gnEps);
623 minim->
minimize(problem, endCriteria, initialStepSize);
628 writeBoxGeometries(oldHmat, newHmat,
"Original Box Geometry",
629 "Optimized Box Geometry",
"Angstroms");
633 Mat3x3d refHmat = snap->
getHmat();
635 forceMan->calcForces();
636 Mat3x3d ptRef = thermo.getPressureTensor();
637 RealType V0 = thermo.getVolume();
639 ptRef *= Constants::elasticConvert;
641 Vector6d stress(0.0);
642 Vector6d strain(0.0);
643 Vector6d lstress(0.0);
644 Mat3x3d epsilon(0.0);
646 std::vector<std::vector<RealType>> stressStrain;
647 std::vector<RealType> strainValues;
648 std::vector<RealType> energyValues;
655 SimInfo::MoleculeIterator miter;
665 Mat3x3d deformation(0.0);
666 std::vector<RealType> A2;
670 Mat3x3d pressureTensor;
672 for (std::vector<Vector6d>::iterator it = strainBasis.begin();
673 it != strainBasis.end(); ++it) {
675 int ii = std::distance(strainBasis.begin(), it);
677 strainValues.clear();
678 energyValues.clear();
679 stressStrain.clear();
680 stressStrain.resize(6);
682 for (
int n = 0; n < nMax; n++) {
684 de = -0.5 * dmax + dmax * RealType(n) / RealType(nMax - 1);
688 eta.setupVoigtTensor(L[0], L[1], L[2], L[3] / 2., L[4] / 2., L[5] / 2.);
691 if (eta.frobeniusNorm() > 0.7) {
692 std::cerr <<
"Deformation is too large!\n";
699 while (norm > 1.0e-10) {
700 x = eta - eps * eps / 2.0;
702 norm = test.frobeniusNorm();
713 delta = deformation * pos;
716 Mat3x3d Hmat = deformation * refHmat;
718 shake->constraintR();
719 forceMan->calcForces();
720 if (hasFlucQ) flucQ->applyConstraints();
721 shake->constraintF();
724 if (!method.compare(
"energy")) {
725 energy = thermo.getPotential();
726 energyValues.push_back(energy);
735 Mat3x3d idm = deformation.inverse();
736 RealType ddm = deformation.determinant();
738 pressureTensor = thermo.getPressureTensor();
740 pressureTensor *= Constants::elasticConvert;
742 Mat3x3d tao = idm * (pressureTensor * idm);
745 lstress = tao.toVoigtTensor();
747 for (
int j = 0; j < 6; j++) {
748 stressStrain[j].push_back(lstress[j]);
752 strainValues.push_back(de);
757 if (!method.compare(
"energy")) {
758 quadraticFit(strainValues, energyValues, a, b, c);
759 A2.push_back(a * Constants::energyElasticConvert / V0);
761 for (
int j = 0; j < 6; j++) {
762 quadraticFit(strainValues, stressStrain[j], a, b, c);
763 sigma(6 * ii + j) = b;
769 if (!method.compare(
"energy")) {
770 C(0, 0) = 2. * A2[0];
771 C(0, 1) = 1. * (-A2[0] - A2[1] + A2[6]);
772 C(0, 2) = 1. * (-A2[0] - A2[2] + A2[7]);
773 C(0, 3) = .5 * (-A2[0] - A2[3] + A2[8]);
774 C(0, 4) = .5 * (-A2[0] + A2[9] - A2[4]);
775 C(0, 5) = .5 * (-A2[0] + A2[10] - A2[5]);
776 C(1, 1) = 2. * A2[1];
777 C(1, 2) = 1. * (A2[11] - A2[1] - A2[2]);
778 C(1, 3) = .5 * (A2[12] - A2[1] - A2[3]);
779 C(1, 4) = .5 * (A2[13] - A2[1] - A2[4]);
780 C(1, 5) = .5 * (A2[14] - A2[1] - A2[5]);
781 C(2, 2) = 2. * A2[2];
782 C(2, 3) = .5 * (A2[15] - A2[2] - A2[3]);
783 C(2, 4) = .5 * (A2[16] - A2[2] - A2[4]);
784 C(2, 5) = .5 * (A2[17] - A2[2] - A2[5]);
785 C(3, 3) = .5 * A2[3];
786 C(3, 4) = .25 * (A2[18] - A2[3] - A2[4]);
787 C(3, 5) = .25 * (A2[19] - A2[3] - A2[5]);
788 C(4, 4) = .5 * A2[4];
789 C(4, 5) = .25 * (A2[20] - A2[4] - A2[5]);
790 C(5, 5) = .5 * A2[5];
796 ci = qr.solve(sigma);
823 for (
int i = 0; i < 5; i++) {
824 for (
int j = i + 1; j < 6; j++) {
833 writeMatrix(C,
"Elastic Tensor",
"GPa");
834 writeMatrix(S,
"Compliance Tensor",
"GPa^-1");
836 writeMaterialProperties(C, S);
Abstract constraint class.
void cmdline_parser_print_help(void)
Print the help.
Abstract optimization method class.
Abstract optimization problem class.
Rectangular matrix class with contiguous flat storage.
Dynamically-sized vector class.
abstract class for propagating fluctuating charge variables
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.
static OptimizationFactory & getInstance()
Returns an instance of Optimization factory.
QuantLib::OptimizationMethod * createOptimization(const std::string &id, SimInfo *info)
Looks up the type identifier in the internal map.
void negate()
Negates the value of this matrix in place.
The only responsibility of SimCreator is to parse the meta-data file and create a SimInfo instance ba...
SimInfo * createSim(const std::string &mdFileName, bool loadInitCoords=true)
Setup Simulation.
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.
int getNFluctuatingCharges()
Returns the total number of fluctuating charges that are present.
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.
Vector< Real, Dim > & operator=(const Vector< Real, Dim > &v)
copy assignment operator
Criteria to end optimization process:
Abstract class for constrained optimization method.
virtual EndCriteria::Type minimize(Problem &P, const EndCriteria &endCriteria, RealType initialStepSize)=0
minimize the optimization problem P
Constrained optimization problem.
The header file for the command line option parser generated by GNU Gengetopt version 2....
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.
void registerAll()
register force fields, integrators and optimizers
bool invertMatrix(MatrixType &A, MatrixType &AI)
Invert input square matrix A into matrix AI.
Where the command line options are stored.
unsigned inputs_num
unamed options number
char ** inputs
unamed options (options without names)
char * input_arg
input dump file.
unsigned int method_given
Whether method was given.
int npoints_arg
number of points for fitting stress-strain relationship (default='25').
unsigned int delta_given
Whether delta was given.
double delta_arg
size of relative volume changes for strains.
int box_flag
Optimize box geometry before performing calculation (default=off).
unsigned int input_given
Whether input was given.
char * method_arg
Calculation Method.