maxwelllink.matter.md.force_fields.cs2compass module

Flexible CS2 force field (cs2compass).

Implements the COMPASS class2 model of carbon disulfide [H. Sun, J. Phys. Chem. B 102, 7338 (1998)].

class maxwelllink.matter.md.force_fields.cs2compass.CS2COMPASSForceField[source]

Bases: DummyForceField

Flexible CS2 force field (cs2compass).

Implements the COMPASS class2 model of carbon disulfide [H. Sun, J. Phys. Chem. B 102, 7338 (1998)].

Atoms are stored in the canonical order [C, S, S, C, S, S, ...].

__init__(n_molecules=36, positions=None, box=None, replicate=None, rcut=None, ewald_wrcut=None)[source]

Initialize the cs2compass force field and build the initial geometry.

Parameters:
  • n_molecules (int, default: 36) – Number of CS2 molecules. Ignored when positions is given. With the default value 36 and no positions/box, the bundled bulk-CS2 box (cs2_36.xyz, atomic units, the LAMMPS reference starting geometry) is loaded so that a fully default force field is production-ready.

  • positions (array-like of float, shape (3 * n_molecules, 3), optional) – Initial atomic positions in Bohr, ordered [C, S, S, ...]. If None a default geometry is built with a single equilibrium molecule for n_molecules == 1, otherwise a cubic lattice inside box.

  • box (float or array-like of float, shape (3,), optional) – Periodic box lengths in Bohr. None treats the system as a finite cluster.

  • replicate (int or array-like of int, shape (3,), optional) – Replicate the periodic cell. The molecules and the box lengths grow together, so the density is unchanged.

  • rcut (float, optional) – Real-space cutoff in Bohr for the periodic LJ and Coulomb sums. Defaults to 14 Bohr (the LAMMPS pair cutoff), also clamped to half the shortest box side (14.49 Bohr in the bundled 36-CS2 box).

  • ewald_wrcut (float, optional) – Real-space cutoff in Bohr for the Ewald sum (also sets \(\alpha = \pi / \mathrm{wrcut}\) and kmax = int(alpha * max(box))). Defaults to rshort * min(0.5, 1.2 * n_atoms**(-1/6)).

build_force_kernels(xp, threads_per_block=128)[source]

Return this force field’s compiled kernels from kernels_cs2compass.

Parameters:
  • xp (module) – Array module: numpy for the CPU path, cupy for the GPU path.

  • threads_per_block (int, default: 128) – CUDA block size, ignored on the CPU path.

Returns:

The compiled force evaluator.

Return type:

kernels_cs2compass.CS2COMPASSForceKernels

compute(x, efield, terms=None)[source]

Evaluate the total cs2compass force and potential energy.

Parameters:
  • x (numpy.ndarray of float, shape (na, 3)) – Atomic positions in atomic units (Bohr).

  • efield (numpy.ndarray of float, shape (3,)) – Effective electric field [E_x, E_y, E_z] in atomic units.

  • terms (numpy.ndarray of float, shape (2,), optional) – Filled with the stretch and the bend energy when given.

Returns:

  • forces (numpy.ndarray of float, shape (na, 3)) – Total force on each atom in atomic units.

  • potential (float) – Mechanical potential energy in atomic units (Hartree).

compute_fast(x, efield, terms=None)

Evaluate the force and potential with the compiled (numba) kernels.

Physically identical to compute() but several times faster. The kernels and the output buffer are built once and reused.

Parameters:
  • x (numpy.ndarray of float, shape (na, 3)) – Atomic positions in atomic units (Bohr).

  • efield (numpy.ndarray of float, shape (3,)) – Effective electric field [E_x, E_y, E_z] in atomic units.

  • terms (numpy.ndarray of float, shape (len(reported_term_names),), optional) – Filled with the energy terms of reported_term_names when given.

Returns:

  • forces (numpy.ndarray of float, shape (na, 3)) – Total force on each atom in atomic units.

  • potential (float) – Mechanical potential energy in atomic units (Hartree).

dipole(x)[source]

Compute the molecular dipole moment from the atomic charges.

Parameters:

x (numpy.ndarray of float, shape (na, 3)) – Atomic positions in atomic units (Bohr).

Returns:

The total dipole \(\boldsymbol{\mu} = \sum_i q_i \mathbf{r}_i\) over the C and S charges, in atomic units.

Return type:

numpy.ndarray of float, shape (3,)

dipole_velocity(v)[source]

Compute the time derivative of the molecular dipole moment.

Parameters:

v (numpy.ndarray of float, shape (na, 3)) – Atomic velocities in atomic units.

Returns:

The dipole velocity \(\mathrm{d}\boldsymbol{\mu}/\mathrm{d}t = \sum_i q_i \mathbf{v}_i\) over the charges, in atomic units.

Return type:

numpy.ndarray of float, shape (3,)

has_compiled_kernels = True
molecule_symbols = ('C', 'S', 'S')
name = 'cs2compass'
reported_term_names = ('stretch_au', 'bend_au')