eOn 3.2.0
Long-timescale dynamics: aKMC, NEB, parallel replica
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
HessianJob.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
*/
12
#include "
eon/HessianJob.h
"
13
#include "
eon/BaseStructures.h
"
14
#include "
eon/EonLogger.h
"
15
#include "
eon/HelperFunctions.h
"
16
#include "
eon/Hessian.h
"
17
#include "
eon/JobResult.h
"
18
#include "
eon/Matter.h
"
19
#include "
eon/MobileAtoms.h
"
20
#include "
eon/PotRegistry.h
"
21
#include "
eon/Potential.h
"
22
23
#include <filesystem>
24
#include <format>
25
#include <fstream>
26
#include <stdexcept>
27
#include <string>
28
29
namespace
eonc
{
30
31
std::vector<std::string>
HessianJob::run
(
void
) {
32
std::string matter_in =
eonc::helpers::getRelevantFile
(
"pos.con"
);
33
34
std::vector<std::string> returnFiles;
35
36
auto
matter = std::make_unique<Matter>(
pot
,
params
);
37
38
if
(!
eonc::io::io_ok
(matter->con2matter(matter_in))) {
39
EONC_LOG_CRITICAL
(
"Failed to load {}"
, matter_in);
40
throw
std::runtime_error(
"failed to load "
+ matter_in);
41
}
42
43
Hessian
hessian(
params
, matter.get());
44
45
// [Hessian] phva_atoms = PHVA mobile/active set (displaced in FD). free/fixed
46
// is the optimizer mask; resolveMobileAtoms intersects the list with free.
47
const
VectorXi mobile =
eonc::resolveMobileAtoms
(
48
matter.get(),
params
.hessian_options().phva_atoms);
49
const
bool
no_mobile = mobile.size() == 0;
50
bool
freqs_ok =
false
;
51
bool
modes_ok =
false
;
52
if
(!no_mobile) {
53
const
VectorXd freqs = hessian.
getFreqs
(matter.get(), mobile);
54
freqs_ok = freqs.size() > 0;
55
if
(freqs_ok &&
params
.hessian_options().write_modes) {
56
modes_ok =
writeNormalModes
(*matter, mobile, freqs, hessian.
getModes
(),
57
"modes.con"
);
58
if
(!modes_ok) {
59
EONC_LOG_ERROR
(
"[Hessian] failed to write modes.con"
);
60
}
61
}
62
}
63
64
std::string results_file(
"results.dat"
);
65
returnFiles.push_back(results_file);
66
67
const
auto
status =
68
freqs_ok ?
RunStatus::GOOD
:
RunStatus::FAIL_POTENTIAL_FAILED
;
69
auto
env =
JobResultEnvelope::fromMinimization
(
70
status,
params
.potential_options().potential,
71
PotRegistry::get
().total_force_calls(),
false
, 0.0);
72
env.job_type =
"hessian"
;
73
env.extras.emplace_back(
"force_calls"
,
static_cast<
double
>
(env.force_calls));
74
env.writeResultsDat(results_file);
75
if
(std::filesystem::exists(
"hessian.dat"
)) {
76
returnFiles.push_back(
"hessian.dat"
);
77
}
78
if
(modes_ok) {
79
returnFiles.push_back(
"modes.con"
);
80
}
81
82
return
returnFiles;
83
}
84
85
}
// namespace eonc
BaseStructures.h
EonLogger.h
EONC_LOG_ERROR
#define EONC_LOG_ERROR(...)
Definition
EonLogger.h:261
EONC_LOG_CRITICAL
#define EONC_LOG_CRITICAL(...)
Definition
EonLogger.h:267
HelperFunctions.h
HessianJob.h
Hessian.h
JobResult.h
Matter.h
MobileAtoms.h
PotRegistry.h
Potential.h
eonc::HessianJob::run
std::vector< std::string > run(void) override
Virtual run; used solely for dynamic dispatch.
Definition
HessianJob.cpp:31
eonc::Hessian
Definition
Hessian.h:47
eonc::Hessian::getModes
const MatrixXd & getModes() const noexcept
Eigenvectors of the mass-weighted Hessian, one column per eigenvalue of getFreqs(),...
Definition
Hessian.h:58
eonc::Hessian::getFreqs
VectorXd getFreqs(Matter *matterIn, const VectorXi &atomsIn)
Definition
Hessian.cpp:102
eonc::Job::pot
std::shared_ptr< Potential > pot
Definition
Job.h:63
eonc::Job::params
Parameters params
Definition
Job.h:58
eonc::PotRegistry::get
static PotRegistry & get() noexcept
Process-lifetime singleton.
Definition
PotRegistry.cpp:50
eonc::helpers::getRelevantFile
std::string getRelevantFile(std::string filename)
Definition
HelperFunctions.cpp:122
eonc::io::io_ok
constexpr bool io_ok(IoStatus s) noexcept
Definition
ConFileIO.h:38
eonc
RAII resource manager for the ARTn C library with global synchronization.
Definition
ARTnSaddleSearch.cpp:23
eonc::resolveMobileAtoms
VectorXi resolveMobileAtoms(const Matter *matter, const std::string &atomList)
PHVA-class mobile set for FD Hessian and matrix-free Krylov (Lanczos / Davidson).
Definition
MobileAtoms.cpp:68
eonc::writeNormalModes
bool writeNormalModes(Matter &matter, const VectorXi &atoms, const VectorXd &eigenvalues, const MatrixXd &modes, const std::string &path)
Writes one frame of matter per mode to path, the mode as the displacements section and mode_eigenvalu...
Definition
Hessian.cpp:775
eonc::RunStatus::GOOD
@ GOOD
Definition
BaseStructures.h:117
eonc::RunStatus::FAIL_POTENTIAL_FAILED
@ FAIL_POTENTIAL_FAILED
Definition
BaseStructures.h:117
eonc::JobResultEnvelope::fromMinimization
static JobResultEnvelope fromMinimization(RunStatus status, PotType pot, std::uint64_t fcalls, bool hasE, double energy)
Definition
JobResult.h:101
client
HessianJob.cpp
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf