Symbolic Potential

The SymbolicPotential class is defined below, along with some child classes:

class siegpy.symbolicpotentials.SymbolicPotential(sym_func, grid=None)[source]

Bases: siegpy.potential.Potential

A Symbolic potential is defined by a symbolic function using the sympy package. The symbolic function can be encoded in a string. The function must be a function of x only (no other parameters).

Parameters:
  • sym_func (str or sympy symbolic function) – Symbolic function of the potential.
  • grid (list or numpy array or NoneType) – Discretization grid of the potential (optional).
Raises:

ValueError – If a parameter of the symbolic function is not \(x\).

Examples

The symbolic function can be a string:

>>> f = "1 / (x**2 + 1)"
>>> pot = SymbolicPotential(f)

Updating the grid automatically updates the values of the potential:

>>> xgrid = [-1, 0, 1]
>>> pot.grid = xgrid
>>> pot.values
array([ 0.5,  1. ,  0.5])

The symbolic function must be a function of x only:

>>> from sympy.abc import a, b, x
>>> f = a / (x**2 + b)
>>> SymbolicPotential(f)
Traceback (most recent call last):
ValueError: The only variable of the analytic function should be x.

This means you must assign values to the parameters beforehand:

>>> pot = SymbolicPotential(f.subs([(a, 1), (b, 1)]), grid=xgrid)
>>> pot.values
array([ 0.5,  1. ,  0.5])
symbolic
Returns:Symbolic function of the potential.
Return type:Sympy symbolic function
grid
Returns:Values of the grid.
Return type:NoneType or numpy array
_compute_values(grid)[source]

Evaluate the values of the potential for a given grid.

Parameters:grid (list or numpy array) – Discretization grid or complex scaled grid.
Returns:Values of the potential according to its grid.
Return type:numpy array
complex_scaled_values(coord_map)[source]

Evaluate the complex scaled potential for a given coordinate mapping.

Parameters:coord_map (CoordMap) – Coordinate mapping.
Returns:Complex scaled values of the potential.
Return type:numpy array
__add__(other)[source]
Parameters:other (Potential) – Another potential.
Returns:Sum of both potentials.
Return type:SymbolicPotential or Potential
Raises:ValueError – If the other potential is not symbolic and both potentials have no grid.
class siegpy.symbolicpotentials.WoodsSaxonPotential(l, V0, lbda, grid=None)[source]

Bases: siegpy.symbolicpotentials.SymbolicPotential

This class defines a symmetric and smooth Woods-Saxon potential of the form:

\[V(x) = V_0 \left( \frac{1}{1 + e^{\lambda(x+l/2)}} - \frac{1}{1 + e^{\lambda(x-l/2)}} \right)\]

where \(V_0\) is the potential depth, \(l\) is the potential characteristic width and \(\lambda\) is the sharpness parameter.

Parameters:
  • l (float) – Characteristic width of the potential.
  • V0 (float) – Potential depth (if negative, it corresponds to a potential barrier).
  • lbda (float) – Sharpness of the potential.
  • grid (numpy array) – Discretization grid of the potential (optional).
Raises:

ValueError – If the width or the sharpness parameters is strictly negative.

width
Returns:Width of the potential.
Return type:float
depth
Returns:Depth of the potential.
Return type:float
sharpness
Returns:Sharpness of the potential.
Return type:float
class siegpy.symbolicpotentials.MultipleGaussianPotential(sym_func, grid=None)[source]

Bases: siegpy.symbolicpotentials.SymbolicPotential

This class avoids some code repetition inside the classes TwoGaussianPotential and FourGaussianPotential.

Parameters:
  • sym_func (str or sympy symbolic function) – Symbolic function of the potential.
  • grid (list or numpy array or NoneType) – Discretization grid of the potential (optional).
Raises:

ValueError – If a parameter of the symbolic function is not \(x\).

Examples

The symbolic function can be a string:

>>> f = "1 / (x**2 + 1)"
>>> pot = SymbolicPotential(f)

Updating the grid automatically updates the values of the potential:

>>> xgrid = [-1, 0, 1]
>>> pot.grid = xgrid
>>> pot.values
array([ 0.5,  1. ,  0.5])

The symbolic function must be a function of x only:

>>> from sympy.abc import a, b, x
>>> f = a / (x**2 + b)
>>> SymbolicPotential(f)
Traceback (most recent call last):
ValueError: The only variable of the analytic function should be x.

This means you must assign values to the parameters beforehand:

