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

#include <HessianJob.h>

Inheritance diagram for eonc::HessianJob:

Public Member Functions

 HessianJob (std::unique_ptr< Parameters > parameters, Runtime &rt)
 ~HessianJob (void)=default
std::vector< std::string > run (void) override
 Virtual run; used solely for dynamic dispatch.
Public Member Functions inherited from eonc::Job
void adoptRuntime (std::unique_ptr< Runtime > rt)
 Take ownership of a Runtime previously passed as Runtime&.
 Job (std::unique_ptr< Parameters > parameters, Runtime &rt)
 Borrow: caller keeps Runtime alive (CLI stack / Python Session).
 Job (std::unique_ptr< Parameters > parameters, std::unique_ptr< Runtime > rt)
 Own a Runtime (one-shot makeJob / rvalue).
 Job (std::unique_ptr< Parameters > parameters)
 Own a default-constructed Runtime.
 Job (std::shared_ptr< Potential > potPassed, const Parameters &parameters)
virtual ~Job ()=default
JobType getType ()
PotRegistry & pots () noexcept
void releasePotential ()
 Drop the Potential so on_destroyed is recorded before Runtime dies.

Additional Inherited Members

Protected Attributes inherited from eonc::Job
JobType jtype
Parameters params
std::unique_ptr< Runtime > owned_runtime_
 Non-null when this Job owns the composition root (one-shot makeJob).
Runtime * runtime_
 Always valid: either owned_runtime_.get() or a caller-owned Runtime.
std::shared_ptr< Potential > pot

Detailed Description

Definition at line 18 of file HessianJob.h.

Constructor & Destructor Documentation

◆ HessianJob()

eonc::HessianJob::HessianJob ( std::unique_ptr< Parameters > parameters,
Runtime & rt )
inline

Definition at line 20 of file HessianJob.h.

21 : Job(std::move(parameters), rt) {}
Job(std::unique_ptr< Parameters > parameters, Runtime &rt)
Borrow: caller keeps Runtime alive (CLI stack / Python Session).
Definition Job.h:76

◆ ~HessianJob()

eonc::HessianJob::~HessianJob ( void )
default

Member Function Documentation

◆ run()

std::vector< std::string > eonc::HessianJob::run ( void )
overridevirtual

Virtual run; used solely for dynamic dispatch.

Implements eonc::Job.

Definition at line 31 of file HessianJob.cpp.

31 {
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 =
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}
#define EONC_LOG_ERROR(...)
Definition EonLogger.h:261
#define EONC_LOG_CRITICAL(...)
Definition EonLogger.h:267
std::shared_ptr< Potential > pot
Definition Job.h:63
Parameters params
Definition Job.h:58
static PotRegistry & get() noexcept
Process-lifetime singleton.
size_t total_force_calls() const noexcept
std::string getRelevantFile(std::string filename)
constexpr bool io_ok(IoStatus s) noexcept
Definition ConFileIO.h:38
VectorXi resolveMobileAtoms(const Matter *matter, const std::string &atomList)
PHVA-class mobile set for FD Hessian and matrix-free Krylov (Lanczos / Davidson).
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
static JobResultEnvelope fromMinimization(RunStatus status, PotType pot, std::uint64_t fcalls, bool hasE, double energy)
Definition JobResult.h:101

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