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, regression tests, and
workflows focused on one classical cavity mode. 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 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 and \(\delta_{\mathrm{DSE}} = 1\) only when include_dse=True.
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: |
|
When |
|
When |
|
When |
|
When |
Returned data¶
Calling SingleModeSimulation with record_history=True
populates:
SingleModeSimulation.time_history– time stamps in atomic units.SingleModeSimulation.qc_history– cavity coordinate \(q_c(t)\).SingleModeSimulation.pc_history– cavity momentum \(\dot{q}_c(t)\).SingleModeSimulation.drive_history– external drive values.SingleModeSimulation.molecule_response_history– summed molecular response alongcoupling_axis.SingleModeSimulation.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 maxwelllink.molecule.molecule.Molecule.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.