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

#include <NudgedElasticBand.h>

Inheritance diagram for eonc::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)
bool supportsFiniteDifferenceCurvature () const override
Public Member Functions inherited from eonc::ObjectiveFunction
 ObjectiveFunction (const Parameters &paramsPassed)
virtual ~ObjectiveFunction ()
virtual std::optional< double > knownCurvature () const
virtual void minimumImage (Eigen::Ref< Eigen::Vector3d >) const
virtual VectorXd getMasses () const
virtual bool getPeriodic () const

Public Attributes

NudgedElasticBand::NEBStatus status

Private Attributes

NudgedElasticBand * neb

Additional Inherited Members

Protected Attributes inherited from eonc::ObjectiveFunction
const Parameters & params

Detailed Description

Definition at line 119 of file NudgedElasticBand.h.

Constructor & Destructor Documentation

◆ NEBObjectiveFunction()

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

Definition at line 121 of file NudgedElasticBand.h.

123 : ObjectiveFunction(parametersPassed), neb{nebPassed} {}
ObjectiveFunction(const Parameters &paramsPassed)

◆ ~NEBObjectiveFunction()

eonc::NEBObjectiveFunction::~NEBObjectiveFunction ( void )
inline

Definition at line 126 of file NudgedElasticBand.h.

126{};

Member Function Documentation

◆ degreesOfFreedom()

int eonc::NEBObjectiveFunction::degreesOfFreedom ( )
virtual

Implements eonc::ObjectiveFunction.

Definition at line 93 of file NEBObjectiveFunction.cpp.

93 {
94 return static_cast<int>(nebSegment(*neb) * neb->numImages);
95}

◆ difference()

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

Implements eonc::ObjectiveFunction.

Definition at line 122 of file NEBObjectiveFunction.cpp.

123 {
124 const long seg = nebSegment(*neb);
125 const long atomDof = 3L * neb->atoms;
126 VectorXd pbcDiff(seg * neb->numImages);
127 for (int i = 1; i <= neb->numImages; i++) {
128 const int n = (i - 1) * static_cast<int>(seg);
129 pbcDiff.segment(n, atomDof) =
130 neb->path[i]->pbcV(a.segment(n, atomDof) - b.segment(n, atomDof));
131 if (neb->solidState()) {
132 pbcDiff.segment(n + atomDof, 9) =
133 a.segment(n + atomDof, 9) - b.segment(n + atomDof, 9);
134 }
135 }
136 return pbcDiff;
137}

◆ getConvergence()

double eonc::NEBObjectiveFunction::getConvergence ( )
virtual

Implements eonc::ObjectiveFunction.

Definition at line 118 of file NEBObjectiveFunction.cpp.

118 {
119 return neb->convergenceForce();
120}

◆ getEnergy()

double eonc::NEBObjectiveFunction::getEnergy ( )
virtual

Implements eonc::ObjectiveFunction.

Definition at line 47 of file NEBObjectiveFunction.cpp.

47 {
48 // The band update evaluates dirty images as one batch; summing image
49 // energies on a moved band would otherwise evaluate them one at a time.
50 if (neb->movedAfterForceCall)
51 neb->updateForces();
52 double Energy{0};
53 for (long i = 1; i <= neb->numImages; i++) {
54 Energy += neb->path[i]->getPotentialEnergy();
55 }
56 return Energy;
57}

◆ getGradient()

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

Implements eonc::ObjectiveFunction.

Definition at line 24 of file NEBObjectiveFunction.cpp.

24 {
25 if (neb->movedAfterForceCall)
26 neb->updateForces();
27 const long seg = nebSegment(*neb);
28 const long atomDof = 3L * neb->atoms;
29 VectorXd gradV(seg * neb->numImages);
30 for (long i = 1; i <= neb->numImages; i++) {
31 // Negate in-place during copy to avoid a second pass over 40KB
32 gradV.segment(seg * (i - 1), atomDof) =
33 -VectorXd::Map(neb->projectedForce[i]->data(), atomDof);
34 if (neb->solidState()) {
35 const eonc::neb::CartesianStep step = eonc::neb::solidStateCartesianStep(
36 *neb->path[i], *neb->projectedForce[i], neb->cellForce(i),
37 neb->solidJacobian());
38 gradV.segment(seg * (i - 1), atomDof) =
39 -VectorXd::Map(step.positions.data(), atomDof);
40 gradV.segment(seg * (i - 1) + atomDof, 9) =
41 -VectorXd::Map(step.cell.data(), 9);
42 }
43 }
44 return gradV;
45}
CartesianStep solidStateCartesianStep(const Matter &image, const AtomMatrix &atomicForce, const Matrix3d &cellForce, double jacobian)

