ampsci
High-precision calculations for one- and two-valence atomic systems
DiagramRPA.hpp
1#pragma once
2#include "CorePolarisation.hpp"
3#include "Coulomb/QkTable.hpp"
4#include "HF/Breit.hpp"
5#include "IO/FRW_fileReadWrite.hpp"
6#include "Wavefunction/DiracSpinor.hpp"
7#include <vector>
8class Wavefunction;
9class DiracSpinor;
10namespace DiracOperator {
11class TensorOperator;
12}
13namespace HF {
14class HartreeFock;
15}
16
17namespace ExternalField {
18
19//! RPA correction to matrix elements, using Diagram technique
20/*! @details
21 The basic equation is:
22
23 \f[
24 \langle{w}|{\delta V_{\pm}}|{v}\rangle =
25 \sum_{na}\frac{t_{na}\,\widetilde g_{wavn}}{\varepsilon_a - \varepsilon_n \pm \omega}
26 +
27 \sum_{na}\frac{t_{an}\,\widetilde g_{wnva}}{\varepsilon_a - \varepsilon_n \mp \omega},
28 \f]
29
30 These should be solved self-consistently for all core-excited matrix elements.
31 Should be solved independently for each frequency, including negative frequencies. To maintain Hermicity:
32
33 \f[
34 [\delta V_{\pm}(\omega)]^\dag = \delta V_{\mp}(-\omega).
35 \f]
36
37 The reduced matrix elements are:
38
39 \f[
40 \langle{w}\|{\delta V_{\pm}}\|{v}\rangle =
41 \sum_{na}\frac{(-1)^{k+w-n}}{[k]}\Bigg(
42 \frac{T_{na}\,W^k_{wavn}}{\varepsilon_a - \varepsilon_n \pm \omega}
43 +
44 \frac{(-1)^{a-n}T_{an}\,W^k_{wnva}}{\varepsilon_a - \varepsilon_n \mp \omega}
45 \Bigg).
46 \f]
47
48 @note
49 Stores a pointer to the external field operator.
50 That operator must remain alive for life of DiagramRPA object.
51 Also, for frequency-dependent operators, updating the frequency of the operator externally will affect
52 the results from this class (as it should).
53 The DiagramRPA::solve_core() function should be re called if the external operator is updated.
54
55 @note
56 Stores required W^k integrals (only those which are required).
57 Writes them to disk by default.
58 This can use significant memory, particularly for large basis.
59 At the moment, always uses full basis -- this may optionally change in the future.
60
61 @note
62 Calling DiagramRPA::dV() without calling DiagramRPA::solve_core() will return 0.
63 This is different from previous behaviour, where it returned dV^1, but in line with others.
64 Call with max_its = 0 will also return 0.
65 Call with max_its = 1 will return lowest-order dV correction.
66*/
68
69private:
70 const HF::HartreeFock *p_hf;
71 std::optional<HF::Breit> m_Br{};
72 std::vector<DiracSpinor> m_holes{};
73 std::vector<DiracSpinor> m_excited{};
74
75 // t0 (no RPA). These stay constant for frequency-independent operators
76 // But change for f-dependent. Set during solve_core
77 std::vector<std::vector<double>> m_t0am{};
78 std::vector<std::vector<double>> m_t0ma{};
79 // t's updated each solve_core itteration
80 std::vector<std::vector<double>> m_tam{};
81 std::vector<std::vector<double>> m_tma{};
82
83 // Note: W's depend on rank (also parity)! Can re-use!?
84 // These are probably an excellent candidate for unordered_map?
85 std::vector<std::vector<std::vector<std::vector<double>>>> m_Wanmb{};
86 std::vector<std::vector<std::vector<std::vector<double>>>> m_Wabmn{};
87 std::vector<std::vector<std::vector<std::vector<double>>>> m_Wmnab{};
88 std::vector<std::vector<std::vector<std::vector<double>>>> m_Wmban{};
89
90public:
91 //! @brief Constructs DiagramRPA from a basis and a Hartree-Fock object
92 /*! @details
93 Splits @p basis into core (hole) and excited states, then computes the
94 Coulomb W-matrix integrals required by the diagram RPA equations.
95 If @p atom is non-empty the W matrices are read from a binary cache file
96 (named from the atom label, operator rank, parity, and basis string) to
97 avoid recalculation; if no matching file exists the matrices are computed
98 and the file is written for future use.
99 The Breit interaction is included automatically when present in @p in_hf.
100 @param h Pointer to the external-field tensor operator; must not be null
101 @param basis Complete single-particle basis (holes and excited states)
102 @param in_hf Pointer to the Hartree-Fock object; must not be null
103 @param atom Atom label used to form the W-matrix cache filename;
104 pass an empty string to disable file I/O
105 @param print If true, prints progress information to stdout
106 */
108 const std::vector<DiracSpinor> &basis,
109 const HF::HartreeFock *in_hf, const std::string &atom = "",
110 bool print = true);
111
112 //! @brief Constructs DiagramRPA by reusing W matrices from an existing instance
114 const DiagramRPA *const drpa);
115
116public:
117 //! @brief Iterates the RPA equations to convergence for the core electrons
118 /*! @details
119 Performs a self-consistent iterative solution of the diagram-method RPA
120 equations at external-field frequency @p omega.
121 The zeroth-order matrix elements \f$ t^{(0)}_{am} \f$ are calculated (so long as max_its>0).
122 Each iteration updates the RPA matrix elements \f$ t_{am} \f$ and
123 \f$ t_{ma} \f$ using the precomputed Coulomb W-matrix integrals until the
124 maximum relative change falls below eps_target(), or @p max_its iterations
125 have been performed.
126 @param omega External-field frequency in atomic units
127 @param max_its Maximum number of iterations (default 200)
128 @param print If true, prints per-iteration progress to stdout
129
130 @note
131 Calling DiagramRPA::dV() without calling DiagramRPA::solve_core() will return 0.
132 Call with max_its = 0 will mean that dV() also returns 0.
133 Call with max_its = 1 will mean that dV() returns the lowest-order dV correction.
134 */
135 void solve_core(double omega, int max_its = 200,
136 bool print = true) override final;
137
138 //! @brief Returns the RPA method identifier (diagram)
139 Method method() const final { return Method::diagram; }
140
141 //! @brief Returns the RPA correction to a reduced matrix element
142 /*! @details
143 Computes the many-body RPA correction to the reduced matrix element
144 \f[ \langle a \| \delta V \| b \rangle \f]
145 using the converged RPA matrix elements \f$ t_{am} \f$ from the most
146 recent solve_core() call. Should be called after solve_core() has
147 converged.
148 @param Fa Bra state
149 @param Fb Ket state
150 @return Reduced matrix element of the RPA correction
151
152 @note
153 Not Hermitian - solve_core() must be called with negaitve omega
154 */
155 double dV(const DiracSpinor &Fa, const DiracSpinor &Fb) const override final;
156
157 double dV(const DiracSpinor &Fa, const DiracSpinor &Fb, bool conj) const;
158
159 //! @brief Calculates reduced right-hand-side, projected onto kappa: [dV|phi_m]_kappa
160 DiracSpinor dV_rhs(int kappa, const DiracSpinor &Fm,
161 bool conj = false) const final;
162
163 //! @brief Resets the RPA matrix elements to their unperturbed (zeroth-order) values
164 /*! @details
165 Clears the \f$ t_{am} \f$ and \f$ t_{ma} \f$ matrices (which encode the
166 hole-excited RPA corrections) back to the state prior to any
167 solve_core() call.
168 Use this to discard a failed or poorly converged solution before restarting,
169 for example with a different frequency or damping parameter.
170 */
171 void clear() final;
172
173 //! @brief Updates the zeroth-order matrix elements and resets the RPA solution
174 /*! @details
175 Recomputes the lowest-order (no-RPA) matrix elements \f$ t^{(0)}_{am} \f$
176 for operator @p h . Does not update the rpa T_am values.
177 If @p h is null the currently stored operator is used unchanged.
178 @param h Optional replacement tensor operator; pass nullptr to keep the
179 current operator
180 */
181 void update_t0s(const DiracOperator::TensorOperator *const h = nullptr);
182
183private:
184 // Note: only writes W (depends on k/pi, and basis). Do not write t's, since
185 // they depend on operator. This makes it very fast when making small changes
186 // to operator (don't need to re-calc W)
187 // Note: doesn't depend on grid!
188 bool read_write(const std::string &fname, IO::FRW::RoW rw, bool print = true);
189
190 // Calculates all required W^k integrals (uses rank, parity of h)
191 void fill_W_matrix(const DiracOperator::TensorOperator *const h, bool print);
192 // Calculates all t_am matrix elements (without RPA)
193 void setup_ts(const DiracOperator::TensorOperator *const h);
194
195public:
196 DiagramRPA &operator=(const DiagramRPA &) = delete;
197 DiagramRPA(const DiagramRPA &) = default;
198 ~DiagramRPA() = default;
199};
200
201} // namespace ExternalField
General tensor operator (virtual base class); all single-particle (one-body) tenosor operators derive...
Definition TensorOperator.hpp:197
Stores radial Dirac spinor: F_nk = (f, g)
Definition DiracSpinor.hpp:42
Virtual Core Polarisation class, for <a||dV||b>. See TDHF, DiagramRPA, etc.
Definition CorePolarisation.hpp:38
RPA correction to matrix elements, using Diagram technique.
Definition DiagramRPA.hpp:67
DiracSpinor dV_rhs(int kappa, const DiracSpinor &Fm, bool conj=false) const final
Calculates reduced right-hand-side, projected onto kappa: [dV|phi_m]_kappa.
Definition DiagramRPA.cpp:409
void solve_core(double omega, int max_its=200, bool print=true) override final
Iterates the RPA equations to convergence for the core electrons.
Definition DiagramRPA.cpp:470
void update_t0s(const DiracOperator::TensorOperator *const h=nullptr)
Updates the zeroth-order matrix elements and resets the RPA solution.
Definition DiagramRPA.cpp:316
double dV(const DiracSpinor &Fa, const DiracSpinor &Fb) const override final
Returns the RPA correction to a reduced matrix element.
Definition DiagramRPA.cpp:352
Method method() const final
Returns the RPA method identifier (diagram)
Definition DiagramRPA.hpp:139
void clear() final
Resets the RPA matrix elements to their unperturbed (zeroth-order) values.
Definition DiagramRPA.cpp:310
Solves relativistic Hartree-Fock equations for core and valence. Optionally includes Breit and QED ef...
Definition HartreeFock.hpp:71
Stores Wavefunction (set of valence orbitals, grid, HF etc.)
Definition Wavefunction.hpp:37
Dirac operators: TensorOperator base class and derived implementations for single-particle (one-body)...
Definition GenerateOperator.cpp:3
Calculates many-body corrections (RPA) to matrix elements of external field.
Definition calcMatrixElements.cpp:14
Functions and classes for Hartree-Fock.
Definition CI_Integrals.hpp:13
In-out (timers, profilers, and read/write data)
Definition ChronoTimer.hpp:9