maxwelllink.mxl_drivers.python.batch.md_gpu module¶
GPU-batched classical molecular-dynamics (MD) driver for the aggregated socket hub, with thousands of independent MD systems (same force field and topology) advance together.
- class maxwelllink.mxl_drivers.python.batch.md_gpu.MDGPUBatchModel[source]¶
Bases:
DummyBatchModelVectorized classical-MD batch model: the aggregated-hub front end of the shared
MDEngine.- __init__(*, num, driver_kwargs, backend=None, driver_args=None, store_additional_data=False)[source]¶
Initialize a batch of identical MD systems.
- Parameters:
num (int) – Number of MD systems in the batch; must be positive.
driver_kwargs (mapping) – Keyword arguments of the scalar
MDModeldriver, e.g.{"ff": "co2jcp2021", "thermostat": "nve", "pre_nvt": True}; they are forwarded to the shared engine unchanged.backend ({'cpu', 'gpu', None}, default: None) – The backend choice, matching
matter.MDand the scalarMDModel:'gpu'runs the CUDA kernels through CuPy,'cpu'runs the same compiled physics through numba on the host, andNone(auto) picks the GPU when CuPy reaches a CUDA device.driver_args (sequence, optional) – Positional arguments of the scalar
MDModeldriver.store_additional_data (bool, default: False) – Accepted for parity with the other batch models. The extras are always built, because the cavity solvers read the dipole from them.
- Raises:
ValueError – If
numis not positive, orverboseis enabled.
- append_additional_data()[source]¶
Return per-system dicts matching
MDModel.append_additional_data.- Returns:
One dictionary per system with
time_au,energy_au,potential_au, the half-step dipole (mux_au/muy_au/muz_au) and the force-time dipole (mux_m_au/muy_m_au/muz_m_au).- Return type:
list of dict
- Raises:
RuntimeError – If called before
initialize().
- append_additional_data_columns(keys)[source]¶
Return the requested additional-data fields as one contiguous block.
The engine already holds every field as an array, so this copies only the columns the hub asked for and never builds a dictionary per system.
- Parameters:
keys (sequence of str) – Field names to return, in column order.
- Returns:
The requested fields, one row per system.
- Return type:
numpy.ndarray of float, shape (num, len(keys))
- Raises:
KeyError – If a requested field is not one this driver reports.
- initialize(dt_au, molecule_ids)[source]¶
Allocate the batch state and optionally restore a checkpoint or pre-equilibrate.
- Parameters:
dt_au (float) – The shared time step in atomic units (a.u.).
molecule_ids (array-like of int) – Molecule IDs assigned by the hub; must number exactly
num.
- load_checkpoint(filename=None)[source]¶
Restore the batch state written by
save_checkpoint().- Parameters:
filename (str, optional) – Source path. Defaults to a name built from the first molecule ID.
- Raises:
ValueError – If the checkpoint holds a differently shaped batch.
- save_checkpoint(filename=None)[source]¶
Write the whole batch state to one
.npzfile.- Parameters:
filename (str, optional) – Target path. Defaults to a name built from the first molecule ID.
- step(efield_au)[source]¶
Advance every system by one OBABO velocity-Verlet step under the field.
- Parameters:
efield_au (numpy.ndarray of float, shape (num, 3)) – Contiguous host array of effective electric field vectors in a.u.
- Returns:
Columnar amplitude (
dmu/dt), half-step dipole, force-time dipole, and energy for every system – the same four fields asBatchStepResult, which is all the bridge reads.- Return type: