Global settings

These functions change CAMFR’s global state; see Solvers and settings.

Basics

camfr.set_lambda(wavelength: complex) → None

Set the wavelength. All lengths are in the same unit, normally micrometre (Material.gain assumes it).

camfr.get_lambda() → complex

Return the wavelength. (lambda is a Python keyword, hence the get_ prefix.)

camfr.set_N(N: int) → None

Set the number of modes used in the eigenmode expansion.

camfr.N() → int

Return the number of modes used in the eigenmode expansion.

camfr.set_polarisation(pol: Polarisation) → None

Set the polarisation: TE (default) or TM.

Only used where the polarisations decouple: 2D Cartesian structures (Slab, Planar) and Circ with Bessel order 0.

camfr.get_polarisation() → Polarisation

Return the polarisation set with set_polarisation.

camfr.free_tmps() → None

Free all cached interface scattering matrices.

Saves memory, e.g. at the end of an inner loop; the matrices are recomputed when needed again. Call it between independent calculations.

camfr.free_tmp_interfaces(waveguide: Waveguide) → None

Free the cached interface matrices that involve this waveguide.

Walls and PML

camfr.set_lower_wall(wall: object) → None

Set the wall at x = 0 of subsequently defined Slabs (e.g. slab_E_wall, slab_H_wall). Default: electric wall. Slab.set_lower_wall sets it for one slab.

camfr.set_upper_wall(wall: object) → None

Set the wall at x = width of subsequently defined Slabs (e.g. slab_E_wall, slab_H_wall). Default: electric wall. Slab.set_upper_wall sets it for one slab.

camfr.set_left_wall(wall: Section_wall_type) → None

Set the left boundary of subsequently defined Sections: E_wall (default), H_wall or no_wall.

camfr.set_right_wall(wall: Section_wall_type) → None

Set the right boundary of subsequently defined Sections: E_wall (default), H_wall or no_wall.

camfr.set_lower_PML(PML: float) → None

Add a PML to the lower cladding of subsequently defined Slabs.

The first layer of the slab expression (at x = 0) gets an imaginary thickness PML*1j; PML is normally negative, for absorption. Default 0. Set it before the structures are defined.

camfr.set_upper_PML(PML: float) → None

Add a PML to the upper cladding of subsequently defined Slabs.

The last layer of the slab expression (at x = width) gets an imaginary thickness PML*1j; PML is normally negative, for absorption. Default 0. Set it before the structures are defined.

camfr.set_left_PML(PML: float) → None

Give the left cladding of subsequently defined Sections an imaginary thickness PML*1j (PML < 0 absorbs). Default 0.

camfr.set_right_PML(PML: float) → None

Give the right cladding of subsequently defined Sections an imaginary thickness PML*1j (PML < 0 absorbs). Default 0.

camfr.set_circ_PML(PML: float) → None

Give the cladding of subsequently defined Circ waveguides an imaginary thickness PML*1j (PML < 0 absorbs). Default 0.

Slab and Circ mode solvers

camfr.set_solver(solver: Solver) → None

Select the root finder for the modes of Slab and Circ waveguides.

Parameters:

solver – track (default), ADR, series, ASR or stretched_ASR. series first estimates the modes with a plane-wave expansion (set_mode_surplus sets its size) and then refines them; it suits lossy and metallic structures.

camfr.set_mode_surplus(factor: float) → None

Size of the auxiliary expansion as a multiple of N (default 1.2): plane waves of the series slab solver, default M1 of a Section.

camfr.set_low_index_core(b: bool) → None

Search for modes guided in low-index regions (default False).

Needed for metallic structures whose light travels in low-index gaps, e.g. air between metal layers: with the default, the slab solver can miss those modes.

camfr.set_precision(precision: int) → None

Set the resolution of the scan for guided modes (default 100; higher misses fewer modes but is slower).

camfr.set_precision_rad(precision: int) → None

Set the resolution of the scan for radiation modes (default 100).

camfr.set_precision_enhancement(factor: int) → None

If > 1 (default 1), rescan around each guided mode with precision*factor, to separate nearly degenerate modes.

camfr.set_dx_enhanced(dx: float) → None

Relative half-width of the rescan region of set_precision_enhancement (default 0.01).

camfr.set_degenerate(b: bool) → None

Take special care to find degenerate modes (default True).

camfr.set_orthogonal(b: bool) → None

Treat the modes as orthogonal (default True). False can improve convergence when rounding errors spoil their orthogonality.

camfr.set_chunk_tracing(b: bool) → None

Track the modes in chunks rather than all together. Default True: faster, but can lose modes, especially with strong PML absorption.

camfr.set_sweep_from_previous(b: bool) → None

Start the mode search from the modes of the previous calculation (e.g. a nearby wavelength). Faster, sometimes less stable. Default False.

camfr.set_sweep_steps(steps: int) → None

Initial number of steps of the tracking root finder (default 20).

camfr.set_eps_trace_coarse(eps: float) → None

Coarse intermediate precision of the tracking root finder (default 1e-14).

