ampsci
c++ program for high-precision atomic structure calculations of single-valence systems
CorePolarisation.hpp
1 #pragma once
2 #include "DiracOperator/TensorOperator.hpp"
3 #include "qip/String.hpp"
4 #include <string>
5 #include <vector>
6 class DiracSpinor;
7 namespace DiracOperator {
8 class TensorOperator;
9 }
10 
12 namespace ExternalField {
13 
14 enum class Method { TDHF, basis, diagram, none, Error };
15 
16 inline Method ParseMethod(std::string_view str) {
17  return qip::ci_compare(str, "TDHF") ? Method::TDHF :
18  qip::ci_compare(str, "true") ? Method::TDHF :
19  qip::ci_compare(str, "basis") ? Method::basis :
20  qip::ci_compare(str, "tdhf_basis") ? Method::basis :
21  qip::ci_compare(str, "tdhfbasis") ? Method::basis :
22  qip::ci_compare(str, "diagram") ? Method::diagram :
23  qip::ci_compare(str, "rpad") ? Method::diagram :
24  qip::ci_compare(str, "rpa(d)") ? Method::diagram :
25  qip::ci_compare(str, "none") ? Method::none :
26  qip::ci_compare(str, "false") ? Method::none :
27  qip::ci_compare(str, "") ? Method::none :
28  Method::Error;
29 }
30 
31 enum class dPsiType { X, Y };
32 enum class StateType { bra, ket }; // lhs, rhs
33 
36 
37 protected:
39  : m_h(h), m_rank(h->rank()), m_pi(h->parity()), m_imag(h->imaginaryQ()) {}
40 
41 protected:
43  double m_core_eps{1.0};
44  int m_core_its{0};
45  double m_core_omega{0.0};
46  int m_rank;
47  int m_pi;
48  bool m_imag;
49 
50  double m_eta{0.4};
51  double m_eps{1.0e-10};
52 
53 public:
55  double last_eps() const { return m_core_eps; }
57  double last_its() const { return m_core_its; }
59  double last_omega() const { return m_core_omega; }
60  int rank() const { return m_rank; }
61  int parity() const { return m_pi; }
62  bool imagQ() const { return m_imag; }
63 
65  double &eps_target() { return m_eps; }
67  double eps_target() const { return m_eps; }
68 
70  double eta() const { return m_eta; }
72  void set_eta(double eta) {
73  assert(eta >= 0.0 && eta < 1 && "Must have 0 <= eta < 1");
74  m_eta = eta;
75  }
76 
78  virtual Method method() const = 0;
79 
81  virtual void solve_core(const double omega, int max_its = 100,
82  const bool print = true) = 0;
83 
85  virtual void clear() = 0;
86 
88  virtual double dV(const DiracSpinor &Fn, const DiracSpinor &Fm) const = 0;
89 
90 public:
91  CorePolarisation &operator=(const CorePolarisation &) = delete;
92  CorePolarisation(const CorePolarisation &) = default;
93  virtual ~CorePolarisation() = default;
94 };
95 
96 } // namespace ExternalField
General operator (virtual base class); operators derive from this.
Definition: TensorOperator.hpp:110
bool imaginaryQ() const
returns true if operator is imaginary (has imag MEs)
Definition: TensorOperator.hpp:171
int parity() const
returns parity, as integer (+1 or -1)
Definition: TensorOperator.hpp:174
Stores radial Dirac spinor: F_nk = (f, g)
Definition: DiracSpinor.hpp:41
Virtual Core Polarisation class, for <a||dV||b>. See TDHF, DiagramRPA, etc.
Definition: CorePolarisation.hpp:35
virtual void clear()=0
Clears the dPsi orbitals (sets to zero)
virtual double dV(const DiracSpinor &Fn, const DiracSpinor &Fm) const =0
Calculate reduced matrix element <n||dV||m>
double last_eps() const
Returns eps (convergance) of last solve_core run.
Definition: CorePolarisation.hpp:55
double last_omega() const
Returns omega (frequency) of last solve_core run.
Definition: CorePolarisation.hpp:59
void set_eta(double eta)
Set/update damping factor; 0 means no damping. Must have 0 <= eta < 1.
Definition: CorePolarisation.hpp:72
double eps_target() const
Convergance target.
Definition: CorePolarisation.hpp:67
virtual void solve_core(const double omega, int max_its=100, const bool print=true)=0
Solve RPA equations (for whichever method) for core.
virtual Method method() const =0
Returns RPA method.
double eta() const
Damping factor; 0 means no damping. Must have 0 <= eta < 1.
Definition: CorePolarisation.hpp:70
double last_its() const
Returns its (# of iterations) of last solve_core run.
Definition: CorePolarisation.hpp:57
double & eps_target()
Convergance target.
Definition: CorePolarisation.hpp:65
Dirac Operators: General + derived.
Definition: GenerateOperator.cpp:12
Calculates many-body corrections (RPA) to matrix elements of external field.
Definition: calcMatrixElements.cpp:14
bool ci_compare(std::string_view s1, std::string_view s2)
Case insensitive string compare. Essentially: LowerCase(s1)==LowerCase(s2)
Definition: String.hpp:92