eOn 3.2.0
Long-timescale dynamics: aKMC, NEB, parallel replica
☾
Toggle main menu visibility
Loading...
Searching...
No Matches
MonteCarloJob.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/MonteCarloJob.h
"
13
#include "
eon/BaseStructures.h
"
14
#include "
eon/HelperFunctions.h
"
15
#include "
eon/JobResult.h
"
16
#include "
eon/Matter.h
"
17
#include "
eon/MonteCarlo.h
"
18
#include "
eon/PotRegistry.h
"
19
20
#include <filesystem>
21
#include <format>
22
#include <fstream>
23
#include <stdexcept>
24
#include <string>
25
26
namespace
eonc
{
27
28
std::vector<std::string>
MonteCarloJob::run
(
void
) {
29
std::string posInFilename(
"pos.con"
);
30
std::string posOutFilename(
"out.con"
);
31
32
if
(
params
.main_options().checkpoint) {
33
if
(std::filesystem::exists(
"pos_cp.con"
)) {
34
posInFilename =
"pos_cp.con"
;
35
QUILL_LOG_DEBUG(
log
,
"Resuming from checkpoint\n"
);
36
}
else
{
37
QUILL_LOG_DEBUG(
log
,
"No checkpoint files found\n"
);
38
}
39
}
40
41
std::vector<std::string> returnFiles;
42
43
auto
matter = std::make_shared<Matter>(
pot
,
params
);
44
if
(!
eonc::io::io_ok
(matter->con2matter(posInFilename))) {
45
QUILL_LOG_CRITICAL(
log
,
"Failed to load {}"
, posInFilename);
46
throw
std::runtime_error(
"failed to load "
+ posInFilename);
47
}
48
49
MonteCarlo
mc =
MonteCarlo
(matter,
params
);
50
mc.
run
(
params
.monte_carlo_options().steps,
params
.main_options().temperature,
51
params
.monte_carlo_options().step_size);
52
53
QUILL_LOG_DEBUG(
log
,
"Saving result to {}"
, posOutFilename);
54
if
(
eonc::io::io_ok
(matter->matter2con(posOutFilename))) {
55
returnFiles.push_back(posOutFilename);
56
}
else
{
57
QUILL_LOG_ERROR(
log
,
"Failed to write {}"
, posOutFilename);
58
}
59
60
std::string resultsFilename(
"results.dat"
);
61
auto
env =
JobResultEnvelope::fromMinimization
(
62
RunStatus::GOOD
,
params
.potential_options().potential,
63
PotRegistry::get
().total_force_calls(),
true
,
64
matter->getPotentialEnergy());
65
env.job_type =
"monte_carlo"
;
66
env.writeResultsDat(resultsFilename);
67
returnFiles.push_back(resultsFilename);
68
69
return
returnFiles;
70
}
71
72
}
// namespace eonc
BaseStructures.h
HelperFunctions.h
JobResult.h
Matter.h
MonteCarloJob.h
MonteCarlo.h
PotRegistry.h
eonc::Job::pot
std::shared_ptr< Potential > pot
Definition
Job.h:63
eonc::Job::params
Parameters params
Definition
Job.h:58
eonc::MonteCarloJob::log
eonc::log::Scoped log
Definition
MonteCarloJob.h:28
eonc::MonteCarloJob::run
std::vector< std::string > run(void) override
Virtual run; used solely for dynamic dispatch.
Definition
MonteCarloJob.cpp:28
eonc::MonteCarlo
Definition
MonteCarlo.h:22
eonc::MonteCarlo::run
void run(int numSteps, double temperature, double stepSize)
Definition
MonteCarlo.cpp:19
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
RAII resource manager for the ARTn C library with global synchronization.
Definition
ARTnSaddleSearch.cpp:23
eonc::RunStatus::GOOD
@ GOOD
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
MonteCarloJob.cpp
Generated by
1.17.0
Generated by
Doxygen 1.17.0
Analytics by
Antics
provided by
TurtleTech ehf