Loading...
Searching...
No Matches
gpr::potentials::NwchemGradientOracle Class Reference

#include <gpr/potentials/NwchemGradientOracle.h>

Public Member Functions

 NwchemGradientOracle (std::filesystem::path executable, std::filesystem::path root, std::vector< std::string > elements, bool dispersion=false, NwchemNumericalSettings settings={})
std::string inputText (const Eigen::VectorXd &positions, bool curvature) const
std::string orbitalInputText (const Eigen::VectorXd &positions, bool curvature) const
std::pair< quantum::PotentialEvaluation, Eigen::MatrixXd > compute (const Eigen::VectorXd &positions, bool curvature)
std::pair< quantum::PotentialEvaluation, Eigen::MatrixXd > computeWithOrbitals (const Eigen::VectorXd &positions, bool curvature, const std::filesystem::path &seedFile)
std::pair< quantum::PotentialEvaluation, Eigen::MatrixXd > readRetained (const std::filesystem::path &directory, const Eigen::VectorXd &positions, bool curvature) const
std::pair< quantum::PotentialEvaluation, Eigen::MatrixXd > readRetainedWithOrbitals (const std::filesystem::path &directory, const Eigen::VectorXd &positions, bool curvature) const
quantum::PotentialEvaluation evaluate (const Eigen::VectorXd &positions)
Eigen::MatrixXd hessian (const Eigen::VectorXd &positions)
auto evaluateWithHessian (const Eigen::VectorXd &positions)
std::size_t calls () const noexcept
std::size_t hessianCalls () const noexcept

Detailed Description

Definition at line 47 of file NwchemGradientOracle.h.

Constructor & Destructor Documentation

◆ NwchemGradientOracle()

gpr::potentials::NwchemGradientOracle::NwchemGradientOracle ( std::filesystem::path executable,
std::filesystem::path root,
std::vector< std::string > elements,
bool dispersion = false,
NwchemNumericalSettings settings = {} )
inline

Definition at line 56 of file NwchemGradientOracle.h.

60 {})
61 : executable_(std::filesystem::absolute(executable)),
62 root_(std::filesystem::absolute(root)),
63 elements_(std::move(elements)),
64 dispersion_(dispersion),
65 settings_(settings)
66 {
67 settings_.validate();
68 if (elements_.empty() ||
69 !std::filesystem::is_regular_file(executable_) ||
70 !std::filesystem::create_directory(root_))
71 throw std::invalid_argument(
72 "Native NWChem executable and new oracle directory required");
73 for (const auto& element: elements_)
74 if (element != "H" && element != "C" && element != "N" &&
75 element != "O")
76 throw std::invalid_argument(
77 "Unsupported JCTC benchmark element");
78 }

Member Function Documentation

◆ calls()

std::size_t gpr::potentials::NwchemGradientOracle::calls ( ) const
inlinenoexcept

Definition at line 401 of file NwchemGradientOracle.h.

402 {
403 return calls_.load();
404 }

◆ compute()

std::pair< quantum::PotentialEvaluation, Eigen::MatrixXd > gpr::potentials::NwchemGradientOracle::compute ( const Eigen::VectorXd & positions,
bool curvature )
inline

Definition at line 234 of file NwchemGradientOracle.h.

236 {
237 return computeInput(positions, curvature, nullptr);
238 }

◆ computeWithOrbitals()

std::pair< quantum::PotentialEvaluation, Eigen::MatrixXd > gpr::potentials::NwchemGradientOracle::computeWithOrbitals ( const Eigen::VectorXd & positions,
bool curvature,
const std::filesystem::path & seedFile )
inline

Definition at line 241 of file NwchemGradientOracle.h.

243 {
244 return computeInput(positions, curvature, &seedFile);
245 }

◆ evaluate()

quantum::PotentialEvaluation gpr::potentials::NwchemGradientOracle::evaluate ( const Eigen::VectorXd & positions)
inline

Definition at line 389 of file NwchemGradientOracle.h.

390 {
391 return compute(positions, false).first;
392 }
std::pair< quantum::PotentialEvaluation, Eigen::MatrixXd > compute(const Eigen::VectorXd &positions, bool curvature)

