3.4.16. horton/grid/rtransform.h – Transformation from uniform 1D to non-uniform 1D grids

class RTransform
#include <rtransform.h>

Transformation of radial grid used for integration in spherical coordinates.

Some conventions

  • radius or r are the transformed values, a function of t.
  • t is used for the original grid

Public Functions

RTransform(int npoint)

Create an RTransform object.

Parameters
  • npoint -

    The number of points on the radial grid.

virtual ~RTransform()

Destructor.

virtual double radius(double t) = 0

Compute the radius for a given t. (Forward transformation.)

Parameters
  • t -

    The value on the untransformed grid.

virtual double deriv(double t) = 0

Compute the derivative of the radius w.r.t. t.

Parameters
  • t -

    The value on the untransformed grid.

virtual double deriv2(double t) = 0

Compute the second derivative of the radius w.r.t. t.

Parameters
  • t -

    The value on the untransformed grid.

virtual double deriv3(double t) = 0

Compute the third derivative of the radius w.r.t. t.

Parameters
  • t -

    The value on the untransformed grid.

virtual double inv(double r) = 0

Compute t for a given radius. (Reverse transform.)

Parameters
  • r -

    The value on the transformed grid.

void radius_array(double *t, double *r, int n)

Compute the radii for a given array of t values. (Forward transformation.)

Parameters
  • t -

    The array with values on the untransformed grid.

  • r -

    The output array with radii.

  • n -

    The number of elements in the array.

void deriv_array(double *t, double *d, int n)

Compute derivatives of the radius for a given array of t values.

Parameters
  • t -

    The array with values on the untransformed grid.

  • d -

    The output array with (d r)/(d t).

  • n -

    The number of elements in the array.

void deriv2_array(double *t, double *d, int n)

Compute second derivatives of the radius for a given array of t values.

Parameters
  • t -

    The array with values on the untransformed grid.

  • d -

    The output array with (d^2 r)/(d t^2).

  • n -

    The number of elements in the array.

void deriv3_array(double *t, double *d, int n)

Compute third derivatives of the radius for a given array of t values.

Parameters
  • t -

    The array with values on the untransformed grid.

  • d -

    The output array with (d^3 r)/(d t^3).

  • n -

    The number of elements in the array.

void inv_array(double *r, double *t, int n)

Compute the t values for a given array radii. (Reverse transformation.)

Parameters
  • r -

    The array with radii.

  • t -

    The output array with values on the untransformed grid.

  • n -

    The number of elements in the array.

int get_npoint()

The number of grid points .

Protected Attributes

int npoint

The number of grid points.

class IdentityRTransform
#include <rtransform.h>

Identity transformation, mostly used for debugging. r(t) = t.

Public Functions

IdentityRTransform(int npoint)

Create an IdentityRTransform object.

Parameters
  • npoint -

    The number of points on the radial grid.

virtual double radius(double t)

Forward transformation.

virtual double deriv(double t)

(d r)/(d t)

virtual double deriv2(double t)

(d^2 r)/(d t^2)

virtual double deriv3(double t)

(d^3 r)/(d t^3)

virtual double inv(double r)

Reverse transformation.

class LinearRTransform
#include <rtransform.h>

Linear transformation. r(t) = rmin + t*(rmax - rmin)/(npoint - 1)

Public Functions

LinearRTransform(double rmin, double rmax, int npoint)

Create an LinearRTransform object.

Parameters
  • rmin -

    First radius

  • rmax -

    Last radius

  • npoint -

    The number of points on the radial grid.

virtual double radius(double t)

Forward transformation.

virtual double deriv(double t)

(d r)/(d t)

virtual double deriv2(double t)

(d^2 r)/(d t^2)

virtual double deriv3(double t)

(d^3 r)/(d t^3)

virtual double inv(double r)

Reverse transformation.

double get_rmin()

First radius.

double get_rmax()

Last radius.

double get_alpha()

Slope.

Private Members

double rmin

First radius.

double rmax

Last radius.

double alpha

Slope.

class ExpRTransform
#include <rtransform.h>

Exponential transformation. r(t) = rmin*exp(t*log(rmax/rmin)/(npoint - 1))

Public Functions

ExpRTransform(double rmin, double rmax, int npoint)

Create an ExpRTransform object.

Parameters
  • rmin -

    First radius

  • rmax -

    Last radius

  • npoint -

    The number of points on the radial grid.

virtual double radius(double t)

Forward transformation.

virtual double deriv(double t)

(d r)/(d t)

virtual double deriv2(double t)

(d^2 r)/(d t^2)

virtual double deriv3(double t)

(d^3 r)/(d t^3)

virtual double inv(double r)

Reverse transformation.

double get_rmin()

First radius.

double get_rmax()

Last radius.

double get_alpha()

Exponent.

Private Members

double rmin

First radius.

double rmax

Last radius.

double alpha

Exponent.

class PowerRTransform
#include <rtransform.h>

Power transformation. r(t) = rmin*t^power with power = log(rmax/rmin)/log(npoint)

Public Functions

PowerRTransform(double rmin, double rmax, int npoint)

Create a PowerRTransform object.

Parameters
  • rmin -

    First radius

  • rmax -

    Last radius

  • npoint -

    The number of points on the radial grid.

virtual double radius(double t)

Forward transformation.

virtual double deriv(double t)

(d r)/(d t)

virtual double deriv2(double t)

(d^2 r)/(d t^2)

virtual double deriv3(double t)

(d^3 r)/(d t^3)

virtual double inv(double r)

Reverse transformation.

double get_rmin()

First radius.

double get_rmax()

Last radius.

double get_power()

The power of t.

Private Members

double rmin

First radius.

double rmax

Last radius.

double power

The power of t.

class HyperbolicRTransform
#include <rtransform.h>

Hyperbolic transformation. r(t) = a*t/(1 - b*t)

Public Functions

HyperbolicRTransform(double a, double b, int npoint)

Create a HyperbolicRTransform object.

Parameters
  • a -

    Prefactor in r(t).

  • b -

    Parameter in denominator of r(t).

  • npoint -

    The number of points on the radial grid.

virtual double radius(double t)

Forward transformation.

virtual double deriv(double t)

(d r)/(d t)

virtual double deriv2(double t)

(d^2 r)/(d t^2)

virtual double deriv3(double t)

(d^3 r)/(d t^3)

virtual double inv(double r)

Reverse transformation.

double get_a()

Prefactor in r(t)

double get_b()

Parameter in denominator of r(t)

Private Members

double a

Prefactor in r(t)

double b

Parameter in denominator of r(t)