Index

ParamMappingABC(data, move_range, func[, …]) A Mapping for storing and updating forcefield parameters.
ParamMapping(data[, move_range, func]) A Mapping for storing and updating forcefield parameters.

API

class FOX.armc.ParamMappingABC(data, move_range, func, constraints=None, **kwargs)[source]

A Mapping for storing and updating forcefield parameters.

Besides the implementation of the Mapping protocol, this class has access to four main methods:

Note that __call__() will internally call all other three methods.

Examples

>>> import pandas as pd

>>> df = pd.DataFrame(..., index=pd.MultiIndex(...))
>>> param = ParamMapping(df, ...)

>>> idx = param.move()
move_range

An 1D array with all allowed move steps.

Type:np.ndarray[np.float64], shape \((n,)\)
func

The callable used for applying \(\phi\) to the auxiliary error. The callable should take an two floats as arguments and return a new float.

Type:Callable
_net_charge

The net charge of the molecular system. Only applicable if the "charge" is among the passed parameters.

Type:float, optional
FILL_VALUE: ClassVar[Mapping[Literal[min, max, count, frozen, guess, unit], numpy.generic]] = mappingproxy({'min': -inf, 'max': inf, 'count': -1, 'frozen': False, 'guess': False, 'unit': ''})

Fill values for when optional keys are absent.

add_param(idx, value, **kwargs)[source]

Add a new parameter to this instance.

Parameters:
  • idx (tuple[str, str, str]) – The index of the new parameter. Must be compatible with pd.DataFrame.loc.
  • value (float) – The value of the new parameter.
  • **kwargs (Any) – Values for ParamMappingABC.metadata.
abstract identify_move(param)[source]

Identify the to-be moved parameter and the size of the move.

Parameters:param (str) – The name of the parameter-containg column.
Returns:The index of the to-be moved parameter, it’s value and the size of the move.
Return type:tuple[tuple[str, str, str], float, float]
clip_move(idx, value)[source]

An optional function for clipping the value of value.

Parameters:
Returns:

The newly clipped value of the moved parameter.

Return type:

float

apply_constraints(idx, value, param)[source]

An optional function for applying further constraints based on idx and value.

Should perform an inplace update of this instance.

Parameters:
  • idx (tuple[str, str, str]) – The index of the moved parameter.
  • value (float) – The value of the moved parameter.
  • param (str) – The name of the parameter-containg column.
Returns:

Any exceptions raised during this functions’ call.

Return type:

Exception, optional

to_struct_array()[source]

Stack all Series in this instance into a single structured array.

constraints_to_str()[source]

Convert the constraints into a human-readably pandas.Series.

class FOX.armc.ParamMapping(data, move_range=array([[0.9, 0.905, 0.91, 0.915, 0.92, 0.925, 0.93, 0.935, 0.94, 0.945, 0.95, 0.955, 0.96, 0.965, 0.97, 0.975, 0.98, 0.985, 0.99, 0.995, 1.005, 1.01, 1.015, 1.02, 1.025, 1.03, 1.035, 1.04, 1.045, 1.05, 1.055, 1.06, 1.065, 1.07, 1.075, 1.08, 1.085, 1.09, 1.095, 1.1  ]]), func=<ufunc 'multiply'>, **kwargs)[source]

A Mapping for storing and updating forcefield parameters.

Besides the implementation of the Mapping protocol, this class has access to four main methods:

Note that __call__() will internally call all other three methods.

Examples

>>> import pandas as pd

>>> df = pd.DataFrame(..., index=pd.MultiIndex(...))
>>> param = ParamMapping(df, ...)

>>> idx = param.move()
move_range

An 1D array with all allowed move steps.

Type:np.ndarray[np.float64], shape \((n,)\)
func

The callable used for applying \(\phi\) to the auxiliary error. The callable should take an two floats as arguments and return a new float.

Type:Callable
_net_charge

The net charge of the molecular system. Only applicable if the "charge" is among the passed parameters.

Type:float, optional
CHARGE_LIKE: ClassVar[FrozenSet[str]] = frozenset({'charge'})

A set of charge-like parameters which require a parameter re-normalization after every move.

identify_move(param_idx)[source]

Identify and return a random parameter and move size.

Parameters:param_idx (int) – The name of the parameter-containg column.
Returns:The index of the to-be moved parameter, it’s value and the size of the move.
Return type:tuple[tuple[str, str, str], float, float]
clip_move(idx, value)[source]

Ensure that value falls within a user-specified range.

Parameters:
Returns:

The newly clipped value of the moved parameter.

Return type:

float

apply_constraints(idx, value, param_idx)[source]

Apply further constraints based on idx and value.

Performs an inplace update of this instance.

Parameters:
  • idx (tuple[str, str, str]) – The index of the moved parameter.
  • value (float) – The value of the moved parameter.
  • param_idx (int) – The name of the parameter-containg column.