Meep FDTD Solver¶
The maxwelllink.em_solvers.meep backend couples MaxwellLink molecules to
Meep (pymeep) simulations. It wraps
meep.Simulation, converts between Meep units and atomic units, creates
regularized polarization sources, and shuttles electric-field integrals and
driver responses each time step.
Note
The Meep backend advances the classical Maxwell equations
with constitutive relations \(\mathbf{D} = \varepsilon_0 \varepsilon^{\ast}_{\mathrm{r}}(\mathbf{r}, \omega)\, \mathbf{E}\) and \(\mathbf{B} = \mu\, \mathbf{H}\) (typically \(\mu = \mu_0\)). Molecular sources enter through
where each spatial kernel \(\boldsymbol{\kappa}_{m}^{i}\) is normalized over the molecular volume \(\Omega_m\). The solver supplies every coupled molecule with the regularized electric field
and expects the returned dipole time derivative \(d\mu_{m}^{i}/dt\) to reconstruct \(\mathbf{J}_{\mathrm{mol}}\) self-consistently on the FDTD grid.
Requirements¶
pymeep (imported as
meep) must be installed. Import failures raise a clearImportError.Optional mpi4py support is detected automatically. When present, only the Meep master rank communicates with the molecular drivers while amplitudes are broadcast to worker ranks.
Usage¶
Socket mode¶
import meep as mp
import maxwelllink as mxl
from maxwelllink import sockets as mxs
host, port = mxs.get_available_host_port()
hub = mxl.SocketHub(host=host, port=port, timeout=10.0, latency=1e-5)
molecule = mxl.Molecule(
hub=hub,
center=mp.Vector3(0, 0, 0),
size=mp.Vector3(1, 1, 1),
sigma=0.1,
dimensions=2,
)
sim = mxl.MeepSimulation(
hub=hub,
molecules=[molecule],
time_units_fs=0.1,
cell_size=mp.Vector3(8, 8, 0),
geometry=[],
sources=[],
boundary_layers=[mp.PML(3.0)],
resolution=10,
)
# Launch the driver separately (e.g. mxl_driver --model tls --port <port> ...)
sim.run(until=90)
Non-socket mode¶
import meep as mp
import maxwelllink as mxl
molecule = mxl.Molecule(
driver="tls",
driver_kwargs=dict(
omega=0.242,
mu12=187.0,
orientation=2,
pe_initial=1e-4,
),
center=mp.Vector3(),
size=mp.Vector3(1, 1, 1),
sigma=0.1,
dimensions=2,
)
sim = mxl.MeepSimulation(
molecules=[molecule],
time_units_fs=0.1,
cell_size=mp.Vector3(8, 8, 0),
geometry=[],
sources=[],
boundary_layers=[mp.PML(3.0)],
resolution=10,
)
sim.run(until=90)
MaxwellLink inserts the appropriate coupling step automatically: sockets when
hub is provided, or embedded drivers otherwise.
Parameters¶
Name |
Description |
|---|---|
|
Optional |
|
Iterable of |
|
Meep time unit expressed in femtoseconds (default |
|
Sequence of Meep geometry objects forwarded to |
|
List of native Meep sources. Molecular sources are added automatically; this list is for additional excitations. |
|
Simulation domain size passed to |
|
List of boundary conditions (for example |
|
Spatial resolution (pixels per distance unit). Used to derive |
|
Remaining keyword arguments are forwarded verbatim to |
Returned data¶
sim.molecules– list ofMoleculeMeepWrapperinstances. Each wrapper exposes the underlyingMolecule.molecule.additional_data_history– diagnostics produced by the driver (time stamps, populations, energies, custom JSON payloads).Standard Meep data channels remain available (e.g.
sim.fields, flux regions, near-to-far field monitors).For debugging,
maxwelllink.em_solvers.meep.instantaneous_source_amplitudesstores the most recent source amplitudes per polarization fingerprint.
Notes¶
MeepSimulationenforcesCourant = 0.5. Provideresolutionand other grid parameters accordingly.MPI runs automatically confine socket communication to rank 0 while broadcasting amplitudes to all ranks; disconnections pause the solver until the hub reports reconnection.