bdld.potential package¶
Submodules¶
bdld.potential.mueller_brown module¶
Müller-Brown Potential class to be evaluated with md
- class bdld.potential.mueller_brown.MuellerBrownPotential(scaling_factor=None)¶
Bases:
Potential
Müller-Brown potential
This is a 2D potential with three metastable states
It consists of a sum of four exponential terms: -200*exp( -(x-1)^2 -10*y^2 ) -100*exp( -x^2 -10*(y-0.5)^2 ) -170*exp( -6.5*(x+0.5)^2 + 11*(x+0.5)*(y-1.5) -6.5*(y-1.5)^2 ) +15*exp( 0.7*(x+1)^2 +0.6*(x+1)*(y-1) +0.7*(y-1)^2 )
The potential and its coefficients are described in K. Müller and L. D. Brown, Theoretical Chemistry Accounts, 53, 1979 pp. 75–93.
- Parameters:
scaling_factor (
Optional
[float
]) – scale potential by factor
- energy(pos)¶
Get energy at position
- Parameters:
pos (
Union
[List
[float
],ndarray
]) – position to be evaluated (given as list or array even in 1d)- Return type:
float
- Returns:
energy
- evaluate(pos)¶
Get potential energy and force at position
Faster than base method because exponentials need to be evaluated only once
- Parameters:
pos (
Union
[List
[float
],ndarray
]) – position to be evaluated- Return type:
Tuple
[float
,ndarray
]- Returns:
(energy, force)
- force(pos)¶
Get force at position
- Parameters:
pos (
Union
[List
[float
],ndarray
]) – position to be evaluated (given as list or array even in 1d)- Return force:
array with force per direction
- Return type:
ndarray
bdld.potential.polynomial module¶
Potential based on polynomial functions to be evaluated with md
- class bdld.potential.polynomial.PolynomialPotential(coeffs, ranges=None)¶
Bases:
Potential
Simple polynomial potential class defined by coefficients
- Parameters:
coeffs (
Union
[List
[float
],ndarray
]) – Coefficients of polynomial potentialder – Coefficients of derivative of potential per direction
n_dim – Dimensions of potential
polyval – polyval function of np.polynomial.polynomial to use
ranges (
Optional
[List
[Tuple
[float
,float
]]]) – (min, max) values of potential (optional)
- energy(pos)¶
Get energy at position
- Parameters:
pos (
Union
[List
[float
],ndarray
]) – position to be evaluated (given as list or array even in 1d)- Return energy:
energy at position
- Return type:
float
- force(pos)¶
Get force at position
- Parameters:
pos (
Union
[List
[float
],ndarray
]) – position to be evaluated (given as list or array even in 1d)- Return force:
array with force per direction
- Return type:
ndarray
- set_polyval()¶
Selects polyval function from numpy.polynomial.polynomial depending on self.n_dim
- Return type:
Callable
- bdld.potential.polynomial.coefficients_from_file(filename, n_dim)¶
Read coefficients from file
This should be compatible to the ves_md_linearexpansion files
The syntax for the files is rows with one coefficient each. The first n_dim columns contain the polynomial orders per dimension, the next one the coefficient value. Remaining columns are ignored.
- Parameters:
filename (
str
) – path to file holding the coefficientsn_dim (
int
) – dimensions of potential
- Return type:
ndarray
bdld.potential.potential module¶
Potential class to be evaluated with md
- class bdld.potential.potential.BoundaryCondition(value)¶
Bases:
Enum
Enum for the different boundary conditions
- periodic = 2¶
- reflective = 1¶
- class bdld.potential.potential.Potential¶
Bases:
object
Base class for potentials
Collection of some functionality that all should have All derived potentials must implement energy() and force() functions and set some description in __str__()
- apply_boundary_condition_periodic(pos, mom)¶
Apply periodic boundary condition
If the particle is outside the potential range, it is moved to the other side of the potential range Because position and momentum are numpy arrays, they are passed by reference and can be changed in place
- Parameters:
pos (
ndarray
) – position of particle per directionmom (
ndarray
) – momentum of particle per direction (not actually changed)
- Return type:
None
- apply_boundary_condition_reflective(pos, mom)¶
Apply reflective boundary condition
If the particle is outside the potential range, it is set to the boundary and its momentum is reversed
Because position and momentum are numpy arrays, they are passed by reference and can be changed in place
- Parameters:
pos (
ndarray
) – position of particle per directionmom (
ndarray
) – momentum of particle per direction
- Return type:
None
- property boundary_condition¶
Type of boundary condition for the potential
- calculate_probability_density(kt, ranges, grid_points)¶
Calculate the probability density associated with the potential on a grid
- Parameters:
kt (
float
) – Thermal energy of systemranges (
List
[Tuple
[float
,float
]]) – List of ranges of the grid per dimension (min, max)grid_points (
List
[int
]) – number of points per dimension
- Raises:
ValueError – if dimensions of points or ranges and potential do not match
- Return prob:
grid with normalized probablities
- Return type:
- calculate_reference(pos, mintozero=True)¶
Calculate reference from potential at given positions
- Parameters:
pos (
Union
[List
[ndarray
],ndarray
]) – positions to evaluatemintozero (bool) – shift fes minimum to zero
- Return fes:
list numpy array with fes values at positions
- Return type:
ndarray
- energy(pos)¶
Get energy at position, needs to be overriden by derived class
- Parameters:
pos (
Union
[List
[float
],ndarray
]) – position to be evaluated- Return type:
float
- Returns:
energy
- evaluate(pos)¶
Get potential energy and forces at position
- Parameters:
pos (
Union
[List
[float
],ndarray
]) – position to be evaluated- Return type:
Tuple
[float
,ndarray
]- Returns:
(energy, forces)
- force(pos)¶
Get energy at position, needs to be overriden by derived class
- Parameters:
pos (
Union
[List
[float
],ndarray
]) – position to be evaluated- Return type:
ndarray
- Returns:
array with force per direction
- get_fields()¶
Return list of identifiers for the potential dimensions
Can be overwritten by subclasses to have custom names
- Return type:
List
[str
]
Module contents¶
Import all submodules