relentless.model.potential.PairParameters#
- class relentless.model.potential.PairParameters(types, params)#
Parameters for pairs of types.
A pair is a tuple of two types, and each type is a
str. A named list of parameters can be set for each pair of types. The parameters for a pair are assumed to be symmetric, so the pair(i,j)is the same as the pair(j,i).The same parameters can also be set for each type. These values are not used directly in evaluating the per-pair coefficients, but they can be used in a
DependentVariableset for each pair, e.g., as part of a mixing rule.- Parameters:
- Raises:
ValueError – If
paramsis empty.TypeError – If
paramsis not only strings.
Examples
Create a pair parameters for types
AandBwith parametersepsilonandsigma:coeff = PairParameters(types=('A','B'), params=('epsilon','sigma'))
The parameters can be accessed or iterated using
params:>>> print(coeff.params) ('epsilon','sigma')
Set a parameter for a pair by accessing it directly:
coeff['A','A']['epsilon'] = 2.0
Parameters can also be assigned using
update, which works the same asdict.update():coeff['A','A'].update(sigma=2.5) >>> print(coeff['A','A']) {'epsilon':2.0, 'sigma':2.5}
Assigning a
dictto a pair using the=operator resets any parameters that are not specified:coeff['A','A'] = {'sigma': 2.5} >>> print(coeff['A','A']) {'epsilon':None, 'sigma':2.5}
Parameters can be a mix of constants and
Variableobjects. To get the value of all parameters, useevaluate():>>> coeff['A','A']['epsilon'] = relentless.variable.IndependentVariable(1.0) >>> print(coeff.evaluate(('A','A'))) {'epsilon':1.0, 'sigma':2.5}
Methods
evaluate(key)Evaluate parameters.
from_json(data)to_json()Export parameters to a JSON-compatible dictionary.
- evaluate(key)#
Evaluate parameters.