Loading...
Searching...
No Matches
SurrogatePotential.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*/
13
14#include <span>
15
16namespace eonc {
17
18std::tuple<double, AtomMatrix, double>
19SurrogatePotential::get_ef_var(const AtomMatrix pos, const VectorXi atmnrs,
20 const Matrix3d box) {
21 double energy{std::numeric_limits<double>::infinity()};
22 long nAtoms = static_cast<long>(pos.rows());
23 AtomMatrix forces{MatrixXd::Zero(nAtoms, 3)};
24 double var{0};
25 const auto n = static_cast<size_t>(nAtoms);
26 this->force(std::span<const double>(pos.data(), n * 3),
27 std::span<const int>(atmnrs.data(), n),
28 std::span<double>(forces.data(), n * 3), &energy, &var,
29 std::span<const double>(box.data(), 9));
30 return std::make_tuple(energy, forces, var);
31}
32
33} // namespace eonc
Eigen::Matrix< double, 3, 3, eOnStorageOrder > Matrix3d
Definition Eigen.h:35
Eigen::Matrix< double, Eigen::Dynamic, 3, eOnStorageOrder > AtomMatrix
Definition Eigen.h:37
virtual void force(long nAtoms, const double *positions, const int *atomicNrs, double *forces, double *energy, double *variance, const double *box)=0
std::tuple< double, AtomMatrix, double > get_ef_var(const AtomMatrix pos, const VectorXi atmnrs, const Matrix3d box)
RAII resource manager for the ARTn C library with global synchronization.