maxwelllink.matter.md.force_fields.ch4compass module¶
Flexible CH4 force field (ch4compass).
Implements the COMPASS class2 model of methane [H. Sun, J. Phys. Chem. B 102, 7338 (1998)].
- class maxwelllink.matter.md.force_fields.ch4compass.CH4COMPASSForceField[source]¶
Bases:
DummyForceFieldFlexible CH4 force field (ch4compass).
Implements the COMPASS class2 model of methane [H. Sun, J. Phys. Chem. B 102, 7338 (1998)].
Atoms are stored in the canonical order
[C, H, H, H, H, C, H, H, H, H, ...].- __init__(n_molecules=100, positions=None, box=None, replicate=None, rcut=None, ewald_wrcut=None)[source]¶
Initialize the ch4compass force field and build the initial geometry.
- Parameters:
n_molecules (int, default: 100) – Number of CH4 molecules. Ignored when
positionsis given. With the default value 100 and nopositions/box, the bundled bulk-CH4 box (ch4_100.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 (5 * n_molecules, 3), optional) – Initial atomic positions in Bohr, ordered
[C, H, H, H, H, ...]. IfNonea default geometry is built with a single equilibrium molecule forn_molecules == 1, otherwise a cubic lattice insidebox.box (float or array-like of float, shape (3,), optional) – Periodic box lengths in Bohr.
Nonetreats 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 10 Angstrom (the LAMMPS pair cutoff), also clamped to half the shortest box side (17.35 Bohr in the bundled 100-CH4 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 torshort * 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_ch4compass.- Parameters:
xp (module) – Array module:
numpyfor the CPU path,cupyfor the GPU path.threads_per_block (int, default: 128) – CUDA block size, ignored on the CPU path.
- Returns:
The compiled force evaluator.
- Return type:
- compute(x, efield, terms=None)[source]¶
Evaluate the total ch4compass 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_nameswhen 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 H 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', 'H', 'H', 'H', 'H')¶
- name = 'ch4compass'¶
- reported_term_names = ('stretch_au', 'bend_au')¶