maxwelllink.matter package¶
Standalone matter calculations with MaxwellLink’s built-in drivers.
- class maxwelllink.matter.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:
- class maxwelllink.matter.SpectrumResult[source]¶
Bases:
objectAn absorption spectrum extracted from a dipole trajectory.
- Variables:
energy_ev (numpy.ndarray, shape (n_omega,)) – Photon energy grid in eV.
strength_au (numpy.ndarray, shape (n_omega,)) – Dipole strength function
S(omega)along the kicked direction, in atomic units (1/Hartree).alpha_au (numpy.ndarray of complex, shape (n_omega, 3)) – The kicked column of the polarizability tensor, in atomic units.
method (str) –
'fft'or'pade'.damping_ev (float) – Lorentzian broadening (HWHM) applied to the signal, in eV.
- __init__(energy_ev, strength_au, alpha_au, method, damping_ev, details=<factory>)¶
- Parameters:
energy_ev (ndarray)
strength_au (ndarray)
alpha_au (ndarray)
method (str)
damping_ev (float)
details (dict)
- Return type:
None
- alpha_au: ndarray¶
- damping_ev: float¶
- details: dict¶
- energy_ev: ndarray¶
- method: str¶
- property omega_au¶
The energy grid in atomic units (Hartree).
- strength_au: ndarray¶
- maxwelllink.matter.dipole_spectrum(time_au, dipole_au, kick_au, direction='z', method='pade', damping_ev=0.1, energy_range_ev=(0.0, 10.0), n_energies=2000, subtract_initial=True, pade_max_points=5000)[source]¶
Absorption spectrum of a delta-kicked dipole trajectory.
- Parameters:
time_au (array-like of float, shape (n,)) – Uniformly spaced sample times in atomic units (an offset first sample, e.g. the drivers’ midpoint times
(k + 1/2) dt, is handled).dipole_au (array-like of float, shape (n, 3) or (n,)) – Dipole samples in atomic units. A 1D array is taken as the component along
direction.kick_au (float) – The delta-kick strength the trajectory was started with.
direction ({'x', 'y', 'z'}, default: 'z') – The kicked direction (selects the diagonal element for the strength function).
method ({'pade', 'fft'}, default: 'pade') – The discrete transform: the Pade-accelerated one of Bruner et al., or a plain damped Fourier sum.
damping_ev (float, default: 0.1) – Lorentzian broadening (HWHM): the signal is multiplied by
exp(-gamma t)withgamma = damping_ev(converted to a.u.).energy_range_ev (tuple of float, default: (0.0, 10.0)) – Photon-energy window of the output grid.
n_energies (int, default: 2000) – Number of grid points.
subtract_initial (bool, default: True) – Subtract the first dipole sample before transforming.
pade_max_points (int, default: 5000) – The Pade solve is O(n^2) in the number of samples, so trajectories longer than this are truncated first (the method’s premise is that a short signal is enough).
Noneuses every sample.
- Return type: