IMLCV.base.bias

Contents

IMLCV.base.bias#

Exceptions#

EnergyError

Common base class for all non-exit exceptions.

BiasError

Common base class for all non-exit exceptions.

Classes#

EnergyResult

Base class for dataclasses that should act like a JAX pytree node.

Energy

EnergyFn

Base class for dataclasses that should act like a JAX pytree node.

PlumedEnerg

Bias

base class for biased MD runs.

CompositeBias

Class that combines several biases in one single bias.

BiasModify

Bias according to CV.

BiasF

Bias according to CV.

NoneBias

Bias according to CV.

Functions#

_zero_fun(cvs)

_constant(cvs[, val])

Module Contents#

class IMLCV.base.bias.EnergyResult(*args, **kwargs)#

Bases: IMLCV.base.datastructures.MyPyTreeNode

Base class for dataclasses that should act like a JAX pytree node.

energy: jax.Array#
gpos: jax.Array | None#
vtens: jax.Array | None#
__add__(other: EnergyResult) EnergyResult#
exception IMLCV.base.bias.EnergyError#

Bases: Exception

Common base class for all non-exit exceptions.

class IMLCV.base.bias.Energy#
external_callback = True#
manual_vtens = False#
property nl: IMLCV.base.CV.NeighbourList | None#
property cell: jax.Array | None#
Abstractmethod:

property coordinates: jax.Array | None#
Abstractmethod:

property sp: IMLCV.base.CV.SystemParams | None#
abstract _compute_coor(sp: IMLCV.base.CV.SystemParams, nl: IMLCV.base.CV.NeighbourList | None, gpos=False, vir=False) EnergyResult#
_handle_exception(e=None)#
get_vtens_finite_difference(sp: IMLCV.base.CV.SystemParams, nl: IMLCV.base.CV.NeighbourList | None, eps=1e-05, gpos=False)#
compute_from_system_params(sp: IMLCV.base.CV.SystemParams, gpos=False, vir=False, nl: IMLCV.base.CV.NeighbourList | None = None, manual_vir=None, shmap=False, shmap_kwarg=ShmapKwargs.create()) EnergyResult#
save(filename: str | pathlib.Path)#
static load(filename) Energy#
class IMLCV.base.bias.EnergyFn(*args, **kwargs)#

Bases: Energy, IMLCV.base.datastructures.MyPyTreeNode

Base class for dataclasses that should act like a JAX pytree node.

external_callback = False#
f: Callable#
_sp: IMLCV.base.CV.SystemParams | None = None#
_nl: IMLCV.base.CV.NeighbourList | None = None#
kwargs: dict#
static_kwargs: dict#
property nl#
property cell: jax.Array | None#
property coordinates: jax.Array | None#
property sp: IMLCV.base.CV.SystemParams | None#
_compute_coor(sp: IMLCV.base.CV.SystemParams, nl: IMLCV.base.CV.NeighbourList | None, gpos=False, vir=False) EnergyResult#
class IMLCV.base.bias.PlumedEnerg#

Bases: Energy

exception IMLCV.base.bias.BiasError#

Bases: Exception

Common base class for all non-exit exceptions.

class IMLCV.base.bias.Bias(*args, **kwargs)#

Bases: abc.ABC, IMLCV.base.datastructures.MyPyTreeNode

base class for biased MD runs.

collective_variable: IMLCV.base.CV.CollectiveVariable#
start: int | None#
step: int | None#
finalized: bool#
slice_exponent: float#
log_exp_slice: bool#
slice_mean: bool#
static create(*args, **kwargs)#
Abstractmethod:

update_bias(md: IMLCV.base.MdEngine.MDEngine) Bias#

update the bias.

Can only change the properties from _get_args

_update_bias() tuple[bool, typing_extensions.Self]#

update the bias.

Can only change the properties from _get_args

compute_from_system_params(sp: IMLCV.base.CV.SystemParams, nl: IMLCV.base.CV.NeighbourList | None = None, gpos=False, vir=False, chunk_size: int | None = None, shmap=False, use_jac=False, push_jac=False, rel=False, shmap_kwargs=ShmapKwargs.create()) tuple[IMLCV.base.CV.CV, EnergyResult]#

Computes the bias, the gradient of the bias wrt the coordinates and the virial.

compute_from_cv(cvs: IMLCV.base.CV.CV, diff=False, chunk_size=None, shmap=False, shmap_kwargs=ShmapKwargs.create()) tuple[jax.Array, IMLCV.base.CV.CV | None]#

compute the energy and derivative.

If map==False, the cvs are assumed to be already mapped

abstract _compute(cvs) jax.Array#

function that calculates the bias potential.

plot(name: str | None = None, traj: list[IMLCV.base.CV.CV] | None = None, dlo_kwargs=None, dlo=None, vmax=100 * kjmol, map=False, inverted=False, margin=0.1, dpi=300, T=300 * kelvin, **kwargs)#
resample(cv_grid: IMLCV.base.CV.CV | None = None, n=40, margin=0.3) Bias#
save(filename: str | pathlib.Path, cv_file: pathlib.Path | None = None)#
static load(filename) Bias#
__getstate__()#
__setstate__(statedict: dict)#
bounds_from_bias(T, sign=1.0, margin=1e-10, n=50)#
kl_divergence(other: Bias, T: float, symmetric=True, margin=0.2, sign=1.0, n=100)#
slice(T, inverted=True, vmax=None, n_max_bias=100000.0, margin=0.2, macro_chunk=10000, offset=True) dict[int, dict[tuple[int], Bias]]#
apply(cvs: list[IMLCV.base.CV.CV], shmap=False, macro_chunk_size=10000)#
class IMLCV.base.bias.CompositeBias(*args, **kwargs)#

Bases: Bias

Class that combines several biases in one single bias.

biases: list[Bias]#
fun: Callable#
classmethod create(biases: list[Bias], fun=jnp.sum) CompositeBias#
_compute(cvs)#

function that calculates the bias potential.

update_bias(md: IMLCV.base.MdEngine.MDEngine) Bias#

update the bias.

Can only change the properties from _get_args

IMLCV.base.bias._zero_fun(cvs: IMLCV.base.CV.CV)#
IMLCV.base.bias._constant(cvs: IMLCV.base.CV.CV, val: float = 0.0)#
class IMLCV.base.bias.BiasModify(*args, **kwargs)#

Bases: Bias

Bias according to CV.

fun: Callable#
bias: Bias#
kwargs: dict#
static_kwargs: dict#
classmethod create(fun: Callable, bias: Bias, kwargs: dict = {}, static_kwargs: dict = {}) BiasModify#
_compute(cvs)#

function that calculates the bias potential.

update_bias(md: IMLCV.base.MdEngine.MDEngine) Bias#

update the bias.

Can only change the properties from _get_args

__getstate__()#
__setstate__(statedict: dict)#
class IMLCV.base.bias.BiasF(*args, **kwargs)#

Bases: Bias

Bias according to CV.

g: Callable#
static_kwargs: dict#
kwargs: dict#
static create(cvs: IMLCV.base.CV.CollectiveVariable, g: Callable = _constant, kwargs: dict = {}, static_kwargs: dict = {}) BiasF#
_compute(cvs)#

function that calculates the bias potential.

class IMLCV.base.bias.NoneBias(*args, **kwargs)#

Bases: BiasF

Bias according to CV.

static create(collective_variable: IMLCV.base.CV.CollectiveVariable) NoneBias#