maxwelllink.mxl_drivers.python.models.sho_model module¶
- class maxwelllink.mxl_drivers.python.models.sho_model.SHOModel[source]¶
Bases:
DummyModelA simple harmonic oscillator (SHO) classical molecular dynamics model.
This class implements a SHO model for classical molecular dynamics, which can be integrated with the MaxwellLink framework. The SHO model is characterized by its frequency, dipole moment, and orientation of the dipole moment. The velocity verlet algorithm is used for integration.
The Hamiltonian for this SHO is given by: \(H = \frac{1}{2} m \omega^2 q^2 + \frac{1}{2m} p^2 - \mu_{0} q \cdot E\)
Notes
Implementing this class is mostly for demonstration purposes. Users who want to enjoy advanced classical molecular dynamics simulations should use the LAMMPS or DFTB+ socket driver, or the ASE python driver instead.
- __init__(omega=2.4188843e-1, mu0=1.870819866e2, orientation=2, p_initial=0.0, q_initial=0.0, checkpoint=False, restart=False, verbose=False)[source]¶
Initialize the necessary parameters for the SHO classical molecular dynamics model.
- Parameters:
omega (float, default: 2.4188843e-1) – Transition frequency in atomic units (a.u.). Default is
2.4188843e-1a.u. (1.0in MEEP units with[T]=0.1 fs).mu0 (float, default: 1.870819866e2) – Dipole-coordinate coupling prefactor in atomic units (a.u.). The instantaneous dipole is \(\mu(t) = \mu_{0}\, q(t)\). Default is
1.870819866e2a.u. (0.1in MEEP units with[T]=0.1 fs).orientation (int, default: 2) – Orientation of the dipole moment; can be
0(x),1(y), or2(z).p_initial (float, default: 0.0) – Initial momentum of the oscillator.
q_initial (float, default: 0.0) – Initial position of the oscillator.
checkpoint (bool, default: False) – Whether to enable checkpointing.
restart (bool, default: False) – Whether to restart from a checkpoint if available.
verbose (bool, default: False) – Whether to print verbose output.
- append_additional_data()[source]¶
Append additional data to be sent back to MaxwellLink.
The data can be retrieved by the user via the Python interface:
maxwelllink.SocketMolecule.additional_data_history, whereadditional_data_historyis a list of dictionaries.- Returns:
A dictionary containing additional data.
- Return type:
dict
- calc_amp_vector()[source]¶
Update the source amplitude vector after propagating this molecule for one time step.
- Returns:
Amplitude vector in the form \([\mathrm{d}\mu_x/\mathrm{d}t,\ \mathrm{d}\mu_y/\mathrm{d}t,\ \mathrm{d}\mu_z/\mathrm{d}t]\).
- Return type:
numpy.ndarray of float, shape (3,)
- commit_step()¶
Commit the previewed step and return the staged amplitude.
This method applies the changes from the staged step to the internal state and returns the calculated amplitude vector.
Notes
This method should not be overridden by subclasses.
- Returns:
Amplitude vector in the form \([\mathrm{d}\mu_x/\mathrm{d}t,\ \mathrm{d}\mu_y/\mathrm{d}t,\ \mathrm{d}\mu_z/\mathrm{d}t]\).
- Return type:
numpy.ndarray of float, shape (3,)
- have_result()¶
Check if a staged step is ready to be committed.
Notes
This method should not be overridden by subclasses.
- Returns:
Whether a staged step is ready.
- Return type:
bool
- initialize(dt_new, molecule_id)[source]¶
Set the time step and molecule ID for this SHO model, and provide additional initialization for the SHO.
- Parameters:
dt_new (float) – The new time step in atomic units (a.u.).
molecule_id (int) – The ID of the molecule.
- propagate(effective_efield_vec)[source]¶
Propagate the SHO classical molecular dynamics given the effective electric field vector.
- Parameters:
effective_efield_vec (array-like of float, shape (3,)) – Effective electric field vector in the form
[E_x, E_y, E_z].
- stage_step(E_vec)¶
Stage a propagation step with the given effective electric field vector.
This method performs the propagation and calculates the amplitude vector, but does not commit the changes to the internal state. The result can be committed later using the
self.commit_stepmethod.Notes
This method should not be overridden by subclasses.
- Parameters:
E_vec (array-like of float, shape (3,)) – Effective electric field vector in the form
[E_x, E_y, E_z].