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 DependentVariable set for each pair, e.g., as part of a mixing rule.

Parameters:
Raises:

Examples

Create a pair parameters for types A and B with parameters epsilon and sigma:

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 as dict.update():

coeff['A','A'].update(sigma=2.5)
>>> print(coeff['A','A'])
{'epsilon':2.0, 'sigma':2.5}

Assigning a dict to 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 Variable objects. To get the value of all parameters, use evaluate():

>>> 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.

Parameters:

key (str) – Key for which the parameters are evaluated.

Returns:

params – The evaluated parameters.

Return type:

dict

to_json()#

Export parameters to a JSON-compatible dictionary.

Returns:

Evaluated parameters.

Return type:

dict