camfr.set_C_upperright(factor: complex) → None

Scale the upper right corner of the complex region searched for complex modes, relative to the default (default 1+1j).

camfr.set_estimate_cutoff(factor: float) → None

Slab solver: safety factor for the range of the mode search (default 1.2).

camfr.set_eta_ASR(eta: float) → None

Stretching parameter (0 to 1) of the ASR slab solver (default 1).

camfr.set_beta(beta: complex) → None

Set the out-of-plane wavenumber beta (along y) of Slabs, for off-plane incidence. Default 0.

camfr.set_backward_modes(b: bool) → None

Extra stability for Circ structures with backward and complex modes (e.g. a metal wall close to the last interface). Slower; default False.

camfr.set_circ_order(order: int) → None

Set the order of the Bessel modes (and angular dependence) in Circ waveguides (default 1).

camfr.set_circ_field_type(fieldtype: Fieldtype) → None

Set the angular field dependence of sources in Circ waveguides: cos_type (default) or sin_type.

camfr.set_mueller_precision(precision: float) → None

Precision of the Mueller root finder (default 1e-14).

Section solver

camfr.set_section_solver(solver: Section_solver) → None

Select the Section estimation algorithm: L (default), L_anis, NT, OS, ASR_2D or ASR_2D_stretched.

camfr.set_mode_correction(correction: Mode_correction) → None

Select how Section mode estimates are refined: none (default), snap, guided_only or full.

camfr.set_estimate_cutoff_section(factor: float) → None

Section solver: discard plane-wave estimates with kz above factor times the largest material wavenumber (default 2).

camfr.set_keep_all_estimates(b: bool) → None

Section solver: keep all plane-wave estimates and set N to their number (default False).

camfr.set_keep_all_1D_estimates(b: bool) → None

Keep all 1D (slab) estimates in the Section solver (default False).

camfr.set_section_reduction(b: bool) → None

Use the reduced eigenmatrix in the Section solver (default True).

camfr.set_calc_field_profiles(b: bool) → None

Compute the field profiles of Section modes (default True). False only gives the effective indices, faster.

camfr.print_estimates(b: bool) → None

Print the Section mode estimates (default False).

camfr.set_section_eta_ASR(eta: float) → None

Stretching parameter (0 to 1) of the ASR_2D section solver (default 1).

camfr.set_n_eff_max(n_eff: float) → None

ASR_2D section solver: discard estimates with a larger effective index (default 10).

camfr.set_NOV(nov: int) → None

ASR_2D section solver: number of eigenvalues kept (default 50).

camfr.set_u_step(u_step: float) → None

ASR_2D_stretched section solver: stretching step in x (default 0: automatic).

camfr.set_v_step(v_step: float) → None

ASR_2D_stretched section solver: stretching step in y (default 0: automatic).

camfr.set_percentage_stretched(fraction: float) → None

ASR_2D_stretched section solver: amount of stretching, from 0 (plain ASR) to 1 (default).

camfr.set_extended_output(b: bool) → None

ASR_2D section solver: print diagnostic output (default False).

camfr.A_switch(b: bool) → None

Expert switch of the ASR_2D section solver (default False).

camfr.B_switch(b: bool) → None

Expert switch of the ASR_2D section solver (default True).

camfr.C_switch(b: bool) → None

Expert switch of the ASR_2D section solver (default False).

camfr.D_switch(b: bool) → None

Expert switch of the ASR_2D section solver (default True).

BlochSection

camfr.set_fourier_orders(Mx: int, My: int = 0) → None

Set the Fourier orders of BlochSection in x and y; also sets N = 2*(2*Mx+1)*(2*My+1).

camfr.get_fourier_orders_x() → int

Return the number of Fourier orders Mx of BlochSection.

camfr.get_fourier_orders_y() → int

Return the number of Fourier orders My of BlochSection.

Stacks and cavities

camfr.set_stability(stability: Stability) → None

Set the treatment of nearly singular matrices: normal (default), extra or SVD.

camfr.set_unstable_exp_threshold(eps: float) → None

Growing exponentials smaller than this are set to zero (default 1e-12). Larger values (e.g. 1e-6) decouple waveguides sooner.

camfr.set_field_calc_heuristic(heuristic: Field_calc_heuristic) → None

Select the excitation used to compute fields in stacks: identical (default) or symmetric.

camfr.set_bloch_calc(method: Bloch_calc) → None

Select the Bloch mode algorithm: GEV (default) or T.

camfr.set_eigen_calc(method: Eigen_calc) → None

Select the cavity eigenvalue algorithm: lapack (default) or arnoldi.

camfr.set_gain_material(material: object) → None

Set the gain material of a Cavity.

The imaginary part of this material’s index is varied to find a lasing mode (Cavity.find_mode).

camfr.set_always_recalculate(b: bool) → None

Recalculate waveguides and stacks even if nothing changed (default False).

camfr.set_always_dense(b: bool) → None

Treat all interfaces as dense, also between uniform waveguides (default False).

camfr.set_davy(b: bool) → None

Debug: write the slab overlap matrices to files (default False).