High-precision calculations for one- and two-valence atomic systems
DiracSpinor

ok

Stores radial Dirac spinor: F_nk = (f, g)

\[ \psi_{n\kappa m} = \frac{1}{r} \begin{pmatrix} f_{n\kappa}(r)\,\Omega_{\kappa m}\\ g_{n\kappa}(r)\,\Omega_{-\kappa m} \end{pmatrix}, \quad F_{n\kappa} = \begin{pmatrix} f_{n\kappa}(r)\\ g_{n\kappa}(r) \end{pmatrix} \]

Construction.
Takes in constant n and k=kappa values + grid
  • A shared pointer to the Grid is stored (to avoid many copies of Grid)
Operator Overloads
  • Intuative operator overloads are provided (Fa, Fb are DiracSpinors):
  • v * Fa, where v is a double or vector works the obvious way
  • Fa * Fb = <Fa|Fb>
  • Fa == Fb returns true if {na,ka}=={nb,kb}
  • Fa > Fb : first compares n, and then kappa (via kappa_index)
  • Fa +/- Fb : Adds/subtracts the two spinors (and updates p0/pinf)
  • You can make copies: auto Fnew = Fa
  • And you can re-asign: Fb = Fa (provided Fa and Fb have same n and kappa!)
  • n and kappa are constant, cannot be changed. Avoids angular errors.
  • all 'set_' functions return mutable references to variables

#include <DiracSpinor.hpp>

Public Types

using Index = uint16_t
 

