ampsci
High-precision calculations for one- and two-valence atomic systems
Grid

ok

Non-uniform radial grid with Jacobian, suitable for atomic structure calculations.

Defines a mapping from a uniform grid u = {0, du, 2du, ...} to a non-uniform grid r(u), along with the Jacobian dr/du and the convenience quantity (1/r)(dr/du).

Three grid types are supported (see GridType):

  • loglinear (default): logarithmic at small r, linear at large r; controlled by the turning point b.
  • logarithmic: r = r0 * exp(u); good for tightly bound states.
  • linear: uniform spacing in r.

Grid points and Jacobians are stored as std::vector<double> and can be iterated over directly (const iterators only).

#include <Grid.hpp>

Public Member Functions

 Grid (double in_r0, double in_rmax, std::size_t in_num_points, GridType in_gridtype, double in_b=0)
 Construct grid directly from parameters.
 
 Grid (const GridParameters &in)
 Construct grid from a GridParameters struct.
 
auto r0 () const
 Minimum (first) grid point r[0].
 
auto front () const
 Minimum (first) grid point r[0]; alias for r0()
 
auto rmax () const
 Maximum (last) grid point r[N-1].
 
auto back () const
 Maximum (last) grid point r[N-1]; alias for rmax()
 
auto num_points () const
 Number of grid points.
 
auto size () const
 Number of grid points; alias for num_points()
 
auto du () const
 Uniform step size du.
 
auto type () const
 Grid type (loglinear, logarithmic, or linear)
 
auto loglin_b () const
 Log-linear turning point b: roughly logarithmic for r<b, linear for r>b.
 
const std::vector< double > & r () const
 Full grid vector r.
 
auto r (std::size_t i) const
 Grid point r[i], with range checking.
 
auto at (std::size_t i) const
 Grid point r[i], with range checking; alias for r(i)
 
auto operator() (std::size_t i) const
 Grid point r[i], with range checking; alias for r(i)
 
const std::vector< double > & drdu () const
 Full Jacobian vector dr/du.
 
auto drdu (std::size_t i) const
 Jacobian (dr/du)[i], with range checking.
 
const std::vector< double > & drduor () const
 Full vector of (1/r)(dr/du)
 
auto drduor (std::size_t i) const
 (1/r)(dr/du)[i], with range checking
 
std::size_t getIndex (double x, bool require_nearest=false) const
 Returns the grid index closest to x. If require_nearest is false, returns the index of the largest grid point x.
 
std::string gridParameters () const
 Returns a human-readable string of grid parameters.
 
std::vector< double > rpow (double k) const
 Returns a vector of r^k for each grid point.
 
auto begin () const
 Const iterator to first grid point.
 
auto end () const
 Const iterator past last grid point.
 
auto cbegin () const
 Const iterator to first grid point.
 
auto cend () const
 Const iterator past last grid point.
 
auto rbegin () const
 Const reverse iterator to last grid point.
 
auto rend () const
 Const reverse iterator before first grid point.
 
auto crbegin () const
 Const reverse iterator to last grid point.
 
auto crend () const
 Const reverse iterator before first grid point.
 
void extend_to (double new_rmax)
 Extends the grid to at least new_rmax.
 
GridParameters params () const
 Returns a GridParameters struct that can be used to reconstruct this grid.
 

Static Public Member Functions

static double calc_du_from_num_points (double in_r0, double in_rmax, std::size_t in_num_points, GridType in_gridtype, double in_b=0)
 Given r0, rmax, and num_points, calculates the uniform step size du.
 
static std::size_t calc_num_points_from_du (double in_r0, double in_rmax, double in_du, GridType in_gridtype, double in_b=0)
 Given r0, rmax, and du, calculates the number of grid points.
 

Constructor & Destructor Documentation

◆ Grid() [1/2]

Grid::Grid ( double  in_r0,
double  in_rmax,
std::size_t  in_num_points,
GridType  in_gridtype,
double  in_b = 0 
)

Construct grid directly from parameters.

◆ Grid() [2/2]

Grid::Grid ( const GridParameters in)

Construct grid from a GridParameters struct.

Member Function Documentation

◆ r0()

