SmoothFunction¶
The SmoothFunction
class and its methods are defined hereafter.
It is used as the base class of two more specific smooth functions:
- the
TanhSmoothFunction
class, - and the
ErfSmoothFunction
class.
-
class
siegpy.smoothfunctions.
SmoothFunction
(x0, lbda, c0=1, cp=1, cm=-1, grid=None)[source]¶ Bases:
object
Note
This is an abstract class.
Smooth functions are used when a smooth complex scaling is applied to the potential. The aim of this class is to easily update the values of the smooth functions (and its derivatives) when the Refection-Free Complex Absorbing Potentials and the Virial operator are defined.
The smooth functions \(q\) used here are of the form:
\[q(x) = c_0 + c_+ r(\lambda (x - x_0)) - c_- r(\lambda (x + x_0))\]The smooth function should be 0 on a large part of the \([-x_0, x_0]\) range of the grid, while tending to 1 at both infinities.
The initialization of a smooth function requires the value of \(x_0\) and of the parameter \(\lambda\), indicating how smoothly the function goes from 0 to 1 (the larger, the sharper).
Parameters: - x0 (float) – Inflection point.
- lbda (float) – Sharpness parameter (the function is smoother for smaller values).
- c0 (float) – Constant term \(c_0\) of the smooth function defintion (default to 1).
- cp (float) – Constant term \(c_+\) of the smooth function defintion (default to 1).
- cm (float) – Constant term \(c_-\) of the smooth function defintion (default to -1).
- array (numpy) – Discretization grid of the smooth function (optional).
Raises: ValueError
– Ifx0
orlbda
are not strictly positive.-
x0
¶ Returns: Inflection point. Return type: float
-
lbda
¶ Returns: Sharpness parameter. Return type: float
-
grid
¶ Returns: Discretization grid of the smooth function. Return type: numpy array
-
values
¶ Returns: Values of the smooth function. Return type: numpy array
-
dx_values
¶ Returns: Values of the first derivative of the smooth function. Return type: numpy array
-
dx2_values
¶ Returns: Values of the second derivative of the smooth function. Return type: numpy array
-
dx3_values
¶ Returns: Values of the third derivative of the smooth function. Return type: numpy array
-
dxi_values
¶ Returns: Values of the first derivative of the smooth function with respect to both parameters \(x_0\) and \(\lambda\). Return type: numpy array
-
dx_dxi_values
¶ Returns: Values of the first derivative with respect to both parameters \(x_0\) and \(\lambda\) of the first derivative of the smooth function. Return type: numpy array
-
_get_r_values
(grid)[source]¶ Note
This is an asbtract method.
Parameters: grid (numpy array) – Discretization grid. Returns: Values of the function \(r\), evaluated on a given set of grid points. Return type: numpy array
-
_get_r_dx_values
(grid)[source]¶ Note
This is an asbtract method.
Parameters: grid (numpy array) – Discretization grid. Returns: - Values of first derivative of the function \(r\),
- evaluated on a given set of grid points.
-
class
siegpy.smoothfunctions.
ErfSmoothFunction
(x0, lbda, c0=1, cp=1, cm=-1, grid=None)[source]¶ Bases:
siegpy.smoothfunctions.SmoothFunction
In this case, the function \(r\) corresponds to the error function \(\text{erf}\).
The smooth functions \(q\) used here are of the form:
\[q(x) = c_0 + c_+ r(\lambda (x - x_0)) - c_- r(\lambda (x + x_0))\]The smooth function should be 0 on a large part of the \([-x_0, x_0]\) range of the grid, while tending to 1 at both infinities.
The initialization of a smooth function requires the value of \(x_0\) and of the parameter \(\lambda\), indicating how smoothly the function goes from 0 to 1 (the larger, the sharper).
Parameters: - x0 (float) – Inflection point.
- lbda (float) – Sharpness parameter (the function is smoother for smaller values).
- c0 (float) – Constant term \(c_0\) of the smooth function defintion (default to 1).
- cp (float) – Constant term \(c_+\) of the smooth function defintion (default to 1).
- cm (float) – Constant term \(c_-\) of the smooth function defintion (default to -1).
- array (numpy) – Discretization grid of the smooth function (optional).
Raises: ValueError
– Ifx0
orlbda
are not strictly positive.-
_get_r_values
(grid)[source]¶ Parameters: grid (numpy array) – Discretization grid. Returns: - Values of the function \(\text{erf}\), evaluated on a
- given set of grid points.
-
_get_r_dx_values
(grid)[source]¶ Parameters: grid (numpy array) – Discretization grid. Returns: - Values of first derivative of the function
- \(\text{erf}\), evaluated on a given set of grid points.
-
class
siegpy.smoothfunctions.
TanhSmoothFunction
(x0, lbda, c0=1, cp=1, cm=-1, grid=None)[source]¶ Bases:
siegpy.smoothfunctions.SmoothFunction
In this case, the function \(r\) corresponds to the hyperbolic tangent \(\tanh\).
The smooth functions \(q\) used here are of the form:
\[q(x) = c_0 + c_+ r(\lambda (x - x_0)) - c_- r(\lambda (x + x_0))\]The smooth function should be 0 on a large part of the \([-x_0, x_0]\) range of the grid, while tending to 1 at both infinities.
The initialization of a smooth function requires the value of \(x_0\) and of the parameter \(\lambda\), indicating how smoothly the function goes from 0 to 1 (the larger, the sharper).
Parameters: - x0 (float) – Inflection point.
- lbda (float) – Sharpness parameter (the function is smoother for smaller values).
- c0 (float) – Constant term \(c_0\) of the smooth function defintion (default to 1).
- cp (float) – Constant term \(c_+\) of the smooth function defintion (default to 1).
- cm (float) – Constant term \(c_-\) of the smooth function defintion (default to -1).
- array (numpy) – Discretization grid of the smooth function (optional).
Raises: ValueError
– Ifx0
orlbda
are not strictly positive.-
_get_r_values
(grid)[source]¶ Parameters: grid (numpy array) – Discretization grid. Returns: - Values of the function \(\tanh\), evaluated on a
- given set of grid points.
-
_get_r_dx_values
(grid)[source]¶ Parameters: grid (numpy array) – Discretization grid. Returns: - Values of first derivative of the function \(\tanh\),
- evaluated on a given set of grid points.