ampsci
c++ program for high-precision atomic structure calculations of single-valence systems
YkTable.hpp
1 #pragma once
2 #include "Angular/CkTable.hpp"
3 #include "Angular/SixJTable.hpp"
4 #include "Wavefunction/DiracSpinor.hpp"
5 #include <unordered_map>
6 #include <vector>
7 
8 namespace Coulomb {
9 
12 
26 class YkTable {
27 
28 private:
29  std::vector<std::unordered_map<uint32_t, std::vector<double>>> m_Y{};
30  Angular::CkTable m_Ck{};
31  Angular::SixJTable m_6j{};
32 
33 public:
34  YkTable(const std::vector<DiracSpinor> &a_orbs,
35  const std::vector<DiracSpinor> &b_orbs) {
36  calculate(a_orbs, b_orbs);
37  }
38  YkTable(const std::vector<DiracSpinor> &a_orbs) { calculate(a_orbs); }
39  YkTable() {}
40 
41  //----------------------------------------------------------------------------
46  void calculate(const std::vector<DiracSpinor> &as,
47  const std::vector<DiracSpinor> &bs);
50  void calculate(const std::vector<DiracSpinor> &as) { calculate(as, as); }
51 
53  void extend_angular(int new_max_2j);
54 
56  const Angular::CkTable &Ck() const { return m_Ck; }
58  const Angular::SixJTable &SixJ() const { return m_6j; }
59 
62  const std::vector<double> *get(const int k, const DiracSpinor &Fa,
63  const DiracSpinor &Fb) const;
64 
67  [[nodiscard]] double R(const int k, const DiracSpinor &Fa,
68  const DiracSpinor &Fb, const DiracSpinor &Fc,
69  const DiracSpinor &Fd) const;
70 
73  [[nodiscard]] double Q(const int k, const DiracSpinor &Fa,
74  const DiracSpinor &Fb, const DiracSpinor &Fc,
75  const DiracSpinor &Fd) const;
76 
79  [[nodiscard]] double P(const int k, const DiracSpinor &Fa,
80  const DiracSpinor &Fb, const DiracSpinor &Fc,
81  const DiracSpinor &Fd) const;
82 
83  [[nodiscard]] double P2(const int k, const DiracSpinor &Fa,
84  const DiracSpinor &Fb, const DiracSpinor &Fc,
85  const DiracSpinor &Fd,
86  const std::vector<double> &fk = {}) const;
87 
90  [[nodiscard]] double W(const int k, const DiracSpinor &Fa,
91  const DiracSpinor &Fb, const DiracSpinor &Fc,
92  const DiracSpinor &Fd) const;
93 
96  [[nodiscard]] DiracSpinor Qkv_bcd(const int k, int kappa,
97  const DiracSpinor &Fb,
98  const DiracSpinor &Fc,
99  const DiracSpinor &Fd) const;
100 
104  [[nodiscard]] DiracSpinor
105  Pkv_bcd(const int k, int kappa, const DiracSpinor &Fb, const DiracSpinor &Fc,
106  const DiracSpinor &Fd, const std::vector<double> &f2k = {}) const;
107 
108 private:
109  // Allocates space for the Yk table, but does not calculate Yk. This is
110  // because allocation cannot be done in parallel, but once allocation is done,
111  // calculation can be done in //
112  void allocate_space(const std::vector<DiracSpinor> &a_orbs,
113  const std::vector<DiracSpinor> &b_orbs);
114 
115  // Returns key used for look-up table (unordered_map), considers symmetry
116  uint32_t ab_key(const DiracSpinor &Fa, const DiracSpinor &Fb) const;
117 
118  // Returns reference to yk vector at 'key'; if no such vector exists, creates
119  // it first.
120  std::vector<double> &get_or_insert(std::size_t k, uint32_t key);
121 
122  // Returns reference to yk vector at 'key'. This vector *must* exist already
123  std::vector<double> &get_ref(const int k, const DiracSpinor &Fa,
124  const DiracSpinor &Fb);
125 };
126 
127 } // namespace Coulomb
Lookup table for C^k and 3j symbols (special m=1/2, q=0 case)
Definition: CkTable.hpp:42
Lookup table for Wigner 6J symbols.
Definition: SixJTable.hpp:24
Calculates + stores Hartree Y functions + Angular (w/ look-up), taking advantage of symmetry.
Definition: YkTable.hpp:26
DiracSpinor Pkv_bcd(const int k, int kappa, const DiracSpinor &Fb, const DiracSpinor &Fc, const DiracSpinor &Fd, const std::vector< double > &f2k={}) const
Calculates P^K(v)_bcd using existing yk integrals, including (optional) screening factors....
Definition: YkTable.cpp:221
DiracSpinor Qkv_bcd(const int k, int kappa, const DiracSpinor &Fb, const DiracSpinor &Fc, const DiracSpinor &Fd) const
Calculates Q^K(v)_bcd using existing yk integrals. Note: Yk and Ck tables must include all required v...
Definition: YkTable.cpp:201
double Q(const int k, const DiracSpinor &Fa, const DiracSpinor &Fb, const DiracSpinor &Fc, const DiracSpinor &Fd) const
Calculates Qk using the existing yk integrals. Note: Yk and Ck tables must include all required value...
Definition: YkTable.cpp:127
const Angular::SixJTable & SixJ() const
Returns a (const ref) to SixJ table [see Angular::SixJTable].
Definition: YkTable.hpp:58
void calculate(const std::vector< DiracSpinor > &as, const std::vector< DiracSpinor > &bs)
Re-calculates all y_ab functions (will over-ride existing ones); NOTE: only calculates for a in as,...
Definition: YkTable.cpp:14
const Angular::CkTable & Ck() const
Returns a (const ref) to Ck table [see Angular::CkTable].
Definition: YkTable.hpp:56
const std::vector< double > * get(const int k, const DiracSpinor &Fa, const DiracSpinor &Fb) const
Returns a pointer to constant vector y^k_ab. If that integral is not stored, returns nullptr.
Definition: YkTable.cpp:70
double W(const int k, const DiracSpinor &Fa, const DiracSpinor &Fb, const DiracSpinor &Fc, const DiracSpinor &Fd) const
Calculates Wk=Qk+Pk using the existing yk integrals. Note: Yk and Ck tables must include all required...
Definition: YkTable.cpp:195
double R(const int k, const DiracSpinor &Fa, const DiracSpinor &Fb, const DiracSpinor &Fc, const DiracSpinor &Fd) const
Calculates Rk using the existing yk integrals. Note: Yk and Ck tables must include all required value...
Definition: YkTable.cpp:118
double P(const int k, const DiracSpinor &Fa, const DiracSpinor &Fb, const DiracSpinor &Fc, const DiracSpinor &Fd) const
Calculates Pk using the existing yk integrals. Note: Yk and Ck tables must include all required value...
Definition: YkTable.cpp:145
void extend_angular(int new_max_2j)
Extends the Ck and 6J tables up to new maximum 2*j.
Definition: YkTable.cpp:46
void calculate(const std::vector< DiracSpinor > &as)
Re-calculates all y_ij functions (will over-ride existing ones) [i and j in as].
Definition: YkTable.hpp:50
Stores radial Dirac spinor: F_nk = (f, g)
Definition: DiracSpinor.hpp:41
Functions (+classes) for computing Coulomb integrals.
Definition: Coulomb.hpp:8