Note
Go to the end to download the full example code.
Counter-streaming beams go turbulent¶
The lossy problem the solved real-space step was measured on: two components collide and the flow breaks up.

/home/runner/work/NLSE/NLSE/NLSE/solvers/nlse.py:182: UserWarning: The MLX backend is not installed here, so CPU will be used instead — the fastest one available. Install mlx to use MLX, 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=1.50e-04 exceeds split-step accuracy limit (4.98e-05). Reducing to 4.48e-05.
delta_z = self._capped_delta_z(delta_z, A, method)
Propagation: 0%| | 0.00/100 [00:00<?, ?%/s]
Propagation: 100%|██████████| 100/100 [01:27<00:00, 1.14%/s]
Time spent to solve : 87.63338106900005 s (CPU)
array([[ 0.27637655-2.9725555e-02j, 1.8697624 -8.7581235e-01j,
3.4343312 -1.4051603e+00j, ..., -0.87621176+2.7425733e+00j,
-0.86121935+1.1756768e+00j, -0.64081347+6.1063677e-01j],
[ 3.0515254 +1.6852412e+00j, 4.6509304 +3.6947879e-01j,
5.1936407 -1.3372231e+00j, ..., -2.1129737 +5.6220288e+00j,
-1.0708597 +4.2313528e+00j, 0.76944596+2.9165740e+00j],
[ 4.231117 +2.8455992e+00j, 4.079919 +3.2829599e+00j,
3.297777 +2.7439342e+00j, ..., 1.351612 +1.1168299e+00j,
2.6642046 +2.4315631e+00j, 3.804654 +2.5183561e+00j],
...,
[ 4.1957855 +2.8297093e+00j, 3.8348446 +2.5621474e+00j,
2.691773 +2.4575994e+00j, ..., 1.5773629 +1.4359707e+00j,
3.289304 +2.7020240e+00j, 4.041312 +3.2242475e+00j],
[ 3.1344655 +1.6810782e+00j, 0.8473452 +2.9397113e+00j,
-1.0274792 +4.2616773e+00j, ..., 5.212818 -3.2864480e+00j,
5.139399 -1.2709531e+00j, 4.7043586 +3.9898223e-01j],
[ 0.32870656-3.7216526e-03j, -0.66872203+5.8379656e-01j,
-0.8776942 +1.1258004e+00j, ..., 4.470187 -1.9946876e+00j,
3.456886 -1.3825043e+00j, 1.8917439 -8.3645284e-01j]],
shape=(1024, 1024), dtype=complex64)
import numpy as np
from NLSE import NLSE
N = 1024
n2 = -1.6e-9
window = 8e-3
power = 1.05
Isat = 10e4
L = 20e-2
alpha = 20
waist = 2e-3
waist_d = 1e-3
backend = "MLX"
simu = NLSE(alpha, power, window, n2, None, L, NX=N, NY=N, Isat=Isat, backend=backend)
simu.V = 1e-4 * np.exp(-(np.hypot(simu.XX, simu.YY) ** 2) / waist_d**2)
kp = 2 * np.pi * 5e3
E0 = np.exp(-(np.hypot(simu.XX, simu.YY) ** 2) / waist**2).astype(np.complex64)
E0[0 : N // 2, :] *= np.exp(1j * kp * simu.XX[0 : N // 2, :])
E0[N // 2 :, :] *= np.exp(-1j * kp * simu.XX[N // 2 :, :])
simu.out_field(E0, L, plot=True)
Total running time of the script: (1 minutes 28.551 seconds)