ampsci
c++ program for high-precision atomic structure calculations of single-valence systems
RadialF.hpp
1 #pragma once
2 #include "DiracOperator/TensorOperator.hpp"
3 #include "IO/InputBlock.hpp"
4 #include "Wavefunction/Wavefunction.hpp"
5 
6 namespace DiracOperator {
7 
11 class RadialF final : public ScalarOperator {
12  // = some function of r
13  // Pass only grid to just get r, or
14  // either pass a lambda/function [f(r)], or a number, n, (for r^n)
15  // Explicitely even with rank 0, so ...
16 private:
17  std::vector<double> fillVec(const Grid &gr,
18  const std::function<double(double)> &f) {
19  std::vector<double> f_r;
20  f_r.reserve(gr.num_points());
21  for (auto r : gr.r())
22  f_r.push_back(f(r));
23  return f_r;
24  }
25 
26 public:
27  RadialF(const Grid &rgrid, const std::function<double(double)> &f)
28  : ScalarOperator(Parity::even, 1.0, fillVec(rgrid, f)) {}
29  RadialF(const Grid &rgrid, const double n)
30  : ScalarOperator(Parity::even, 1.0, fillVec(rgrid, [n](double r) {
31  return std::pow(r, n);
32  })) {}
33  std::string name() const override final { return "RadialFunction"; }
34  std::string units() const override final { return "au"; }
35 };
36 
38 class dr final : public ScalarOperator {
39 
40 public:
41  dr()
42  : ScalarOperator(Parity::even, 1.0, {}, {1, 0, 0, 1}, 1, Realness::real) {
43  }
44  std::string name() const override final { return "dr"; }
45  std::string units() const override final { return "au"; }
46 };
47 
48 //------------------------------------------------------------------------------
49 inline std::unique_ptr<DiracOperator::TensorOperator>
50 generate_r(const IO::InputBlock &input, const Wavefunction &wf) {
51  using namespace DiracOperator;
52  input.check({{"power", "Power (real) for r^k"}});
53  if (input.has_option("help")) {
54  return nullptr;
55  }
56  const auto power = input.get("power", 1.0);
57  std::cout << "r^(" << power << ")\n";
58  return std::make_unique<RadialF>(wf.grid(), power);
59 }
60 
61 inline std::unique_ptr<DiracOperator::TensorOperator>
62 generate_dr(const IO::InputBlock &input, const Wavefunction &) {
63  input.check({{"", "no input"}});
64  if (input.has_option("help")) {
65  return nullptr;
66  }
67  using namespace DiracOperator;
68  return std::make_unique<dr>();
69 }
70 
71 } // namespace DiracOperator
General function of r, even scalar operator.
Definition: RadialF.hpp:11
std::string name() const override final
Returns "name" of operator (e.g., 'E1')
Definition: RadialF.hpp:33
std::string units() const override final
Returns units of operator (usually au, may be MHz, etc.)
Definition: RadialF.hpp:34
Speacial case for scalar operator.
Definition: TensorOperator.hpp:233
radial derivative operator
Definition: RadialF.hpp:38
std::string units() const override final
Returns units of operator (usually au, may be MHz, etc.)
Definition: RadialF.hpp:45
std::string name() const override final
Returns "name" of operator (e.g., 'E1')
Definition: RadialF.hpp:44
Holds grid, including type + Jacobian (dr/du)
Definition: Grid.hpp:31
auto num_points() const
Number of grid points.
Definition: Grid.hpp:64
const std::vector< double > & r() const
Grid points, r.
Definition: Grid.hpp:75
Holds list of Options, and a list of other InputBlocks. Can be initialised with a list of options,...
Definition: InputBlock.hpp:142
bool check(std::initializer_list< std::string > blocks, const std::vector< std::pair< std::string, std::string >> &list, bool print=false) const
Check all the options and blocks in this; if any of them are not present in 'list',...
Definition: InputBlock.hpp:594
bool has_option(std::string_view key) const
Check is option is present (even if not set) in current block.
Definition: InputBlock.hpp:201
T get(std::string_view key, T default_value) const
If 'key' exists in the options, returns value. Else, returns default_value. Note: If two keys with sa...
Definition: InputBlock.hpp:417
Stores Wavefunction (set of valence orbitals, grid, HF etc.)
Definition: Wavefunction.hpp:36
const Grid & grid() const
Returns a const reference to the radial grid.
Definition: Wavefunction.hpp:81
Dirac Operators: General + derived.
Definition: GenerateOperator.cpp:12