maxwelllink.matter.md package¶
Built-in classical molecular dynamics in MaxwellLink
- class maxwelllink.matter.md.MD[source]¶
Bases:
objectA single standalone classical-MD simulation.
Example
>>> co2 = MD(ff="co2jcp2021", n_molecules=1, dt_fs=0.25) >>> co2.equilibrate(duration_ps=2.0, temperature_K=300.0) >>> result = co2.run(duration_ps=10.0, thermostat="nve") >>> frequency_cm, intensity = result.ir_spectrum()
- __init__(ff='qtip4pf', n_molecules=None, xyz=None, positions=None, box=None, replicate=None, rcut=None, ewald_wrcut=None, dt_fs=0.5, temperature_K=300.0, friction_fs=100.0, init_velocities=True, backend='cpu', force_evaluator='auto', seed=0, verbose=False, *, property_filename=None, property_list='base', traj_filename=None, traj_content='positions', record_every_steps=10, record_max_steps=None)[source]¶
Initialize the MD Engine.
- Parameters:
ff (str or DummyForceField, default: 'qtip4pf') – A registered force-field name (
'qtip4pf'flexible water,'co2jcp2021'flexible CO2,'cs2compass'flexible CS2,'ch4compass'flexible CH4; list them all withmaxwelllink.matter.available_force_fields()) or a ready-made user-defined force-field instance.n_molecules (int, optional) – Number of molecules of a default-built geometry, before any
replicate.Nonekeeps each force field’s own default (the bundled 32-water / 36-CO2 / 36-CS2 / 100-CH4 bulk boxes).xyz (str, optional) – XYZ file (Angstrom) with the starting geometry, atoms ordered as the force field expects.
positions (array-like of float, shape (n_atoms, 3), optional) – Starting geometry in Bohr; overridden by
xyz.box (float or array-like of float, shape (3,), optional) – Periodic box lengths in Bohr;
Nonetreats the system as a 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 cutoffs in Bohr of the periodic non-bonded and Ewald sums.
ewald_wrcut (float, optional) – Real-space cutoffs in Bohr of the periodic non-bonded and Ewald sums.
dt_fs (float, default: 0.5) – Integration time step in femtoseconds.
temperature_K (float, default: 300.0) – Default temperature: initial Maxwell-Boltzmann velocities, and the bath of
equilibrate()/ NVT runs unless they override it.friction_fs (float, default: 100.0) – Default Langevin relaxation time in femtoseconds.
init_velocities (bool, default: True) – Sample initial velocities at
temperature_K;Falsestarts at rest.backend ({'cpu', 'gpu', None}, default: 'cpu') –
'cpu'runs the compiled (numba) kernels;'gpu'runs the CUDA kernels through CuPy;Nonepicks the GPU automatically when one is reachable. The GPU integrator assigns one CUDA block per system, so a single cell usually runs fastest on the CPU, while the GPU backend shines in the many-cell batch drivers.force_evaluator ({'auto', 'numba', 'numpy'}, default: 'auto') – CPU force evaluator;
'numpy'forces the reference implementation.seed (int, default: 0) – Random seed (initial velocities and Langevin noise).
verbose (bool, default: False) – Print a short note when the cell is initialized.
property_filename (str, optional) – Filename for the property file.
property_list (str or list or tuple, default: "base") – Select “base”, “all”, or semicolon-separated property names. Lists and tuples are also accepted. Only used when
property_filenameis set.traj_filename (str, optional) – Runtime extended-XYZ output with one frame per independent system. Positions are in Angstrom, atomic velocities in Bohr per atomic time, and molecular body-frame angular velocities in inverse atomic time. Angular output automatically includes the corresponding principal moments of inertia in electron-mass times Bohr-squared units. Each molecule’s six angular-output values are repeated for all its atoms.
traj_content (str, default: "positions") – Content to record: “positions”, “velocities”, “angular_velocity_body”, or “all”. Angular output contains three angular velocities followed by three principal moments of inertia. “all” includes positions, atomic velocities, and these six angular-output columns. Velocities and angular data are sampled before the final Langevin O half-step.
record_every_steps (int, default: 10) – Record the property and trajectory files every this many production steps, independently of the arrays returned by
run().record_max_steps (int, optional) – Maximum number of records in each output file;
Nonefor no cap.
- equilibrate(duration_ps=20.0, temperature_K=None, friction_fs=None)[source]¶
Thermalize the cell with a Langevin (NVT) trajectory, in place.
Nothing is recorded; call
run()afterwards for production data.- Parameters:
duration_ps (float, default: 20.0) – Equilibration length in picoseconds.
temperature_K (float, optional) – Bath temperature; the constructor’s
temperature_Kby default.friction_fs (float, optional) – Langevin relaxation time; the constructor’s
friction_fsby default.
- Returns:
The cell itself, so calls can be chained.
- Return type:
- run(duration_ps=None, n_steps=None, thermostat='nve', temperature_K=None, friction_fs=None, field=None, record_every=1, snapshot_every=None)[source]¶
Propagate the cell and record its trajectory.
Successive calls continue from the current state, so a typical session is
equilibrate()followed by one or morerun()calls.- Parameters:
duration_ps (float, optional) – Length of the run in picoseconds. Give this or
n_steps.n_steps (int, optional) – Number of time steps; overrides
duration_ps.thermostat ({'nve', 'nvt'}, default: 'nve') – Plain velocity Verlet, or with a Langevin thermostat.
temperature_K (float, optional) – NVT bath temperature; the constructor’s value by default.
friction_fs (float, optional) – NVT Langevin relaxation time; the constructor’s value by default.
field (optional) – External electric field in atomic units:
None(field-free), a constant(3,)vector, an(n_steps, 3)table, or a callablefield(t_au) -> (3,)evaluated at the start of every step.record_every (int, default: 1) – Keep every this-many steps in the returned arrays.
snapshot_every (int, optional) – Also record the geometry and velocities every this-many steps.
- Return type:
Subpackages¶
- maxwelllink.matter.md.force_fields package
CH4COMPASSForceFieldCH4COMPASSForceField.__init__()CH4COMPASSForceField.build_force_kernels()CH4COMPASSForceField.compute()CH4COMPASSForceField.compute_fast()CH4COMPASSForceField.dipole()CH4COMPASSForceField.dipole_velocity()CH4COMPASSForceField.has_compiled_kernelsCH4COMPASSForceField.molecule_symbolsCH4COMPASSForceField.nameCH4COMPASSForceField.reported_term_names
CO2JCP2021ForceFieldCO2JCP2021ForceField.__init__()CO2JCP2021ForceField.build_force_kernels()CO2JCP2021ForceField.compute()CO2JCP2021ForceField.compute_fast()CO2JCP2021ForceField.dipole()CO2JCP2021ForceField.dipole_velocity()CO2JCP2021ForceField.has_compiled_kernelsCO2JCP2021ForceField.molecule_symbolsCO2JCP2021ForceField.nameCO2JCP2021ForceField.reported_term_names
CS2COMPASSForceFieldCS2COMPASSForceField.__init__()CS2COMPASSForceField.build_force_kernels()CS2COMPASSForceField.compute()CS2COMPASSForceField.compute_fast()CS2COMPASSForceField.dipole()CS2COMPASSForceField.dipole_velocity()CS2COMPASSForceField.has_compiled_kernelsCS2COMPASSForceField.molecule_symbolsCS2COMPASSForceField.nameCS2COMPASSForceField.reported_term_names
DummyForceFieldDummyForceField.__init__()DummyForceField.build_force_kernels()DummyForceField.compute()DummyForceField.compute_fast()DummyForceField.dipole()DummyForceField.dipole_velocity()DummyForceField.has_compiled_kernelsDummyForceField.molecule_symbolsDummyForceField.nameDummyForceField.reported_term_names
QTIP4PFForceFieldQTIP4PFForceField.__init__()QTIP4PFForceField.build_force_kernels()QTIP4PFForceField.compute()QTIP4PFForceField.compute_fast()QTIP4PFForceField.dipole()QTIP4PFForceField.dipole_velocity()QTIP4PFForceField.has_compiled_kernelsQTIP4PFForceField.molecule_symbolsQTIP4PFForceField.nameQTIP4PFForceField.reported_term_names
available_force_fields()replicate_cell()- Submodules
- maxwelllink.matter.md.kernels package