Single-Mode Cavity¶
The maxwelllink.em_solvers.single_mode_cavity module provides a
lightweight electromagnetic solver that replaces a full FDTD grid with a single
damped harmonic oscillator. It evolves entirely in atomic units while
supporting the same Molecule abstraction used by the Meep
backend, making it well suited for rapid prototyping. Multiple molecular dipole
components can be coupled simultaneously by supplying composite axes such as
"xy".
Note
The cavity replaces the full EM grid with canonical coordinate \(\mathbf{q}_c\) and momentum \(\mathbf{p}_c = \dot{\mathbf{q}}_c\) obeying the component-wise equation
where \(\omega_c\) is frequency_au, \(\kappa\) is damping_au, \(\varepsilon = 1/\sqrt{\epsilon_0 V}\) is coupling_strength, and \(D(t)\) is the optional external drive. The drive enters the cavity equation only when excite_ph=True (default). The sum runs over the dipole components selected by coupling_axis for each coupled molecule. The effective electric field returned to the drivers is
with \(\boldsymbol{\mu}(t)\) the summed molecular dipole restricted to the requested axes, \(\delta_{\mathrm{DSE}} = 1\) only when include_dse=True, and \(\delta_{\mathrm{exc,mol}} = 1\) only when excite_mol=True (with \(\hat{\mathbf{e}}\) the unit vector along coupling_axis).
When temperature_au > 0 and initializer="maxwell_boltzmann", the initial cavity coordinate and momentum are resampled from a Maxwell-Boltzmann distribution at temperature \(T\) (atomic units),
overriding any provided qc_initial / pc_initial. If langevin_tau_au is also supplied, a Langevin thermostat with damping time \(\tau\) is applied to the cavity momentum every step,
Requirements¶
No additional dependencies beyond the MaxwellLink Python stack are required.
Usage¶
Socket mode¶
import maxwelllink as mxl
hub = mxl.SocketHub(host="127.0.0.1", port=31415, timeout=10.0, latency=1e-5)
molecule = mxl.Molecule(hub=hub)
sim = mxl.SingleModeSimulation(
dt_au=0.5,
frequency_au=0.242,
damping_au=0.0,
molecules=[molecule],
coupling_strength=1e-4,
qc_initial=[0, 0, 1e-5],
coupling_axis="z",
hub=hub,
record_history=True,
)
sim.run(steps=4000)
Launch mxl_driver --model tls --port 31415 ... (or another driver) after running this script.
Non-socket mode¶
import maxwelllink as mxl
tls = mxl.Molecule(
driver="tls",
driver_kwargs=dict(
omega=0.242,
mu12=187.0,
orientation=2,
pe_initial=1e-4,
),
)
sim = mxl.SingleModeSimulation(
dt_au=0.5,
frequency_au=0.242,
damping_au=0.0,
molecules=[tls],
coupling_strength=1e-4,
qc_initial=[0, 0, 1e-5],
coupling_axis="z",
record_history=True,
)
sim.run(steps=4000)
Parameters¶
Name |
Description |
|---|---|
|
Integration time step in atomic units. Must be positive. |
|
Cavity angular frequency \(\omega_c\) (a.u.). |
|
Linear damping coefficient \(\kappa\) applied to the cavity momentum (a.u.). |
|
Iterable of |
|
Constant float or callable |
|
Scalar prefactor \(g\) for the molecular polarization feedback. Default: |
|
One or more dipole components to couple (case-insensitive union of |
|
Optional |
|
Initial cavity coordinate vector (sequence of three floats or scalar applied to each coupled axis). Default: |
|
Initial cavity momentum vector (a.u.). Default: |
|
Initial total molecular dipole vector prior to axis masking (a.u.). Default: |
|
Initial time derivative of the total molecular dipole vector (a.u.). Default: |
|
Cavity temperature in atomic units (Hartree), used by the optional initializer and Langevin thermostat. Default: |
|
Langevin thermostat relaxation time \(\tau\) (a.u.). When supplied, a Langevin thermostat is applied to the cavity momentum each step. Leave as |
|
Optional initial-condition sampler. Set to |
|
Seed for the RNG that drives the optional Maxwell-Boltzmann sampling and Langevin kicks. Use a fixed integer for reproducibility. Default: |
|
When |
|
When |
|
When |
|
When |
|
When |
|
When |
Returned data¶
Calling simu`=:class:`~maxwelllink.em_solvers.single_mode_cavity.SingleModeSimulation with record_history=True
populates:
simu.time_history– time stamps in atomic units.simu.qc_history– cavity coordinate \(q_c(t)\).simu.pc_history– cavity momentum \(\dot{q}_c(t)\).simu.drive_history– external drive values.simu.molecule_response_history– summed molecular response alongcoupling_axis.simu.energy_history– total energy of the cavity and coupled molecules (requiresrecord_history=True).
Each Molecule keeps
additional_data_history, which records driver
data (e.g., TLS populations, energies, timestamps). Socket drivers may
append extra JSON payloads through the hub; embedded drivers populate the same
history via append_additional_data().
Notes¶
Provide either
stepsoruntiltoSingleModeSimulation.run(), not both.Socket-mode molecules must all bind to the same
SocketHub; the simulation waits until every driver acknowledges initialization.Setting
record_history=Falseavoids list allocations for throughput-critical runs.