Loading...
Searching...
No Matches
NEBObjectiveFunction Class Reference

#include <NudgedElasticBand.h>

Inheritance diagram for NEBObjectiveFunction:

Public Member Functions

 NEBObjectiveFunction (NudgedElasticBand *nebPassed, const Parameters &parametersPassed)
 ~NEBObjectiveFunction (void)
VectorXd getGradient (bool fdstep=false)
double getEnergy ()
void setPositions (const VectorXd &x)
VectorXd getPositions ()
int degreesOfFreedom ()
bool isConverged ()
bool isUncertain ()
double getConvergence ()
VectorXd difference (const VectorXd &a, const VectorXd &b)
Public Member Functions inherited from eonc::ObjectiveFunction
 ObjectiveFunction (const Parameters &paramsPassed)
virtual ~ObjectiveFunction ()

Public Attributes

NudgedElasticBand::NEBStatus status

Private Attributes

NudgedElasticBandneb

Additional Inherited Members

Protected Attributes inherited from eonc::ObjectiveFunction
const Parametersparams

Detailed Description

Definition at line 106 of file NudgedElasticBand.h.

Constructor & Destructor Documentation

◆ NEBObjectiveFunction()

eonc::NEBObjectiveFunction::NEBObjectiveFunction ( NudgedElasticBand * nebPassed,
const Parameters & parametersPassed )
inline

Definition at line 108 of file NudgedElasticBand.h.

110 : ObjectiveFunction(parametersPassed),
111 neb{nebPassed} {}
NudgedElasticBand * neb
ObjectiveFunction(const Parameters &paramsPassed)

◆ ~NEBObjectiveFunction()

Definition at line 114 of file NudgedElasticBand.h.

114{};

Member Function Documentation

◆ degreesOfFreedom()

Implements eonc::ObjectiveFunction.

Definition at line 56 of file NEBObjectiveFunction.cpp.

56 {
57 return 3 * neb->numImages * neb->atoms;
58}

◆ difference()

VectorXd eonc::NEBObjectiveFunction::difference ( const VectorXd & a,
const VectorXd & b )
virtual

Implements eonc::ObjectiveFunction.

Definition at line 85 of file NEBObjectiveFunction.cpp.

86 {
87 VectorXd pbcDiff(3 * neb->numImages * neb->atoms);
88 for (int i = 1; i <= neb->numImages; i++) {
89 int n = (i - 1) * 3 * neb->atoms;
90 int m = 3 * neb->atoms;
91 pbcDiff.segment(n, m) =
92 neb->path[i]->pbcV(a.segment(n, m) - b.segment(n, m));
93 }
94 return pbcDiff;
95}

◆ getConvergence()

Implements eonc::ObjectiveFunction.

Definition at line 81 of file NEBObjectiveFunction.cpp.

81 {
82 return neb->convergenceForce();
83}

◆ getEnergy()

Implements eonc::ObjectiveFunction.

Definition at line 29 of file NEBObjectiveFunction.cpp.

29 {
30 double Energy{0};
31 for (long i = 1; i <= neb->numImages; i++) {
32 Energy += neb->path[i]->getPotentialEnergy();
33 }
34 return Energy;
35}

◆ getGradient()

VectorXd eonc::NEBObjectiveFunction::getGradient ( bool fdstep = false)
virtual

Implements eonc::ObjectiveFunction.

Definition at line 16 of file NEBObjectiveFunction.cpp.

16 {
17 if (neb->movedAfterForceCall)
18 neb->updateForces();
19 const long seg = 3 * neb->atoms;
20 VectorXd gradV(seg * neb->numImages);
21 for (long i = 1; i <= neb->numImages; i++) {
22 // Negate in-place during copy to avoid a second pass over 40KB
23 gradV.segment(seg * (i - 1), seg) =
24 -VectorXd::Map(neb->projectedForce[i]->data(), seg);
25 }
26 return gradV;
27}

◆ getPositions()

Implements eonc::ObjectiveFunction.

Definition at line 46 of file NEBObjectiveFunction.cpp.

46 {
47 VectorXd posV;
48 posV.resize(3 * neb->atoms * neb->numImages);
49 for (long i = 1; i <= neb->numImages; i++) {
50 posV.segment(3 * neb->atoms * (i - 1), 3 * neb->atoms) =
51 VectorXd::Map(neb->path[i]->getPositions().data(), 3 * neb->atoms);
52 }
53 return posV;
54}

◆ isConverged()

Implements eonc::ObjectiveFunction.

Definition at line 76 of file NEBObjectiveFunction.cpp.

76 {
77 bool force_conv = getConvergence() < params.neb_options.force_tolerance;
78 return force_conv;
79}
const Parameters & params

◆ isUncertain()

Definition at line 60 of file NEBObjectiveFunction.cpp.

60 {
61 double maxMaxUnc = std::numeric_limits<double>::lowest();
62 double currentMaxUnc{0};
63 for (long idx = 0; idx <= neb->numImages; idx++) {
64 currentMaxUnc = neb->path[idx]->getEnergyVariance();
65 if (currentMaxUnc > maxMaxUnc) {
66 maxMaxUnc = currentMaxUnc;
67 }
68 }
69 bool unc_conv{maxMaxUnc > params.gp_surrogate_options.uncertainty};
70 if (unc_conv) {
72 }
73 return unc_conv;
74}
NudgedElasticBand::NEBStatus status

◆ setPositions()

void eonc::NEBObjectiveFunction::setPositions ( const VectorXd & x)
virtual

Implements eonc::ObjectiveFunction.

Definition at line 37 of file NEBObjectiveFunction.cpp.

37 {
38 neb->movedAfterForceCall = true;
39 for (long i = 1; i <= neb->numImages; i++) {
40 neb->path[i]->setPositions(AtomMatrix::Map(
41 x.segment(3 * neb->atoms * (i - 1), 3 * neb->atoms).data(), neb->atoms,
42 3));
43 }
44}

Member Data Documentation

◆ neb

◆ status


The documentation for this class was generated from the following files: