IMLCV.new_yaff namespace#

Submodules#

IMLCV.new_yaff.ff module#

class IMLCV.new_yaff.ff.YaffFF(*, system, md_engine)#

Bases: MyPyTreeNode

compute(gpos=False, vtens=False)#
Return type:

tuple[EnergyResult, tuple[EnergyResult, Array]]

static create(md_engine)#
md_engine: NewYaffEngine#
replace(**updates)#

Returns a new object replacing the specified fields with new values.

system: YaffSys#

IMLCV.new_yaff.iterative module#

Base class for iterative algorithms

class IMLCV.new_yaff.iterative.AttributeStateItem(*, key, value)#

Bases: StateItem

get_value(iterative)#
replace(**updates)#

Returns a new object replacing the specified fields with new values.

class IMLCV.new_yaff.iterative.CellStateItem(*, key, value)#

Bases: StateItem

get_value(iterative)#
key: str = 'cell'#
replace(**updates)#

Returns a new object replacing the specified fields with new values.

class IMLCV.new_yaff.iterative.ConsErrStateItem(*, key, value)#

Bases: StateItem

get_value(iterative)#
replace(**updates)#

Returns a new object replacing the specified fields with new values.

class IMLCV.new_yaff.iterative.Hook(*, name='hook', kind='base', method='none', start=<factory>, step=<factory>)#

Bases: MyPyTreeNode

expects_call(counter)#
kind: str = 'base'#
method: str = 'none'#
name: str = 'hook'#
replace(**updates)#

Returns a new object replacing the specified fields with new values.

start: Array#
step: Array#
class IMLCV.new_yaff.iterative.PosStateItem(*, key, value)#

Bases: StateItem

get_value(iterative)#
key: str = 'pos'#
replace(**updates)#

Returns a new object replacing the specified fields with new values.

class IMLCV.new_yaff.iterative.StateItem(*, key, value)#

Bases: MyPyTreeNode

get_value(iterative)#
Return type:

Any

key: str#
replace(**updates)#

Returns a new object replacing the specified fields with new values.

update(iterative)#
value: Any#

IMLCV.new_yaff.npt module#

IMLCV.new_yaff.nvt module#

IMLCV.new_yaff.system module#

class IMLCV.new_yaff.system.YaffCell(*, rvecs)#

Bases: MyPyTreeNode

static create(sp)#
property nvec#
replace(**updates)#

Returns a new object replacing the specified fields with new values.

rvecs: Array#
property volume#
class IMLCV.new_yaff.system.YaffSys(*, numbers, masses, pos, cell, charges=None)#

Bases: MyPyTreeNode

cell: YaffCell#
charges: Array | None = None#
static create(md, tic)#
masses: Array#
property natom#
numbers: Array#
pos: Array#
replace(**updates)#

Returns a new object replacing the specified fields with new values.

property sp#

IMLCV.new_yaff.utils module#

Auxiliary routines for initial velocities

IMLCV.new_yaff.utils.angular_moment(pos, vel, masses)#

Compute the angular moment of a set of point particles

Arguments:

Return type:

Array

pos

An (N, 3) array with atomic positions.

vel

An (N, 3) array with atomic velocities.

masses

An (N,) array with atomic masses.

Returns: a (3,) array with the angular momentum vector.

IMLCV.new_yaff.utils.angular_velocity(ang_mom, iner_tens, epsilon=1e-10)#

Derive the angular velocity from the angular moment and the inertia tensor

Arguments:

Return type:

Array

ang_mom

An (3,) array with angular momenta.

iner_tens

A (3, 3) array with the inertia tensor.

Optional arguments:

epsilon

A threshold for the low eigenvalues of the inertia tensor. When an eigenvalue is below this threshold, it is assumed to be zero plus some (irrelevant) numerical noise.

Returns: An (3,) array with the angular velocity vector.

In principle these routine should merely return:

jnp.linalg.solve(inter_tens, ang_mom).

However, when the inertia tensor has zero eigenvalues (linear molecules, single atoms), this routine will use a proper pseudo inverse of the inertia tensor.

IMLCV.new_yaff.utils.cell_lower(rvecs)#

Transform the cell tensor to its lower diagonal form. The transformation is described here https://lammps.sandia.gov/doc/Howto_triclinic.html, bearing in mind that YAFF stores cell vectors as rows, not columns.

Arguments:

Return type:

tuple[Array, Array]

rvecs

A [3x3] NumPy array representing a cell tensor

Returns:

newrvecs

A [3x3] NumPy array representing a lower-diagonal form of rvecs

rot

A [3x3] matrix representing the rotation matrix to go from rvecs to newrvecs

IMLCV.new_yaff.utils.cell_symmetrize(ff, vector_list=None, tensor_list=None)#

Symmetrizes the unit cell tensor, and updates the position vectors

Arguments:

Return type:

tuple[Array, Array, list[Array], list[Array]]

ff

A ForceField instance

Optional arguments:

vector_list

A list of numpy vectors which should be transformed under the symmetrization. Note that the positions are already transformed automatically

tensor_list

A list of numpy tensors of rank 2 which should be transformed under the symmetrization.

IMLCV.new_yaff.utils.clean_momenta(pos, vel, masses, cell)#

Remove any relevant external momenta

Arguments:

Return type:

tuple[Array, Array]

pos

An (N, 3) array with atomic positions. This array is not modified.

vel

An (N, 3) array with atomic velocities. This array is modified in-place.

masses

An (N,) array with atomic masses

cell

A Cell instance describing the periodic boundary conditions.

IMLCV.new_yaff.utils.get_ndof_baro(dim, anisotropic, vol_constraint)#

Calculates the number of degrees of freedom associated with the cell fluctuation

Arguments:

Return type:

int

dim

The dimension of the system

anisotropic

Boolean value determining whether anisotropic cell fluctuations are allowed

vol_constraint

Boolean value determining whether the cell volume can change

IMLCV.new_yaff.utils.get_ndof_internal_md(natom, nper)#

Return the effective number of internal degrees of freedom for MD simulations

Arguments:

Return type:

int

natom

The number of atoms

nper

The number of periodic boundary conditions (0 for isolated systems)

IMLCV.new_yaff.utils.get_random_vel(temp0, scalevel0, masses, key, select=None)#

Generate random atomic velocities using a Maxwell-Boltzmann distribution

Arguments:

Return type:

Array

temp0

The temperature for the Maxwell-Boltzmann distribution.

scalevel0

When set to True, the velocities are rescaled such that the instantaneous temperature coincides with temp0.

masses

An (N,) array with atomic masses.

Optional arguments:

select

When given, this must be an array of integer indexes. Only for these atoms (masses) initial velocities will be generated.

Returns: An (N, 3) array with random velocities. When the select option is used, the shape of the results is (M, 3), where M is the length of the select array.

IMLCV.new_yaff.utils.get_random_vel_press(mass, temp, key)#

Generates symmetric tensor of barostat velocities

Arguments:

Return type:

Array

mass

The Barostat mass

temp

The temperature at which the velocities are selected

IMLCV.new_yaff.utils.inertia_tensor(pos, masses)#

Compute the inertia tensor for a given set of point particles

Arguments:

Return type:

Array

pos

An (N, 3) array with atomic positions.

masses

An (N,) array with atomic masses.

Returns: a (3, 3) array containing the inertia tensor.

IMLCV.new_yaff.utils.remove_angular_moment(pos, vel, masses)#

Zero the global angular momentum.

Arguments:

Return type:

tuple[Array, Array]

pos

An (N, 3) array with atomic positions. This array is not modified.

vel

An (N, 3) array with atomic velocities. This array is modified in-place.

masses

An (N,) array with atomic masses

The zero angular momentum is achieved by subtracting angular rigid body motion from the atomic velocities. (The angular momentum is measured with respect to the center of mass to avoid that this routine reintroduces a linear COM velocity. This is also beneficial for the numerical stability.)

IMLCV.new_yaff.utils.remove_com_moment(vel, masses)#

Zero the linear center-of-mass momentum.

Arguments:

Return type:

Array

vel

An (N, 3) array with atomic velocities. This array is modified in-place.

masses

An (N,) array with atomic masses

The zero linear COM momentum is achieved by subtracting translational rigid body motion from the atomic velocities.

IMLCV.new_yaff.utils.rigid_body_angular_velocities(pos, ang_vel)#

Generate the velocities of a set of atoms that move as a rigid body.

Arguments:

Return type:

Array

pos

An (N, 3) array with atomic positions.

ang_vel

An (3,) array with the angular velocity vector of the rigid body.

Returns: An (N, 3) array with atomic velocities in the rigid body. Note that the linear momentum is zero.

IMLCV.new_yaff.utils.stabilized_cholesky_decomp(mat)#

Do LDL^T and transform to MM^T with negative diagonal entries of D put equal to zero Assume mat is square and symmetric (but not necessarily positive definite).

Return type:

Array

IMLCV.new_yaff.verlet module#