Phasematching
NonlinearCrystals.CollinearPhaseMatch — TypeCollinearPhaseMatch <: PhaseMatchEncapsulates a full collinear phase-matching solution, including refractive data, geometric parameters, nonlinear efficiency, and bandwidths (fields refr_data, pm_data, eff_data, and bw_data, respectively). In addition, field access is forwarded to the internal fields of both refr_data and pm_data for convenience.
NonlinearCrystals.PMBandwidthData — TypePMBandwidthDataRepresents the phase-matching bandwidths of a collinear configuration, defined as the range of parameters over which the phase mismatch Δk remains within ±π / L for a given interaction length L.
The stored values are ΔX · L quantities (units of Hz·m, K·m, rad·m), which characterize the tolerance of the phase-matching condition to changes in each parameter X:
omega_L_bw: Tuple of angular frequency bandwidths (Δω · L) for the three waves (r₁, r₂, b). Each entry is computed by holding that wave's frequency fixed while adjusting the other two to maintain the phase-matching condition (1/λr₁ + 1/λr₂ = 1/λ_b).temp_L_bw: Temperature bandwidth (ΔT · L) computed by evaluating how Δk varies with small temperature changes, with all wavelengths and geometry fixed.theta_L_bw: Angular bandwidth with respect to polar angle θ (Δθ · L), evaluated at fixed temperature and wavelengths.phi_L_bw: Angular bandwidth with respect to azimuthal angle ϕ (Δϕ · L), also at fixed conditions.
These values describe how sensitive the phase-matching is to deviations in each parameter. For example, a small theta_L_bw means tight angular alignment is needed, while a large temp_L_bw suggests thermally robust operation.
Bandwidths are calculated as:
\[ΔX · L = \frac{2π}{|∂Δk/∂X|}\]
where Δk is the phase mismatch, and X is one of frequency, temperature, or angle.
NonlinearCrystals.PMCollinearData — TypePMCollinearDataRepresents the geometry and wavelengths of a collinear phase-matching configuration, including propagation angles theta_pm and phi_pm, crystal reference, temperature, and polarization type data (hi_or_lo_rrb and optional PMType classification).
This is the geometric input used to calculate CollinearPhaseMatch properties.
NonlinearCrystals.PMEfficiencyData — TypePMEfficiencyDataStores the effective nonlinear coefficient d_eff (with and without Miller scaling) and the associated conversion factor S₀·L². Used to compare the efficiency of different phase-matching solutions based on geometry and polarization.
NonlinearCrystals.PMType — TypePMTypeDescribes the polarization type of a phase-matching configuration, including the principal plane (e.g. :XY or :UD for uniaxial crystals), the polarization of each wave (:o or :e), and a human-readable type classification like "I", "II/III", "IV", or "V".
Used for diagnostic purposes and auto-labeling of phase-match types.
NonlinearCrystals.calc_noncritical_pm_lines — Methodcalc_noncritical_pm_lines(principal_axis, hi_or_lo_rrb, cr; ...)Computes the coordinates of Δk = 0 isolines in the λb-λr1 parameter space where noncritical phase-matching is achieved (i.e., phase matching occurs at fixed propagation direction, along the crystal's principal_axis).
Returns:
segments_b: vector of λ_b curves (x-axis)segments_r: corresponding λ_r1 curves (y-axis)cb_intersections,cr_intersections: SHG symmetry intersection points (e.g., λb = λr / 2)
NonlinearCrystals.delta_k — Methoddelta_k(theta_pm, phi_pm, hi_or_lo_rrb, cr; lambda_r1, lambda_r2, lambda_b, temp)Computes the phase mismatch Δk = kr1 + kr2 - kb for a given configuration. Each `kiis calculated from2π * ni / λibased on the given crystalcr, propagation anglesthetapm,phipm, and the three polarization typeshiorlo_rrb`.
NonlinearCrystals.delta_k_with_shifting — Methoddelta_k_with_shifting(theta_pm, phi_pm, hi_or_lo_rrb, cr; ...)Same as delta_k, but allows small parameter perturbations (Δθ, Δϕ, ΔT, Δωr1, Δωr2, Δωb). The frequency shifts adjust the wavelengths while conserving energy (Δωr1 + Δωr2 = Δωb), enabling bandwidth estimation.
Used internally for computing how Δk varies with perturbations for calculating ΔX · L quantities in PMBandwidthData.
NonlinearCrystals.find_all_ncpm_over_lambda — Functionfind_all_ncpm_over_lambda(pol_rrb, cr, temp; lambda_r1, lambda_r2, lambda_b, ...)Finds all noncritical phase-matches (NCPM) by varying wavelength, while keeping the temperature fixed. You must specify exactly one of the three wavelengths (lambda_r1, lambda_r2, or lambda_b) and leave the others as nothing. The scan range is chosen automatically based on the crystal's validity domain. Returns a list of CollinearPhaseMatch solutions found within the allowed range. The return value can be an empty array if no solution is found.
NonlinearCrystals.find_all_ncpm_over_temp — Methodfind_all_ncpm_over_temp(pol_rrb, cr; lambda_r1, lambda_r2, lambda_b, temp_min, temp_max, ...)Returns all noncritical phase-matching (NCPM) configurations where Δk = 0 can be achieved by tuning the temperature. You must specify at least two of the three wavelengths, and a temperature range [temp_min, temp_max]. The search is limited to propagation along principal axes. Returns an array of CollinearPhaseMatch solutions. The return value can be an empty array if no solution is found.
NonlinearCrystals.find_all_pms_along_dimension — Methodfind_all_pms_along_dimension(pol_rrb, cr; ...)Performs a one-dimensional search to find all collinear phase-matching solutions (Δk ≈ 0) for a given polarization tuple pol_rrb.
Depending on which parameters are held fixed (lambda_r1, lambda_r2, lambda_b, temp_min == temp_max, or angular constraints like theta_fixed), this scans over:
- Wavelength (λb or λr1)
- Temperature
- Angle (θ or ϕ)
This function is the main backend used by higher-level routines like find_nearest_pm_along_theta_phi or find_all_ncpm_over_temp.
Returns a list of CollinearPhaseMatch solutions found by detecting sign changes in Δk via a global search and refining them with bisection.
NonlinearCrystals.find_nearest_pm_along_lambda_r_b — Methodfind_nearest_pm_along_lambda_r_b(pol_rrb, cr; lambda_r1, lambda_r2, lambda_b, ...)Searches for the best phase-match for a given pair of red and blue wavelengths. You must specify exactly one of lambda_r1 or lambda_r2, plus lambda_b.
Scans along both the missing red wavelength and the blue wavelength, finds all matching configurations (via find_all_pms_along_dimension), and returns the one closest to the provided values.
Used to fine-tune a target wavelength combination to an actual valid phase-match geometry.
NonlinearCrystals.find_nearest_pm_along_theta_phi — Methodfind_nearest_pm_along_theta_phi(theta_target, phi_target, pol_rrb, cr; ...)Searches for the phase-matching configuration closest to a given direction (theta_target, phi_target) by scanning phase-matches at fixed θ or fixed ϕ, using find_all_pms_along_dimension.
The search returns the CollinearPhaseMatch whose propagation direction is most aligned (in dot product) with the target vector. Returns nothing if no solution is found.
NonlinearCrystals.plot_critical_pms — Methodplot_critical_pms(cr::NonlinearCrystal; kwargs...) -> FigureVisualizes and compares critical phase-matching solutions for a given nonlinear crystal cr across all possible polarization configurations and propagation directions. This plot gives insight into how the phase-matching characteristics vary with angle for a fixed wavelength triplet (λr1, λr2, λ_b).
Each horizontal segment in the figure corresponds to a distinct type of phase-matching configuration, and the plot shows how key quantities vary along that solution contour (i.e., as a function of θ and ϕ for which Δk = 0).
Plotted Quantities per Phasematch
For each matched solution (Δk = 0), the following attributes are visualized:
- Refractive index
- Group index
- β₂ — group velocity dispersion, unit: fs²/mm
- Walkoff angle — spatial beam walkoff, unit: mrad
- ω BW × L — angular frequency bandwidth product (Δω·L), from group velocity mismatch
- T BW × L — temperature tolerance (ΔT·L), from thermal dispersion mismatch
- ϕ BW × L, θ BW × L — angular acceptance bandwidths
- |d_eff| — effective nonlinearity (with Miller scaling applied)
- ϕ, θ — propagation angles
- Type — phase-matching type and polarization roles (label only)
Optional Arguments
hi_or_lo_rrb: One or more polarization configurations (e.g.,(:hi, :hi, :lo))lambda_r1,lambda_r2,lambda_b: At least two must be specified, the third is inferredtemp: Temperature at which to evaluate phase-matchingn_points: Angular resolutionsize: Plot size as a tuple (width, height)
Output
Returns a vertically stacked GLMakie Figure containing multiple linked plots, each showing one of the quantities above. Each horizontal span corresponds to a continuous critical phase-matching curve (i.e., varying θ and ϕ for fixed λ and T).
NonlinearCrystals.plot_delta_k_map — Methodplot_delta_k_map(hi_or_lo_rrb, cr; ...)Plots a 2D or 3D map of the phasemismatch Δk over the angular domain (θ, ϕ) for a given polarization assignment (hi_or_lo_rrb) and wavelength triplet.
Depending on plot_type:
:polar→ Shows Mercator style projected θ–ϕ map with Δk color-coded and phase match contours overlaid:sphere→ Visualizes Δk on the surface of a 3D unit sphere using ray direction vectors
NonlinearCrystals.plot_noncritical_pms — Methodplot_noncritical_pms(principal_axis, cr; ...)Generates an interactive plot of all noncritical phase-matching lines (Δk = 0) in λb-λr1 space for a given crystal cr along the selected principal_axis.
Each plotted contour represents a set of wavelength triplets (λr1, λr2, λ_b) that satisfy phase-matching without angular adjustment. Supports both Type I (equal polarization) and Type II (cross-polarized) combinations.
You can control the polarization combination via hi_or_lo_rrb, limit the scan ranges, and adjust the resolution with ngrid.
Returns a GLMakie Figure.
NonlinearCrystals.pm_wavelengths — Methodpm_wavelengths(; lambda_r1=nothing, lambda_r2=nothing, lambda_b=nothing)Given any two of the three wavelengths involved in a second-order three-wave interaction (λ_r1, λ_r2, λ_b), compute the third to satisfy energy conservation:
\[1 / λ_{b} = 1 / λ_{r,1} + 1 / λ_{r,2}\]
Returns the tuple (λr1, λr2, λ_b). Throws an error if the relation is not fulfilled or fewer than two inputs are provided.
NonlinearCrystals.setup_click_saver — Methodsetup_click_saver(ax; pick_filter, position_units=nothing, compute_pm)Adds a left-click handler to the Makie axis ax that uses pick_filter to select a plot element, optionally transforms the clicked position via position_units, and computes a phase-match with compute_pm. If successful, the result is pushed to the global selected_pms array. Returns nothing.