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

#include <BasinHoppingSaddleSearch.h>

Inheritance diagram for eonc::BasinHoppingSaddleSearch:

Public Member Functions

 BasinHoppingSaddleSearch (std::shared_ptr< Matter > reactant, std::shared_ptr< Matter > displacement, std::shared_ptr< Potential > potPassed, const Parameters &parametersPassed)
 ~BasinHoppingSaddleSearch ()=default
int run (void)
double getEigenvalue ()
AtomMatrix getEigenvector ()
std::string_view describeStatus (int status) const override
int getStatus () const override
Public Member Functions inherited from eonc::SaddleSearchMethod
 SaddleSearchMethod (std::shared_ptr< Potential > potPassed, const Parameters &paramsPassed)
virtual ~SaddleSearchMethod ()
virtual int getIterationCount () const
virtual int getForceCalls () const

Public Attributes

double eigenvalue {0.0}
AtomMatrix eigenvector
std::shared_ptr< Matterreactant
std::shared_ptr< Mattersaddle
std::shared_ptr< Matterproduct
int status {0}

Private Attributes

eonc::log::Scoped log

Additional Inherited Members

Protected Attributes inherited from eonc::SaddleSearchMethod
std::shared_ptr< Potentialpot
const Parametersparams

Detailed Description

Definition at line 22 of file BasinHoppingSaddleSearch.h.

Constructor & Destructor Documentation

◆ BasinHoppingSaddleSearch()

eonc::BasinHoppingSaddleSearch::BasinHoppingSaddleSearch ( std::shared_ptr< Matter > reactant,
std::shared_ptr< Matter > displacement,
std::shared_ptr< Potential > potPassed,
const Parameters & parametersPassed )
inline

Definition at line 24 of file BasinHoppingSaddleSearch.h.

28 : SaddleSearchMethod(potPassed, parametersPassed),
29 reactant{std::make_shared<Matter>(*reactant)},
30 saddle{displacement} {
31 eigenvector.resize(reactant->numberOfAtoms(), 3);
32 eigenvector.setZero();
33 }
SaddleSearchMethod(std::shared_ptr< Potential > potPassed, const Parameters &paramsPassed)

◆ ~BasinHoppingSaddleSearch()

eonc::BasinHoppingSaddleSearch::~BasinHoppingSaddleSearch ( )
default

Member Function Documentation

◆ describeStatus()

std::string_view eonc::BasinHoppingSaddleSearch::describeStatus ( int status) const
inlineoverridevirtual

Implements eonc::SaddleSearchMethod.

Definition at line 39 of file BasinHoppingSaddleSearch.h.

39 {
41 }
static constexpr std::string_view statusMessage(int status)
Human-readable message for a status code.

◆ getEigenvalue()

double BasinHoppingSaddleSearch::getEigenvalue ( )
virtual

◆ getEigenvector()

AtomMatrix BasinHoppingSaddleSearch::getEigenvector ( )
virtual

Implements eonc::SaddleSearchMethod.

Definition at line 84 of file BasinHoppingSaddleSearch.cpp.

84{ return eigenvector; }

◆ getStatus()

int eonc::BasinHoppingSaddleSearch::getStatus ( ) const
inlineoverridevirtual

Reimplemented from eonc::SaddleSearchMethod.

Definition at line 42 of file BasinHoppingSaddleSearch.h.

42{ return status; }

◆ run()

int BasinHoppingSaddleSearch::run ( void )
virtual

Implements eonc::SaddleSearchMethod.

Definition at line 22 of file BasinHoppingSaddleSearch.cpp.

22 {
23 // minimize "saddle"
24 saddle->relax(false, true, false, "displacementmin");
25 product = std::make_shared<Matter>(pot, params);
26 *product = *saddle;
27 // accept or reject based on boltzman
28 // exp(-de/(kB*params.main_options.temperature))
29 double eproduct, ereactant, de;
30 eproduct = product->getPotentialEnergy();
31 ereactant = reactant->getPotentialEnergy();
32 de = eproduct - ereactant;
33 double kB = params.constants.kB;
34 double Temperature = params.main_options.temperature;
35 double arg = -de / (kB * Temperature);
36 double p = std::exp(arg);
37 double r = eonc::helpers::random();
38 if (ereactant < eproduct) {
39 if (r > p) { // reject
40 return 1;
41 }
42 }
43 // NEB reactant to minimized "saddle"
44 NudgedElasticBand neb(reactant, product, params, pot);
45 if (!eonc::io::io_ok(
46 neb.path[0]->matter2con("neb_initial_band.con", false))) {
47 QUILL_LOG_WARNING(log, "Failed to write neb_initial_band.con");
48 }
49 for (int j = 1; j < neb.numImages; j++) {
50 if (!eonc::io::io_ok(neb.path[j]->matter2con("neb_initial_band", true))) {
51 QUILL_LOG_WARNING(log, "Failed to append neb_initial_band frame");
52 }
53 }
54 neb.compute();
55 // pick the maximum energy image along the band
56 double Emax = -1e100;
57 int HighestImage = 0;
58
59 for (int i = 1; i < neb.numImages; i++) {
60 double Etest = neb.path[i]->getPotentialEnergy();
61 QUILL_LOG_DEBUG(log, "i: {} Etest: {:.1f}", i, Etest);
62 if (Etest > Emax) {
63 Emax = Etest;
64 HighestImage = i;
65 }
66 }
67 // do dimer
68 // Calculate initial direction
69 AtomMatrix r_1 = neb.path[HighestImage - 1]->getPositions();
70 AtomMatrix r_2 = neb.path[HighestImage]->getPositions();
71 AtomMatrix r_3 = neb.path[HighestImage + 1]->getPositions();
72 AtomMatrix direction = (r_3 - r_1) / 2;
73 MinModeSaddleSearch dim(neb.path[HighestImage], direction.normalized(),
74 ereactant, params, pot);
75 dim.run();
76 *saddle = *neb.path[HighestImage];
77 eigenvalue = dim.getEigenvalue();
78 eigenvector = dim.getEigenvector();
79 return 0;
80}
Eigen::Matrix< double, Eigen::Dynamic, 3, eOnStorageOrder > AtomMatrix
Definition Eigen.h:37
std::shared_ptr< Potential > pot
double random(long newSeed=0)
constexpr bool io_ok(IoStatus s) noexcept
Definition ConFileIO.h:38

Member Data Documentation

◆ eigenvalue

double eonc::BasinHoppingSaddleSearch::eigenvalue {0.0}

Definition at line 44 of file BasinHoppingSaddleSearch.h.

44{0.0};

◆ eigenvector

AtomMatrix eonc::BasinHoppingSaddleSearch::eigenvector

Definition at line 45 of file BasinHoppingSaddleSearch.h.

◆ log

eonc::log::Scoped eonc::BasinHoppingSaddleSearch::log
private

Definition at line 54 of file BasinHoppingSaddleSearch.h.

◆ product

std::shared_ptr<Matter> eonc::BasinHoppingSaddleSearch::product

Definition at line 49 of file BasinHoppingSaddleSearch.h.

◆ reactant

std::shared_ptr<Matter> eonc::BasinHoppingSaddleSearch::reactant

Definition at line 47 of file BasinHoppingSaddleSearch.h.

◆ saddle

std::shared_ptr<Matter> eonc::BasinHoppingSaddleSearch::saddle

Definition at line 48 of file BasinHoppingSaddleSearch.h.

◆ status

int eonc::BasinHoppingSaddleSearch::status {0}

Definition at line 51 of file BasinHoppingSaddleSearch.h.

51{0};

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