auto Grid::r0 ( ) const
inline

Minimum (first) grid point r[0].

◆ front()

auto Grid::front ( ) const
inline

Minimum (first) grid point r[0]; alias for r0()

◆ rmax()

auto Grid::rmax ( ) const
inline

Maximum (last) grid point r[N-1].

◆ back()

auto Grid::back ( ) const
inline

Maximum (last) grid point r[N-1]; alias for rmax()

◆ num_points()

auto Grid::num_points ( ) const
inline

Number of grid points.

◆ size()

auto Grid::size ( ) const
inline

Number of grid points; alias for num_points()

◆ du()

auto Grid::du ( ) const
inline

Uniform step size du.

◆ type()

auto Grid::type ( ) const
inline

Grid type (loglinear, logarithmic, or linear)

◆ loglin_b()

auto Grid::loglin_b ( ) const
inline

Log-linear turning point b: roughly logarithmic for r<b, linear for r>b.

◆ r() [1/2]

const std::vector< double > & Grid::r ( ) const
inline

Full grid vector r.

◆ r() [2/2]

auto Grid::r ( std::size_t  i) const
inline

Grid point r[i], with range checking.

◆ at()

auto Grid::at ( std::size_t  i) const
inline

Grid point r[i], with range checking; alias for r(i)

◆ operator()()

auto Grid::operator() ( std::size_t  i) const
inline

Grid point r[i], with range checking; alias for r(i)

◆ drdu() [1/2]

const std::vector< double > & Grid::drdu ( ) const
inline

Full Jacobian vector dr/du.

◆ drdu() [2/2]

auto Grid::drdu ( std::size_t  i) const
inline

Jacobian (dr/du)[i], with range checking.

◆ drduor() [1/2]

const std::vector< double > & Grid::drduor ( ) const
inline

Full vector of (1/r)(dr/du)

◆ drduor() [2/2]

auto Grid::drduor ( std::size_t  i) const
inline

(1/r)(dr/du)[i], with range checking

◆ getIndex()

std::size_t Grid::getIndex ( double  x,
bool  require_nearest = false 
) const

Returns the grid index closest to x. If require_nearest is false, returns the index of the largest grid point x.

◆ gridParameters()

std::string Grid::gridParameters ( ) const

Returns a human-readable string of grid parameters.

◆ rpow()

std::vector< double > Grid::rpow ( double  k) const

Returns a vector of r^k for each grid point.

◆ begin()

auto Grid::begin ( ) const
inline

Const iterator to first grid point.

◆ end()

auto Grid::end ( ) const
inline

Const iterator past last grid point.

◆ cbegin()

auto Grid::cbegin ( ) const
inline

Const iterator to first grid point.

◆ cend()

auto Grid::cend ( ) const
inline

Const iterator past last grid point.

◆ rbegin()

auto Grid::rbegin ( ) const
inline

Const reverse iterator to last grid point.

◆ rend()

auto Grid::rend ( ) const
inline

Const reverse iterator before first grid point.

◆ crbegin()

auto Grid::crbegin ( ) const
inline

Const reverse iterator to last grid point.

◆ crend()

auto Grid::crend ( ) const
inline

Const reverse iterator before first grid point.

◆ extend_to()

void Grid::extend_to ( double  new_rmax)

Extends the grid to at least new_rmax.

This is the only mutating function; use with caution. The extended grid is not guaranteed to end exactly at new_rmax it will typically extend slightly beyond, as new points must land on the existing uniform u grid.

◆ params()

GridParameters Grid::params ( ) const
inline

Returns a GridParameters struct that can be used to reconstruct this grid.

◆ calc_du_from_num_points()

double Grid::calc_du_from_num_points ( double  in_r0,
double  in_rmax,
std::size_t  in_num_points,
GridType  in_gridtype,
double  in_b = 0 
)
static

Given r0, rmax, and num_points, calculates the uniform step size du.

◆ calc_num_points_from_du()

std::size_t Grid::calc_num_points_from_du ( double  in_r0,
double  in_rmax,
double  in_du,
GridType  in_gridtype,
double  in_b = 0 
)
static

Given r0, rmax, and du, calculates the number of grid points.


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