ampsci
High-precision calculations for one- and two-valence atomic systems
RadPot.hpp
1#pragma once
2#include "FGRadPot.hpp"
3#include "IO/FRW_fileReadWrite.hpp"
4#include "IO/InputBlock.hpp"
5#include "Maths/Interpolator.hpp"
6#include "Physics/PhysConst_constants.hpp"
7#include "qip/Vector.hpp"
8#include <algorithm>
9#include <vector>
10
11//! Radiative QED corrections (Flambaum-Ginges Radiative Potenti)
12namespace QED {
13
14//==============================================================================
15//! Constructs and stores the Flambaum-Ginges QED Radiative Potential
16class RadPot {
17
18public:
19 //============================================================================
20 //! Scale factors for Uehling, high, low, magnetic, Wickman-Kroll
21 struct Scale {
22 double u, h, l, m, wk;
23 };
24
25 //============================================================================
26 //! Extra fitting for s,p,d etc. states.
27 /*! @details Will assume factor for higher l's same as last one.
28 e.g., {1,1} => 1,1,1,1,...
29 e.g., {1,0} => 1,0,0,0,...
30 */
31 struct Xl {
32
33 private:
34 std::vector<double> m_x;
35
36 public:
37 Xl();
38 Xl(std::vector<double> x);
39
40 double operator()(int l) const;
41 };
42
43 //============================================================================
44private:
45 double m_Z, m_rN, m_rcut;
46 Scale m_f;
47 Xl m_xl;
48 bool print;
49
50 std::vector<double> mVu{}; // Uehling
51 std::vector<double> mVh{}; // High-freq electric SE (without A)
52 std::vector<double> mVl{}; // Low-freq electric SE (without B)
53 std::vector<double> mHm{}; // Magnetic FF
54 std::vector<double> mVwk{}; // Approx Wickman-Kroll
55
56public:
57 //! Empty constructor
58 RadPot();
59
60 //! Constructor: will build potential
61 /*! @details
62 rcut is maxum radius (atomic units) to calc potential for.
63 */
64 RadPot(const std::vector<double> &r, double Z, double rN = 0.0,
65 double rcut = 0.0, Scale f = {1.0, 1.0, 1.0, 1.0, 0.0}, Xl xl = {},
66 bool tprint = true, bool do_readwrite = true,
67 const std::string &label = "");
68
69 bool read_write(const std::vector<double> &r, IO::FRW::RoW rw,
70 const std::string &label_x = "");
71
72 void form_potentials(const std::vector<double> &r);
73
74 //! Returns entire electric part of potential
75 std::vector<double> Vel(int l = 0) const;
76 //! Returns H_mag (magnetic self-energy form vactor)
77 std::vector<double> Hmag(int) const;
78 //! Uehling potential
79 std::vector<double> Vu(int l = 0) const;
80 //! Low-frequency electric self-energy potential
81 std::vector<double> Vl(int l = 0) const;
82 //! High-frequency electric self-energy potential
83 std::vector<double> Vh(int l = 0) const;
84
85 template <typename Func>
86 std::vector<double> fill(Func f, const std::vector<double> &r);
87
88 template <typename Func>
89 std::vector<double> fill(Func f, const std::vector<double> &r,
90 std::size_t stride);
91};
92
93//============================================================================
94//==============================================================================
95template <typename Func>
96std::vector<double> RadPot::fill(Func f, const std::vector<double> &r) {
97 std::vector<double> v;
98 v.resize(r.size());
99
100 const auto rcut = m_rcut == 0.0 ? r.back() : m_rcut;
101
102 // index for r cut-off
103 const auto icut = std::size_t(std::distance(
104 begin(r),
105 std::find_if(begin(r), end(r), [rcut](auto ri) { return ri > rcut; })));
106
107#pragma omp parallel for
108 for (auto i = 0ul; i < icut; ++i) {
109 // nb: Use H -> H+V (instead of H-> H-V), so change sign!
110 v[i] = -f(m_Z, r[i], m_rN);
111 }
112 return v;
113}
114
115//==============================================================================
116template <typename Func>
117std::vector<double> RadPot::fill(Func f, const std::vector<double> &r,
118 std::size_t stride) {
119
120 const auto rcut = m_rcut == 0.0 ? r.back() : m_rcut;
121
122 // index for r cut-off
123 const auto icut =
124 std::size_t(std::distance(
125 begin(r),
126 std::find_if(begin(r), end(r), [rcut](auto ri) { return ri > rcut; }))) /
127 stride;
128
129 std::vector<double> tv, tr;
130 tv.resize(icut);
131 tr.resize(icut);
132
133#pragma omp parallel for
134 for (auto i = 0ul; i < icut; ++i) {
135 // nb: Use H -> H+V (instead of H-> H-V), so change sign!
136 tv[i] = -f(m_Z, r[i * stride], m_rN);
137 tr[i] = r[i * stride];
138 }
139 return stride == 1 ? tv : Interpolator::interpolate(tr, tv, r);
140}
141
142//==============================================================================
143//! Function constructs a Radiative potential with given input parameters; rN_au is nuclear radius (not rms radius), in atomic units
144RadPot ConstructRadPot(const std::vector<double> &r, double Z_eff, double rN_au,
145 const IO::InputBlock &input = {}, bool print = true,
146 bool do_readwrite = true, const std::string &label = "");
147
148} // namespace QED
Holds a named list of key=value options and nested InputBlocks.
Definition InputBlock.hpp:154
Constructs and stores the Flambaum-Ginges QED Radiative Potential.
Definition RadPot.hpp:16
std::vector< double > Vel(int l=0) const
Returns entire electric part of potential.
Definition RadPot.cpp:155
RadPot()
Empty constructor.
Definition RadPot.cpp:26
std::vector< double > Vl(int l=0) const
Low-frequency electric self-energy potential.
Definition RadPot.cpp:176
std::vector< double > Vu(int l=0) const
Uehling potential.
Definition RadPot.cpp:170
std::vector< double > Vh(int l=0) const
High-frequency electric self-energy potential.
Definition RadPot.cpp:183
std::vector< double > Hmag(int) const
Returns H_mag (magnetic self-energy form vactor)
Definition RadPot.cpp:164
Scale factors for Uehling, high, low, magnetic, Wickman-Kroll.
Definition RadPot.hpp:21
double f(RaB r, PrincipalQN n, DiracQN k, Zeff z, AlphaFS a)
Upper radial component.
Definition DiracHydrogen.cpp:71
std::vector< double > interpolate(const std::vector< double > &x_in, const std::vector< double > &y_in, const std::vector< double > &x_out, Method method=Method::cspline)
Performs interpolation using GSL (GNU Scientific Library)
Definition Interpolator.hpp:162
Radiative QED corrections (Flambaum-Ginges Radiative Potenti)
Definition RadPot.cpp:11
RadPot ConstructRadPot(const std::vector< double > &r, double Z_eff, double rN_au, const IO::InputBlock &input, bool print, bool do_readwrite, const std::string &label)
Function constructs a Radiative potential with given input parameters; rN_au is nuclear radius (not r...
Definition RadPot.cpp:191
Extra fitting for s,p,d etc. states.
Definition RadPot.hpp:31