>>> pot = SymbolicPotential(f.subs([(a, 1), (b, 1)]), grid=xgrid)
>>> pot.values
array([ 0.5,  1. ,  0.5])
classmethod from_Gaussians(*args, **kwargs)[source]

Note

This is an asbtract class method.

Initalization of the potential from Gaussian functions and not from the parameters allowing to define these Gaussian functions.

Returns:Potential initialized from multiple Gaussian functions.
Return type:MultipleGaussianPotential
gaussians

Note

This is an asbtract property.

Returns:All the Gaussian functions used to create the potential.
Return type:list
sigmas
Returns:Sigma of the Gaussian functions of the potential.
Return type:list
centers
Returns:Center of the Gaussian functions of the potential.
Return type:list
amplitudes
Returns:Amplitude of the Gaussian functions of the potential.
Return type:list
class siegpy.symbolicpotentials.TwoGaussianPotential(sigma1, xc1, h1, sigma2, xc2, h2, grid=None)[source]

Bases: siegpy.symbolicpotentials.MultipleGaussianPotential

This class defines a potential made of the sum of two Gaussian functions.

Parameters:
  • sigma1 (float) – Sigma of the first Gaussian function.
  • xc1 (float) – Center of the first Gaussian function.
  • h1 (float) – Amplitude of the first Gaussian function.
  • sigma2 (float) – Sigma of the second Gaussian function.
  • xc2 (float) – Center of the second Gaussian function.
  • h2 (float) – Amplitude of the second Gaussian function.
  • grid (numpy array) – Discretization grid of the potential (optional).
classmethod from_Gaussians(gauss1, gauss2, grid=None)[source]

Initialization of a TwoGaussianPotential instance from two Gaussian functions.

Parameters:
  • gauss1 (Gaussian) – First Gaussian function.
  • gauss2 (Gaussian) – Second Gaussian function.
  • grid (numpy array) – Discretization grid of the potential (optional).
Returns:

Potential initialized from two Gaussian functions.

Return type:

TwoGaussianPotential

gaussian1
Returns:First Gaussian function of the potential.
Return type:Gaussian
gaussian2
Returns:Second Gaussian function of the potential.
Return type:Gaussian
gaussians
Returns:Both Gaussian functions of the potential.
Return type:list
class siegpy.symbolicpotentials.FourGaussianPotential(sigma1, xc1, h1, sigma2, xc2, h2, sigma3, xc3, h3, sigma4, xc4, h4, grid=None)[source]

Bases: siegpy.symbolicpotentials.MultipleGaussianPotential

This class defines a potential made of the sum of four Gaussian functions.

Parameters:
  • sigma1 (float) – Sigma of the first Gaussian function.
  • xc1 (float) – Center of the first Gaussian function.
  • h1 (float) – Amplitude of the first Gaussian function.
  • sigma2 (float) – Sigma of the second Gaussian function.
  • xc2 (float) – Center of the second Gaussian function.
  • h2 (float) – Amplitude of the second Gaussian function.
  • sigma3 (float) – Sigma of the third Gaussian function.
  • xc3 (float) – Center of the third Gaussian function.
  • h3 (float) – Amplitude of the third Gaussian function.
  • sigma4 (float) – Sigma of the fouth Gaussian function.
  • xc4 (float) – Center of the fouth Gaussian function.
  • h4 (float) – Amplitude of the fouth Gaussian function.
  • grid (numpy array) – Discretization grid of the potential (optional).
classmethod from_Gaussians(gauss1, gauss2, gauss3, gauss4, grid=None)[source]

Initialization of a FourGaussianPotential instance from four Gaussian functions.

Parameters:
  • gauss1 (Gaussian) – First Gaussian function.
  • gauss2 (Gaussian) – Second Gaussian function.
  • gauss3 (Gaussian) – Third Gaussian function.
  • gauss4 (Gaussian) – Fourth Gaussian function.
  • grid (numpy array) – Discretization grid of the potential (optional).
Returns:

Potential initialized from four Gaussian functions.

Return type:

FourGaussianPotential

gaussian1
Returns:First Gaussian function of the potential.
Return type:Gaussian
gaussian2
Returns:Second Gaussian function of the potential.
Return type:Gaussian
gaussian3
Returns:Third Gaussian function of the potential.
Return type:Gaussian
gaussian4
Returns:Fouth Gaussian function of the potential.
Return type:Gaussian
gaussians
Returns:Four Gaussian functions of the potential.
Return type:list