grid.rtransform module

Contents

grid.rtransform module#

Transformation from 1D intervals [a, b] to other 1D intervals [c, d].

class grid.rtransform.BaseTransform#

Bases: ABC

Abstract class for transformation.

property codomain#

tuple: Transformation codomain.

abstract deriv(x)#

Abstract method for 1st derivative of transformation.

abstract deriv2(x)#

Abstract method for the second derivative of transformation.

abstract deriv3(x)#

Abstract method for the third derivative of transformation.

property domain#

tuple: Transformation domain.

abstract inverse(r)#

Abstract method for inverse transformation.

abstract transform(x)#

Abstract method for transformation.

transform_1d_grid(oned_grid)#

Generate a new integral grid by transforming the provided grid.

\[\begin{split}\int^{\inf}_0 g(r) d r &= \int^{r(\infty)}_{r(0)} g(r(x)) \frac{dr}{dx} dx \\ &= \int^{r(\infty)}_{r(0)} g(r(x)) \frac{dr}{dx} dx \\ &\approx \sum_{i=1}^N g(r(x_i)) \frac{dr}{dx}(x_i) w_i \\ &\approx \sum_{i=1}^N g(r(x_i)) \frac{dr}{dx}(x_i) w^r_n \\ w^r_n &= w^x_n \cdot \frac{dr}{dx}\end{split}\]

Parameters#

oned_gridOneDGrid

An instance of one-dimensional grid.

Returns#

OneDGrid

Transformed one-dimensional grid spanning a different domain.

class grid.rtransform.BeckeRTransform(rmin: float, R: float, trim_inf: bool = True)#

Bases: BaseTransform

Becke Transformation.

The Becke transformation transforms from \([-1, 1]\) to \([r_{min}, \infty)\) according to [1]

\[r(x) = R \frac{1 + x}{1 - x} + r_{min}.\]

The inverse transformation is given by

\[x(r) = \frac{r - r_{min} - R} {r - r_{min} + R}.\]

References#

property R#

float: the scale factor for the transformed array.

deriv(x: ndarray)#

Compute the first derivative of Becke transformation.

\[\frac{dr_i}{dx_i} = 2R \frac{1}{(1-x)^2}\]

Parameters#

xnp.array(N,)

One-dimensional array in the domain \([-1, 1]\).

Returns#

np.ndarray(N,)

First derivative of Becke transformation at each point.

deriv2(x: ndarray)#

Compute the second derivative of Becke transformation.

\[\frac{d^2r}{dx^2} = 4R \frac{1}{1-x^3}\]

Parameters#

xnp.array(N,)

One-dimensional array in the domain \([-1, 1]\).

Returns#

np.ndarray(N,)

Second derivative of Becke transformation at each point.

deriv3(x: ndarray)#

Compute the third derivative of Becke transformation.

\[\frac{d^3r}{dx^3} = 12R \frac{1}{1 - x^4}\]

Parameters#

xnp.array(N,)

One-dimensional array in the domain \([-1, 1]\).

Returns#

np.ndarray(N,)

Third derivative of Becke transformation at each point.

static find_parameter(array: ndarray, rmin: float, radius: float)#

Compute R such that half of the points in \([r_{min}, \infty)\) are within radius.

Parameters#

arraynp.ndarray(N,)

One-dimensional array in the domain \([-1, 1]\).

rminfloat

Minimum value for transformed array.

radiusfloat

Atomic radius of interest.

Returns#

float :

The optimal value of scale factor R.

inverse(r: ndarray)#

Transform \([r_{mi}n, \infty)\) back to original \([-1, 1]\).

\[x_i = \frac{r_i - r_{min} - R} {r_i - r_{min} + R}\]

Parameters#

rnp.ndarray(N,)

One-dimensional array in the codomain \([r_{min}, \infty)\).

Returns#

np.ndarray(N,)

One dimensional array in \([-1, 1]\).

property rmin#

float: the minimum value for the transformed array.

transform(x: ndarray)#

Transform from \([-1, 1]\) to \([r_{min}, \infty)\).

\[r_i = R \frac{1 + x_i}{1 - x_i} + r_{min}\]

Parameters#

xnp.ndarray(N,)

One-dimensional array in the domain \([-1, 1]\).

Returns#

np.ndarray(N,)

Transformed array located between \([r_min, \infty)\).

class grid.rtransform.ExpRTransform(rmin: float, rmax: float, b: float = None)#

Bases: BaseTransform

Exponential transform from \([0, \infty)\) to \([r_{min}, r_{max}]\).

This transformation is given by

\[r(x) = r_{min} e^{x \log\bigg(\frac{r_{max}}{r_{min} / b} \bigg)},\]
where \(b\) maps to rmax. If None, then the \(b\) is taken to be the maximum

from the first grid that is being transformed. This transformation always maps zero to \(r_{min}\).

The inverse transformation is given by

\[x(r) = \frac{\log\big(\frac{r}{r_{min}} \big) b}{\log(\frac{r_{max}}{r_{min}})}\]
property b#

float: Parameter \(b\) that maps/transforms to \(r_{max}\).

deriv(x: ndarray)#

Compute the first derivative of exponential transform.

Parameters#

xndarray(N,)

One-dimensional array in the domain of the transformation.

Return#

ndarray(N,)

First derivative of transformation at x.

deriv2(x: ndarray)#

Compute the second derivative of exponential transform.

Parameters#

xndarray(N,)

One-dimensional array in the domain of the transformation.

Return#

ndarray(N,)

Second derivative of transformation at x.

deriv3(x: ndarray)#

Compute the third derivative of exponential transform.

Parameters#

xndarray(N,)

One-dimensional array in the domain of the transformation.

Return#

ndarray(N,)

Third derivative of transformation at x.

inverse(r: ndarray)#

Compute the inverse of exponential transform.

\[x(r_i) = \frac{\log\big(\frac{r}{r_{min}} \big) b}{\log(\frac{r_{max}}{r_{min}})},\]

where \(b\) is a prespecified parameter

Parameters#

rndarray(N,)

One-dimensional array in the domain of the transformation.

Return#

ndarray(N,)

Inverse transformation at r.

property rmax#

float: the value of rmax.

property rmin#

float: the value of rmin.

set_maximum_parameter_b(x)#

Sets up the parameter b from taken the maximum over x.

transform(x: ndarray)#

Perform exponential transform.

\[r = r_{min} e^{x \log\bigg(\frac{r_{max}}{r_{min} / b} \bigg)},\]

where \(b\) is a prespecified parameter that maps to \(r_{max}\).

Parameters#

xndarray(N,)

One-dimensional array in the domain of the transformation.

Return#

ndarray(N,)

The transformation of x in the co-domain of the transformation.

class grid.rtransform.HandyModRTransform(rmin: float, rmax: float, m: int, trim_inf=True)#

Bases: BaseTransform

Modified Handy Transformation class from \([-1, 1]\) to \([r_{min}, r_{max}]\).

This transformation is given by

\[r(x) = \frac{(1+x)^m (r_{max} - r_{min})} { 2^m (1 - 2^m + r_{max} - r_{min}) - (1 + x)^m (r_{max} - r_{min} - 2^m )} + r_{min},\]

where \(m > 0\).

The inverse transformation is given by

\[x(r) = 2 \sqrt[m]{ \frac{(r - r_{min})(r_{max} - r_{min} - 2^m + 1)} {(r - r_{min})(r_{max} - r_{min} - 2^m) + r_{max} - r_{min}} } - 1.\]
deriv(x: ndarray)#

Compute the first derivative of modified Handy transformation.

\[\frac{dr}{dx} = -\frac{ 2^m m (r_{max}-r_{min})(2^m-r_{max}+r_{min}-1)(1+x)^{m-1}} {\left( 2^m (2^m-1-r_{max}+r_{min})-(2^m-r_{max} + r_{min})(1 + x)^m\right)^2}\]

Parameters#

x: ndarrray(N,)

One dimensional array in \([-1,1]\).

Returns#

ndarrray(N,)

The first derivative of Handy transformation at each point.

deriv2(x: ndarray)#

Compute the second derivative of modified Handy transformation.

Parameters#

x: ndarrray(N,)

One dimensional array in \([-1,1]\).

Returns#

ndarrray(N,)

The second derivative of Handy transformation at each point.

deriv3(x: ndarray)#

Compute the third derivative of modified Handy transformation.

Parameters#

x: ndarrray(N,)

One dimensional array in \([-1,1]\).

Returns#

ndarrray(N,)

The third derivative of Handy transformation at each point.

inverse(r: ndarray)#

Inverse transform from \([r_{min},r_{max}]\) to \([-1,1]\).

\[x_i = 2 \sqrt[m]{ \frac{(r_i - r_{min})(r_{max} - r_{min} - 2^m + 1)} {(r_i - r_{min})(r_{max} - r_{min} - 2^m) + r_{max} - r_{min}} } - 1\]

Parameters#

rndarrray(N,)

One dimensional array in \([r_{min},\infty)\).

Returns#

ndarrray(N,)

The original one dimensional array in \([-1,1]\).

property m#

integer: Free and extra parameter, m must be > 0.

property rmax#

float: The maximum value for the transformed radial array.

property rmin#

float: The minimum value for the transformed radial array.

transform(x: ndarray)#

Transform given array \([-1,1]\) to radial array \([r_{min},r_{max}]\).

\[r_i = \frac{(1+x_i)^m (r_{max} - r_{min})} { 2^m (1 - 2^m + r_{max} - r_{min}) - (1 + x_i)^m (r_{max} - r_{min} - 2^m )} + r_{min}\]

Parameters#

x: ndarray(N,)

One dimensional array in \([-1,1]\).

Returns#

ndarray(N,)

One dimensional array in \([r_{min},r_{max}]\).

class grid.rtransform.HandyRTransform(rmin: float, R: float, m: int, trim_inf=True)#

Bases: BaseTransform

Handy Transformation class from \([-1, 1]\) to \([r_{min}, \infty)\).

This transformation is given by

\[r(x) = R \left( \frac{1+x}{1-x} \right)^m + r_{min}.\]

The inverse transformations is given by

\[x(r) = \frac{\sqrt[m]{r-r_{min}} - \sqrt[m]{R}} {\sqrt[m]{r-r_{min}} + \sqrt[m]{R}}.\]
property R#

float: The scale factor for the transformed radial array.

deriv(x: ndarray)#

Compute the first derivative of Handy transformation.

\[\frac{dr}{dx} = 2mR \frac{(1+x)^{m-1}}{(1-x)^{m+1}}\]

Parameters#

x: ndarray(N,)

One dimensional array with values between \([-1,1]\).

Returns#

ndarray(N,)

The first derivative of Handy transformation at each point.

deriv2(x: ndarray)#

Compute the second derivative of Handy transformation.

\[\frac{d^2r}{dx^2} = 4mR (m + x) \frac{(1+x)^{m-2}}{(1-x)^{m+2}}\]

Parameters#

xndarray(N,)

One dimensional array in \([-1,1]\).

Returns#

ndarray(N,)

The second derivative of Handy transformation at each point.

deriv3(x: ndarray)#

Compute the third derivative of Handy transformation.

\[\frac{d^3r}{dx^3} = 4mR ( 1 + 6 m x + 2 m^2 + 3 x^2) \frac{(1+x)^{m-3}}{(1-x)^{m+3}}\]

Parameters#

array: np.ndarray(N,)

One dimensional array in \([-1,1]\).

Returns#

np.ndarray(N,)

The third derivative of Handy transformation at each point.

inverse(r: ndarray)#

Inverse transform from \([r_{min},\infty)\) to \([-1,1]\).

\[x_i = \frac{\sqrt[m]{r_i-r_{min}} - \sqrt[m]{R}} {\sqrt[m]{r_i-r_{min}} + \sqrt[m]{R}}\]

Parameters#

rnp.ndarray(N,)

One dimensional array in \([r_{min},\infty)\).

Returns#

np.ndarray(N,)

One-dimensional array in \([-1,1]\).

property m#

integer: Free and extra parameter, m must be > 0.

property rmin#

float: The minimum value for the transformed radial array.

transform(x: ndarray)#

Transform from \([-1,1]\) to \([r_{min},\infty)\).

\[r_i = R \left( \frac{1+x_i}{1-x_i} \right)^m + r_{min}\]

Parameters#

x: np.ndarray(N,)

One dimensional array in \([-1,1]\).

Returns#

np.ndarray(N,)

One dimensional array in \([r_{min},\infty)\).

class grid.rtransform.HyperbolicRTransform(a: float, b: float)#

Bases: BaseTransform

Hyperbolic transform from :math`[0, infty)` to \([0, \infty)\).

The transformation is given by

\[r(x) = \frac{a x}{(1 - bx)},\]

where \(b ( N - 1) \geq 1\), and \(N\) is the number of points in x.

The inverse transformation is given by

\[x(r) = \frac{r}{a + br}\]
property a#

float: value of parameter a.

property b#

float: value of parameter b.

deriv(x: ndarray)#

Compute the first derivative of hyperbolic transformation.

Parameters#

xndarray(N,)

One-dimensional array in the domain of the transformation \([0,\infty)\).

Return#

ndarray(N,)

First derivative of transformation at x.

deriv2(x: ndarray)#

Compute the second derivative of hyperbolic transformation.

Parameters#

xndarray(N,)

One-dimensional array in the domain of the transformation \([0,\infty)\).

Return#

ndarray(N,)

Second derivative of transformation at x.

deriv3(x: ndarray)#

Compute the third derivative of hyperbolic transformation.

Parameters#

xndarray(N,)

One-dimensional array in the domain of the transformation \([0,\infty)\).

Return#

ndarray(N,)

Third derivative of transformation at x.

inverse(r: ndarray)#

Compute the inverse of hyperbolic transformation.

\[x(r) = \frac{r}{a + br}\]

Parameters#

rndarray(N,)

One-dimensional array in the domain of the transformation \([0,\infty)\).

Return#

ndarray(N,)

Inverse transformation at r.

transform(x: ndarray)#

Perform hyperbolic transformation.

\[r_i = \frac{a x_i}{(1 - bx_i)},\]

where \(b ( N - 1) \geq 1\), and \(N\) is the number of points in x.

Parameters#

xndarray(N,)

One-dimensional array in the domain of the transformation \([0,\infty)\).

Return#

ndarray(N,)

The transformation of x to the co-domain of the transformation.

class grid.rtransform.IdentityRTransform#

Bases: BaseTransform

Identity Transform class.

The identity transform class trivially transforms from \([0, \infty)\) to \([0, \infty)\) given by

\[r(x) = x.\]

The inverse transformation is given by

\[x(r) = r.\]
deriv(x: ndarray)#

Compute the first derivative of identity transform.

Parameters#

xndarray(N,)

One dimension numpy array located in \([0, \infty)\).

Returns#

ndarray(N,)

First derivative of identity transformation at x.

deriv2(x: ndarray)#

Compute the second derivative of identity transform.

Parameters#

xndarray(N,)

One dimension numpy array located in \([0, \infty)\).

Returns#

ndarray(N,)

Second derivative of identity transformation at x.

deriv3(x: ndarray)#

Compute the third derivative of identity transform.

Parameters#

xndarray(N,)

One dimension numpy array located in \([0, \infty)\).

Returns#

np.ndarray(N,)

Third derivative of identity transformation at x.

inverse(r: ndarray)#

Compute the inverse of identity transform.

Parameters#

rndarray(N,)

One dimension numpy array located in \([0, \infty)\).

Returns#

np.ndarray(N,)

Inverse transformation of the identity transformation at x.

transform(x: ndarray)#

Perform given array into itself.

\[r_i = x_i\]

Parameters#

xndarray(N,)

One dimension numpy array located in \([0, \infty)\).

Returns#

ndarray(N,)

Identity transformation at each point x.

class grid.rtransform.InverseRTransform(transform: BaseTransform)#

Bases: BaseTransform

Inverse transformation class for any general transformation.

deriv(r: ndarray)#

Compute the first derivative of inverse transformation.

\[\frac{dx}{dr} = (\frac{dr}{dx})^{-1}\]

Parameters#

rnp.array(N,)

One-dimensional array in the co-domain r of the original transformation.

Returns#

np.ndarray(N,)

First derivative of the inverse transformation at each point r.

deriv2(r: ndarray)#

Compute the second derivative of inverse transformation.

\[\frac{d^2 x}{dr^2} = - \frac{d^2 r}{dx^2} (\frac{dx}{dr})^3\]

Parameters#

rnp.array(N,)

One-dimensional array in the co-domain r of the original transformation.

Returns#

np.ndarray(N,)

Second derivative of the inverse transformation at each point r.

deriv3(r: ndarray)#

Compute the third derivative of inverse transformation.

\[\frac{d^3 x}{dr^3} = -\frac{d^3 r}{dx^3} (\frac{dx}{dr})^4 + 3 (\frac{d^2 r}{dx^2})^2 (\frac{dx}{dr})^5\]

Parameters#

rnp.array(N,)

One-dimensional array in the co-domain r of the original transformation.

Returns#

np.ndarray(N,)

Third derivative of inverse transformation at each point r.

inverse(x: ndarray)#

Transform array to the co-domain of the provided transformation.

This transformation is equivalent to the transformation function of the original transformation (i.e. OriginTF.transform).

Parameters#

xnp.ndarray

One-dimension array in the domain x of the original transformation.

Returns#

np.ndarray

One-dimensional array in the co-domain r of the original transformation.

transform(r: ndarray)#

Transform array back to the original, domain of the provided transformation.

This transformation is equivalent to the inverse function of the original transformation (i.e. OriginTF.inverse).

Parameters#

rnp.ndarray(N,)

One-dimensional array in the co-domain r of the original transformation.

Returns#

np.ndarray(N,)

Original one-dimensional array in the domain x of the original transformation.

class grid.rtransform.KnowlesRTransform(rmin: float, R: float, k: int, trim_inf=True)#

Bases: BaseTransform

Knowles Transformation from \([-1, 1]\) to \([r_{min}, \infty)\).

The transformation is given by

\[r(x) = r_{min} - R \log \left( 1 - 2^{-k} (x + 1)^k \right),\]

where \(k > 0\) and \(R\) is the scaling parameter.

The inverse transformation is given by

\[x(r) = 2 \sqrt[k]{1-\exp \left( -\frac{r-r_{min}}{R}\right)}-1\]
property R#

float: The scale factor for the transformed radial array.

deriv(x: ndarray)#

Compute the first derivative of Knowles transformation.

\[\frac{dr}{dx} = kR \frac{(1+x_i)^{k-1}}{2^k-(1+x_i)^k}\]

Parameters#

x: ndarray(N,)

One dimensional array with values between \([-1,1]\).

Returns#

ndarray(N,)

The first derivative of Knowles transformation at each point.

deriv2(x: ndarray)#

Compute the second derivative of Knowles transformation.

\[\frac{d^2r}{dx^2} = kR \frac{(1+x_i)^{k-2} \left(2^k(k-1) + (1+x_i)^k \right)}{\left( 2^k-(1+x_i)^k\right)^2}\]

Parameters#

xndarray(N,)

One dimensional array in \([-1,1]\).

Returns#

ndarray(N,)

The second derivative of Knowles transformation at each point.

deriv3(x: ndarray)#

Compute the third derivative of Knowles transformation.

\[\frac{d^3r}{dx^3} = kR \frac{(1+x_i)^{k-3} \left( 4^k (k-1) (k-2) + 2^k (k-1)(k+4)(1+x_i)^k +2(1+x_i)^k \right)}{\left( 2^k - (1+x_i)^k \right)^3}\]

Parameters#

x: ndarray(N,)

One dimensional array with values between \([-1,1]\).

Returns#

ndarray(N,)

The third derivative of Knowles transformation at each point.

inverse(r: ndarray)#

Inverse of transformation from \([r_{min},\infty)\) to \([-1,1]\).

\[x_i = 2 \sqrt[k]{1-\exp \left( -\frac{r_i-r_{min}}{R}\right)}-1\]

Parameters#

r: ndarray(N,)

One-dimensional array in \([r_{min},\infty)\).

Returns#

ndarray(N,)

The inverse transformation in \([-1,1]\).

property k#

float: Free and extra parameter, k must be > 0.

property rmin#

float: The minimum value for the transformed radial array.

transform(x: ndarray)#

Transform from \([-1,1]\) to \([r_{min},\infty)\).

\[r_i = r_{min} - R \log \left( 1 - 2^{-k} (x_i + 1)^k \right)\]

Parameters#

x: np.ndarray(N,)

One dimensional array in \([-1,1]\).

Returns#

np.ndarray(N,)

One dimensional array in \([r_{min},\infty)\).

class grid.rtransform.LinearFiniteRTransform(rmin: float, rmax: float)#

Bases: BaseTransform

Linear finite transformation from \([-1, 1]\) to \([r_{min}, r_{max}]\).

The Linear transformation from finite interval \([-1, 1]\) to finite interval \([r_{min}, r_{max}]\) is given by

\[r(x) = \frac{r_{max} - r_{min}}{2} (1 + x) + r_{min}.\]

The inverse transformation is given by

\[x(r) = \frac{2 r - (r_{max} + r_{min})}{r_{max} - r_{min}}\]
deriv(x: ndarray)#

Compute the 1st order derivative.

\[\frac{dr}{dx} = \frac{r_{max} - r_{min}}{2}\]

Parameters#

xndarray

One-dimensional array in the domain \([-1, 1]\).

Returns#

float or np.ndarray

First order derivative at given points.

deriv2(x: ndarray)#

Compute the second order derivative.

\[\frac{d^2 r}{dx^2} = 0\]

Parameters#

xndarray

One-dimensional array in the domain \([-1, 1]\).

Returns#

float or np.ndarray

Second order derivative at given points.

deriv3(x: ndarray)#

Compute the third order derivative.

\[\frac{d^2 r}{dx^2} = 0\]

Parameters#

xndarray

One-dimensional array in the domain \([-1, 1]\).

Returns#

ndarray

Third order derivative at given points.

inverse(r: ndarray)#

Compute the inverse of the transformation.

\[x_i = \frac{2 r_i - (r_{max} + r_{min})}{r_{max} - r_{min}}\]

Parameters#

rndarray

One-dimensional array in the co-domain \([r_{min}, r_{max}]\).

Returns#

ndarray

One-dimensional array in the domain \([-1, 1]\).

transform(x: ndarray)#

Transform from interval \([-1, 1]\) to \([r_{min}, r_{max}]\).

\[r_i = \frac{r_{max} - r_{min}}{2} (1 + x_i) + r_{min}.\]

This transformation maps \(r_i(-1) = r_{min}\) and \(r_i(1) = r_{max}\).

Parameters#

xndarray

One-dimensional array in the domain \([-1, 1]\).

Returns#

float or np.ndarray

Transformed points between \([r_{min}, r_{max}]\)

class grid.rtransform.LinearInfiniteRTransform(rmin: float, rmax: float, b: float = None)#

Bases: BaseTransform

Linear transform from interval \([0, \infty)\) to \([r_{min}, r_{max})\).

This transformation linearly maps the infinite interval \([0, \infty)\) to a finite interval \([r_{min}, r_{max}]\) given by

\[r(x) = \frac{(r_{max} - r_{min})}{b} x + r_{min},\]

where \(r(b) = r_{max}\). If None, then the \(b\) is taken to be the maximum from the first grid that is being transformed. This transformation always maps zero to \(r_{min}\).

The original goal is to transform the UniformGrid, equally-spaced integers from 0 to N-1, to \([r_{min}, r_{max}]\).

The inverse is given by

\[x(r) = (r - r_{min}) \frac{\max_i (r_i)}{r_{max} - r_{min}}\]
property b#

float: Parameter such that \(r(b) = r_{max}\).

deriv(x: ndarray)#

Compute the first derivative of linear transformation.

Parameters#

xndarray(N,)

One-dimensional array in the domain \([0, \infty)\).

Returns#

ndarray(N,)

First derivative of transformation at x.

deriv2(x: ndarray)#

Compute the second derivative of linear transformation.

Parameters#

xndarray(N,)

One-dimensional array in the domain \([0, \infty)\).

Returns#

ndarray(N,)

Second derivative of transformation at x.

deriv3(x: ndarray)#

Compute the third derivative of linear transformation.

Parameters#

xndarray(N,)

One-dimensional array in the domain \([0, \infty)\).

Returns#

ndarray(N,)

Third derivative of transformation at x.

inverse(r: ndarray)#

Compute the inverse of linear transformation.

\[x_i = (r - r_{min}) / frac{b}{r_{max} - r_{min}}\]

Parameters#

rndarray(N,)

One-dimensional array in the domain \([r_{min}, r_{max}]\).

Returns#

ndarray(N,)

Inverse of transformation from coordinate \(r\) to \(x\).

property rmax#

float: rmax value of the tf.

property rmin#

float: rmin value of the tf.

set_maximum_parameter_b(x)#

Sets up the parameter b from taken the maximum over some grid x.

transform(x: ndarray)#

Transform from interval \([0, \infty)\) to \([r_{min}, r_{max}]\).

\[r_i = \frac{(r_{max} - r_{min})}{\max_i x_i} x_i + r_{min},\]

where \(N\) is the number of points. The goal is to transform equally-spaced integers from 0 to N-1, to \([r_{min}, r_{max}]\).

Parameters#

xndarray(N,)

One-dimensional array in the domain \([0, \infty)\).

Returns#

ndarray(N,)

Transformed points between \([r_{min}, r_{max}]\).

class grid.rtransform.MultiExpRTransform(rmin: float, R: float, trim_inf=True)#

Bases: BaseTransform

MultiExp Transformation class from \([-1,1]\) to \([r_{min}, \infty)\). [2]

The transformation is given by

\[r(x) = -R \log \left( \frac{x + 1}{2} \right) + r_{min}\]

The inverse of this transformation is given by

\[x(r) = 2 \exp \left( \frac{-(r - r_{min})}{R} \right) - 1\]

References#

property R#

float: The scale factor for the transformed radial array.

deriv(x: ndarray)#

Compute the first derivative of MultiExp transformation.

\[\frac{dr}{dx} = -\frac{R}{1+x}\]

Parameters#

xndarray(N,)

One dimensional in \([-1, 1]\).

Returns#

ndarray(N,)

The first derivative of MultiExp transformation at each point.

deriv2(x: ndarray)#

Compute the second derivative of MultiExp transformation.

\[\frac{d^2r}{dx^2} = \frac{R}{(1 + x)^2}\]

Parameters#

xndarray(N,)

One dimensional in \([-1,1]\).

Returns#

ndarray(N,)

The second derivative of MultiExp transformation at each point.

deriv3(x: ndarray)#

Compute the third derivative of MultiExp transformation.

\[\frac{d^3r}{dx^3} = -\frac{2R}{(1 + x)^3}\]

Parameters#

xndarray(N,)

One dimensional array in \([-1,1]\).

Returns#

ndarray(N,)

The third derivative of MultiExp transformation at each point.

inverse(r: ndarray)#

Inverse of transform from \([r_{min},\infty)\) to \([-1,1]\).

\[x_i = 2 \exp \left( \frac{-(r_i - r_{min})}{R} \right) - 1\]

Parameters#

rnp.ndarray(N,)

One-dimensional array in \([r_{min}, \infty)\).

Returns#

np.ndarray(N,)

The inverse of transformation in \([-1, 1]\).

property rmin#

float: The minimum value for the transformed radial array.

transform(x: ndarray)#

Transform from [-1,1] to \([r_{min},\infty)\).

\[r_i = -R \log \left( \frac{x_i + 1}{2} \right) + r_{min}\]

Parameters#

xndarray(N,)

One dimensional array with values between \([-1,1]\).

Returns#

ndarray(N,)

Transformed array located between \([r_{min},\infty)\).

class grid.rtransform.PowerRTransform(rmin: float, rmax: float, b: float = None)#

Bases: BaseTransform

Power transform class from \([0, \infty)\) to \([r_{min}, r_{max}]\).

This transformations is given by

\[r(x) = r_{min} (x + 1)^{\frac{\log(r_{max} - \log(r_{min}}{\log(b + 1)}},\]

such that \(r(b) = r_{max}\).

The inverse of the transformation is given by

\[x(r) = \frac{r}{r_{min}}^{\frac{\log(N)}{\log(r_{max}) - \log(r_{min})}} - 1.\]
property b#

float: Parameter \(b\) that maps/transforms to \(r_{max}\).

deriv(x: ndarray)#

Compute first derivative of power transform.

Parameters#

xndarray(N,)

One-dimensional array in the domain of the transformation \([0,\infty)\).

Return#

ndarray(N,)

First derivative of transformation at x.

deriv2(x: ndarray)#

Compute second derivative of power transform.

Parameters#

xndarray(N,)

One-dimensional array in the domain of the transformation \([0,\infty)\).

Return#

ndarray(N,)

Second derivative of transformation at x.

deriv3(x: ndarray)#

Compute third derivative of power transform.

Parameters#

xndarray(N,)

One-dimensional array in the domain of the transformation \([0,\infty)\).

Return#

ndarray(N,)

Third derivative of transformation at x.

inverse(r: ndarray)#

Compute the inverse of power transform.

\[x(r) = \frac{r}{r_{min}}^{\frac{\log(b + 1)}{\log(r_{max}) - \log(r_{min})}} - 1\]

such that \(r(b) = r_{max}\).

Parameters#

rndarray(N,)

One-dimensional array in the co-domain of the transformation.

Return#

ndarray(N,)

Inverse of transformation at r.

property rmax#

float: the value of rmax.

property rmin#

float: the value of rmin.

set_maximum_parameter_b(x)#

Sets up the parameter b from taken the maximum over x.

transform(x: ndarray)#

Perform power transform.

\[r = r_{min} (x + 1)^{\frac{\log(r_{max} - \log(r_{min}}{b + 1}},\]

such that \(r(b) = r_{max}\).

Parameters#

xndarray(N,)

One-dimensional array in the domain of the transformation \([0,\infty)\).

Return#

ndarray(N,)

The transformation of x to the co-domain of the transformation.