maxwelllink.em_solvers.meep module¶
Meep-specific EM units and coupling utilities for MaxwellLink.
Provides conversions between Meep units and atomic units, plus helpers for source construction and field integrations.
- class maxwelllink.em_solvers.meep.MeepSimulation[source]¶
Bases:
SimulationA wrapper of
meep.Simulationwith MaxwellLink features.This extends Meep’s simulation to couple with quantum models via MaxwellLink.
- molecules¶
Wrapped molecules coupled to the EM grid.
- Type:
list of MoleculeMeepWrapper
- time_units_fs¶
Time unit in femtoseconds for unit conversions.
- Type:
float
- __init__(hub=None, molecules=None, time_units_fs=0.1, **kwargs)[source]¶
Initialize the simulation and wrap molecules with Meep adapters.
- Parameters:
hub (
SocketHubor None, optional) – Socket hub for driver communication.molecules (list or None, optional) – Molecules to couple; will be wrapped as
MoleculeMeepWrapper.time_units_fs (float, default: 0.1) – The Meep time unit expressed in femtoseconds.
**kwargs – Additional keyword arguments forwarded to
meep.Simulation.
- static __new__(cls, *args, **kwargs)¶
- Parameters:
args (Any)
kwargs (Any)
- Return type:
Any
- run(*user_step_funcs, **kwargs)[source]¶
Run the simulation with optional user step functions and stopping conditions.
Notes
If molecules are present, a MaxwellLink coupling step is automatically inserted (socket or non-socket variant as appropriate) before user-provided step functions.
- Parameters:
*user_step_funcs – One or more per-step callables.
**kwargs – Passed through to
meep.Simulation.run(e.g.,until=...).
- class maxwelllink.em_solvers.meep.MeepUnits[source]¶
Bases:
DummyEMUnits- __init__(time_units_fs=0.1)[source]¶
Meep unit system with conversions to/from atomic units.
- Parameters:
time_units_fs (float, default: 0.1) – The Meep time unit expressed in femtoseconds.
- efield_em_to_au(Emu_vec3)[source]¶
Convert the regularized electric-field integral from Meep units to atomic units.
Notes
This helper is used directly by the Meep backend.
- Parameters:
Emu_vec3 (array-like of float, shape (3,)) – Regularized field integral in Meep units.
- Returns:
Field integral in atomic units.
- Return type:
numpy.ndarray of float, shape (3,)
- source_amp_au_to_em(amp_au_vec3)[source]¶
Convert source amplitude (a.u.) to Meep units.
- Parameters:
amp_au_vec3 (array-like of float, shape (3,)) – Source amplitude vector in atomic units.
- Returns:
Source amplitude vector in Meep units.
- Return type:
numpy.ndarray of float, shape (3,)
- time_em_to_au(time_em)[source]¶
Convert Meep time to atomic units.
- Parameters:
time_em (float) – Time in Meep units.
- Returns:
Time in atomic units.
- Return type:
float
- units_helper(dx, dt)[source]¶
Explain the Meep unit system and its connection to atomic units.
This prints a summary of conversions based on the current resolution and Courant factor.
- Parameters:
dx (float) – Spatial grid spacing in Meep units.
dt (float) – Time step size in Meep units.
- Raises:
RuntimeError – If the Courant factor is not
0.5.
- class maxwelllink.em_solvers.meep.MoleculeMeepWrapper[source]¶
Bases:
MoleculeDummyWrapperWrapper that adapts a
Moleculeto Meep, handling units, sources, and IO.- __init__(time_units_fs=0.1, dt=None, molecule=None)[source]¶
Initialize the Meep molecule wrapper.
- Parameters:
time_units_fs (float, default: 0.1) – The Meep time unit expressed in femtoseconds.
dt (float or None, optional) – Time step in Meep units; if provided, propagated to the molecule.
molecule (Molecule) – The molecule to wrap and couple to Meep.
- calc_amp_vector()¶
Compute and return the current source amplitude vector from the molecule.
- Returns:
Source amplitudes in atomic units.
- Return type:
numpy.ndarray of float, shape (3,)
- initialize_driver(assigned_id)¶
Initialize the wrapped molecule’s driver (non-socket mode).
Notes
Uses the molecule’s cached
dt_aubut changes itsmolecule_idfromassigned_id.- Parameters:
assigned_id (int)
- propagate(efield_vec3)¶
Propagate the wrapped molecule for one EM step.
- Parameters:
efield_vec3 (array-like of float, shape (3,)) – Effective electric field vector in atomic units.
- maxwelllink.em_solvers.meep.update_molecules(hub, molecules, sources_non_molecule=None)[source]¶
MPI-safe step function aligned with the no-MPI version and streaming sources.
- Parameters:
hub (
SocketHub) – Socket hub for driver communication.molecules (list of MoleculeMeepWrapper) – Molecules to couple.
sources_non_molecule (list or None, optional) – Additional Meep sources unrelated to molecules.
- Returns:
A step function compatible with
meep.Simulation.run.- Return type:
callable
- maxwelllink.em_solvers.meep.update_molecules_no_mpi(hub, molecules, sources_non_molecule=None)[source]¶
Create a Meep step function (sockets, no MPI) that couples molecules to the EM grid.
- Parameters:
hub (
SocketHub) – Socket hub for driver communication.molecules (list of MoleculeMeepWrapper) – Molecules to couple.
sources_non_molecule (list or None, optional) – Additional Meep sources unrelated to molecules.
- Returns:
A step function compatible with
meep.Simulation.run.- Return type:
callable
- maxwelllink.em_solvers.meep.update_molecules_no_socket(molecules, sources_non_molecule=None)[source]¶
Create a Meep step function (no sockets) that couples molecules to the EM grid.
- Parameters:
molecules (list of MoleculeMeepWrapper) – Molecules to couple.
sources_non_molecule (list or None, optional) – Additional Meep sources unrelated to molecules.
- Returns:
A step function compatible with
meep.Simulation.run.- Return type:
callable