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>(std::move(ownedPot), params);
30 if (!eonc::io::io_ok(pos->inp2matter(posInFilename))) {
31 QUILL_LOG_CRITICAL(log, "Failed to load {}", posInFilename);
32 throw std::runtime_error("failed to load " + posInFilename);
33 }
34
35 // A point job evaluates the selected potential even when the input
36 // contains a saved energy and force evaluation.
37 pos->setPositions(pos->getPositions());
38 QUILL_LOG_DEBUG(log, "Energy: {:.12f}", pos->getPotentialEnergy());
39 std::stringstream freeForcesStream;
40 freeForcesStream << pos->getForcesFree();
41 QUILL_LOG_DEBUG(log, "(free) Forces:\n{}", freeForcesStream.str());
42 QUILL_LOG_DEBUG(log, "Max atom force: {:.12f}", pos->maxForce());
43
44 // Energy and Max_Force are the SVN reference format (see
45 // data/reference/point_*.dat); the rest is the key set every other job
46 // writes and eon.explorer reads.
48 RunStatus::GOOD, params.potential_options().potential,
49 pots().total_force_calls(), true, pos->getPotentialEnergy());
50 env.provenance = provenanceForJob(params);
51 env.job_type = "point";
52 env.extras.emplace_back("Energy", pos->getPotentialEnergy());
53 env.extras.emplace_back("Max_Force", pos->maxForce());
54 env.writeResultsDat(resultsFilename);
55 returnFiles.push_back(resultsFilename);
56
57 return returnFiles;
58}
59
60} // namespace eonc
PotRegistry & pots() noexcept
Definition Job.h:109
Parameters params
Definition Job.h:58
std::unique_ptr< Potential > ownedPot
Exclusive until a multi-owner job promotes it in the public constructor.
Definition Job.h:64
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
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.
JobResultProvenance provenanceForJob(const Parameters &params)
Optimizer backend, engine identity, rgpot pin, and xts ABI from a job.
static JobResultEnvelope fromMinimization(RunStatus status, PotType pot, std::uint64_t fcalls, bool hasE, double energy)
Definition JobResult.h:251