ensembler.conditions package

Submodules

ensembler.conditions.box_conditions module

class ensembler.conditions.box_conditions._boundaryCondition(system: system = None, tau: int = 1, verbose: bool = False)[source]

Bases: ensembler.conditions._basicCondition._conditionCls

This parent class is defining some functions for the actual box conditions.

higherbounds: Iterable[numbers.Number]
lowerbounds: Iterable[numbers.Number]
class ensembler.conditions.box_conditions.boxBoundaryCondition(boundary: Union[Iterable[numbers.Number], Iterable[Iterable[numbers.Number]]], every_step: int = 1, system: system = None, verbose: bool = False)[source]

Bases: ensembler.conditions.box_conditions._boundaryCondition

__init__(boundary: Union[Iterable[numbers.Number], Iterable[Iterable[numbers.Number]]], every_step: int = 1, system: system = None, verbose: bool = False)[source]

box boundary condition This class can be used to define a box, which is restrictiring the phase space to its boundaries. Warning: This is not a very useful condition in most cases as the hard boundary leads to box effects in the simulation. We rather suggest the using the periodic boundary condition. Useage: Add this class as condition to a system.

Parameters
  • boundary (Union[Iterable[Number], Iterable[Iterable[Number]]]) – defines the bounds of the system (in 3D-MD = box). Give here for each dimension the extrem coordinates.

  • system (systemType, optional) – here a system can be given, normally this argument is not needed, as the system is coupling itself, if the condition is passed on construction to the system.

apply(current_position: Union[Iterable[numbers.Number], numbers.Number], current_velocity: Union[Iterable[numbers.Number], numbers.Number])[source]

apply function interface. Needs to be implemented. - takes all needed parameters

apply_coupled()[source]

Applies the box Condition to the coupled system.

name: str = 'Box Boundary Condition'
class ensembler.conditions.box_conditions.periodicBoundaryCondition(boundary: Union[Iterable[numbers.Number], Iterable[Iterable[numbers.Number]]], every_step: int = 1, system: system = None, verbose: bool = False)[source]

Bases: ensembler.conditions.box_conditions._boundaryCondition

__init__(boundary: Union[Iterable[numbers.Number], Iterable[Iterable[numbers.Number]]], every_step: int = 1, system: system = None, verbose: bool = False)[source]
periodic boundary condition

This class allows to enable sampling in mirror images and projects the coordinates to the restricted space. Add this class as condition to a system.

Useage: Add this class as condition to a system.

Parameters
  • boundary (Union[Iterable[Number], Iterable[Iterable[Number]]]) – defines the bounds of the system (in 3D-MD = box). Give here for each dimension the extrem coordinates.

  • system (systemType, optional) – here a system can be given, normally this argument is not needed, as the system is coupling itself, if the condition is passed on construction to the system.

apply(current_position: Union[Iterable[numbers.Number], numbers.Number]) → Union[Iterable[numbers.Number], numbers.Number][source]

apply the periodic boundary condition :Parameters: * current_position (Union[Iterable[Number], Number]) – current system position

  • current_velocity (Union[Iterable[Number], Number]) – current systems velocity

Returns

new position

a new position in the defined space

Return type

Union[Iterable[Number], Number]

apply_coupled()[source]

Applies the box Condition to the coupled system.

name: str = 'Periodic Boundary Condition'
verbose: bool = False

ensembler.conditions.restrain_conditions module

class ensembler.conditions.restrain_conditions.Restraint(system: system = None, tau: int = 1, verbose: bool = False)[source]

Bases: ensembler.conditions._basicCondition._conditionCls

class ensembler.conditions.restrain_conditions.positionRestraintCondition(position_0: Union[numbers.Number, Iterable[numbers.Number]], every_step: int = 1, restraint_functional: potential = <class 'ensembler.potentials.OneD.harmonicOscillatorPotential'>, system: system = None, verbose: bool = False)[source]

Bases: ensembler.conditions.restrain_conditions.Restraint

The position restraint is adding a bias to a certain position selected in the coordinate space

__init__(position_0: Union[numbers.Number, Iterable[numbers.Number]], every_step: int = 1, restraint_functional: potential = <class 'ensembler.potentials.OneD.harmonicOscillatorPotential'>, system: system = None, verbose: bool = False)[source]
__init__

builds the bias to a certain position_0 in the coordinate space, which is applied every_step

Parameters
  • position_0 (Union[Number, Iterable[Number]]) – coordinate space position

  • every_step (int, optional) – apply bias every_step. (default=1)

  • restraint_functional (potentialType, optional) – potential function for the bias (default: harmonic oscillator)

  • system (systemType, optional) – system to couple to (default: None -> not coupled)

  • verbose (bool, optional) – shall I tell you a story?

apply(current_position: Union[Iterable[numbers.Number], numbers.Number]) → Tuple[numbers.Number, numbers.Number][source]
apply

applies the condition

Parameters

current_position (Union[Iterable[Number], Number]) – the current to position to bias

Returns

the potential energy bias, the force bias.

Return type

Tuple[Number, Number]

apply_coupled() → NoReturn[source]

apply the condition to the coupled system.

functional: potential
name: str = 'position restraint'
position_0: Union[numbers.Number, Iterable[numbers.Number]]

ensembler.conditions.thermostats module

class ensembler.conditions.thermostats.andersonThermostat(temperature: float = 298, temperature_noise_range: float = 25, MConstraintsDims: int = 1, system: system = None, tau: int = 1, kb=8.31446261815324, a: float = 1, k: float = 1, N_dens: float = 0.005, N: float = 1, verbose: bool = False)[source]

Bases: ensembler.conditions.thermostats.thermostat

-UnderConstuction- andersenThermostat

This thermostat was developed by anderson 1980 and is also called stochastic collisions method. This method is optimal for single particle simulations as it tries to simulate a particle that collides with virtual particles from a temperature bath. At each collision, the velocity and the interval of the next collision is randomly reassigned and reselected from a Maxwell-Boltzmann distribution. This applying the thermostat leads to an at least microcanonical Simulation. Simulated energies should be gaussian distributed.

[Molecular Modelling Principles and Applications, A. R. Leach, second edition] FIX MAXWWELL POSITIONING!

N: float = 10
N_dens: float = 0.1
__init__(temperature: float = 298, temperature_noise_range: float = 25, MConstraintsDims: int = 1, system: system = None, tau: int = 1, kb=8.31446261815324, a: float = 1, k: float = 1, N_dens: float = 0.005, N: float = 1, verbose: bool = False)[source]

__This Thermostat is underconstruction! __

Parameters
  • temperature (float, optional) – desired temperature

  • temperature_noise_range (float, optional) – noise range

  • MConstraintsDims

  • system (system, optional) – a system, that shall be thermostated

  • tau (int, optional) – every n step apply thermostat

  • kb (float, optional) – boltzman constant

  • a (float, optional) – collision parameter

  • k (float, optional) – collision parameter

  • N_dens (float, optional) – virtual particle density

  • N (int, optional) – virtual particle number

  • verbose (bool, optional) – I can be loud and noisy!

a: float = 1
apply_coupled()[source]

apply_coupled function interface. Needs to be implemented if you want to use the condition with a system. takes the coupled system and passes the correct parameters to apply.

k: float = 1
kb: float = 8.31446261815324
temperature: float
temperature_noise_range: float
class ensembler.conditions.thermostats.berendsenThermostate(tau: float, dt: float, MConstraintsDims: int = 1, system: system = None, verbose: bool = False)[source]

Bases: ensembler.conditions.thermostats.thermostat

__init__(tau: float, dt: float, MConstraintsDims: int = 1, system: system = None, verbose: bool = False)[source]

__under contsruction! __ This thermostat is not tested, no guarantee for correctness!

reference: Molecular dynamics with coupling to an external bath; H.J.C. Berendsen

Parameters
  • tau (int, optional) – apply every n steps.

  • dt (float, optional) – time step

  • MConstraintsDims (int, optional) – number of dimensions

  • system (system, optional) – a target system to be thermostated

  • verbose (bool, optional) – More output? You want more output?

_calculate_current_temperature()[source]

autofunction: _calculate current Temperature (eq. 32,33) :return:

_calculate_scaling_factor()[source]
autofunction: _calculate_scaling_factor

(eq.34)

Returns

apply_coupled()[source]

apply_coupled function interface. Needs to be implemented if you want to use the condition with a system. takes the coupled system and passes the correct parameters to apply.

class ensembler.conditions.thermostats.thermostat(system: system, tau: int, verbose: bool = False)[source]

Bases: ensembler.conditions._basicCondition._conditionCls

Thermostat

This is the parent class of Thermostats. The apply function of this class is not implemented and needs to be overwritten by each subclass.

Module contents

Conditions that get applied to a system simulation. Like Thermostats, position restraints or periodic boundary conditions.