ampsci
High-precision calculations for one- and two-valence atomic systems
CI_Integrals.hpp
1#pragma once
2#include "CSF.hpp"
3#include "Coulomb/QkTable.hpp"
4#include "Coulomb/meTable.hpp"
5#include "LinAlg/Matrix.hpp"
6#include "MBPT/Sigma2.hpp" //temp - remove after refactor
7#include <string>
8#include <vector>
9class DiracDiracSpinor;
10namespace MBPT {
11class CorrelationPotential;
12}
13namespace HF {
14class Breit;
15}
16
17namespace CI {
18
19/*!
20 @brief Antisymmetrised two-body Coulomb matrix element in the coupled CSF
21 basis.
22 @details
23 Evaluates the angular-reduced, antisymmetrised Coulomb interaction between
24 two two-electron CSFs \f$ |vw; J\rangle \f$ and \f$ |xy; J\rangle \f$:
25
26 \f[
27 \langle vw; J \| g \| xy; J \rangle
28 = \eta_{vw}\eta_{xy}
29 \sum_k (-1)^{j_v+j_x+k+J}
30 \begin{Bmatrix} j_v & j_w & J \\ j_y & j_x & k \end{Bmatrix}
31 Q^k_{vwxy} + \text{exchange},
32 \f]
33
34 where \f$ \eta_{ab} = 1/\sqrt{2} \f$ if \f$ a = b \f$ (identical-particle
35 normalisation) and 1 otherwise, and \f$ Q^k \f$ are the Coulomb integrals stored in @p qk.
36
37 @param qk Table of Coulomb \f$ Q^k \f$ integrals.
38 @param v,w Indices of the bra single-particle states.
39 @param x,y Indices of the ket single-particle states.
40 @param twoJ Twice the total angular momentum 2J of the coupled pair.
41 @return Antisymmetrised, angular-reduced two-body Coulomb matrix element.
42*/
43double CSF2_Coulomb(const Coulomb::QkTable &qk, DiracSpinor::Index v,
44 DiracSpinor::Index w, DiracSpinor::Index x,
45 DiracSpinor::Index y, int twoJ);
46
47/*!
48 @brief Two-body \f$ \Sigma_2 \f$ (MBPT) correction to CSF2_Coulomb().
49 @details
50 Evaluates the same angular reduction as CSF2_Coulomb(), but using the
51 two-body \f$ \Sigma_2 \f$ integrals \f$ S^k \f$ stored in @p Sk in place of
52 the Coulomb \f$ Q^k \f$ integrals. Adds the second-order MBPT correction to
53 the two-electron interaction.
54
55 @param Sk Table of two-body \f$ \Sigma_2 \f$ (\f$ L^k \f$) integrals.
56 @param v,w Indices of the bra single-particle states.
57 @param x,y Indices of the ket single-particle states.
58 @param twoJ Twice the total angular momentum 2J of the coupled pair.
59 @return Antisymmetrised two-body \f$ \Sigma_2 \f$ matrix element.
60*/
61double CSF2_Sigma2(const Coulomb::LkTable &Sk, DiracSpinor::Index v,
62 DiracSpinor::Index w, DiracSpinor::Index x,
63 DiracSpinor::Index y, int twoJ);
64
65/*!
66 @brief Antisymmetrised two-body Breit matrix element in the coupled CSF
67 basis.
68 @details
69 Evaluates the same angular reduction as CSF2_Coulomb(), but using the Breit
70 \f$ B^k \f$ integrals stored in @p Bk.
71
72 @param Bk Table of Breit \f$ W^k \f$ integrals.
73 @param v,w Indices of the bra single-particle states.
74 @param x,y Indices of the ket single-particle states.
75 @param twoJ Twice the total angular momentum 2J of the coupled pair.
76 @return Antisymmetrised two-body Breit matrix element.
77*/
78double CSF2_Breit(const Coulomb::WkTable &Bk, DiracSpinor::Index v,
79 DiracSpinor::Index w, DiracSpinor::Index x,
80 DiracSpinor::Index y, int twoJ);
81
82/*!
83 @brief CI Hamiltonian matrix element between two two-electron CSFs.
84 @details
85 Computes \f$ H_{AB} = \langle A | \hat{H} | B \rangle \f$ using the
86 Slater-Condon rules, including one-body terms from @p h1 (which may already
87 incorporate \f$ \Sigma_1 \f$ corrections) and the two-body Coulomb
88 interaction via CSF2_Coulomb().
89
90 Does NOT include \f$ \Sigma_2 \f$ or Breit corrections; add those via
91 Sigma2_AB() and Breit_AB() respectively.
92
93 @param A,B The two CSFs.
94 @param twoJ Twice the total angular momentum 2J.
95 @param h1 Table of one-body matrix elements \f$ \langle a | h_1 | b \rangle \f$.
96 @param qk Table of Coulomb \f$ Q^k \f$ integrals.
97 @return CI Hamiltonian matrix element \f$ H_{AB} \f$.
98*/
99double Hab(const CI::CSF2 &A, const CI::CSF2 &B, int twoJ,
100 const Coulomb::meTable<double> &h1, const Coulomb::QkTable &qk);
101
102/*!
103 @brief Two-body \f$ \Sigma_2 \f$ correction to Hab().
104 @details
105 Evaluates the MBPT \f$ \Sigma_2 \f$ contribution to the CI matrix element
106 using CSF2_Sigma2(). Add to Hab() to form the full CI+MBPT Hamiltonian
107 matrix element.
108
109 @param A,B The two CSFs.
110 @param twoJ Twice the total angular momentum 2J.
111 @param Sk Table of \f$ \Sigma_2 \f$ (\f$ L^k \f$) integrals.
112 @return \f$ \Sigma_2 \f$ correction to \f$ H_{AB} \f$.
113*/
114double Sigma2_AB(const CI::CSF2 &A, const CI::CSF2 &B, int twoJ,
115 const Coulomb::LkTable &Sk);
116
117/*!
118 @brief Breit correction to Hab().
119 @details
120 Evaluates the two-body Breit contribution to the CI matrix element using
121 CSF2_Breit(). Add to Hab() to include the Breit interaction.
122
123 @param A,B The two CSFs.
124 @param twoJ Twice the total angular momentum 2J.
125 @param Bk Table of Breit \f$ W^k \f$ integrals.
126 @return Breit correction to \f$ H_{AB} \f$.
127*/
128double Breit_AB(const CI::CSF2 &A, const CI::CSF2 &B, int twoJ,
129 const Coulomb::WkTable &Bk);
130
131/*!
132 @brief Builds the one-body Hamiltonian matrix element table for the CI basis.
133 @details
134 Constructs a lookup table of single-particle matrix elements
135 \f$ \langle a | h_1 | b \rangle \f$ for all pairs \f$ a, b \f$ in
136 @p ci_basis. The diagonal elements are the HF single-particle energies.
137
138 If @p include_Sigma1 is true, the one-body MBPT \f$ \Sigma_1 \f$ correction
139 is computed from the Coulomb integrals in @p qk using @p s1_basis_core and
140 @p s1_basis_excited as the internal lines of the MBPT diagrams and added to
141 the diagonal.
142
143 @param ci_basis Basis states for which table entries are needed.
144 @param s1_basis_core Core states used as internal lines for \f$ \Sigma_1 \f$.
145 @param s1_basis_excited Excited states used as internal lines for \f$ \Sigma_1 \f$.
146 @param qk Table of Coulomb \f$ Q^k \f$ integrals.
147 @param include_Sigma1 If true, add one-body MBPT \f$ \Sigma_1 \f$ corrections.
148 @return Table of \f$ \langle a | h_1 | b \rangle \f$ matrix elements.
149
150 @warning Assumes @p ci_basis states are Hartree-Fock eigenstates, so
151 off-diagonal HF terms vanish.
152*/
153[[nodiscard]] Coulomb::meTable<double>
154calculate_h1_table(const std::vector<DiracSpinor> &ci_basis,
155 const std::vector<DiracSpinor> &s1_basis_core,
156 const std::vector<DiracSpinor> &s1_basis_excited,
157 const Coulomb::QkTable &qk, bool include_Sigma1);
158
159/*!
160 @brief Builds the one-body Hamiltonian table using a precomputed
161 CorrelationPotential.
162 @details
163 Overload of calculate_h1_table() that uses a CorrelationPotential object
164 (i.e., a precomputed \f$ \Sigma_1 \f$ operator) instead of computing MBPT
165 diagrams on the fly. Preferred when a CorrelationPotential is available, as
166 it is generally faster and more complete.
167
168 @param ci_basis Basis states for which table entries are needed.
169 @param Sigma Precomputed one-body correlation potential \f$ \Sigma_1 \f$.
170 @param include_Sigma1 If true, include \f$ \Sigma_1 \f$ corrections from @p Sigma.
171 @return Table of \f$ \langle a | h_1 | b \rangle \f$ matrix elements.
172*/
173[[nodiscard]] Coulomb::meTable<double>
174calculate_h1_table(const std::vector<DiracSpinor> &ci_basis,
175 const MBPT::CorrelationPotential &Sigma,
176 bool include_Sigma1);
177
178/*!
179 @brief Builds or loads the two-body Breit integral table.
180 @details
181 Computes Breit \f$ W^k \f$ integrals for all pairs in @p ci_basis using the
182 Breit operator @p pBr. Results are cached to/from @p bk_filename.
183
184 If @p pBr is nullptr or @p no_new_integralsQ is true, no new integrals are
185 computed; only cached values are loaded.
186
187 @param bk_filename Filename for caching the \f$ W^k \f$ table.
188 @param pBr Pointer to Breit operator; if nullptr, returns empty table.
189 @param ci_basis Basis for which Breit integrals are needed.
190 @param max_k Maximum multipolarity k to include.
191 @param no_new_integralsQ If true, skip computing any new integrals.
192 @return Table of Breit \f$ W^k \f$ integrals.
193*/
194[[nodiscard]] Coulomb::WkTable
195calculate_Bk(const std::string &bk_filename, const HF::Breit *const pBr,
196 const std::vector<DiracSpinor> &ci_basis, int max_k,
197 bool no_new_integralsQ = false);
198
199/*!
200 @brief Returns the subset of @p basis matching @p subset_string, excluding
201 states in @p frozen_core_string.
202 @details
203 Filters @p basis to retain only states described by the ampsci basis-string
204 notation (e.g., "20spdf") that are not part of the frozen core.
205
206 @param basis Full single-particle basis to filter.
207 @param subset_string Basis-string specifying which states to keep.
208 @param frozen_core_string Basis-string specifying core states to exclude.
209 @return Filtered basis vector.
210*/
211[[nodiscard]] std::vector<DiracSpinor>
212basis_subset(const std::vector<DiracSpinor> &basis,
213 const std::string &subset_string,
214 const std::string &frozen_core_string = "");
215
216/*!
217 @brief Reduced matrix element between two CI states (low-level overload).
218 @details
219 Evaluates the reduced matrix element of a rank-@p K_rank tensor operator
220 between two CI states:
221
222 \f[
223 \redmatel{A}{T^K}{B}
224 = \sum_{ij} c_i^A \, c_j^B \, \redmatel{\text{CSF}_i}{T^K}{\text{CSF}_j},
225 \f]
226
227 where the single-particle reduced matrix elements are looked up from @p h.
228
229 @param cA,cB CI expansion coefficient vectors for states A and B.
230 @param CSFAs,CSFBs CSF bases for states A and B respectively.
231 @param twoJA,twoJB Twice the total angular momentum of states A and B.
232 @param h Lookup table of single-particle reduced matrix elements.
233 @param K_rank Rank of the tensor operator.
234 @param Parity Parity of the operator (+1 or -1).
235 @return Reduced matrix element \f$ \redmatel{A}{T^K}{B} \f$.
236*/
238 const std::vector<CI::CSF2> &CSFAs, int twoJA,
240 const std::vector<CI::CSF2> &CSFBs, int twoJB,
241 const Coulomb::meTable<double> &h, int K_rank, int Parity);
242
243/*!
244 @brief Reduced matrix element between two CI states (PsiJPi overload).
245 @details
246 Convenience wrapper around the low-level ReducedME() overload. Extracts
247 expansion coefficients and CSF lists from @p As and @p Bs for the requested
248 solution indices @p iA and @p iB.
249
250 @param As,Bs CI solution containers for the two states.
251 @param iA,iB Solution indices within @p As and @p Bs.
252 @param h Lookup table of single-particle reduced matrix elements.
253 @param K_rank Rank of the tensor operator.
254 @param Parity Parity of the operator (+1 or -1).
255 @return Reduced matrix element \f$ \redmatel{A}{T^K}{B} \f$.
256*/
257inline double ReducedME(const PsiJPi &As, std::size_t iA, const PsiJPi &Bs,
258 std::size_t iB, const Coulomb::meTable<double> &h,
259 int K_rank, int Parity) {
260 return ReducedME(As.coefs(iA), As.CSFs(), As.twoJ(), Bs.coefs(iB), Bs.CSFs(),
261 Bs.twoJ(), h, K_rank, Parity);
262}
263
264/*!
265 @brief Reduced matrix element between two two-electron CSFs.
266 @details
267 Evaluates \f$ \redmatel{X; J_X}{T^K}{V; J_V} \f$ for a rank-@p K_rank
268 one-body tensor operator using the standard 6j angular reduction, accounting
269 for identical-particle normalisation factors.
270
271 @warning This function may not handle all cases correctly; results should be
272 verified for non-trivial configurations.
273*/
274double RME_CSF2(const CI::CSF2 &X, int twoJX, const CI::CSF2 &V, int twoJV,
275 const Coulomb::meTable<double> &h, int K_rank);
276
277/*!
278 @brief Determines the best-fit (S, L) term for a two-electron state by
279 matching the g-factor.
280 @details
281 Iterates over all allowed (S, L) combinations for given orbital angular
282 momenta @p l1, @p l2 and total @p twoJ /2, and returns the pair whose
283 Lande g-factor is closest to @p gJ_target.
284
285 @param l1,l2 Orbital angular momenta of the two electrons.
286 @param twoJ Twice the total angular momentum 2J.
287 @param gJ_target Target g-factor to match.
288 @return Best-fit {2S, L} pair.
289*/
290std::pair<int, int> Term_S_L(int l1, int l2, int twoJ, double gJ_target);
291
292//! Returns spectroscopic term symbol string, e.g. "3P_1"
293std::string Term_Symbol(int two_J, int L, int two_S, int parity);
294//! Returns term symbol without the J subscript, e.g. "3P"
295std::string Term_Symbol(int L, int two_S, int parity);
296
297/*!
298 @brief Constructs the full CI Hamiltonian matrix in the CSF basis.
299 @details
300 Builds the symmetric matrix \f$ H_{AB} \f$ for all CSF pairs in @p psi,
301 calling Hab() for each element and optionally adding Breit and
302 \f$ \Sigma_2 \f$ corrections.
303
304 @param psi CI solution container holding the CSF basis and J/parity.
305 @param h1 One-body matrix element table (may include \f$ \Sigma_1 \f$).
306 @param qk Coulomb \f$ Q^k \f$ integral table.
307 @param Bk Pointer to Breit \f$ W^k \f$ table; ignored if nullptr.
308 @param Sk Pointer to \f$ \Sigma_2 \f$ \f$ L^k \f$ table; ignored if nullptr.
309 @return Full CI Hamiltonian matrix in the CSF basis.
310*/
311LinAlg::Matrix<double> construct_Hci(const PsiJPi &psi,
312 const Coulomb::meTable<double> &h1,
313 const Coulomb::QkTable &qk,
314 const Coulomb::WkTable *Bk = nullptr,
315 const Coulomb::LkTable *Sk = nullptr);
316
317} // namespace CI
Two-electron configuration state function (CSF).
Definition CSF.hpp:28
Container for CI solutions in a single (J, parity) sector.
Definition CSF.hpp:141
LinAlg::View< const double > coefs(std::size_t i) const
CI expansion coefficients for the ith solution (one per CSF)
Definition CSF.cpp:172
const std::vector< CSF2 > & CSFs() const
Full list of CSFs spanning this (J, parity) sector.
Definition CSF.cpp:160
int twoJ() const
Twice the total angular momentum 2J for this sector.
Definition CSF.cpp:187
Base class template to store Coulomb integrals, and similar. 3 specific cases (by template instantiat...
Definition QkTable.hpp:90
Look-up table for matrix elements. Note: does not assume any symmetry: (a,b) is stored independantly ...
Definition meTable.hpp:17
Breit (Hartree-Fock Breit) interaction potential.
Definition Breit.hpp:52
Matrix class; row-major.
Definition Matrix.hpp:39
Proved a "view" onto an array.
Definition Matrix.ipp:7
Functions and classes for Configuration Interaction calculations.
Definition CI_Integrals.cpp:11
double CSF2_Breit(const Coulomb::WkTable &Bk, DiracSpinor::Index v, DiracSpinor::Index w, DiracSpinor::Index x, DiracSpinor::Index y, int twoJ)
Antisymmetrised two-body Breit matrix element in the coupled CSF basis.
Definition CI_Integrals.cpp:131
Coulomb::meTable< double > calculate_h1_table(const std::vector< DiracSpinor > &ci_basis, const std::vector< DiracSpinor > &s1_basis_core, const std::vector< DiracSpinor > &s1_basis_excited, const Coulomb::QkTable &qk, bool include_Sigma1)
Builds the one-body Hamiltonian matrix element table for the CI basis.
Definition CI_Integrals.cpp:231
double Sigma2_AB(const CI::CSF2 &A, const CI::CSF2 &B, int twoJ, const Coulomb::LkTable &Sk)
Two-body correction to Hab().
Definition CI_Integrals.cpp:179
LinAlg::Matrix< double > construct_Hci(const PsiJPi &psi, const Coulomb::meTable< double > &h1, const Coulomb::QkTable &qk, const Coulomb::WkTable *Bk, const Coulomb::LkTable *Sk)
Constructs the full CI Hamiltonian matrix in the CSF basis.
Definition CI_Integrals.cpp:527
double Breit_AB(const CI::CSF2 &A, const CI::CSF2 &B, int twoJ, const Coulomb::WkTable &Bk)
Breit correction to Hab().
Definition CI_Integrals.cpp:187
double RME_CSF2(const CI::CSF2 &X, int twoJX, const CI::CSF2 &V, int twoJV, const Coulomb::meTable< double > &h, int K_rank)
Reduced matrix element between two two-electron CSFs.
Definition CI_Integrals.cpp:424
std::string Term_Symbol(int two_J, int L, int two_S, int parity)
Returns spectroscopic term symbol string, e.g. "3P_1".
Definition CI_Integrals.cpp:513
std::pair< int, int > Term_S_L(int l1, int l2, int twoJ, double gJ_target)
Determines the best-fit (S, L) term for a two-electron state by matching the g-factor.
Definition CI_Integrals.cpp:472
double Hab(const CI::CSF2 &X, const CI::CSF2 &V, int twoJ, const Coulomb::meTable< double > &h1, const Coulomb::QkTable &qk)
CI Hamiltonian matrix element between two two-electron CSFs.
Definition CI_Integrals.cpp:196
double ReducedME(const LinAlg::View< const double > &cA, const std::vector< CI::CSF2 > &CSFAs, int twoJA, const LinAlg::View< const double > &cB, const std::vector< CI::CSF2 > &CSFBs, int twoJB, const Coulomb::meTable< double > &h, int K_rank, int Parity)
Reduced matrix element between two CI states (low-level overload).
Definition CI_Integrals.cpp:385
Coulomb::WkTable calculate_Bk(const std::string &bk_filename, const HF::Breit *const pBr, const std::vector< DiracSpinor > &ci_basis, int max_k, bool no_new_integrals)
Builds or loads the two-body Breit integral table.
Definition CI_Integrals.cpp:302
std::vector< DiracSpinor > basis_subset(const std::vector< DiracSpinor > &basis, const std::string &subset_string, const std::string &frozen_core_string)
Returns the subset of basis matching subset_string, excluding states in frozen_core_string.
Definition CI_Integrals.cpp:346
double CSF2_Sigma2(const Coulomb::LkTable &Sk, DiracSpinor::Index v, DiracSpinor::Index w, DiracSpinor::Index x, DiracSpinor::Index y, int twoJ)
Two-body (MBPT) correction to CSF2_Coulomb().
Definition CI_Integrals.cpp:75
double CSF2_Coulomb(const Coulomb::QkTable &qk, DiracSpinor::Index v, DiracSpinor::Index w, DiracSpinor::Index x, DiracSpinor::Index y, int twoJ)
Antisymmetrised two-body Coulomb matrix element in the coupled CSF basis.
Definition CI_Integrals.cpp:16
Functions and classes for Hartree-Fock.
Definition CI_Integrals.hpp:13
Many-body perturbation theory.
Definition CI_Integrals.hpp:10