eOn client
Long-timescale dynamics: aKMC, NEB, parallel replica
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
PointJob.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/PointJob.h
"
13
#include "
eon/BaseStructures.h
"
14
#include "
eon/Matter.h
"
15
#include "
eon/PotRegistry.h
"
16
#include "magic_enum/magic_enum.hpp"
17
18
#include <format>
19
#include <fstream>
20
#include <sstream>
21
#include <stdexcept>
22
23
std::vector<std::string>
PointJob::run
() {
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
}
BaseStructures.h
Matter.h
PointJob.h
PotRegistry.h
PointJob::run
std::vector< std::string > run(void)
Virtual run; used solely for dynamic dispatch.
Definition
PointJob.cpp:23
eonc::Job::pot
std::shared_ptr< Potential > pot
Definition
Job.h:55
eonc::Job::params
Parameters params
Definition
Job.h:54
eonc::PointJob::log
eonc::log::Scoped log
Definition
PointJob.h:28
eonc::PotRegistry::get
static PotRegistry & get() noexcept
Process-lifetime singleton.
Definition
PotRegistry.cpp:50
eonc::io::io_ok
constexpr bool io_ok(IoStatus s) noexcept
Definition
ConFileIO.h:38
eonc::RunStatus::GOOD
@ GOOD
Definition
BaseStructures.h:111
client
PointJob.cpp
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf