SWPotential¶
The SWPotential
class representing a 1D Square-Well Potential
(1DSWP) is defined below.
-
class
siegpy.swpotential.
SWPotential
(l, V0, grid=None)[source]¶ Bases:
siegpy.functions.Rectangular
,siegpy.potential.Potential
A 1D SW potential is nothing but a rectangular function that is considered as a potential. This class therefore inherits from and extends the
Rectangular
andPotential
classes.A 1D SWP is initialized from a width \(l\) and a depth \(V_0\). If a grid is given, the potential is discretized over this grid.
Parameters: - l (float) – Width of the potential.
- V0 (float) – Depth of the potential.
- grid (numpy array or list or set) – Discretization grid of the potential (optional).
Raises: ValueError
– If the depth and width of the potential are not strictly positive.Examples
A SWPotential instance represents nothing but a centered rectangular function with a negative amplitude:
>>> xgrid = [-4, -2, 0, 2, 4] >>> pot = SWPotential(5, 10, grid=xgrid) >>> pot.width == 5 and pot.amplitude == -10 True >>> pot.center == 0 and pot.momentum == 0 True >>> pot.values array([ 0.+0.j, -10.+0.j, -10.+0.j, -10.+0.j, 0.+0.j])
Rather than dealing with a negative amplitude, the positive depth of the SW potential is mainly used:
>>> pot.depth 10
-
classmethod
from_center_and_width
(xc, a, k0=0.0, h=1.0, grid=None)[source]¶ Class method overriding the inherited
siegpy.functions.Rectangular.from_center_and_width()
class method.Parameters: - xc (float) – Center of the potential (must be 0).
- a (float) – Width of the potential.
- k0 (float) – Initial momentum of the potential (must be 0).
- h (float) – Depth of the potential (default to 1).
- grid (list or numpy array) – Discretization grid (optional).
Returns: An initialized 1D SW potential.
Return type: Raises: ValueError
– If the initial momentum or the center is not zero.Examples
>>> pot = SWPotential.from_center_and_width(0, 5, h=-10) >>> pot.width == 5 and pot.depth == 10 True
A Potential cannot have a non-zero center nor an initial momentum:
>>> SWPotential.from_center_and_width(2, 5) Traceback (most recent call last): ValueError: A SWPotential must be centered. >>> SWPotential.from_center_and_width(0, 5, k0=1) Traceback (most recent call last): ValueError: A SWPotential cannot have an initial momentum.
The same is valid for the
from_width_and_center()
class method:>>> SWPotential.from_width_and_center(5, 2) Traceback (most recent call last): ValueError: A SWPotential must be centered. >>> SWPotential.from_width_and_center(5, 0, k0=1) Traceback (most recent call last): ValueError: A SWPotential cannot have an initial momentum.
-
depth
¶ Returns: Depth of the 1D SW potential. Return type: float
-
__eq__
(other)[source]¶ Parameters: other (object) – Any other object. Returns: True
if two SW potentials have the same width and depth.Return type: bool Examples
>>> SWPotential(5, 10) == SWPotential(5, 10, grid=[-1, 0, 1]) True >>> SWPotential(5, 10) == Potential([-1, 0, 1], [-10, -10, -10]) False
-
__add__
(other)[source]¶ Override of the addition, taking care of the case of the addition of two SW potentials with the same width.
Parameters: other (Potential) – Another potential Returns: The sum of both potentials. Return type: Potential or Function Examples
The addition of two Square-Well potentials of the same width keeps the analyticity:
>>> xgrid = [-4, -2, 0, 2, 4] >>> pot = SWPotential(5, 10, grid=xgrid) >>> pot += SWPotential(5, 5) >>> isinstance(pot, SWPotential) True >>> pot.amplitude == -15 and pot.depth == 15 and pot.width == 5 True >>> pot.values array([ 0.+0.j, -15.+0.j, -15.+0.j, -15.+0.j, 0.+0.j])
In any other case, the analyticity is lost, but the result still is a potential:
>>> pot += Potential(xgrid, [5, 5, 5, 5, 5]) >>> isinstance(pot, SWPotential) False >>> isinstance(pot, Potential) True >>> pot.values array([ 5.+0.j, -10.+0.j, -10.+0.j, -10.+0.j, 5.+0.j])
-
complex_scaled_values
(coord_map)[source]¶ Evaluates the complex scaled SW potential. It actually amounts to the potential without complex scaling, as the Square-Well Potential is a piecewise function (the complex scaling has no effect on it).
Parameters: coord_map (CoordMap) – Coordinate mapping. Returns: Complex scaled values of the potential. Return type: numpy array