◆ evaluateWithHessian()

auto gpr::potentials::NwchemGradientOracle::evaluateWithHessian ( const Eigen::VectorXd & positions)
inline

Definition at line 397 of file NwchemGradientOracle.h.

398 {
399 return compute(positions, true);
400 }

◆ hessian()

Eigen::MatrixXd gpr::potentials::NwchemGradientOracle::hessian ( const Eigen::VectorXd & positions)
inline

Definition at line 393 of file NwchemGradientOracle.h.

394 {
395 return compute(positions, true).second;
396 }

◆ hessianCalls()

std::size_t gpr::potentials::NwchemGradientOracle::hessianCalls ( ) const
inlinenoexcept

Definition at line 405 of file NwchemGradientOracle.h.

406 {
407 return hessianCalls_.load();
408 }

◆ inputText()

std::string gpr::potentials::NwchemGradientOracle::inputText ( const Eigen::VectorXd & positions,
bool curvature ) const
inline

Definition at line 82 of file NwchemGradientOracle.h.

84 {
85 if (positions.size() !=
86 static_cast<Eigen::Index>(3 * elements_.size()) ||
87 !positions.allFinite())
88 throw std::invalid_argument(
89 "Finite native NWChem molecular coordinates required");
90 std::ostringstream input;
91 input
92 << "start point\necce_print point.ecce\nmemory total 1500 "
93 "mb\ncharge 0\ngeometry units bohr nocenter noautosym noautoz\n"
94 << std::setprecision(17);
95 for (std::size_t atom = 0; atom < elements_.size(); ++atom)
96 input << elements_[atom] << ' ' << positions[3 * atom] << ' '
97 << positions[3 * atom + 1] << ' ' << positions[3 * atom + 2]
98 << '\n';
99 input << "end\nbasis spherical\n * library 6-31g*\nend\ndft\n xc "
100 "b3lyp\n mult 1\n iterations 500\n direct\n grid "
101 << settings_.gridName() << " nodisk\n";
102 if (settings_.scf == NwchemNumericalSettings::Scf::Strict)
103 input << " convergence energy 1e-11 density 1e-10 gradient 1e-10\n";
104 else
105 input << " convergence energy 1e-6 density 1e-5 gradient 5e-4\n";
106 if (dispersion_) input << " disp vdw 3\n";
107 input << "end\n";
108 if (curvature) input << "hessian\n thresh 1e-10\nend\n";
109 input << "task dft gradient\n";
110 if (curvature) input << "task dft frequencies\n";
111 return input.str();
112 }

◆ orbitalInputText()

std::string gpr::potentials::NwchemGradientOracle::orbitalInputText ( const Eigen::VectorXd & positions,
bool curvature ) const
inline

Definition at line 115 of file NwchemGradientOracle.h.

117 {
118 auto text = inputText(positions, curvature);
119 const auto end = text.find("end\n", text.find("\ndft\n"));
120 text.insert(end, " vectors input seed.movecs output point.movecs\n");
121 return text;
122 }
std::string inputText(const Eigen::VectorXd &positions, bool curvature) const

◆ readRetained()

std::pair< quantum::PotentialEvaluation, Eigen::MatrixXd > gpr::potentials::NwchemGradientOracle::readRetained ( const std::filesystem::path & directory,
const Eigen::VectorXd & positions,
bool curvature ) const
inline

Definition at line 373 of file NwchemGradientOracle.h.

376 {
377 return readRetainedInput(directory, positions, curvature, false);
378 }

◆ readRetainedWithOrbitals()

std::pair< quantum::PotentialEvaluation, Eigen::MatrixXd > gpr::potentials::NwchemGradientOracle::readRetainedWithOrbitals ( const std::filesystem::path & directory,
const Eigen::VectorXd & positions,
bool curvature ) const
inline

Definition at line 380 of file NwchemGradientOracle.h.

383 {
384 const auto digest = verifyOrbitalSeed(directory);
385 auto result = readRetainedInput(directory, positions, curvature, true);
386 verifyOrbitalSeed(directory, digest);
387 return result;
388 }

The documentation for this class was generated from the following file: