Note
Go to the end to download the full example code.
Two coupled components¶
CNLSE propagates a two-component field with cross-phase modulation between them.

/home/runner/work/NLSE/NLSE/NLSE/solvers/nlse.py:182: UserWarning: The CL backend is not installed here, so CPU will be used instead — the fastest one available. Install pyopencl to use CL, or pass backend='CPU' to silence this.
self._backend: Backend = get_backend(backend, grid_size=(NX, NY))
/home/runner/work/NLSE/NLSE/NLSE/solvers/nlse.py:380: UserWarning: delta_z=4.14e-05 exceeds split-step accuracy limit (1.52e-05). Reducing to 1.37e-05.
delta_z = self._capped_delta_z(delta_z, A, method)
Propagation: 0%| | 0.00/100 [00:00<?, ?%/s]
Propagation: 100%|██████████| 100/100 [11:34<00:00, 6.94s/%]
Time spent to solve : 694.4423133869999 s (CPU)
import numpy as np
from NLSE import CNLSE
PRECISION_COMPLEX = np.complex64
PRECISION_REAL = np.float32
N = 2048
n2 = -1.6e-9
n12 = -1e-10
waist = 2.23e-3
waist2 = 70e-6
window = 4 * waist
puiss = 1.05
Isat = 10e4 # saturation intensity in W/m^2
Isat2 = waist / waist2 * Isat
L = 10e-2
alpha = 20
def main():
simu_c = CNLSE(
alpha,
puiss,
window,
n2,
n12,
None,
L,
NX=N,
NY=N,
Isat=Isat,
omega=None,
backend="CL",
)
simu_c.puiss2 = 10e-3
simu_c.n22 = 1e-10
simu_c.I_sat2 = Isat2
simu_c.k2 = 2 * np.pi / 795e-9
E_0 = np.exp(-(simu_c.XX**2 + simu_c.YY**2) / waist**2).astype(PRECISION_COMPLEX)
V = np.exp(-(simu_c.XX**2 + simu_c.YY**2) / waist2**2).astype(PRECISION_COMPLEX)
simu_c.out_field(
np.array([E_0, V]),
L,
verbose=True,
plot=True,
splitting="lie",
)
if __name__ == "__main__":
main()
Total running time of the script: (11 minutes 37.498 seconds)