Virtual run; used solely for dynamic dispatch.
29 {
34 throw std::runtime_error("failed to load " + posFile);
35 }
37
38 constexpr std::array<double, 9> dRs = {1e-7, 1e-6, 1e-5, 1e-4, 1e-3,
39 5e-3, 0.01, 0.05, 0.1};
40
42
43 const double cutoff =
params.structure_comparison_options().neighbor_cutoff;
44 long epicenter =
47 displacement.resize(
reactant->numberOfAtoms(), 3);
48 displacement.setZero();
49 std::string displaced;
50 for (
int i = 0; i <
reactant->numberOfAtoms(); i++) {
51 if (
reactant->distance(epicenter, i) <= cutoff) {
52
53
54 if (!displaced.empty()) {
55 displaced.push_back(' ');
56 }
57 displaced += std::to_string(i);
58 for (int j = 0; j < 3; j++) {
60 continue;
61 }
63 }
64 }
65 }
67 const double dispNorm = displacement.norm();
68 if (!(dispNorm > 0.0)) {
69 throw std::runtime_error(
70 "FiniteDifferenceJob: no free atoms in the epicenter neighborhood");
71 }
72 displacement /= dispNorm;
73
76 pots().total_force_calls(),
false, 0.0);
78 env.job_type = "finite_difference";
79
80 std::ofstream table("curvature.dat");
81 table << std::format("{:>14s} {:>14s}\n", "dR", "curvature");
85 double curvature = 0.0;
86 for (size_t dRi = 0; dRi < dRs.size(); ++dRi) {
87 posB = posA + displacement * dRs[dRi];
90 curvature =
matDot(forceB - forceA, displacement) / dRs[dRi];
91 table << std::format("{:14.8f} {:14.8f}\n", dRs[dRi], curvature);
92 env.extras.emplace_back(std::format("dR_{}", dRi), dRs[dRi]);
93 env.extras.emplace_back(std::format("curvature_{}", dRi), curvature);
95 table.flush();
96 }
97
99 env.writeResultsDat("results.dat");
100 std::vector<std::string> returnFiles;
101 returnFiles.push_back("results.dat");
102 returnFiles.push_back("curvature.dat");
103 return returnFiles;
104}
double matDot(const AtomMatrix &a, const AtomMatrix &b)
SIMD-optimized dot product for contiguous Eigen matrices.
Eigen::Matrix< double, Eigen::Dynamic, 3, eOnStorageOrder > AtomMatrix
#define EONC_LOG_INFO(...)
#define EONC_LOG_CRITICAL(...)
PotRegistry & pots() noexcept
std::shared_ptr< Potential > pot
Set when one Potential is shared across Matters, images, or a caller.
size_t total_force_calls() const noexcept
long minCoordinatedEpiCenter(const Matter *matter, double neighborCutoff)
std::string getRelevantFile(std::string filename)
constexpr bool io_ok(IoStatus s) noexcept
JobResultProvenance provenanceForJob(const Parameters ¶ms)
Optimizer backend, engine identity, rgpot pin, and xts ABI from a job.
static JobResultEnvelope fromMinimization(RunStatus status, PotType pot, std::uint64_t fcalls, bool hasE, double energy)