eOn 3.2.0
Long-timescale dynamics: aKMC, NEB, parallel replica
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
JobResult.h
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
#pragma once
13
14
#include "
BaseStructures.h
"
15
16
#include <cstdint>
17
#include <format>
18
#include <fstream>
19
#include <sstream>
20
#include <stdexcept>
21
#include <string>
22
#include <utility>
23
#include <vector>
24
25
#include "magic_enum/magic_enum.hpp"
26
27
namespace
eonc
{
28
32
struct
JobResultEnvelope
{
33
std::string
job_type
;
34
int
status_code
{0};
35
std::string
status_text
;
36
std::string
potential_type
;
37
std::int64_t
random_seed
{-1};
38
std::uint64_t
force_calls
{0};
39
double
potential_energy
{0.0};
40
bool
has_energy
{
false
};
41
double
potential_energy_saddle
{0.0};
42
double
potential_energy_reactant
{0.0};
43
double
potential_energy_product
{0.0};
44
bool
has_saddle
{
false
};
45
bool
has_reactant
{
false
};
46
bool
has_product
{
false
};
47
std::vector<std::pair<std::string, double>>
extras
;
48
std::vector<std::pair<std::string, std::string>>
tags
;
49
50
std::string
toString
()
const
{
51
std::ostringstream out;
52
out <<
status_code
<<
" termination_reason\n"
;
53
if
(!
status_text
.empty()) {
54
out <<
status_text
<<
" termination_reason_text\n"
;
55
}
56
if
(!
job_type
.empty()) {
57
out <<
job_type
<<
" job_type\n"
;
58
}
59
if
(!
potential_type
.empty()) {
60
out <<
potential_type
<<
" potential_type\n"
;
61
}
62
if
(
random_seed
>= 0) {
63
out <<
random_seed
<<
" random_seed\n"
;
64
}
65
out <<
force_calls
<<
" total_force_calls\n"
;
66
if
(
has_energy
) {
67
out << std::format(
"{:.12e} potential_energy\n"
,
potential_energy
);
68
}
69
if
(
has_saddle
) {
70
out << std::format(
"{:.12e} potential_energy_saddle\n"
,
71
potential_energy_saddle
);
72
}
73
if
(
has_reactant
) {
74
out << std::format(
"{:.12e} potential_energy_reactant\n"
,
75
potential_energy_reactant
);
76
}
77
if
(
has_product
) {
78
out << std::format(
"{:.12e} potential_energy_product\n"
,
79
potential_energy_product
);
80
}
81
for
(
const
auto
&kv :
extras
) {
82
out << std::format(
"{:.12e} {}\n"
, kv.second, kv.first);
83
}
84
for
(
const
auto
&kv :
tags
) {
85
out << kv.second <<
" "
<< kv.first <<
"\n"
;
86
}
87
return
out.str();
88
}
89
90
void
writeResultsDat
(
const
std::string &path)
const
{
91
std::ofstream out(path, std::ios::binary);
92
if
(!out) {
93
throw
std::runtime_error(
"JobResultEnvelope: cannot open "
+ path);
94
}
95
out <<
toString
();
96
if
(!out) {
97
throw
std::runtime_error(
"JobResultEnvelope: write failed for "
+ path);
98
}
99
}
100
101
static
JobResultEnvelope
fromMinimization
(
RunStatus
status,
PotType
pot
,
102
std::uint64_t fcalls,
bool
hasE,
103
double
energy) {
104
JobResultEnvelope
e;
105
e.
job_type
=
"minimization"
;
106
e.
status_code
=
static_cast<
int
>
(status);
107
e.
status_text
= std::string(magic_enum::enum_name<RunStatus>(status));
108
e.
potential_type
= std::string(magic_enum::enum_name<PotType>(
pot
));
109
e.
force_calls
= fcalls;
110
e.
has_energy
= hasE;
111
e.
potential_energy
= energy;
112
return
e;
113
}
114
};
115
116
}
// namespace eonc
BaseStructures.h
eonc::pot
Definition
ExternalCommand.h:22
eonc
RAII resource manager for the ARTn C library with global synchronization.
Definition
ARTnSaddleSearch.cpp:23
eonc::PotType
PotType
Definition
BaseStructures.h:36
eonc::RunStatus
RunStatus
Definition
BaseStructures.h:117
eonc::JobResultEnvelope
In-memory JobResult scalars.
Definition
JobResult.h:32
eonc::JobResultEnvelope::extras
std::vector< std::pair< std::string, double > > extras
Definition
JobResult.h:47
eonc::JobResultEnvelope::force_calls
std::uint64_t force_calls
Definition
JobResult.h:38
eonc::JobResultEnvelope::potential_energy
double potential_energy
Definition
JobResult.h:39
eonc::JobResultEnvelope::has_saddle
bool has_saddle
Definition
JobResult.h:44
eonc::JobResultEnvelope::potential_energy_product
double potential_energy_product
Definition
JobResult.h:43
eonc::JobResultEnvelope::potential_energy_saddle
double potential_energy_saddle
Definition
JobResult.h:41
eonc::JobResultEnvelope::tags
std::vector< std::pair< std::string, std::string > > tags
Definition
JobResult.h:48
eonc::JobResultEnvelope::potential_type
std::string potential_type
Definition
JobResult.h:36
eonc::JobResultEnvelope::writeResultsDat
void writeResultsDat(const std::string &path) const
Definition
JobResult.h:90
eonc::JobResultEnvelope::has_reactant
bool has_reactant
Definition
JobResult.h:45
eonc::JobResultEnvelope::status_code
int status_code
Definition
JobResult.h:34
eonc::JobResultEnvelope::has_energy
bool has_energy
Definition
JobResult.h:40
eonc::JobResultEnvelope::job_type
std::string job_type
Definition
JobResult.h:33
eonc::JobResultEnvelope::status_text
std::string status_text
Definition
JobResult.h:35
eonc::JobResultEnvelope::potential_energy_reactant
double potential_energy_reactant
Definition
JobResult.h:42
eonc::JobResultEnvelope::toString
std::string toString() const
Definition
JobResult.h:50
eonc::JobResultEnvelope::random_seed
std::int64_t random_seed
Definition
JobResult.h:37
eonc::JobResultEnvelope::fromMinimization
static JobResultEnvelope fromMinimization(RunStatus status, PotType pot, std::uint64_t fcalls, bool hasE, double energy)
Definition
JobResult.h:101
eonc::JobResultEnvelope::has_product
bool has_product
Definition
JobResult.h:46
include
eon
JobResult.h
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf