grid.rtransform module

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

class BaseTransform[source]

Bases: ABC

Abstract class for transformation.

__init__()
property codomain

Transformation codomain.

Type:

tuple

abstractmethod deriv(x)[source]

Abstract method for 1st derivative of transformation.

abstractmethod deriv2(x)[source]

Abstract method for the second derivative of transformation.

abstractmethod deriv3(x)[source]

Abstract method for the third derivative of transformation.

property domain

Transformation domain.

Type:

tuple

abstractmethod inverse(r)[source]

Abstract method for inverse transformation.

abstractmethod transform(x)[source]

Abstract method for transformation.

transform_1d_grid(oned_grid)[source]

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_grid (OneDGrid) – An instance of one-dimensional grid.

Returns:

Transformed one-dimensional grid spanning a different domain.

Return type:

OneDGrid

class BeckeRTransform(rmin, R, trim_inf=True)[source]

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

the scale factor for the transformed array.

Type:

float

__init__(rmin, R, trim_inf=True)[source]

Construct Becke transform, \([-1, 1]\) to :math`[r_{min}, infty)`.

Parameters:
  • rmin (float) – The minimum coordinate \(r_{min}\) in the transformed interval \([r_{min}, \infty)\).

  • R (float) – The scale factor used in the transformation.

  • trim_inf (bool, optional) – Flag to trim infinite value in transformed array. If True, it will replace np.inf with 1e16. This may cause unexpected errors in the following operations.

property codomain

Transformation codomain.

Type:

tuple

deriv(x)[source]

Compute the first derivative of Becke transformation.

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

x (np.array(N,)) – One-dimensional array in the domain \([-1, 1]\).

Returns:

First derivative of Becke transformation at each point.

Return type:

np.ndarray(N,)

deriv2(x)[source]

Compute the second derivative of Becke transformation.

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

x (np.array(N,)) – One-dimensional array in the domain \([-1, 1]\).

Returns:

Second derivative of Becke transformation at each point.

Return type:

np.ndarray(N,)

deriv3(x)[source]

Compute the third derivative of Becke transformation.

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

x (np.array(N,)) – One-dimensional array in the domain \([-1, 1]\).

Returns:

Third derivative of Becke transformation at each point.

Return type:

np.ndarray(N,)

property domain

Transformation domain.

Type:

tuple

static find_parameter(array, rmin, radius)[source]

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

Parameters:
  • array (np.ndarray(N,)) – One-dimensional array in the domain \([-1, 1]\).

  • rmin (float) – Minimum value for transformed array.

  • radius (float) – Atomic radius of interest.

Returns:

The optimal value of scale factor R.

Return type:

float

inverse(r)[source]

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

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

r (np.ndarray(N,)) – One-dimensional array in the codomain \([r_{min}, \infty)\).

Returns:

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

Return type:

np.ndarray(N,)

property rmin

the minimum value for the transformed array.

Type:

float

transform(x)[source]

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

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

x (np.ndarray(N,)) – One-dimensional array in the domain \([-1, 1]\).

Returns:

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

Return type:

np.ndarray(N,)

transform_1d_grid(oned_grid)[source]

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_grid (OneDGrid) – An instance of one-dimensional grid.

Returns:

Transformed one-dimensional grid spanning a different domain.

Return type:

OneDGrid

class ExpRTransform(rmin, rmax, b=None)[source]

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}})}\]
__init__(rmin, rmax, b=None)[source]

Initialize exp transform instance.

Parameters:
  • rmin (float) – Minimum value for transformed points.

  • rmax (float) – Maximum value for transformed points.

  • b (float) – Maximum \(b\) of a prespecified radial grid \([0, b]\) such that \(b\) maps to rmax. If None, then the maximum is taken and stored from the grid that is transformed initially.

property b

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

Type:

float

property codomain

Transformation codomain.

Type:

tuple

deriv(x)[source]

Compute the first derivative of exponential transform.

Parameters:

x (ndarray(N,)) – One-dimensional array in the domain of the transformation.

Returns:

First derivative of transformation at x.

Return type:

ndarray(N,)

deriv2(x)[source]

Compute the second derivative of exponential transform.

Parameters:

x (ndarray(N,)) – One-dimensional array in the domain of the transformation.

Returns:

Second derivative of transformation at x.

Return type:

ndarray(N,)

deriv3(x)[source]

Compute the third derivative of exponential transform.

Parameters:

x (ndarray(N,)) – One-dimensional array in the domain of the transformation.

Returns:

Third derivative of transformation at x.

Return type:

ndarray(N,)

property domain

Transformation domain.

Type:

tuple

inverse(r)[source]

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:

r (ndarray(N,)) – One-dimensional array in the domain of the transformation.

Returns:

Inverse transformation at r.

Return type:

ndarray(N,)

property rmax

the value of rmax.

Type:

float

property rmin

the value of rmin.

Type:

float

set_maximum_parameter_b(x)[source]

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

transform(x)[source]

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:

x (ndarray(N,)) – One-dimensional array in the domain of the transformation.

Returns:

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

Return type:

ndarray(N,)

transform_1d_grid(oned_grid)[source]

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_grid (OneDGrid) – An instance of one-dimensional grid.

Returns:

Transformed one-dimensional grid spanning a different domain.

Return type:

OneDGrid

class HandyModRTransform(rmin, rmax, m, trim_inf=True)[source]

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.\]
__init__(rmin, rmax, m, trim_inf=True)[source]

Construct a modified Handy transform from \([-1, 1]\) to \([r_{min}, r_{max}]\).

Parameters:
  • rmin (float) – The minimum coordinate for transformed radial array.

  • rmax (float) – The maximum coordinate for transformed radial array.

  • m (integer m > 0) – Free parameter, m must be > 0.

  • trim_inf (bool, optional) – Flag to trim infinite value in transformed array. If True, it will replace np.inf with 1e16. This may cause unexpected errors in the following operations.

property codomain

Transformation codomain.

Type:

tuple

deriv(x)[source]

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:

The first derivative of Handy transformation at each point.

Return type:

ndarrray(N,)

deriv2(x)[source]

Compute the second derivative of modified Handy transformation.

Parameters:

x (ndarrray(N,)) – One dimensional array in \([-1,1]\).

Returns:

The second derivative of Handy transformation at each point.

Return type:

ndarrray(N,)

deriv3(x)[source]

Compute the third derivative of modified Handy transformation.

Parameters:

x (ndarrray(N,)) – One dimensional array in \([-1,1]\).

Returns:

The third derivative of Handy transformation at each point.

Return type:

ndarrray(N,)

property domain

Transformation domain.

Type:

tuple

inverse(r)[source]

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:

r (ndarrray(N,)) – One dimensional array in \([r_{min},\infty)\).

Returns:

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

Return type:

ndarrray(N,)

property m

Free and extra parameter, m must be > 0.

Type:

integer

property rmax

The maximum value for the transformed radial array.

Type:

float

property rmin

The minimum value for the transformed radial array.

Type:

float

transform(x)[source]

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:

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

Return type:

ndarray(N,)

transform_1d_grid(oned_grid)[source]

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_grid (OneDGrid) – An instance of one-dimensional grid.

Returns:

Transformed one-dimensional grid spanning a different domain.

Return type:

OneDGrid

class HandyRTransform(rmin, R, m, trim_inf=True)[source]

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

The scale factor for the transformed radial array.

Type:

float

__init__(rmin, R, m, trim_inf=True)[source]

Construct Handy transformation.

Parameters:
  • rmin (float) – The minimum coordinate for transformed radial array.

  • R (float) – The scale factor for transformed radial array.

  • m (integer m > 0) – Free parameter, m must be > 0.

  • trim_inf (bool, optional) – Flag to trim infinite value in transformed array. If True, it will replace np.inf with 1e16. This may cause unexpected errors in the following operations.

property codomain

Transformation codomain.

Type:

tuple

deriv(x)[source]

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:

The first derivative of Handy transformation at each point.

Return type:

ndarray(N,)

deriv2(x)[source]

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:

x (ndarray(N,)) – One dimensional array in \([-1,1]\).

Returns:

The second derivative of Handy transformation at each point.

Return type:

ndarray(N,)

deriv3(x)[source]

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:

The third derivative of Handy transformation at each point.

Return type:

np.ndarray(N,)

property domain

Transformation domain.

Type:

tuple

inverse(r)[source]

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:

r (np.ndarray(N,)) – One dimensional array in \([r_{min},\infty)\).

Returns:

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

Return type:

np.ndarray(N,)

property m

Free and extra parameter, m must be > 0.

Type:

integer

property rmin

The minimum value for the transformed radial array.

Type:

float

transform(x)[source]

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:

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

Return type:

np.ndarray(N,)

transform_1d_grid(oned_grid)[source]

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_grid (OneDGrid) – An instance of one-dimensional grid.

Returns:

Transformed one-dimensional grid spanning a different domain.

Return type:

OneDGrid

class HyperbolicRTransform(a, b)[source]

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}\]
__init__(a, b)[source]

Hyperbolic transform class.

Parameters:
  • a (float) – parameter a to determine hyperbolic function

  • b (float) – parameter b to determine hyperbolic function

property a

value of parameter a.

Type:

float

property b

value of parameter b.

Type:

float

property codomain

Transformation codomain.

Type:

tuple

deriv(x)[source]

Compute the first derivative of hyperbolic transformation.

Parameters:

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

Returns:

First derivative of transformation at x.

Return type:

ndarray(N,)

deriv2(x)[source]

Compute the second derivative of hyperbolic transformation.

Parameters:

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

Returns:

Second derivative of transformation at x.

Return type:

ndarray(N,)

deriv3(x)[source]

Compute the third derivative of hyperbolic transformation.

Parameters:

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

Returns:

Third derivative of transformation at x.

Return type:

ndarray(N,)

property domain

Transformation domain.

Type:

tuple

inverse(r)[source]

Compute the inverse of hyperbolic transformation.

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

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

Returns:

Inverse transformation at r.

Return type:

ndarray(N,)

transform(x)[source]

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:

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

Returns:

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

Return type:

ndarray(N,)

transform_1d_grid(oned_grid)[source]

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_grid (OneDGrid) – An instance of one-dimensional grid.

Returns:

Transformed one-dimensional grid spanning a different domain.

Return type:

OneDGrid

class IdentityRTransform[source]

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.\]
__init__()[source]
property codomain

Transformation codomain.

Type:

tuple

deriv(x)[source]

Compute the first derivative of identity transform.

Parameters:

x (ndarray(N,)) – One dimension numpy array located in \([0, \infty)\).

Returns:

First derivative of identity transformation at x.

Return type:

ndarray(N,)

deriv2(x)[source]

Compute the second derivative of identity transform.

Parameters:

x (ndarray(N,)) – One dimension numpy array located in \([0, \infty)\).

Returns:

Second derivative of identity transformation at x.

Return type:

ndarray(N,)

deriv3(x)[source]

Compute the third derivative of identity transform.

Parameters:

x (ndarray(N,)) – One dimension numpy array located in \([0, \infty)\).

Returns:

Third derivative of identity transformation at x.

Return type:

np.ndarray(N,)

property domain

Transformation domain.

Type:

tuple

inverse(r)[source]

Compute the inverse of identity transform.

Parameters:

r (ndarray(N,)) – One dimension numpy array located in \([0, \infty)\).

Returns:

Inverse transformation of the identity transformation at x.

Return type:

np.ndarray(N,)

transform(x)[source]

Perform given array into itself.

\[r_i = x_i\]
Parameters:

x (ndarray(N,)) – One dimension numpy array located in \([0, \infty)\).

Returns:

Identity transformation at each point x.

Return type:

ndarray(N,)

transform_1d_grid(oned_grid)[source]

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_grid (OneDGrid) – An instance of one-dimensional grid.

Returns:

Transformed one-dimensional grid spanning a different domain.

Return type:

OneDGrid

class InverseRTransform(transform)[source]

Bases: BaseTransform

Inverse transformation class for any general transformation.

__init__(transform)[source]

Construct InverseRTransform instance.

Parameters:

transform (BaseTransform) – One-dimension transformation instance.

property codomain

Transformation codomain.

Type:

tuple

deriv(r)[source]

Compute the first derivative of inverse transformation.

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

r (np.array(N,)) – One-dimensional array in the co-domain r of the original transformation.

Returns:

First derivative of the inverse transformation at each point r.

Return type:

np.ndarray(N,)

deriv2(r)[source]

Compute the second derivative of inverse transformation.

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

r (np.array(N,)) – One-dimensional array in the co-domain r of the original transformation.

Returns:

Second derivative of the inverse transformation at each point r.

Return type:

np.ndarray(N,)

deriv3(r)[source]

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:

r (np.array(N,)) – One-dimensional array in the co-domain r of the original transformation.

Returns:

Third derivative of inverse transformation at each point r.

Return type:

np.ndarray(N,)

property domain

Transformation domain.

Type:

tuple

inverse(x)[source]

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:

x (np.ndarray) – One-dimension array in the domain x of the original transformation.

Returns:

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

Return type:

np.ndarray

transform(r)[source]

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:

r (np.ndarray(N,)) – One-dimensional array in the co-domain r of the original transformation.

Returns:

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

Return type:

np.ndarray(N,)

transform_1d_grid(oned_grid)[source]

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_grid (OneDGrid) – An instance of one-dimensional grid.

Returns:

Transformed one-dimensional grid spanning a different domain.

Return type:

OneDGrid

class KnowlesRTransform(rmin, R, k, trim_inf=True)[source]

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

The scale factor for the transformed radial array.

Type:

float

__init__(rmin, R, k, trim_inf=True)[source]

Construct Knowles transformation class.

Parameters:
  • rmin (float) – The minimum coordinate for transformed radial array.

  • R (float) – The scale factor for transformed radial array.

  • k (integer k > 0) – Free parameter, k must be > 0.

  • trim_inf (bool, optional) – Flag to trim infinite value in transformed array. If True, it will replace np.inf with 1e16. This may cause unexpected errors in the following operations.

property codomain

Transformation codomain.

Type:

tuple

deriv(x)[source]

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:

The first derivative of Knowles transformation at each point.

Return type:

ndarray(N,)

deriv2(x)[source]

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:

x (ndarray(N,)) – One dimensional array in \([-1,1]\).

Returns:

The second derivative of Knowles transformation at each point.

Return type:

ndarray(N,)

deriv3(x)[source]

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:

The third derivative of Knowles transformation at each point.

Return type:

ndarray(N,)

property domain

Transformation domain.

Type:

tuple

inverse(r)[source]

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:

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

Return type:

ndarray(N,)

property k

Free and extra parameter, k must be > 0.

Type:

float

property rmin

The minimum value for the transformed radial array.

Type:

float

transform(x)[source]

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:

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

Return type:

np.ndarray(N,)

transform_1d_grid(oned_grid)[source]

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_grid (OneDGrid) – An instance of one-dimensional grid.

Returns:

Transformed one-dimensional grid spanning a different domain.

Return type:

OneDGrid

class LinearFiniteRTransform(rmin, rmax)[source]

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}}\]
__init__(rmin, rmax)[source]

Construct linear transformation instance.

Parameters:
  • rmin (float) – Minimum value for transformed interval.

  • rmax (float) – Maximum value for transformed interval.

property codomain

Transformation codomain.

Type:

tuple

deriv(x)[source]

Compute the 1st order derivative.

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

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

Returns:

First order derivative at given points.

Return type:

float or np.ndarray

deriv2(x)[source]

Compute the second order derivative.

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

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

Returns:

Second order derivative at given points.

Return type:

float or np.ndarray

deriv3(x)[source]

Compute the third order derivative.

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

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

Returns:

Third order derivative at given points.

Return type:

ndarray

property domain

Transformation domain.

Type:

tuple

inverse(r)[source]

Compute the inverse of the transformation.

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

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

Returns:

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

Return type:

ndarray

transform(x)[source]

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:

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

Returns:

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

Return type:

float or np.ndarray

transform_1d_grid(oned_grid)[source]

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_grid (OneDGrid) – An instance of one-dimensional grid.

Returns:

Transformed one-dimensional grid spanning a different domain.

Return type:

OneDGrid

class LinearInfiniteRTransform(rmin, rmax, b=None)[source]

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}}\]
__init__(rmin, rmax, b=None)[source]

Initialize linear transform class.

Parameters:
  • rmin (float) – Define the lower end of the linear transform

  • rmax (float) – Define the upper end of the linear transform

  • b (float) – Maximum \(b\) of a prespecified radial grid \([0, b]\) such that \(b\) maps to rmax. If None, then the maximum is taken and stored from the grid that is transformed initially.

property b

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

Type:

float

property codomain

Transformation codomain.

Type:

tuple

deriv(x)[source]

Compute the first derivative of linear transformation.

Parameters:

x (ndarray(N,)) – One-dimensional array in the domain \([0, \infty)\).

Returns:

First derivative of transformation at x.

Return type:

ndarray(N,)

deriv2(x)[source]

Compute the second derivative of linear transformation.

Parameters:

x (ndarray(N,)) – One-dimensional array in the domain \([0, \infty)\).

Returns:

Second derivative of transformation at x.

Return type:

ndarray(N,)

deriv3(x)[source]

Compute the third derivative of linear transformation.

Parameters:

x (ndarray(N,)) – One-dimensional array in the domain \([0, \infty)\).

Returns:

Third derivative of transformation at x.

Return type:

ndarray(N,)

property domain

Transformation domain.

Type:

tuple

inverse(r)[source]

Compute the inverse of linear transformation.

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

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

Returns:

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

Return type:

ndarray(N,)

property rmax

rmax value of the tf.

Type:

float

property rmin

rmin value of the tf.

Type:

float

set_maximum_parameter_b(x)[source]

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

transform(x)[source]

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:

x (ndarray(N,)) – One-dimensional array in the domain \([0, \infty)\).

Returns:

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

Return type:

ndarray(N,)

transform_1d_grid(oned_grid)[source]

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_grid (OneDGrid) – An instance of one-dimensional grid.

Returns:

Transformed one-dimensional grid spanning a different domain.

Return type:

OneDGrid

class MultiExpRTransform(rmin, R, trim_inf=True)[source]

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

The scale factor for the transformed radial array.

Type:

float

__init__(rmin, R, trim_inf=True)[source]

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

Parameters:
  • rmin (float) – The minimum coordinate for transformed radial array.

  • R (float) – The scale factor for transformed radial array.

  • trim_inf (bool, optional) – Flag to trim infinite value in transformed array. If True, it will replace np.inf with 1e16. This may cause unexpected errors in the following operations.

property codomain

Transformation codomain.

Type:

tuple

deriv(x)[source]

Compute the first derivative of MultiExp transformation.

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

x (ndarray(N,)) – One dimensional in \([-1, 1]\).

Returns:

The first derivative of MultiExp transformation at each point.

Return type:

ndarray(N,)

deriv2(x)[source]

Compute the second derivative of MultiExp transformation.

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

x (ndarray(N,)) – One dimensional in \([-1,1]\).

Returns:

The second derivative of MultiExp transformation at each point.

Return type:

ndarray(N,)

deriv3(x)[source]

Compute the third derivative of MultiExp transformation.

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

x (ndarray(N,)) – One dimensional array in \([-1,1]\).

Returns:

The third derivative of MultiExp transformation at each point.

Return type:

ndarray(N,)

property domain

Transformation domain.

Type:

tuple

inverse(r)[source]

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

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

r (np.ndarray(N,)) – One-dimensional array in \([r_{min}, \infty)\).

Returns:

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

Return type:

np.ndarray(N,)

property rmin

The minimum value for the transformed radial array.

Type:

float

transform(x)[source]

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

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

x (ndarray(N,)) – One dimensional array with values between \([-1,1]\).

Returns:

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

Return type:

ndarray(N,)

transform_1d_grid(oned_grid)[source]

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_grid (OneDGrid) – An instance of one-dimensional grid.

Returns:

Transformed one-dimensional grid spanning a different domain.

Return type:

OneDGrid

class PowerRTransform(rmin, rmax, b=None)[source]

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.\]
__init__(rmin, rmax, b=None)[source]

Initialize power transform instance.

Parameters:
  • rmin (float) – Minimum value for transformed points

  • rmax (float) – Maximum value for transformed points

  • b (float) – The parameter b that maps to \(r_{max}\).

property b

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

Type:

float

property codomain

Transformation codomain.

Type:

tuple

deriv(x)[source]

Compute first derivative of power transform.

Parameters:

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

Returns:

First derivative of transformation at x.

Return type:

ndarray(N,)

deriv2(x)[source]

Compute second derivative of power transform.

Parameters:

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

Returns:

Second derivative of transformation at x.

Return type:

ndarray(N,)

deriv3(x)[source]

Compute third derivative of power transform.

Parameters:

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

Returns:

Third derivative of transformation at x.

Return type:

ndarray(N,)

property domain

Transformation domain.

Type:

tuple

inverse(r)[source]

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:

r (ndarray(N,)) – One-dimensional array in the co-domain of the transformation.

Returns:

Inverse of transformation at r.

Return type:

ndarray(N,)

property rmax

the value of rmax.

Type:

float

property rmin

the value of rmin.

Type:

float

set_maximum_parameter_b(x)[source]

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

transform(x)[source]

Perform power transform.

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

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

Parameters:

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

Returns:

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

Return type:

ndarray(N,)

transform_1d_grid(oned_grid)[source]

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_grid (OneDGrid) – An instance of one-dimensional grid.

Returns:

Transformed one-dimensional grid spanning a different domain.

Return type:

OneDGrid