Skip to content

kups.application.md

MDParticles

Bases: Particles

Particle state for molecular dynamics simulations.

Extends :class:Particles with gradient, momenta, and derived kinematic quantities needed by MD integrators.

Attributes:

Name Type Description
position_gradients Array

Energy gradient w.r.t. positions, shape (n_atoms, 3).

momenta Array

Particle momenta, shape (n_atoms, 3).

exclusion Index[ExclusionId]

Per-particle exclusion index (defaults to one group per atom via :func:default_exclusion if not supplied).

Source code in src/kups/application/md/data.py
@dataclass
class MDParticles(Particles):
    """Particle state for molecular dynamics simulations.

    Extends :class:`Particles` with gradient, momenta, and derived
    kinematic quantities needed by MD integrators.

    Attributes:
        position_gradients: Energy gradient w.r.t. positions, shape ``(n_atoms, 3)``.
        momenta: Particle momenta, shape ``(n_atoms, 3)``.
        exclusion: Per-particle exclusion index (defaults to one group per
            atom via :func:`default_exclusion` if not supplied).
    """

    position_gradients: Array
    momenta: Array
    exclusion: Index[ExclusionId] = field(default=None, kw_only=True)  # type: ignore

    def __post_init__(self):
        if self.exclusion is None:
            object.__setattr__(self, "exclusion", default_exclusion(len(self.charges)))

    @property
    def forces(self) -> Array:
        """Negative position gradient, shape ``(n_atoms, 3)``."""
        return -self.position_gradients

    @property
    def velocities(self) -> Array:
        """Velocities derived from momenta and masses, shape ``(n_atoms, 3)``."""
        return self.momenta / self.masses[..., None]

    @property
    def kinetic_energy(self) -> Array:
        """Per-particle kinetic energy, shape ``(n_atoms,)``."""
        return particle_kinetic_energy(self.momenta, self.masses)

forces property

Negative position gradient, shape (n_atoms, 3).

kinetic_energy property

Per-particle kinetic energy, shape (n_atoms,).

velocities property

Velocities derived from momenta and masses, shape (n_atoms, 3).

MDSystems

Per-system state for molecular dynamics simulations.

Attributes:

Name Type Description
unitcell UnitCell

Unit cell geometry for each system.

temperature Array

Target temperature (K), shape (n_systems,).

time_step Array

Integration timestep (internal time units), shape (n_systems,).

friction_coefficient Array

Langevin friction (1/time), shape (n_systems,).

thermostat_time_constant Array

CSVR coupling time (time), shape (n_systems,).

target_pressure Array

Target pressure (energy/length^3), shape (n_systems,).

pressure_coupling_time Array

Barostat coupling time (time), shape (n_systems,).

compressibility Array

Isothermal compressibility (length^3/energy), shape (n_systems,).

minimum_scale_factor Array

Minimum barostat scale factor, shape (n_systems,).

unitcell_gradients UnitCell

Energy gradient w.r.t. the unit cell, stored as a :class:UnitCell (the lattice_vectors leaf holds the shape-(n_systems, 3, 3) gradient used by :attr:stress_tensor).

potential_energy Array

Total potential energy per system (eV), shape (n_systems,).

Source code in src/kups/application/md/data.py
@dataclass
class MDSystems:
    """Per-system state for molecular dynamics simulations.

    Attributes:
        unitcell: Unit cell geometry for each system.
        temperature: Target temperature (K), shape ``(n_systems,)``.
        time_step: Integration timestep (internal time units), shape ``(n_systems,)``.
        friction_coefficient: Langevin friction (1/time), shape ``(n_systems,)``.
        thermostat_time_constant: CSVR coupling time (time), shape ``(n_systems,)``.
        target_pressure: Target pressure (energy/length^3), shape ``(n_systems,)``.
        pressure_coupling_time: Barostat coupling time (time), shape ``(n_systems,)``.
        compressibility: Isothermal compressibility (length^3/energy), shape ``(n_systems,)``.
        minimum_scale_factor: Minimum barostat scale factor, shape ``(n_systems,)``.
        unitcell_gradients: Energy gradient w.r.t. the unit cell, stored as a
            :class:`UnitCell` (the ``lattice_vectors`` leaf holds the
            shape-``(n_systems, 3, 3)`` gradient used by
            :attr:`stress_tensor`).
        potential_energy: Total potential energy per system (eV), shape ``(n_systems,)``.
    """

    unitcell: UnitCell
    temperature: Array
    time_step: Array
    friction_coefficient: Array
    thermostat_time_constant: Array
    target_pressure: Array
    pressure_coupling_time: Array
    compressibility: Array
    minimum_scale_factor: Array
    unitcell_gradients: UnitCell
    potential_energy: Array

    @property
    def stress_tensor(self) -> Array:
        """Virial stress tensor, shape ``(n_systems, 3, 3)``."""
        return (
            -self.unitcell_gradients.lattice_vectors
            / self.unitcell.volume[..., None, None]
        )

stress_tensor property

Virial stress tensor, shape (n_systems, 3, 3).