Loading...
Searching...
No Matches
ASE.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 "eon/Potential.h"
15#include <pybind11/pybind11.h>
16
17namespace py = pybind11;
18
19class ASE : public eonc::Potential {
20
21private:
22 size_t counter{0};
23 py::module_ py_module; // Member to store the Python module
24 py::object calculator; // Member to store the ASE calculator object
25 py::object _calculate; // Member to store the Python function to calculate
26 // forces and energy
27 py::object batch_calculate_;
28 bool has_batch_{false};
29
30public:
31 ASE(const eonc::Parameters &a_params);
32 virtual ~ASE() {
33 QUILL_LOG_INFO(eonc::log::get(), "[ASE] called potential {} times",
34 counter);
35 }
36
37 void force(long nAtoms, const double *R, const int *atomicNrs, double *F,
38 double *U, double *variance, const double *box) override;
39 [[nodiscard]] bool isThreadSafe() const noexcept override { return false; }
42 [[nodiscard]] bool needsPerImageInstance() const noexcept override {
43 return true;
44 }
45 [[nodiscard]] bool supportsBatchEvaluation() const noexcept override {
46 return has_batch_;
47 }
48 void forceBatch(long nSystems, long nAtoms, const double *const *positions,
49 const int *const *atomicNrs, double *const *forces,
50 double *energies, double *variances,
51 const double *const *boxes) override;
52};
bool needsPerImageInstance() const noexcept override
ASE calculators are independent objects.
Definition ASE.h:42
py::object batch_calculate_
Definition ASE.h:27
virtual ~ASE()
Definition ASE.h:32
bool has_batch_
Definition ASE.h:28
py::object calculator
Definition ASE.h:24
bool supportsBatchEvaluation() const noexcept override
Whether this potential supports batched evaluation of N systems in a single call.
Definition ASE.h:45
void force(long nAtoms, const double *R, const int *atomicNrs, double *F, double *U, double *variance, const double *box) override
Definition ASE.cpp:69
py::module_ py_module
Definition ASE.h:23
bool isThreadSafe() const noexcept override
Whether this potential's force() can be called from multiple threads on the SAME instance.
Definition ASE.h:39
void forceBatch(long nSystems, long nAtoms, const double *const *positions, const int *const *atomicNrs, double *const *forces, double *energies, double *variances, const double *const *boxes) override
Definition ASE.cpp:108
size_t counter
Definition ASE.h:22
py::object _calculate
Definition ASE.h:25
ASE(const eonc::Parameters &a_params)
Definition ASE.cpp:30
quill::Logger * get() noexcept
Get or create the default "combi" logger.
Definition EonLogger.h:44