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

#include <PointJob.h>

Inheritance diagram for eonc::PointJob:

Public Member Functions

 PointJob (std::unique_ptr< Parameters > parameters)
 ~PointJob (void)=default
std::vector< std::string > run (void)
 Virtual run; used solely for dynamic dispatch.
Public Member Functions inherited from eonc::Job
 Job (std::unique_ptr< Parameters > parameters)
 Job (std::shared_ptr< Potential > potPassed, const Parameters &parameters)
virtual ~Job ()=default
JobType getType ()

Private Attributes

eonc::log::Scoped log

Additional Inherited Members

Protected Attributes inherited from eonc::Job
JobType jtype
Parameters params
std::shared_ptr< Potentialpot

Detailed Description

Definition at line 20 of file PointJob.h.

Constructor & Destructor Documentation

◆ PointJob()

eonc::PointJob::PointJob ( std::unique_ptr< Parameters > parameters)
inline

Definition at line 22 of file PointJob.h.

23 : Job(std::move(parameters)) {}
Job(std::unique_ptr< Parameters > parameters)
Definition Job.h:58

◆ ~PointJob()

eonc::PointJob::~PointJob ( void )
default

Member Function Documentation

◆ run()

std::vector< std::string > PointJob::run ( void )
virtual

Virtual run; used solely for dynamic dispatch.

Implements eonc::Job.

Definition at line 23 of file PointJob.cpp.

23 {
24 std::vector<std::string> returnFiles;
25 std::string posInFilename("pos.con");
26 std::string resultsFilename("results.dat");
27
28 auto pos = std::make_unique<Matter>(pot, params);
29 if (!eonc::io::io_ok(pos->con2matter(posInFilename))) {
30 QUILL_LOG_CRITICAL(log, "Failed to load {}", posInFilename);
31 throw std::runtime_error("failed to load " + posInFilename);
32 }
33
34 QUILL_LOG_DEBUG(log, "Energy: {:.12f}", pos->getPotentialEnergy());
35 std::stringstream freeForcesStream;
36 freeForcesStream << pos->getForcesFree();
37 QUILL_LOG_DEBUG(log, "(free) Forces:\n{}", freeForcesStream.str());
38 QUILL_LOG_DEBUG(log, "Max atom force: {:.12f}", pos->maxForce());
39
40 std::ofstream outFile(resultsFilename, std::ios::binary);
41 if (!outFile) {
42 QUILL_LOG_CRITICAL(log, "Failed to open {}", resultsFilename);
43 throw std::runtime_error("failed to open " + resultsFilename);
44 }
45 // Energy and Max_Force are the SVN reference format (see
46 // data/reference/point_*.dat); the rest is the key set every other job
47 // writes and eon.explorer reads.
48 outFile << std::format("{} termination_reason\n",
49 static_cast<int>(RunStatus::GOOD));
50 outFile << std::format("{} termination_reason_text\n",
51 magic_enum::enum_name<RunStatus>(RunStatus::GOOD));
52 outFile << "point job_type\n";
53 outFile << std::format(
54 "{} potential_type\n",
55 magic_enum::enum_name<PotType>(params.potential_options.potential));
56 outFile << std::format("{} total_force_calls\n",
57 PotRegistry::get().total_force_calls());
58 outFile << std::format("{:.12f} potential_energy\n",
59 pos->getPotentialEnergy());
60 outFile << std::format("{:.12f} Energy\n", pos->getPotentialEnergy());
61 outFile << std::format("{:.12f} Max_Force\n", pos->maxForce());
62 outFile.close();
63 if (!outFile) {
64 QUILL_LOG_CRITICAL(log, "Failed to write {}", resultsFilename);
65 throw std::runtime_error("failed to write " + resultsFilename);
66 }
67 returnFiles.push_back(resultsFilename);
68
69 return returnFiles;
70}
std::shared_ptr< Potential > pot
Definition Job.h:55
Parameters params
Definition Job.h:54
eonc::log::Scoped log
Definition PointJob.h:28
static PotRegistry & get() noexcept
Process-lifetime singleton.
constexpr bool io_ok(IoStatus s) noexcept
Definition ConFileIO.h:38

Member Data Documentation

◆ log

eonc::log::Scoped eonc::PointJob::log
private

Definition at line 28 of file PointJob.h.


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