Solver and analysis
- solve
Calculate the waveguide modes with the finite-difference (FDM) or the finite-element (FEM) solver. The fields, effective indices, losses and TE fractions are saved as described under
FDM(), whichever solver runs.- Parameters:
solver_method (str) – ‘FDM’, ‘FEM’ or ‘bessel’ runs that solver, the same as calling
FDM()orFEM()for the first two, and sets the profile’ssolversetting to it. ‘bessel’ is the exact solver for a round step-index fiber (seesolverundersettings). ‘default’ runs the solver thesolversetting selects, without changing it. That setting is itself ‘default’ unless changed, which is the Bessel solver for a round step-index fiber that guidesnum_modesmodes with no PML set, and the FDM otherwise, default: ‘default’profile (str or int) – the stored profile to solve, in place (one saved with
label_profile()), the same oneget(profile=...)reads. An unknown name raises an error listing the stored profiles. To save a solve under a new name, calllabel_profile()after it. Withsection, the name the solved slice is stored under. Default: ‘_default’section (str) – name of an EME section to solve a slice from, instead of the profile’s own settings/shapes, default: None
propagation_distance (float) – [nm] where along
sectionto take the cross-section, default: Noneinclude_heat (bool) – whether to include the temperature change from the most recent
heat()solve, default: Trueinclude_static (bool) – whether to apply the electro-optic (Pockels) permittivity perturbation from the most recent
electrostatic()solve, default: Trueverbose (bool) – print progress, default: True
simulation_name (str) – simulation name, default: ‘emode’
- Returns:
what
FDM()orFEM()returns, for whichever solver ran.
Note
The FEM solver requires an EMode3D license, so
solve()needs one whenever it runs the FEM: withsolver_method='FEM', or with ‘default’ when the profile’ssolversetting is ‘FEM’. SeeFEMon the Multi-Physics page.
- FDM
Calculate the waveguide modes using the finite difference method. Calling
FDM()sets the profile’ssolversetting to ‘FDM’, soEME()andsweep()then use the FDM too. It automatically runsEM_meshas needed (generatingx,y,permittivity, andpermeability). After solving the mode, the effective index (effective_index), mode propagation loss (loss_dB_per_m), and field components (Fx,Fy,Ex,Ey,Ez,Hx,Hy,Hz,Sx,Sy,Sz) are available, where the fields are normalized to the equation below.\[\frac{1}{2} \mathrm{Re} \iint \left( \vec E \times \vec H^* \right) \! \cdot \! \hat{z} \, \mathrm{d}x \, \mathrm{d}y = 1 \, \mathrm{W}\]It also calculates the TE fraction of each mode (
TE_fraction) with the following equation, and it saves the indices of the TE and TM modes (TE_indicesandTM_indices).\[\mathrm{{TE_fraction}} = \frac{\iint \left| \vec E_\mathrm{x} \right|^2 \, \mathrm{d}x \, \mathrm{d}y}{\iint \left| \vec E_\mathrm{x} \right|^2 + \left| \vec E_\mathrm{y} \right|^2 \, \mathrm{d}x \, \mathrm{d}y}\]A multi-wavelength profile (a wavelength list in
settings(), or a set fromcreate_profile_set()) is solved at each of its wavelengths, and is saved as one solved profile per wavelength, soget()returns a dict keyed by wavelength andplot()andEME()use the modes at each wavelength.FEM()andsolve()do the same. The direct return value then holds every wavelength’s result, keyed by wavelength (see below).- Parameters:
profile (str or int) – the stored profile to solve, in place (one saved with
label_profile()), the same oneget(profile=...)reads. An unknown name raises an error listing the stored profiles. To save a solve under a new name, calllabel_profile()after it. Withsection, the name the solved slice is stored under. Default: ‘_default’section (str) – name of an EME section to solve a slice from, instead of the profile’s own settings/shapes, default: None
propagation_distance (float) – [nm] optional propagation distance used to compute an additional propagation phase/loss, default: None
mode_filter (str) – choose to filter the mode list for propagation direction of ‘forward’, ‘backward’, or ‘none’. It acts in the anisotropic solver only, since the isotropic solver returns forward modes by construction. It is saved in the profile’s settings, so a later
EME()orsweep()that solves this profile again uses it too. Default: ‘forward’fLanczos (int) – size of the eigensolver’s Krylov subspace as a multiple of the number of modes requested, at least 1. The default, None, is automatic: 5 vectors a mode up to 10 modes, and past 10 modes 2 more vectors a mode (
2 num_modes + 31in all), which solves many modes faster with the same effective indices. The anisotropic solver searches twicenum_modes, so its limit starts past 5 modes. An integer is used exactly as given, so raise it if a many-mode solve does not converge. It is saved in the profile’s settings likemode_filter, andFDM()without it saves None. Default: Nonesolve_type (str) – either ‘isotropic’, ‘anisotropic’, or ‘auto’ to control whether anisotropic materials are solved with the full tensor or reduced to their isotropic diagonal, default: ‘auto’
include_heat (bool) – whether to include heat-related material properties when meshing, default: True
include_static (bool) – whether to apply the electro-optic (Pockels) permittivity perturbation from the most recent
electrostatic()solve, default: Truescattering (bool) – whether to automatically calculate interfacial scattering loss for all shapes after solving. The
include_scatteringsetting insettingsdoes the same for every solve of the profile. Default: Falseverbose (bool) – print progress, default: True
simulation_name (str) – simulation name, default: ‘emode’
Note
The direct return value of this function (as called through
emodeconnection) is a dict with keysn_eff_tilde,TE_fraction,TE_indices,TM_indicesandPML_indices. The fields are not part of the return value, since they run to tens of MB for many modes. Useget()orget_fields()to read them andplot()to draw them. For a multi-wavelength profile it is aWavelengthDictof these dicts, one per wavelength, indexable like adict[float, dict](result[1550]['n_eff_tilde']). The individual field components and derived quantities described above (effective_index,loss_dB_per_m,Ex/Ey/etc.) become available afterward from the saved profile viaget()/get_fields(), not as top-level keys of this return value.
- sweep
This function sweeps a calculation as a function of any available setting, shape parameter, or section parameter (EMode3D only). Run a parameter sweep of
keyover definedvaluesby solvingsolve_typefor each value and saving a list of parameters defined by ‘result’ that correspond to thevalues. After running a sweep, the data will be available from a parameter calledsweep_data, which includes all of the specified parameters of this funcion and the data specified by theresultparameter. Theresultparameter can include any parameter that is listed in theinspect()output (after running the desired simulation). Additionally, theresultparameter can include ‘scattering_loss’ (a sum of all scattering losses for each mode) or ‘mode_order’ (a list of mode indices used for tracking the order of the modes).- Parameters:
key (str) – any settings, shape, or section parameter that will have its value changed in the sweep, directly specify the key for settings parameters, specify ‘shape, SHAPE_NAME, SHAPE_KEY’ to specify the SHAPE_KEY of SHAPE_NAME in the default profile, specify ‘shape, PROFILE_NAME, SHAPE_NAME, SHAPE_KEY’ for a shape of the labeled profile PROFILE_NAME (a sweep of it runs
solve_type='EME', the profile reaching the result through the sections built on it), specify ‘section, SECTION_NAME, SECTION_KEY’ to specify the SECTION_KEY of SECTION_NAME. The accepted section keys are ‘length’, ‘num_modes’, ‘minimum_z_step’, ‘overlap_variation’, ‘z_slices’, ‘offset’, ‘window_width’, ‘window_height’, and ‘facet_angle’ (the tilt [degrees] of an angled facet on that section, seemake_angled_facet_port()). Any other section key raises an error naming it. A shape’setch_depth,sidewall_angleandtoneare swept as ‘shape, SHAPE_NAME, etch_depth’ and so on.values (list or array) – the values that define the
keyduring the sweepsolve_type (str) – either ‘mesh’, ‘FDM’, or ‘EME’ to specify which solver to run at each sweep step, where ‘FDM’ means a mode solve with the solver the
solversetting selects (the FDM or the FEM), default: automatically chosen based on thekeyandresultselectionresult (str or list) – the parameters to save from each iteration of the sweep. This can be any value in the eph file. Internally, this calls
get, so if you can read the value withgetyou can collect it withsweep. Additionally, ‘scattering_loss’, ‘mode_order’ and ‘monitor_coupling’ are accepted. ‘monitor_coupling’ collectsmonitor_couplingfor the monitor named bymonitorand the beam described bybeam. With akeythat is one of the beam’s arguments (‘angle’, ‘mode_field_diameter’, ‘center’, ‘index’ or ‘polarization’) the solved chain is reused and only the overlap is evaluated at each value, with no solve, andsweep_dataalso carriespower_through_planeandoverlap. Any other key needssolve_type='EME'and solves the chain at each value. default: ‘effective_index’seed (bool) – whether to seed each solve step with the previous step’s mode list, default: True
adaptive (bool) – only for a wavelength sweep.
valueskeeps its meaning (the wavelengths you want results at), andadaptivechanges only where the solver runs: modes are matched between neighboring solves through a phase-corrected overlap, and a bisection in wavelength places further solves until the mode list stops moving by more thantolerance, or the gap reachesminimum_step. The requested wavelengths are then filled in by interpolating the solved mode lists, which is much cheaper than solving every point when the modes vary smoothly.sweep_dataadditionally carriessolved_wavelengths(where the solver actually ran) andunconverged(any stretch the sampler gave up on, reported rather than raised). Default: Falsetolerance (float) – with
adaptive, the largest mode-list change tolerated between adjacent solves, default: 1e-3minimum_step (float) – [nm] with
adaptive, the smallest wavelength gap the sampler will bisect into, default: the spacing ofvaluesmethod (str) – either ‘direct’ or ‘interpolated’. ‘interpolated’ is only for
key='wavelength'withresult='S_matrix'(EMode3D only): the circuit is solved and refined once at the current wavelength withEME, every cross-section in it is solved atnum_nodeswavelengths (Chebyshev-Lobatto nodes, ends included) overwavelength_range, and the S-matrix at each ofvaluesis rebuilt from the propagation constants and junctions interpolated between them, so no wavelength invaluessolves anything. It suits the hundreds of wavelengths a resonator spectrum needs. A mode that cannot be followed across the range keeps its solve at the current wavelength (its effective index and its junction coupling) at every wavelength, with a warning naming its cross-sections, so the result at the current wavelength is always the solved circuit. One node is predicted from the others:sweep_dataadditionally carriesnum_nodes,interpolation_residual(the largest error at that node in a slice’s propagation phase factor or in a junction’s S-matrix element) andinterpolation_residuals(the node’s wavelength, the slice and junction errors, and the largest error of the whole circuit’s S-matrix). A warning naming the slice or junction is logged wheninterpolation_residualexceedsinterpolation_tolerance. The whole circuit’s error is not checked, since a narrow resonance moved by a small fraction of its width changes it by order one. Default: ‘direct’num_nodes (int) – with
method='interpolated', the number of wavelengths every cross-section is solved at, at least 4. Add nodes, or narrow the range, wheninterpolation_residualis too large, default: 8wavelength_range (tuple[float, float]) – [nm] with
method='interpolated', the range the nodes span, which must contain every one ofvalues, default: the range ofvaluesinterpolation_tolerance (float) – with
method='interpolated', the largestinterpolation_residualaccepted without a warning, default: 1e-4monitor (str) – with
result='monitor_coupling', the name of the monitor (seemonitor), default: Nonebeam (dict) – with
result='monitor_coupling', the keyword arguments ofmonitor_couplingthat describe the beam,mode_field_diameterat least, for examplebeam=dict(mode_field_diameter=10.4e3). A beamkeyoverrides its entry here at each value, default: Nonesimulation_name (str) – simulation name, default: ‘emode’
- converge
Find the resolution, window, PML thickness or number of modes a result needs.
converge()variessettingone step at a time, solving the profile at each step, and watches one quantity of one mode, thetarget. It stops once the target has settled to withintolerance, prints one row per solve and returns the history. The profile’s settings change only withapply=True, so the table can be read first. It runs in every license tier.Each setting is varied in its own way:
'resolution':x_resolutionandy_resolutiontogether, from 20 cells per wavelength in the highest-index material, finer by a factor of \(\sqrt{2}\) a step. Each step is rounded down so a whole number of cells fills the window and, where the shapes allow, every shape edge lies on a grid line. Withsolver='FEM'it variesfem_points_per_wavelengthfrom 1 in the same ratio, withfem_max_refinements=0so the routine and not the FEM’s own refinement sets each step.'window':window_widthandwindow_height, from the core (every shape bounded on all four sides) plus three decay lengths \(1 / (k_0 \sqrt{n_\mathrm{eff}^2 - n_\mathrm{clad}^2})\) of the cladding, growing by one decay length on each side a step. The window stays centered on the core, and an axis folded byboundary_conditionstays centered on its mirror plane. On a bend, the outer side starts beyond the caustic \(n_\mathrm{eff} R / n_\mathrm{clad}\).'pml':pml_thicknesson every side with a PML, from one wavelength in the cladding, growing by half a wavelength a step. With the FEM it starts no thinner than the PML’s imaginary depth (seepml_thicknessundersettings). It needs a PML (pml_NSEW_bool).'modes':num_modes, doubling until the watched mode is among the modes confined to the window rather than to the PML.'all': the window on the coarsest grid, the PML (when one is on), the resolution, the number of modes, then one more check of the window at the final grid.
The rule that stops it depends on how the setting converges. The resolution converges algebraically, so each step’s error is estimated as \(|\Delta_k| / (r^p - 1)\), from the change \(\Delta_k\) since the previous step, the refinement ratio \(r\) and the order \(p\) observed over the last three steps (between 1 and 4, read correctly when the two refinements differ). The x and y resolutions each refine by a ratio of their own, so the estimate is read along each axis and the larger is kept. Three values cannot tell which axis carries the error, and the larger reading keeps the estimate from falling below it. A window and a PML converge exponentially, so the estimate is the change itself. The routine stops as
'converged'once the estimated error is at or below the tolerance on two consecutive steps, and reports the last step’s settings. A change that flips sign between two consecutive steps stops it as'oscillating', since a sequence that alternates has not converged whatever its size. The orthogonality target is the largest overlap between two modes (asorthogonalitycomputes it), which must fall below the tolerance rather than settle, and a run that stops improving it ends as'stalled'.max_solvesormax_timerunning out ends a run as'budget'. So does a step the routine predicts it cannot afford: before each step it estimates the step’s time and memory from the solves before it (the cells grow as the step asks, and the time and the factorization’s memory grow with them as the last two solves show), and it does not start a step that would passmax_timeor need more thanmax_memory. The run then keeps the finest settings it solved, and the result’smessagenames the budget and the step.The watched mode is followed from one step to the next by its overlap, not by its place in the mode list, so a PML mode that moves ahead of it does not change what is watched. A step with no mode overlapping the watched one above 0.9 stops the run as
'lost mode'. One mode of a degenerate pair (a round fiber, a square core) can come back in another polarization from one solve to the next, so fold such a window withboundary_conditionbefore converging it.- Parameters:
setting (str) – ‘resolution’, ‘window’, ‘pml’, ‘modes’ or ‘all’, default: ‘resolution’
target (str) – ‘effective_index’, ‘group_index’ (from
group_index), ‘loss’ (loss_dB_per_m, with the scattering loss wheninclude_scatteringis set) or ‘orthogonality’, default: ‘effective_index’tolerance (float) – the largest acceptable estimated error, absolute for ‘effective_index’ (default 1e-4), ‘group_index’ (1e-3) and ‘orthogonality’ (1e-6), and relative for ‘loss’ (1e-2)
apply (bool) – write the chosen settings to the profile, default: False
max_solves (int) – the most solves to make, across every setting of ‘all’, default: 20
max_time (float) – [s] the most time to take, default: None (no limit)
max_memory (float) – [GB] the most memory one solve may need, default: three quarters of the machine’s physical memory
mode (int) – the mode to watch, an index into the first solve’s mode list, default: 0
profile (str) – the profile to converge, default: ‘_default’
simulation_name (str) – simulation name, default: ‘emode’
- Returns:
a
ConvergenceResultwithstatus,chosen(the chosen settings, assettingstakes them),history(one row per solve:setting,value,settings,quantity,change,estimated_errorandseconds),stages(one per setting varied, with its status, its chosen settings and, for the resolution, its observedorder),message(why a run that did not converge stopped, empty otherwise) andseconds.print(result)prints the table again. The same result is saved on the profile asconvergence.
The guide of the Straight Waveguide Convergence example, a 2000 x 200 nm SiN core in SiO2 at 980 nm, has a known effective index, 1.6874538. Converging its resolution to 1e-4:
em.settings(wavelength=980, window_width=7000, window_height=4200, num_modes=1, boundary_condition='TE', background_material='SiO2') em.shape(name='core', material='SiN', width=2000, height=200, position=[0, 2100]) result = em.converge('resolution', 'effective_index', tolerance=1e-4)
setting value n_eff change est. error time (s) resolution 23.81 nm 1.686959 - - 0.6 resolution 16.67 nm 1.687108 1.5e-04 7.5e-04 0.8 resolution 11.9 nm 1.687301 1.9e-04 4.8e-04 1.8 resolution 8.475 nm 1.687368 6.7e-05 8.5e-05 3.0 resolution 6.024 nm 1.687412 4.3e-05 7.9e-05 6.8 resolution 4.274 nm 1.687433 2.1e-05 2.2e-05 13.0 resolution: converged (x_resolution=4.273504273504273, y_resolution=4.166666666666667, estimated error 2.2e-05, order 2.00) converged at 0.0001 absolute in 27.9 s
The x resolutions divide the 500 nm lattice of the core’s side walls and the y resolutions the 200 nm lattice of its top and bottom, so every edge lies on a grid line. Each row shows the estimate made when its grid was solved. The y resolution carries most of the error of this 200 nm thick core, and read along y the estimates are within a few percent of the true distances from the reference. The x reading is the larger at 6.0 nm, where it puts the 8.5 nm grid at 1.2e-4 (true 8.5e-5), so the run takes one more grid than the y reading alone would. The chosen 4.3 nm grid is 2.1e-5 from the reference.
em.converge('resolution', 'effective_index', tolerance=1e-4, apply=True)would also setx_resolutionandy_resolutionto those values.
- confinement
Calculate confinement factor of specified shape. By default, only the area of the shape that is used to define the refractive index profile is included in the confinement factor. For instance, if another shape with a higher priority overlaps the specified shape, the overlapped area is not included. The confinement factors are also returned by this function. For a multi-wavelength profile, the return value is a dict keyed by wavelength.
- Parameters:
profile (str) – profile name, default: ‘_default’
shape_list – name (from
shape) or list of names of shapes to include in confinement or ‘all’ for all shapes, default: ‘all’mode_list (str or list) – desired modes to calculate confinement, ‘all’, ‘TE’, ‘TM’, or a list of the desired mode indices, default: ‘all’
vertices (list (Nx2)) – list of vertices that define a closed polygon, specifying this parameter will override the
shape_listinput, default: Noneignore_priority (bool) – toggle ignoring overlapped shapes with higher priority, default: False
simulation_name (str) – simulation name, default: ‘emode’
- effective_area
Calculate the effective areas for all modes. After running this function, an array called
effective_areawill become available andreportwill display the effective areas. Theeffective_areais also returned by this function and is in units of \(\mu\text{m}^2\). For a multi-wavelength profile, the return value is a dict keyed by wavelength.\[A_\mathrm{eff} = \frac{\left( \iint \left| \vec E \right|^2 \, \mathrm{d}x \, \mathrm{d}y \right)^2}{\iint \left| \vec E \right|^4 \, \mathrm{d}x \, \mathrm{d}y} \, \mu\text{m}^2\]- Parameters:
profile (str) – profile name, default: ‘_default’
simulation_name (str) – simulation name, default: ‘emode’
- orthogonality
Calculate the highest value of mode overlap between modes in the mode list. After running this function, a variable called
maximum_overlapwill become available in metadata of the named (or default) profile, and themaximum_overlapis returned by this function. For a multi-wavelength profile, the return value is a dict keyed by wavelength. Ideally, this value is less than \(10^{-3}\), indicating an accurate mode list.- Parameters:
profile (str or int) – profile name, default: ‘_default’
simulation_name (str) – simulation name, default: ‘emode’
- group_index
Calculate the group index for all modes.
group_indexsolves the profile first if it is not solved, then finds each mode’s group index from that one solve: the frequency derivative of the mode’s propagation constant, from the mode’s fields and the frequency derivative of the solver’s operator with the materials’ dispersion, \(n_g = c \, \mathrm{d}\beta / \mathrm{d}\omega\). It agrees with a difference of two more solves to about \(10^{-8}\), for the FDM and the FEM. A mode whose loss is more than \(10^{-3}\) of its effective index (a mode of the PML), and every mode of a transformation-optics bend, takes a second solve at 0.01 % longer wavelength instead, with a note in the log. Withmethod='difference'every mode does. After running this function, an array calledgroup_indexwill become available andreportwill display the group index. Thegroup_indexarray is also returned by this function. For a multi-wavelength profile, the return value is a dict keyed by wavelength.- Parameters:
profile (str) – profile name, default: ‘_default’
method (str) – ‘field’ (from the one solve) or ‘difference’ (a forward difference with a second solve at 1.0001 times the wavelength), default: ‘field’
simulation_name (str) – simulation name, default: ‘emode’
- dispersion
Calculate the group index, the group-velocity dispersion and the dispersion parameter of every mode from one solve. The GVD needs the first-order change of each mode with frequency as well, which is one linear solve with the solver’s operator, not a second mode solve. Returns a dict with:
'group_index': asgroup_indexreturns it'GVD': \(\beta_2 = \mathrm{d}^2\beta / \mathrm{d}\omega^2\) in ps2/km'D': \(D = -\frac{2 \pi c}{\lambda^2} \beta_2\) in ps/(nm km)'method': per mode,'field'for a result from the one solve, or'difference'for a mode whose group index took a second solve (seegroup_index), whose GVD is then NaN
For a multi-wavelength profile, the return value is a dict keyed by wavelength. For the dispersion of a mode the field method does not cover,
sweepthe wavelength.- Parameters:
profile (str) – profile name, default: ‘_default’
simulation_name (str) – simulation name, default: ‘emode’
- report
Display a simulation report table with information about each mode:
mode number
effective index
TE fraction
loss (dB/m)
a
PMLcolumn when the profile was solved with a PML, marking the modes that carry less than 75% of their power inside the window (seePML_indicesandwindow_confinementin Variable Descriptions)per-shape confinement factors and scattering loss (if calculated)
effective areas (if calculated)
The line above the table gives the wavelength and the mode solver that produced the modes, for example
Wavelength: 1550.0 nm Solver: FEM. A saved CSV records both below the table.Returns the table as a dictionary keyed by profile name, each table holding one list per column. A multi-wavelength profile returns one table per wavelength, keyed by wavelength. An unsolved profile returns an empty table.
- Parameters:
profile (str) – profile name, default: ‘_default’
save (bool) – whether to save the table to a file or not, default: False
file_name (str) – name of the file to save, default: ‘mode_report’
file_type (str) – file type to save, ‘txt’, ‘latex’, or ‘csv’, default: ‘txt’
simulation_name (str) – simulation name, default: ‘emode’
- label_profile
Saves a copy of the default profile (settings, shapes, mesh and any solved modes) under
namein theprofilesdictionary of the simulation file, meshing it first if needed. A multi-wavelength profile is saved whole, with each member meshed and keeping its own name. Named profiles are read withprofile=NAMEinget,get_fields,get_grid,get_shapeandget_profile, and one wavelength of a multi-wavelength one withprofile='NAME.WAVELENGTH'. They are the inputs tooverlap,mode_orderand the EME section functions, andresetchanges one only when given its name.- Parameters:
name (str) – save the current simulation state to this name, default: ‘0’
simulation_name (str) – simulation name, default: ‘emode’
- overlap
Calculate overlap integral between two modes. The result is returned by this function and saved on the profile named by
profile_b, whereget('overlap', profile=profile_b)reads the latest result andget('overlaps', profile=profile_b)a record of every overlap computed against it (see Variable Descriptions).Coldren, Larry A., Scott W. Corzine, and Milan L. Mashanovitch, ‘’Diode lasers and photonic integrated circuits,’’ John Wiley & Sons, 2012.
\[\mathrm{overlap} = \frac{4 n_\mathrm{eff,1} n_\mathrm{eff,2}}{(n_\mathrm{eff,1} + n_\mathrm{eff,2})^2} \frac{\left| \iint \vec E_1 \times \vec H_2 \, \mathrm{d}x \, \mathrm{d}y \right|^2}{\iint \left| \vec E_1 \times \vec H_1 \right| \, \mathrm{d}x \, \mathrm{d}y \, \iint \left| \vec E_2 \times \vec H_2 \right| \, \mathrm{d}x \, \mathrm{d}y}\]- Parameters:
profile_a (str or int) – label of first profile, default: ‘_default’
mode_a (int) – mode number from the first profile, default: 0
simulation_name_a (str) – simulation name for the first mode set, default: ‘emode’
profile_b (str or int) – label of second profile, default: ‘_default’
mode_b (int) – mode number from the second profile, default: 0
simulation_name_b (str) – simulation name for the second mode set, default: ‘emode’
- farfield
The far field of a mode, normalized to 1 W in the mode. The transverse E on the plane is decomposed into plane waves in the profile’s background material, its angular spectrum. Each direction of travel is labeled by its direction cosines
uxanduy, the sines of its angles from the axis along x and y. The far field in each direction follows from stationary phase, and the field on a screen at a finite distance is the plane-wave sum itself (the Rayleigh-Sommerfeld solution), so it holds at any distance, including within a wavelength of the plane. Withport, the mode leaves the solved chain through that port, and the axis points away from the chain. Otherwise it is a mode ofprofiletraveling along +z.Only E radiates, so the result is exact for a field already in the uniform medium and close for a weakly guiding mode: the fundamental mode of SMF-28 radiates 0.997 of its 1 W, and its far field matches the Hankel transform of the exact HE11 field within 5e-6 of the peak. A mode whose index is far above the background radiates less than would cross a real facet into it.
- Parameters:
mode (int) – the mode, default: 0
port (str or None) – an external port of the chain solved by
EME, such as ‘left’ or ‘right’, default: None (a mode ofprofile)profile (str) – the profile whose mode radiates when
portis None, default: ‘_default’wavelength (float or None) – [nm] which of a multi-wavelength profile’s or chain’s wavelengths to use, the nearest one present, default: None (the first)
screen (Screen or None) – a plane screen to evaluate the field on, default: None
max_angle (float or None) – [degrees] the largest angle from the axis sampled along x and y, at most 90, default: None (eight standard deviations of the angular spectrum)
num_angles (int) – the directions sampled along each axis, default: 201
simulation_name (str) – simulation name, default: ‘emode’
Returns a
FarField:ux,uy: the direction cosines sampled. Directions withux**2 + uy**2 > 1carry no power.theta_xandtheta_yare the same as angles in degrees.fields: ‘Ex’, ‘Ey’ and ‘Ez’, each of shape (len(ux), len(uy)), the far field timesr exp(j k r)[V]. For a left port, z points away from the chain.intensity: the radiant intensity [W/sr], andcut('x')orcut('y')its angles and values along one axis.radiated_power: [W] its integral over the directions sampled.divergence: [degrees] the half-angles along x and y from the second moments of the intensity,arcsin(2 sigma_u), which is a Gaussian beam’s 1/e2 half-angle,lambda / (pi n w0).m_squared: the beam quality factor M2 along x and y from the second moments of the near field and its angular spectrum (ISO 11146). It is 1 for a Gaussian beam,2m + 1along the axis of ordermof a Hermite-Gauss beam, and 1.036 for the fundamental mode of a step-index fiber.waistandwaist_position: [nm] the embedded waist radius along x and y (twice the second-moment width), and its distance ahead of the plane (negative behind it).centroid: [nm] the near field’s intensity centroid (x, y).screen: with a screen, aScreenField: the positionssandt[nm] along the screen’s axes, the same pointsx,y,z[nm] in the plane’s frame,fieldswith all six components (‘Ex’ … ‘Hz’, V/m and A/m),Sn[W/m2] the Poynting flux through the screen along itsnormal, andpower_through_screen[W].
FarField.plot()draws the intensity against the angles, its two cuts and, with a screen, the flux on the screen, with matplotlib in the client’s own Python.A
Screensitsdistance[nm] ahead of the plane atcenter(x, y) [nm], by default the near field’s centroid. It spanswidthandheight[nm] along its own axes u and v, sampled atpoints(one number, or one per axis, default: 101).tilt(degrees) turns it bytilt[0]about y, tipping its normal toward +x, then bytilt[1], tipping it toward +y. Untilted, u is x and v is y. No part of it may lie behind the plane.import emodeconnection as emc ff = em.farfield(mode=0, screen=emc.Screen(distance=100e3, width=60e3, height=60e3)) print(ff.divergence, ff.m_squared) ff.plot()
- mode_order
Calculate mode ordering between two mode lists. The result is returned as a list.
- Parameters:
profile_a (str or int) – label of first profile, default: ‘’
profile_b (str or int) – label of second profile, default: ‘’
raw_fields (bool) – use the raw (un-normalized) field data for the ordering comparison instead of the interpolated fields, default: False
simulation_name (str) – simulation name, default: ‘emode’
- scattering
Calculates the scattering loss from a specified shape and mode using the Volume Current Method [1]. Results are saved in the variables
SHAPE.metadata['scattering_vertical_edges'](total loss from all vertical interfaces),SHAPE.metadata['scattering_horizontal_edges'](total loss from all horizontal interfaces),SHAPE.metadata['scattering_sum'](total scattering loss),SHAPE.metadata['edges'](list of edge points for calculating scattering loss), andSHAPE.metadata['scattering_all_edges'](scattering loss from corresponding edges). The fields are read at the edge itself, as the limit from outside the shape: the tangential components, which are continuous there, and the normal component of the cladding’s side. An FEM solve reads them from its elements, so the loss does not depend onx_resolutionory_resolution, and converges withfem_resolution. An FDM solve extrapolates them to the edge from the two cells beside it, and converges with the grid. This is the value that EMode 1.0.7 and earlier, which read the fields one grid cell outside the edge, approached as the grid was refined. A shape withroughness_field_side='inside'reads them as the limit from inside it instead. The normal component there is smaller by the ratio of the cladding’s permittivity to the shape’s, so the sidewall loss is lower. For a slab, the loss agrees with Payne and Lacey’s result within 1 %. The scattering results are also returned by this function as a dictionary keyed by shape name. For a multi-wavelength profile, the return value is a dict keyed by wavelength.What is modeled:
Edges. Every edge of the outline of a shape with roughness (
roughness_rmsandcorrelation_lengthset withshape), except an edge that lies on the window boundary, such as the bottom of a slab that fills the window’s lower edge. Each edge radiates independently, so the losses of the edges add.Vertical, horizontal and angled edges. A vertical edge (a sidewall) takes the first of a pair of
roughness_rmsandcorrelation_lengthvalues, and a horizontal edge (a top or bottom surface) the second. An angled edge, such as a sloped sidewall, takes the first value. Its loss is computed twice, once as a vertical wall over the edge’s vertical extent and once as a horizontal surface over its horizontal extent, and the two are weighted by \(\sin^2\theta\) and \(\cos^2\theta\), with \(\theta\) the edge’s angle from the horizontal. An edge steeper than 45 degrees counts towardscattering_vertical_edges, a shallower one towardscattering_horizontal_edges. A value per edge, in the order of the outline’s vertices, sets each edge on its own.Roughness statistics. The roughness varies along the propagation direction only, with an exponential autocorrelation \(R(u) = \sigma^2 e^{-|u|/L_c}\), where \(\sigma\) is
roughness_rmsand \(L_c\) iscorrelation_length. Its power spectrum is the Lorentzian \(\tilde{R}(\Omega) = 2 \sigma^2 L_c / (1 + L_c^2 \Omega^2)\), evaluated at the mismatch between the mode’s propagation constant and the component along the guide of each radiated wave’s wave vector.
The loss is in dB/m of power. With
include_scattering=Trueit is part ofloss_dB_per_m, and withEME_settings(apply_scattering=True)an EME section applies it.[1] T. Barwicz and H. A. Haus, “Three-dimensional analysis of scattering losses due to sidewall roughness in microphotonic waveguides,” J. Lightwave Technol. 23, 2719 (2005).
- Parameters:
profile (str) – profile name, default: ‘_default’
shape (str) – name of the shape for calculating the interfacial scattering, can also be a list of shapes or None (which calculates scattering for all shapes), default: None
shapes (str) – alias for shape
mode_list – mode number, list of mode numbers, or ‘all’, default: ‘all’
simulation_name (str) – simulation name for the second mode set, default: ‘emode’
- plot
Interactive plot for the fields (if available), refractive index, and shapes, or saving a plot. Colorbars are in V/nm for the electric fields, A/nm for the magnetic fields, and W/nm2 for the Poynting vectors.
For EME plots in the ‘z-x’ or ‘z-y’ planes, the data dropdown also offers an ‘Outline’ view that displays a geometry-only outline of the declared sections. Once sections are declared with
straight_section(),pwd_section(),taper_section(),bend_section()orgds_section(), callingplot()before runningEME()shows only the ‘Outline’ view, which is useful to check the section layout before solving. AfterEME()has run, ‘Outline’ is available alongside the field components.A plot of a \(\chi^{(2)}\) section uses the declared
excitationrather than a unit mode, because conversion depends on power. Each slice is drawn from the forward amplitudes recorded along it, so the generated wavelength builds along the guide instead of stepping at slice boundaries. Without a declared excitation the field shown is the small-signal response, and the solver says so.- Parameters:
component (str or None) – field component or index, ‘Ex/y/z’, ‘Hx/y/z’, ‘Sx/y/z’, ‘Index’ or ‘Shapes’, default: None (‘Ex’, or ‘Index’ for a circuit with a closed loop)
plot_function (str) – plotting function, one of ‘real’, ‘imag’, ‘abs’, ‘abs^2’ or ‘log’, default: ‘real’
mode (int) – mode number, default: 0
aspect_ratio (str or float) – the height:width aspect ratio, ‘norm’ uses the normal aspect ratio of 0.707, ‘real’ uses the real aspect ratio defined by the simulation window, or a float specifies the aspect ratio, default: ‘norm’
index_outline (bool) – setting index outline, default: True
text_display (bool) – setting text display, default: True
mesh_display (bool) – setting mesh display: the finite-difference grid for an FDM solve, or the triangle mesh for an FEM solve (in the cross-section view), default: False
window_display (bool) – setting window display, default: False
legend (bool) – setting inclusion of a legend on the index and shape plots, default: True
port (int or str) – (EME) the input port that the field is excited from, either a port index or a port name (see
Port), default: 0plane (str) – (EME) plot cross-section plane setting. For 2D simulations, this defaults to ‘x-y’. For 3D simulations, it accepts ‘x-y’, ‘z-x’, or ‘z-y’. The ‘z-y’ panel also draws the plane of each
monitor, default: ‘z-x’slice_position (float or None) – (EME) location of the third dimension for a cross-section display. For example, if plane is ‘z-x’, then the slice_position refers to the y-position of the cross-section. If None, it reduces the third dimension with the reduction selected in the plot window’s slice menu: ‘sum’ (default), which totals the field across the fixed transverse axis, ‘mean’, which averages it, ‘abs sum’, which totals the field’s magnitude, so it cannot cancel where the field has transverse phase structure and shows a non-negative envelope with no longitudinal fringes, or ‘abs sum (approximate)’, which draws the same from each mode’s magnitude summed across the axis, exact for one mode, approximate where modes of different shapes interfere, and faster. The reduction is chosen in the window only and is not an argument of
plot(). Default: Noneforward_only (bool) – (EME) render only the forward-propagating component of the field instead of the total (forward + backward) field. This only changes the display decomposition of the already-solved field and does not re-solve, default: False
wavelength (float) – (EME) which wavelength’s field to render on a multi-wavelength circuit, such as the pump or the second harmonic of a \(\chi^{(2)}\) section. Default: None, the circuit’s first wavelength
resolution (float or str) – (EME) sample spacing in nm along the propagation axis for the ‘z-x’/’z-y’ longitudinal panels, where smaller is finer and ‘auto’ picks a spacing of roughly one sample per horizontal display pixel, default: ‘auto’
excitation (str) – (EME) render the field launched by a free-space field declared with
free_space_field, instead of unit amplitude inmodeatport. It also selects which port the field is viewed at. This is the only API surface for viewing one. In the plot window, the same choice appears in the Mode menu as'<name> (free space)'. Default: Noneview (str) – (EME) what the ‘z-x’ panel shows, either ‘layout’ (every section where its connections place it on the chip, bends turning and sections after a turn turned with them, both axes in um) or ‘simulation’ (the circuit unrolled along its length, as solved), or ‘schematic’ (a block diagram of the circuit’s sections and connections, which needs no solve, see circuit views), default: ‘layout’. The ‘Physical space’ checkbox in the plot window switches between them. Field components follow the guide on the layout, while ‘Index’ and ‘Shapes’ stay unrolled. A circuit with a closed loop (a ring closed with
connect_ports) has no field reconstruction yet: its ‘z-x’ panel draws the layout outline only, ‘Index’ and ‘Shapes’ show its cross-sections, and asking for a field component raises an error.blend_slices (bool) – (EME) blend adjacent slices’ fields linearly for a smooth picture of the ‘z-x’ and ‘z-y’ panels, or draw each slice from its own basis alone (False). It is also a checkbox in the plot window’s Settings menu. Default: True
contours (bool or None) – draw the field contours (True) or not (False). It is also a checkbox in the plot window’s Settings menu. Default: None (on for the ‘x-y’ plane, off for the ‘z-x’ and ‘z-y’ planes)
section (str) – (EME) zoom every view to this section, by name. An unknown name raises an error listing the sections. Default: None (the whole circuit)
normalization (str) – the field family the color scale is normalized to, ‘vector’ (the full transverse vector at the excitation plane), ‘component’ (the plotted component alone) or ‘section’ (each section of a ‘z-x’ or ‘z-y’ panel scaled by its own peak, so a dim section such as a free-space gap stays visible), default: ‘vector’
profile (str or None) – render a stored profile by name instead of the EME section. Once a simulation has declared sections, the plot always follows the section, so this is the only way to view a profile saved by an earlier
label_profile()call. An unknown name raises an error listing the available profiles, default: Nonefile_name (str) – if specified, forces the function to save a file with the given parameters and will not display the interactive plot, file is saved under a directory called EM_figures, default: None
file_type (str) – file type for saving a plot, ‘pdf’ or ‘png’, default: ‘’ (no extension is added to
file_nameunless a file type is given)simulation_name (str) – simulation name, default: ‘emode’
- material_explorer
Interactive material explorer to plot the refractive indices of all available materials. The default wavelength range in the plot corresponds to the recommended range from the material reference listed below the plot. If wavelengths are specified outside this range, the model will be plotted with a dashed line instead of a solid line. User defined materials are also available.
- Parameters:
material (str) – the material the explorer opens on, a name from the material database. The window’s Material menu still switches it. An unknown name raises an error. Default: ‘SiO2’
file_name (str) – if specified, forces the function to save a file with the given parameters and will not display the interactive plot, file is saved under a directory called EM_figures, default: None
file_type (str) – file type for saving a plot, ‘pdf’ or ‘png’, default: ‘’ (no extension is added to
file_nameunless a file type is given)simulation_name (str) – simulation name, default: ‘emode’
- refractive_index
Returns the refractive index from a material name (retrieved from the internal reference list), a MaterialSpec object, or from a custom refractive index value. Optionally, the material’s reference (or citation) may be returned.
- Parameters:
material (str, MaterialSpec, float, or list) – material name, a MaterialSpec (a rotated crystal returns its 3×3 index tensor), or a float/list for a custom value. For AlGaAs, the fraction of Al relative to Ga is included in the material name separated by a comma, for example: “AlGaAs, 0.2” for a Al_{0.2}Ga_{0.8}As.
wavelength (float) – [nm] wavelength, default: 1550
reference (bool) – additionally return the citation for the material, default: False
- Returns:
[n_x, n_y, n_z] or ([n_x, n_y, n_z], reference)
- permeability
Returns the relative permeability from a material name (retrieved from the internal reference list), a MaterialSpec object, or from a custom permeability value. Optionally, the material’s reference (or citation) may be returned.
- Parameters:
material (str, MaterialSpec, float, or list) – material name, a MaterialSpec, or a float/list of 3 floats for a custom value
wavelength (float) – [nm] wavelength, default: 1550
reference (bool) – additionally return the citation for the material, default: False
- Returns:
[permeability_x, permeability_y, permeability_z] or ([permeability_x, permeability_y, permeability_z], reference)
- permittivity
Returns the relative permittivity from a material name (retrieved from the internal reference list), a MaterialSpec object, or from a custom value. For isotropic materials this is a 3-element array, and for fully anisotropic materials, such as a crystal rotated by a MaterialSpec’s
theta,phiandpsi, it is a 3×3 tensor. Optionally, the material’s reference (or citation) may be returned.- Parameters:
material (str, MaterialSpec, float, or list) – material name, a MaterialSpec, or a float/list for a custom value
wavelength (float) – [nm] wavelength, default: 1550
reference (bool) – additionally return the citation for the material, default: False
- Returns:
[eps_x, eps_y, eps_z], a 3×3 array, or the corresponding tuple with reference
- d_matrix
Returns the second-order nonlinear d-matrix of a material. Optionally, the material’s reference (or citation) may be returned.
- Parameters:
material (str) – material name
wavelength (float) – [nm] wavelength, default: 1550
reference (bool) – additionally return the citation for the material, default: False
- Returns:
d-matrix with shape (3, 6), or (d-matrix, reference)
- mesh
Generalized mesh tool for arbitrary shapes on a rectangular grid. This is called internally by
FDMif it has not already been called by the user. Generates vertices for each shape, the actual refractive index for each shape, arrays to define the center points (x,y) of the mesh grid, and the relative permittivity and permeability matrices (permittivityandpermeability).- Parameters:
profile (str) – profile name, default: ‘_default’
run_mesh (bool) – whether to actually run the meshing step now, or just mark the profile as prepared for meshing without running it, default: True
verbose (bool) – control the display of the progress bar, default: True
simulation_name (str) – simulation name, default: ‘emode’