Loading...
Searching...
No Matches
BasinHoppingSaddleSearch.cpp
Go to the documentation of this file.
1/*
2** This file is part of eOn.
3**
4** SPDX-License-Identifier: BSD-3-Clause
5**
6** Copyright (c) 2010--present, eOn Development Team
7** All rights reserved.
8**
9** Repo:
10** https://github.com/TheochemUI/eOn
11*/
13#include "eon/Dimer.h"
14#include "eon/ImprovedDimer.h"
15#include "eon/Lanczos.h"
16#include "eon/LowestEigenmode.h"
19#include <cmath>
20#include <cstdio>
21
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"
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];
79 return 0;
80}
81
83
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