maxwelllink.cavity.bragg module¶
A quarter-wave Bragg (DBR) cavity builder for Meep.
- class maxwelllink.cavity.bragg.BraggResonator[source]¶
Bases:
DummyCavityA quarter-wave Bragg (DBR) cavity in 1, 2, or 3 dimensions or in cylindrical coordinates.
The mirrors are quarter-wave dielectric stacks: alternating layers of high (
n_hi) and low (n_lo) refractive index, each one quarter of the design wavelength thick inside its medium.Examples
>>> from maxwelllink.cavity import BraggResonator >>> cav = BraggResonator(omega=2320.0, units="cm-1", n_pairs=10, ... n_hi=2.0, n_lo=1.0, dimensions=1) >>> print(cav.summary())
- __init__(omega, units='cm-1', n_pairs=3, n_hi=2.0, n_lo=1.0, n_defect=1.0, defect_order=1, dimensions=1, mirror_shape='auto', lateral_size_nm=None, lateral_boundary='pml', resolution=None, pml_nm=None)[source]¶
Initialize the parameters of a quarter-wave Bragg (DBR) cavity.
- Parameters:
omega (float) – Target cavity resonance in
units.units (str, default: "cm-1") – Units of
omega: “cm-1”, “eV”, “au”, “nm”, or “um”.n_pairs (int, default: 3) – Number of quarter-wave layer pairs per mirror (the Q dial).
n_hi (float, default: 2.0) – High refractive index of the mirror stack (
n_hi > n_lo).n_lo (float, default: 1.0) – Low refractive index of the mirror stack.
n_defect (float, default: 1.0) – Refractive index of the defect gap between the mirrors.
defect_order (int, default: 1) – The gap has an optical length of
defect_orderhalf wavelengths; for ring mirrors, the core boundary sits at thedefect_order-th zero of J0 instead.dimensions (int, default: 1) – 1, 2, or 3 (layer stack along x), or
mxl.CYLINDRICAL(the (r, z) half plane;m = 0by default).mirror_shape (str, default: "auto") –
"planar"for flat mirror stacks (along x in Cartesian cells, disks along z in cylindrical ones) or"cylindrical"for concentric ring mirrors around the z axis (cylindrical cells only)."auto"resolves to"cylindrical"fordimensions=mxl.CYLINDRICALand"planar"otherwise.lateral_size_nm (float or None, optional) – Extent (nm) of the allowed region along the directions parallel to the mirrors: y (and z) in 2D/3D, the cavity radius for cylindrical cells with planar (disk) mirrors, or the cell height along z for ring mirrors. Default: 5 cavity wavelengths. Must be omitted in 1D.
lateral_boundary (str, default: "pml") –
"periodic"for an infinite planar cavity (Bloch-periodic boundaries) or"pml"for absorbing lateral boundaries (the only option for cylindrical cells).resolution (float or None, optional) – Meep resolution. Default: at least 20 pixels per wavelength in the densest medium and 8 pixels across the thinnest layer.
pml_nm (float or None, optional) – PML thickness in nm. Default: one cavity wavelength.
- property allowed_bounds_nm¶
Per-axis allowed bounds in nm, e.g.
{"x": (-704.5, 704.5)}.
- emission_setup(offset_nm=(0.0, 0.0, 0.0), component=None)[source]¶
Local-dipole (Purcell) probe of the Bragg cavity: a dipole in the defect gap, polarized parallel to the mirror planes, read out through one plane outside each mirror.
The reference is the homogeneous defect medium (
n_defect), so the LDOS ratio is exact. Same keys asDummyCavity.emission_setup.Notes
Cylindrical cells with the default ring mirrors use an on-axis z-polarized dipole (m = 0), which couples to the confined Ez mode and is regular on the axis.
Cylindrical cells with planar (disk) mirrors default to an azimuthally symmetric (m = 0) ring of radial dipole; for the m = +-1 near-axis dipole, pass
component=mp.Ertogether withm=1.- Parameters:
offset_nm (sequence of three floats, default: (0, 0, 0)) – Displacement (nm) of the dipole from the defect center.
component (Meep field component or None, optional) – Dipole orientation. Default:
mp.Ez(parallel to the mirrors) in Cartesian cells and for cylindrical ring mirrors,mp.Erfor cylindrical disk mirrors.
- estimate_driver_count(region)¶
Estimate how many socket molecules (drivers) a region needs, equal to the number of FDTD grid points inside it.
The authoritative number is written by the susceptibility hub to its
driver_count_fileonce Meep connects.Notes
The default implemented here counts the grid points of a box-shaped region (the slab of the default
place_region). This method can be optionally overridden by subclasses.- Parameters:
region (Meep geometric object) – The region returned by
place_region.- Returns:
The estimated number of drivers (grid points inside the region).
- Return type:
int
- linear_spectrum(omega_min, omega_max, units='cm-1', **kwargs)¶
Compute the far-field linear spectrum of the cavity: the probe declared by
optical_setup().This gives transmission/reflection/absorption for mirror cavities and scattering/absorption/extinction for plasmonic nanocavities.
For the local-dipole (Purcell) observables, use
purcellinstead.- Parameters:
omega_min (float) – Frequency window in
units.omega_max (float) – Frequency window in
units.units (str, default: "cm-1") – Units of the window: “cm-1”, “eV”, “au”, “nm”, or “um”.
**kwargs – Forwarded to
MeepCavityMeasurement:molecules,hub,extra_geometry,nfreq,decay_by,steps,max_time,min_time,source_amplitude, and extra Meep keyword arguments.
- Returns:
Dictionary with arrays
omega_cminv,wavelength_nm,frequency_meep, and the observables of the declared probe.- Return type:
dict
- make_simulation(molecules=None, hub=None, sources=None, extra_geometry=(), **meep_kwargs)[source]¶
Build the simulation as
DummyCavity.make_simulationdoes, after checking that a cylindrical run is consistent with its azimuthal sectorm(see_check_cylindrical_sector).Cartesian cells pass straight through.
- meep_to_nm(value_meep)¶
Convert a length from Meep units to nanometers.
- nm_to_meep(value_nm)¶
Convert a length from nanometers to Meep units.
- optical_setup()[source]¶
Optical setup of the Bragg cavity.
Planar mirrors use the generic transmission planes of
DummyCavity.optical_setup.Cylindrical (ring) mirrors use the dark-field-type scattering probe (cf.
NPoM.optical_setup): an incoming cylindrical wave from a ring source in the radial clearance outside the mirrors drives the m = 0 mode.In both cases the reference structure is a homogeneous
n_lomedium (for the defaultn_lo = 1: vacuum).
- place_molecule(hub=None, driver=None, offset_nm=(0.0, 0.0, 0.0), size_nm=None, sigma_nm=None, hotspot=None, **molecule_kwargs)¶
Create an
mxl.Moleculeinside the cavity (molecule-level coupling).The molecule sits at the cavity hotspot by default and can be shifted with
offset_nm.Its
center,size,sigma, anddimensionsare chosen consistently with the cavity grid, so the returned molecule can be passed directly tomake_simulation.Use
place_regioninstead for grid-level coupling.Notes
This method should not be overridden by subclasses.
- Parameters:
hub (
SocketHubor None, optional) – Socket hub for socket-mode molecules, exclusive withdriver.driver (str or None, optional) – Embedded driver name for non-socket molecules (e.g.
"tls"), exclusive withhub.offset_nm (sequence of three floats, default: (0, 0, 0)) – Displacement (nm) from the hotspot; only components along active axes may be nonzero. Cylindrical molecule coupling supports only an on-axis molecule, so only
(0, 0, dz)is accepted there.size_nm (float or None, optional) – Extent of the molecular polarization region along every active axis. Default: ten times
sigma.sigma_nm (float or None, optional) – Width of the regularized polarization kernel. Default: two grid points, which keeps the kernel resolvable at any resolution.
hotspot (str or None, optional) – Name of an entry in
self.hotspotsto place the molecule at, for cavities with several field maxima. Default:hotspot_center.**molecule_kwargs – Forwarded verbatim to
mxl.Molecule(e.g.driver_kwargs,rescaling_factor,polarization_type). For theanisotropicpolarization type, constructmxl.Moleculedirectly instead (it needs a three-component sigma).
- Return type:
maxwelllink.Molecule
- place_region(epsilon=1.0, hub=None, offset_nm=(0.0, 0.0, 0.0), width_nm=None, rescaling_factor=1.0, **susceptibility_kwargs)¶
Create a region of molecular medium inside the cavity (grid-level coupling), where every FDTD grid point inside the region becomes one socket molecule (TCP sockets only).
Pass the returned region to
make_simulationviaextra_geometry=[region]. Useplace_moleculeinstead for molecule-level coupling.The shape of the region is a convention of each cavity type. The default implemented here is a slab along x filling the allowed region (e.g. the defect gap of a Bragg resonator), with
width_nmshrinking the slab thickness along x.Notes
This method can be optionally overridden by subclasses whose region is not a slab (see
NPoM.place_region).- Parameters:
epsilon (float, default: 1.0) – Background permittivity of the molecular medium.
hub (
SusceptibilitySocketHubor None, optional) – Socket hub of the grid-level route.offset_nm (sequence of three floats, default: (0, 0, 0)) – Displacement (nm) of the region center from the hotspot.
width_nm (float or None, optional) – Size (nm) of the region under the cavity-specific convention (here: the slab thickness along x). Default: fill the natural region of the cavity.
rescaling_factor (float, default: 1.0) – Rescaling factor of
mp.MXLSocketSusceptibility.**susceptibility_kwargs – Forwarded to
mp.MXLSocketSusceptibility(e.g.real_field_only,timeout).
- Returns:
Pass it to
make_simulationviaextra_geometry=[region].- Return type:
mp.Block
- plot(ax=None, **kwargs)¶
Visualize the cavity structure and its optical setup.
- Parameters:
ax (matplotlib Axes or None, optional) – Axes to draw into. A new figure is created when None.
**kwargs – Forwarded to
mp.Simulation.plot2Din 2D and 3D.
- Returns:
The axes containing the plot.
- Return type:
matplotlib Axes
- purcell(omega_min, omega_max, units='cm-1', offset_nm=(0.0, 0.0, 0.0), component=None, **kwargs)¶
Compute the Purcell spectrum of the cavity.
A point dipole at the hotspot drives the cavity in one run and the homogeneous reference structure of
emission_setup()in another, and every observable is the ratio of the two runs.- Parameters:
omega_min (float) – Frequency window in
units.omega_max (float) – Frequency window in
units.units (str, default: "cm-1") – Units of the window: “cm-1”, “eV”, “au”, “nm”, or “um”.
offset_nm (sequence of three floats, default: (0, 0, 0)) – Displacement (nm) of the dipole from the hotspot.
component (Meep field component or None, optional) – Dipole orientation (e.g.
mp.Er). Default: the orientation chosen by the cavity (mp.Ez).**kwargs – Forwarded to
MeepCavityMeasurement:molecules,hub,extra_geometry,nfreq,decay_by,steps,max_time,min_time, and extra Meep keyword arguments.
- Returns:
Dictionary with arrays
omega_cminv,wavelength_nm,frequency_meep, and the Purcell observables:purcell(total decay-rate enhancement),purcell_radiative(far-field enhancement),radiative_efficiency(their ratio), plus the raw LDOS and flux arrays.- Return type:
dict
- sim_kwargs(extra_geometry=())¶
Return the generated Meep ingredients as a plain dict, for users who prefer to assemble
mp.Simulation(**kwargs)themselves.- Parameters:
extra_geometry (sequence, optional) – Geometry appended after the cavity structure.
- Returns:
Keyword arguments for
mp.Simulation:cell_size,geometry,boundary_layers,resolution, andk_pointwhen the cavity is periodic.- Return type:
dict
- summary()¶
Return a human-readable description of the generated setup (MPI Safe).