twpasolver.cmes.base module#

Coupled Mode Equations models and solvers optimized for Numba.

twpasolver.cmes.base.no_reflections_cmes_segmented(x, currents, alphas_table, kappas_table, relations_3wm, relations_4wm, coeffs_3wm_table, coeffs_4wm_table, segment_midpoints, x_array, phi_table)[source]#

RHS of the no-reflections CME system for a segmented (position-dependent) device.

Parameters:
  • alphas_table (ndarray, shape (n_modes, n_segments)) – Local attenuation and wavenumber, interpolated at x via segment_midpoints.

  • kappas_table (ndarray, shape (n_modes, n_segments)) – Local attenuation and wavenumber, interpolated at x via segment_midpoints.

  • coeffs_3wm_table (ndarray, shape (n_relations, n_segments)) – Position-dependent nonlinear coupling coefficients, on the same grid.

  • coeffs_4wm_table (ndarray, shape (n_relations, n_segments)) – Position-dependent nonlinear coupling coefficients, on the same grid.

  • phi_table (ndarray, shape (n_modes, n_x)) – Cumulative phase per mode, precomputed on the solver output grid x_array.

twpasolver.cmes.base.cumulative_phase(gammas_array: ndarray[Any, dtype[complex128]], segment_midpoints: ndarray[Any, dtype[float64]], x_array: ndarray[Any, dtype[float64]]) → ndarray[Any, dtype[float64]][source]#

Phi_m(x) = int Im(gamma_m) dx on x_array, shape (n_freq, n_modes, n_x).

Im(gamma_m) is piecewise-linear on the segment midpoints (constant for one segment); the cumulative trapezoid rule is exact for that interpolant.

twpasolver.cmes.base.no_reflections_cmes_solve(x_array: ndarray[Any, dtype[float64]], y0_broadcast: ndarray[Any, dtype[complex128]], gammas_array: ndarray[Any, dtype[complex128]], relations_3wm, relations_4wm, coeffs_3wm, coeffs_4wm, segment_midpoints: ndarray[Any, dtype[float64]], rk_config: RKSolverConfig | None = None) → ndarray[Any, dtype[complex128]][source]#

Solve the no-reflections CME system for every signal frequency in parallel.

gammas_array has shape (n_freq, n_modes, n_seg), coeffs_* shape (n_rel, n_seg) and segment_midpoints shape (n_seg,); a uniform device is one segment.

Returns:

I – Mode currents with their propagation phase exp(i Phi_m(x)).

Return type:

(n_freq, n_modes, n_positions)