◆ getPositions()

VectorXd eonc::NEBObjectiveFunction::getPositions ( )
virtual

Implements eonc::ObjectiveFunction.

Definition at line 77 of file NEBObjectiveFunction.cpp.

77 {
78 const long seg = nebSegment(*neb);
79 const long atomDof = 3L * neb->atoms;
80 VectorXd posV(seg * neb->numImages);
81 for (long i = 1; i <= neb->numImages; i++) {
82 const long offset = seg * (i - 1);
83 posV.segment(offset, atomDof) =
84 VectorXd::Map(neb->path[i]->getPositions().data(), atomDof);
85 if (neb->solidState()) {
86 posV.segment(offset + atomDof, 9) =
87 VectorXd::Map(neb->path[i]->getCell().data(), 9);
88 }
89 }
90 return posV;
91}

◆ isConverged()

bool eonc::NEBObjectiveFunction::isConverged ( )
virtual

Implements eonc::ObjectiveFunction.

Definition at line 113 of file NEBObjectiveFunction.cpp.

113 {
114 bool force_conv = getConvergence() < params.neb_options().force_tolerance;
115 return force_conv;
116}
const Parameters & params

◆ isUncertain()

bool eonc::NEBObjectiveFunction::isUncertain ( )

Definition at line 97 of file NEBObjectiveFunction.cpp.

97 {
98 double maxMaxUnc = std::numeric_limits<double>::lowest();
99 double currentMaxUnc{0};
100 for (long idx = 0; idx <= neb->numImages + 1; idx++) {
101 currentMaxUnc = neb->path[idx]->getEnergyVariance();
102 if (currentMaxUnc > maxMaxUnc) {
103 maxMaxUnc = currentMaxUnc;
104 }
105 }
106 bool unc_conv{maxMaxUnc > params.gp_surrogate_options().uncertainty};
107 if (unc_conv) {
109 }
110 return unc_conv;
111}
NudgedElasticBand::NEBStatus status

◆ setPositions()

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

Implements eonc::ObjectiveFunction.

Definition at line 59 of file NEBObjectiveFunction.cpp.

59 {
60 neb->movedAfterForceCall = true;
61 const long seg = nebSegment(*neb);
62 const long atomDof = 3L * neb->atoms;
63 for (long i = 1; i <= neb->numImages; i++) {
64 const long offset = seg * (i - 1);
65 if (neb->solidState()) {
66 Matrix3d cell = Matrix3d::Map(x.segment(offset + atomDof, 9).data());
67 cell(0, 1) = 0.0;
68 cell(0, 2) = 0.0;
69 cell(1, 2) = 0.0;
70 neb->path[i]->setCell(cell);
71 }
72 neb->path[i]->setPositions(
73 AtomMatrix::Map(x.segment(offset, atomDof).data(), neb->atoms, 3));
74 }
75}
Eigen::Matrix< double, 3, 3, eOnStorageOrder > Matrix3d
Definition Eigen.h:35

◆ supportsFiniteDifferenceCurvature()

bool eonc::NEBObjectiveFunction::supportsFiniteDifferenceCurvature ( ) const
inlineoverridevirtual

Reimplemented from eonc::ObjectiveFunction.

Definition at line 138 of file NudgedElasticBand.h.

138{ return false; }

Member Data Documentation

◆ neb

NudgedElasticBand* eonc::NEBObjectiveFunction::neb
private

Definition at line 142 of file NudgedElasticBand.h.

◆ status

NudgedElasticBand::NEBStatus eonc::NEBObjectiveFunction::status

Definition at line 139 of file NudgedElasticBand.h.


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