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/HelperFunctions.h"
15#include "eon/JobResult.h"
16#include "eon/Matter.h"
17#include "eon/PotRegistry.h"
18
19#include <sstream>
20#include <stdexcept>
21
22namespace eonc {
23
24std::vector<std::string> PointJob::run() {
25 std::vector<std::string> returnFiles;
26 std::string posInFilename = eonc::helpers::getRelevantFile("pos.con");
27 std::string resultsFilename("results.dat");
28
29 auto pos = std::make_unique<Matter>(pot, params);
30 if (!eonc::io::io_ok(pos->con2matter(posInFilename))) {
31 QUILL_LOG_CRITICAL(log, "Failed to load {}", posInFilename);
32 throw std::runtime_error("failed to load " + posInFilename);
33 }
34
35 QUILL_LOG_DEBUG(log, "Energy: {:.12f}", pos->getPotentialEnergy());
36 std::stringstream freeForcesStream;
37 freeForcesStream << pos->getForcesFree();
38 QUILL_LOG_DEBUG(log, "(free) Forces:\n{}", freeForcesStream.str());
39 QUILL_LOG_DEBUG(log, "Max atom force: {:.12f}", pos->maxForce());
40
41 // Energy and Max_Force are the SVN reference format (see
42 // data/reference/point_*.dat); the rest is the key set every other job
43 // writes and eon.explorer reads.
45 RunStatus::GOOD, params.potential_options().potential,
46 PotRegistry::get().total_force_calls(), true, pos->getPotentialEnergy());
47 env.job_type = "point";
48 env.extras.emplace_back("Energy", pos->getPotentialEnergy());
49 env.extras.emplace_back("Max_Force", pos->maxForce());
50 env.writeResultsDat(resultsFilename);
51 returnFiles.push_back(resultsFilename);
52
53 return returnFiles;
54}
55
56} // namespace eonc
std::shared_ptr< Potential > pot
Definition Job.h:63
Parameters params
Definition Job.h:58
eonc::log::Scoped log
Definition PointJob.h:28
std::vector< std::string > run(void) override
Virtual run; used solely for dynamic dispatch.
Definition PointJob.cpp:24
static PotRegistry & get() noexcept
Process-lifetime singleton.
std::string getRelevantFile(std::string filename)
constexpr bool io_ok(IoStatus s) noexcept
Definition ConFileIO.h:38
RAII resource manager for the ARTn C library with global synchronization.
static JobResultEnvelope fromMinimization(RunStatus status, PotType pot, std::uint64_t fcalls, bool hasE, double energy)
Definition JobResult.h:101