Public Member Functions

 DiracSpinor (int in_n, int in_kappa, std::shared_ptr< const Grid > in_rgrid)
 Constructor: Requires n (PQN), kappa (Dirac QN), and grid (shared pointer, as it's a shared resource)
 
int n () const
 Principal quantum number, n.
 
int kappa () const
 Dirac quantum number, kappa.
 
int l () const
 Orbital angular momentum Q number.
 
double jjp1 () const
 j(j+1)
 
int twoj () const
 
int twojp1 () const
 2j+1
 
int parity () const
 (-1)^l, returns +/- 1
 
std::size_t k_index () const
 kappa index (see AtomData)
 
Index nk_index () const
 (n,kappa) index (see AtomData)
 
std::string symbol (bool gnuplot=false) const
 Single-electron term symbol (e.g., 6s_1/2). Gnuplot=true => 6s_{1/2}.
 
std::string shortSymbol () const
 e.g., 6p_1/2 => 6p-, 6p_3/2 => 6p+
 
bool & exotic ()
 Checks if spinor is for "exotic" lepton, or regular electron.
 
bool exotic () const
 Checks if spinor is for "exotic" lepton, or regular electron.
 
bool negativeEnergyStateQ () const
 NOTE: Only works for regular alpha, and m=1 - shuold fix.
 
void set_new_kappa (int new_kappa)
 Changes 'kappa' angular quantum number. Use with caution!
 
const Gridgrid () const
 Resturns a const reference to the radial grid.
 
std::shared_ptr< const Gridgrid_sptr () const
 Resturns copy of shared_ptr to grid [shared resource] - used when we want to construct a new DiracSpinor that shares this grid.
 
double en () const
 Single-particle energy, not including rest energy.
 
double & en ()
 
const std::vector< double > & f () const
 Upper (large) radial component function, f.
 
std::vector< double > & f ()
 
double f (std::size_t i) const
 Upper (large) radial component, f(r_i)
 
double & f (std::size_t i)
 
const std::vector< double > & g () const
 Lower (small) radial component function, g.
 
std::vector< double > & g ()
 
double g (std::size_t i) const
 Lower (small) radial component, g(r_i)
 
double & g (std::size_t i)
 
auto min_pt () const
 First non-zero point (index for f[i])
 
auto & min_pt ()
 
auto max_pt () const
 Effective size(); index after last non-zero point (index for f[i])
 
auto & max_pt ()
 
double r0 () const
 r0 = r[min_pt] (in atomic units) XXX Kill this?
 
double rinf () const
 rinf = r[max_pt]
 
auto its () const
 Number of iterations until energy convergence (for latest routine only)
 
auto & its ()
 
auto occ_frac () const
 Occupation fraction. =1 for closed shells. =1/(2j+1) for valence.
 
auto & occ_frac ()
 
auto eps () const
 Fractional energy convergence: eps = |(en'-en)/en|.
 
auto & eps ()
 
const DiracSpinorscale (const double factor)
 Scales DiracSpinor (f and g) by constant.
 
const DiracSpinorscale (const std::vector< double > &v)
 Scales DiracSpinor (f and g) by function of r.
 
void normalise (double norm_to=1.0)
 By default normalises to 1, but can normalise to other number.
 
void zero_boundaries ()
 Forces f(r) and g(r) to be zero outside of [p0,pinf)
 
double norm () const
 Returns the norm, defined: Norm = Sqrt[<a|a>].
 
double norm2 () const
 Returns the norm^2, defined: Norm2 = <a|a>
 
std::pair< double, double > r0pinfratio () const
 Returns [f[p0]/f_max , f[pinf]/f_max] - for tests.
 
std::vector< double > rho () const
 rho(r) = sum_m |Psi^2|(r) = (2j+1) * x_occ * |F^2|(r)
 
int num_electrons () const
 Number of occupied electrons: (2j+1)*occ_frac.
 
DiracSpinoroperator+= (const DiracSpinor &rhs)
 Addition of two DiracSpinors - must have same kappa.
 
DiracSpinoroperator-= (const DiracSpinor &rhs)
 
DiracSpinoroperator*= (const double x)
 Scalar multiplication.
 
DiracSpinoroperator*= (const std::vector< double > &v)
 Multiplication by array (function)
 
void orthog (const DiracSpinor &rhs)
 A more correct way to force orthogonality than normal.
 

Static Public Member Functions

static bool comp_l (const DiracSpinor &lhs, const DiracSpinor &rhs)
 Custom comparitors (for sorting): l, j, kappa_index, energy.
 
static bool comp_j (const DiracSpinor &lhs, const DiracSpinor &rhs)
 
static bool comp_ki (const DiracSpinor &lhs, const DiracSpinor &rhs)
 
static bool comp_n (const DiracSpinor &lhs, const DiracSpinor &rhs)
 
static bool comp_en (const DiracSpinor &lhs, const DiracSpinor &rhs)
 
static std::pair< double, std::string > check_ortho (const std::vector< DiracSpinor > &a, const std::vector< DiracSpinor > &b)
 Returns worst |<a|b>| (or |<a|b>-1| for a=b) {val, state_names}.
 
static void orthonormaliseOrbitals (std::vector< DiracSpinor > &orbs, int num_its=1)
 (approximately) OrthoNormalises a set of any orbitals.
 
static DiracSpinor orthogonaliseWrt (const DiracSpinor &Fin, const std::vector< DiracSpinor > &orbs)
 Forces Fin to be orthogonal to orbs. If Fn (i.e., {n,k}) in in orbs, replaces Fin with that from orbs.
 
static DiracSpinor orthonormaliseWrt (const DiracSpinor &Fin, const std::vector< DiracSpinor > &orbs)
 As orthogonaliseWrt(), but normalises Fin afterwards.
 
static std::string shortSymbol (int n, int kappa)
 e.g., 6p_1/2 => 6p-, 6p_3/2 => 6p+
 
static std::string state_config (const std::vector< DiracSpinor > &orbs)
 Returns formatted states string (e.g., '7sp5d') given list of orbs.
 
static DiracSpinor exactHlike (int n, int k, std::shared_ptr< const Grid > rgrid, double zeff, double alpha=0.0, double mass=1.0)
 Constructs H-like (pointlike) DiracSpinor - mainly for testing.
 
static std::vector< DiracSpinorHlikeBasis (int max_l, int num_ns, std::shared_ptr< const Grid > rgrid, double zeff, double alpha=0.0, double mass=1.0)
 Constructs a basis of H-like (pointlike) DiracSpinors - mainly for testing.
 
static std::vector< DiracSpinorHlikeBasis (const std::string &basis_string, std::shared_ptr< const Grid > rgrid, double zeff, double alpha=0.0, double mass=1.0)
 Constructs a basis of H-like (pointlike) DiracSpinors - mainly for testing.
 
static const DiracSpinorfind (int n, int k, const std::vector< DiracSpinor > &orbs)
 Searches for {n,k} in list of orbitals, returns pointer (may be null)
 
static int max_tj (const std::vector< DiracSpinor > &orbs)
 Returns maximum (2j) found in {orbs}.
 
static int max_l (const std::vector< DiracSpinor > &orbs)
 Returns maximum l found in {orbs}.
 
static int max_n (const std::vector< DiracSpinor > &orbs)
 Returns maximum n found in {orbs}.
 
static int max_n (const std::vector< DiracSpinor > &orbs, int kappa)
 Returns maximum n found in {orbs}, for given kappa.
 
static std::size_t max_kindex (const std::vector< DiracSpinor > &orbs)
 Returns maximum kappa_index found in {orbs}.
 
static double max_En (const std::vector< DiracSpinor > &orbs)
 Returns maximum Energy found in {orbs}.
 
static double min_En (const std::vector< DiracSpinor > &orbs)
 Returns maximum Energy found in {orbs}.
 
static std::pair< std::vector< DiracSpinor >, std::vector< DiracSpinor > > split_by_energy (const std::vector< DiracSpinor > &orbitals, double Fermi_energy, int n_min_core=1, int n_max_excited=9999, bool positrons_are_excited=true)
 Splits orbitals into two groups (i.e., core, excited) by energy.
 
static std::pair< std::vector< DiracSpinor >, std::vector< DiracSpinor > > split_by_core (const std::vector< DiracSpinor > &orbitals, const std::vector< DiracSpinor > &core, int n_min_core=1)
 Splits orbitals into two groups (i.e., core, excited).
 
static std::vector< DiracSpinorsubset (const std::vector< DiracSpinor > &basis, const std::string &subset_string, bool exclude_negative_energy=true)
 Takes a subset of an input basis (by copy), according to subset_string.
 

Friends

double operator* (const DiracSpinor &Fa, const DiracSpinor &Fb)
 Returns radial integral (Fa,Fb) = Int(fa*fb + ga*gb)
 
DiracSpinor operator+ (DiracSpinor lhs, const DiracSpinor &rhs)
 
DiracSpinor operator- (DiracSpinor lhs, const DiracSpinor &rhs)
 
DiracSpinor operator* (DiracSpinor Fa, const double x)
 
DiracSpinor operator* (const double x, DiracSpinor Fa)
 
DiracSpinor operator* (const std::vector< double > &v, DiracSpinor Fa)
 
bool operator== (const DiracSpinor &lhs, const DiracSpinor &rhs)
 Comparitor overloads (compares n, then kappa):
 
bool operator!= (const DiracSpinor &lhs, const DiracSpinor &rhs)
 
bool operator< (const DiracSpinor &lhs, const DiracSpinor &rhs)
 
bool operator> (const DiracSpinor &lhs, const DiracSpinor &rhs)
 
bool operator<= (const DiracSpinor &lhs, const DiracSpinor &rhs)
 
bool operator>= (const DiracSpinor &lhs, const DiracSpinor &rhs)
 
std::ostream & operator<< (std::ostream &ostr, const DiracSpinor &Fa)
 Writes short symbol to ostream.
 

Constructor & Destructor Documentation

◆ DiracSpinor()

DiracSpinor::DiracSpinor ( int  in_n,
int  in_kappa,
std::shared_ptr< const Grid in_rgrid 
)

Constructor: Requires n (PQN), kappa (Dirac QN), and grid (shared pointer, as it's a shared resource)

Member Function Documentation

◆ n()

int DiracSpinor::n ( ) const
inline

Principal quantum number, n.

◆ kappa()

int DiracSpinor::kappa ( ) const
inline

Dirac quantum number, kappa.

◆ l()

int DiracSpinor::l ( ) const
inline

Orbital angular momentum Q number.

◆ jjp1()

double DiracSpinor::jjp1 ( ) const
inline

j(j+1)

◆ twojp1()

int DiracSpinor::twojp1 ( ) const
inline

2j+1

◆ parity()

int DiracSpinor::parity ( ) const
inline

(-1)^l, returns +/- 1

◆ k_index()

std::size_t DiracSpinor::k_index ( ) const
inline

kappa index (see AtomData)

◆ nk_index()

Index DiracSpinor::nk_index ( ) const
inline

(n,kappa) index (see AtomData)

◆ symbol()

std::string DiracSpinor::symbol ( bool  gnuplot = false) const

Single-electron term symbol (e.g., 6s_1/2). Gnuplot=true => 6s_{1/2}.

◆ shortSymbol() [1/2]

std::string DiracSpinor::shortSymbol ( ) const

e.g., 6p_1/2 => 6p-, 6p_3/2 => 6p+

◆ exotic() [1/2]

bool & DiracSpinor::exotic ( )
inline

Checks if spinor is for "exotic" lepton, or regular electron.

◆ exotic() [2/2]

bool DiracSpinor::exotic ( ) const
inline

Checks if spinor is for "exotic" lepton, or regular electron.

◆ negativeEnergyStateQ()

bool DiracSpinor::negativeEnergyStateQ ( ) const

NOTE: Only works for regular alpha, and m=1 - shuold fix.

◆ set_new_kappa()

void DiracSpinor::set_new_kappa ( int  new_kappa)

Changes 'kappa' angular quantum number. Use with caution!

◆ grid()

const Grid & DiracSpinor::grid ( ) const
inline

Resturns a const reference to the radial grid.

◆ grid_sptr()

std::shared_ptr< const Grid > DiracSpinor::grid_sptr ( ) const
inline

Resturns copy of shared_ptr to grid [shared resource] - used when we want to construct a new DiracSpinor that shares this grid.

◆ en()

double DiracSpinor::en ( ) const
inline

Single-particle energy, not including rest energy.

◆ f() [1/2]

const std::vector< double > & DiracSpinor::f ( ) const
inline

Upper (large) radial component function, f.

◆ f() [2/2]

double DiracSpinor::f ( std::size_t  i) const
inline

Upper (large) radial component, f(r_i)

◆ g() [1/2]

const std::vector< double > & DiracSpinor::g ( ) const
inline

Lower (small) radial component function, g.

◆ g() [2/2]

double DiracSpinor::g ( std::size_t  i) const
inline

Lower (small) radial component, g(r_i)

◆ min_pt()

auto DiracSpinor::min_pt ( ) const
inline

First non-zero point (index for f[i])

◆ max_pt()

auto DiracSpinor::max_pt ( ) const
inline

Effective size(); index after last non-zero point (index for f[i])

◆ r0()

double DiracSpinor::r0 ( ) const

r0 = r[min_pt] (in atomic units) XXX Kill this?

◆ rinf()

double DiracSpinor::rinf ( ) const

rinf = r[max_pt]

◆ its()

auto DiracSpinor::its ( ) const
inline

Number of iterations until energy convergence (for latest routine only)

◆ occ_frac()

auto DiracSpinor::occ_frac ( ) const
inline

Occupation fraction. =1 for closed shells. =1/(2j+1) for valence.

◆ eps()

auto DiracSpinor::eps ( ) const
inline

Fractional energy convergence: eps = |(en'-en)/en|.

◆ scale() [1/2]

const DiracSpinor & DiracSpinor::scale ( const double  factor)

Scales DiracSpinor (f and g) by constant.

◆ scale() [2/2]

const DiracSpinor & DiracSpinor::scale ( const std::vector< double > &  v)

Scales DiracSpinor (f and g) by function of r.

◆ normalise()

void DiracSpinor::normalise ( double  norm_to = 1.0)

By default normalises to 1, but can normalise to other number.

◆ zero_boundaries()

void DiracSpinor::zero_boundaries ( )

Forces f(r) and g(r) to be zero outside of [p0,pinf)

◆ norm()

double DiracSpinor::norm ( ) const

Returns the norm, defined: Norm = Sqrt[<a|a>].

◆ norm2()

double DiracSpinor::norm2 ( ) const

Returns the norm^2, defined: Norm2 = <a|a>

◆ r0pinfratio()

std::pair< double, double > DiracSpinor::r0pinfratio ( ) const

Returns [f[p0]/f_max , f[pinf]/f_max] - for tests.

◆ rho()

std::vector< double > DiracSpinor::rho ( ) const

rho(r) = sum_m |Psi^2|(r) = (2j+1) * x_occ * |F^2|(r)

◆ num_electrons()

int DiracSpinor::num_electrons ( ) const

Number of occupied electrons: (2j+1)*occ_frac.

◆ operator+=()

DiracSpinor & DiracSpinor::operator+= ( const DiracSpinor rhs)

Addition of two DiracSpinors - must have same kappa.

◆ operator*=() [1/2]

DiracSpinor & DiracSpinor::operator*= ( const double  x)

Scalar multiplication.

◆ operator*=() [2/2]

DiracSpinor & DiracSpinor::operator*= ( const std::vector< double > &  v)

Multiplication by array (function)

◆ comp_l()

static bool DiracSpinor::comp_l ( const DiracSpinor lhs,
const DiracSpinor rhs 
)
inlinestatic

Custom comparitors (for sorting): l, j, kappa_index, energy.

◆ check_ortho()

std::pair< double, std::string > DiracSpinor::check_ortho ( const std::vector< DiracSpinor > &  a,
const std::vector< DiracSpinor > &  b 
)
static

Returns worst |<a|b>| (or |<a|b>-1| for a=b) {val, state_names}.

◆ orthonormaliseOrbitals()

void DiracSpinor::orthonormaliseOrbitals ( std::vector< DiracSpinor > &  orbs,
int  num_its = 1 
)
static

(approximately) OrthoNormalises a set of any orbitals.

Note: only updates orbs, not energies

◆ orthogonaliseWrt()

DiracSpinor DiracSpinor::orthogonaliseWrt ( const DiracSpinor Fin,
const std::vector< DiracSpinor > &  orbs 
)
static

Forces Fin to be orthogonal to orbs. If Fn (i.e., {n,k}) in in orbs, replaces Fin with that from orbs.

◆ orthonormaliseWrt()

DiracSpinor DiracSpinor::orthonormaliseWrt ( const DiracSpinor Fin,
const std::vector< DiracSpinor > &  orbs 
)
static

As orthogonaliseWrt(), but normalises Fin afterwards.

◆ orthog()

void DiracSpinor::orthog ( const DiracSpinor rhs)

A more correct way to force orthogonality than normal.

◆ shortSymbol() [2/2]

std::string DiracSpinor::shortSymbol ( int  n,
int  kappa 
)
static

e.g., 6p_1/2 => 6p-, 6p_3/2 => 6p+

◆ state_config()

std::string DiracSpinor::state_config ( const std::vector< DiracSpinor > &  orbs)
static

Returns formatted states string (e.g., '7sp5d') given list of orbs.

◆ exactHlike()

DiracSpinor DiracSpinor::exactHlike ( int  n,
int  k,
std::shared_ptr< const Grid rgrid,
double  zeff,
double  alpha = 0.0,
double  mass = 1.0 
)
static

Constructs H-like (pointlike) DiracSpinor - mainly for testing.

◆ HlikeBasis() [1/2]

std::vector< DiracSpinor > DiracSpinor::HlikeBasis ( int  max_l,
int  num_ns,
std::shared_ptr< const Grid rgrid,
double  zeff,
double  alpha = 0.0,
double  mass = 1.0 
)
static

Constructs a basis of H-like (pointlike) DiracSpinors - mainly for testing.

Parameters
max_l= maxiumum l (both kappas calculated)
num_ns= number of principle quantum numbers per l (not max n)
mass= lepton mass in units of m_e (default 1 = electron)

◆ HlikeBasis() [2/2]

std::vector< DiracSpinor > DiracSpinor::HlikeBasis ( const std::string &  basis_string,
std::shared_ptr< const Grid rgrid,
double  zeff,
double  alpha = 0.0,
double  mass = 1.0 
)
static

Constructs a basis of H-like (pointlike) DiracSpinors - mainly for testing.

Parameters
basis_string= e.g., "6sp5d": max n for each kappa; all n down to n_min = l+1 are included
mass= lepton mass in units of m_e (default 1 = electron)

◆ find()

const DiracSpinor * DiracSpinor::find ( int  n,
int  k,
const std::vector< DiracSpinor > &  orbs 
)
static

Searches for {n,k} in list of orbitals, returns pointer (may be null)

◆ max_tj()

int DiracSpinor::max_tj ( const std::vector< DiracSpinor > &  orbs)
static

Returns maximum (2j) found in {orbs}.

◆ max_l()

int DiracSpinor::max_l ( const std::vector< DiracSpinor > &  orbs)
static

Returns maximum l found in {orbs}.

◆ max_n() [1/2]

int DiracSpinor::max_n ( const std::vector< DiracSpinor > &  orbs)
static

Returns maximum n found in {orbs}.

◆ max_n() [2/2]

int DiracSpinor::max_n ( const std::vector< DiracSpinor > &  orbs,
int  kappa 
)
static

Returns maximum n found in {orbs}, for given kappa.

◆ max_kindex()

std::size_t DiracSpinor::max_kindex ( const std::vector< DiracSpinor > &  orbs)
static

Returns maximum kappa_index found in {orbs}.

◆ max_En()

double DiracSpinor::max_En ( const std::vector< DiracSpinor > &  orbs)
static

Returns maximum Energy found in {orbs}.

◆ min_En()

double DiracSpinor::min_En ( const std::vector< DiracSpinor > &  orbs)
static

Returns maximum Energy found in {orbs}.

◆ split_by_energy()

std::pair< std::vector< DiracSpinor >, std::vector< DiracSpinor > > DiracSpinor::split_by_energy ( const std::vector< DiracSpinor > &  orbitals,
double  Fermi_energy,
int  n_min_core = 1,
int  n_max_excited = 9999,
bool  positrons_are_excited = true 
)
static

Splits orbitals into two groups (i.e., core, excited) by energy.

  • The first group contains orbitals with energy < energy
  • The second group contains orbitals with energy > energy
  • The first group is also limited to have n >= n_min_core (i.e., exclude deep core states)

◆ split_by_core()

std::pair< std::vector< DiracSpinor >, std::vector< DiracSpinor > > DiracSpinor::split_by_core ( const std::vector< DiracSpinor > &  orbitals,
const std::vector< DiracSpinor > &  core,
int  n_min_core = 1 
)
static

Splits orbitals into two groups (i.e., core, excited).

  • The first group contains orbitals with {n,kappa} in the given "core"
  • The second group contains all of the rest
  • The first group is also limited to have n >= n_min_core (i.e., exclude deep core states)

◆ subset()

std::vector< DiracSpinor > DiracSpinor::subset ( const std::vector< DiracSpinor > &  basis,
const std::string &  subset_string,
bool  exclude_negative_energy = true 
)
static

Takes a subset of an input basis (by copy), according to subset_string.

  • Includes only states matching the subset_string

Friends And Related Symbol Documentation

◆ operator*

double operator* ( const DiracSpinor Fa,
const DiracSpinor Fb 
)
friend

Returns radial integral (Fa,Fb) = Int(fa*fb + ga*gb)

◆ operator==

bool operator== ( const DiracSpinor lhs,
const DiracSpinor rhs 
)
friend

Comparitor overloads (compares n, then kappa):

◆ operator<<

std::ostream & operator<< ( std::ostream &  ostr,
const DiracSpinor Fa 
)
friend

Writes short symbol to ostream.


The documentation for this class was generated from the following files: