Note
Go to the end to download the full example code.
A non-local interaction¶
nl_length convolves the intensity with a kernel before it reaches the phase.

/home/runner/work/NLSE/NLSE/NLSE/solvers/nlse.py:182: UserWarning: The CUPY backend is not installed here, so CPU will be used instead — the fastest one available. Install cupy to use CUPY, 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.00e-04 exceeds split-step accuracy limit (1.55e-05). Reducing to 1.39e-05.
delta_z = self._capped_delta_z(delta_z, A, method)
Propagation: 0%| | 0.00/100 [00:00<?, ?%/s]
Propagation: 1%|▏ | 1.39/100 [00:01<02:14, 1.36s/%]
Propagation: 3%|▎ | 2.79/100 [00:02<01:10, 1.39%/s]
Propagation: 4%|▍ | 4.18/100 [00:02<00:48, 1.96%/s]
Propagation: 6%|▌ | 5.57/100 [00:02<00:38, 2.48%/s]
Propagation: 7%|▋ | 6.97/100 [00:02<00:31, 2.94%/s]
Propagation: 8%|▊ | 8.36/100 [00:02<00:27, 3.36%/s]
Propagation: 10%|▉ | 9.75/100 [00:02<00:24, 3.74%/s]
Propagation: 11%|█ | 11.1/100 [00:02<00:21, 4.08%/s]
Propagation: 13%|█▎ | 12.5/100 [00:02<00:19, 4.40%/s]
Propagation: 14%|█▍ | 13.9/100 [00:02<00:18, 4.69%/s]
Propagation: 15%|█▌ | 15.3/100 [00:03<00:17, 4.96%/s]
Propagation: 17%|█▋ | 16.7/100 [00:03<00:15, 5.21%/s]
Propagation: 18%|█▊ | 18.1/100 [00:03<00:15, 5.44%/s]
Propagation: 20%|█▉ | 19.5/100 [00:03<00:14, 5.66%/s]
Propagation: 21%|██ | 20.9/100 [00:03<00:13, 5.86%/s]
Propagation: 22%|██▏ | 22.3/100 [00:03<00:12, 6.05%/s]
Propagation: 24%|██▎ | 23.7/100 [00:03<00:12, 6.22%/s]
Propagation: 25%|██▌ | 25.1/100 [00:03<00:11, 6.39%/s]
Propagation: 26%|██▋ | 26.5/100 [00:04<00:11, 6.54%/s]
Propagation: 28%|██▊ | 27.9/100 [00:04<00:10, 6.69%/s]
Propagation: 29%|██▉ | 29.3/100 [00:04<00:10, 6.83%/s]
Propagation: 31%|███ | 30.7/100 [00:04<00:09, 6.96%/s]
Propagation: 32%|███▏ | 32.0/100 [00:04<00:09, 7.08%/s]
Propagation: 33%|███▎ | 33.4/100 [00:04<00:09, 7.19%/s]
Propagation: 35%|███▍ | 34.8/100 [00:04<00:08, 7.31%/s]
Propagation: 36%|███▌ | 36.2/100 [00:04<00:08, 7.41%/s]
Propagation: 38%|███▊ | 37.6/100 [00:05<00:08, 7.51%/s]
Propagation: 39%|███▉ | 39.0/100 [00:05<00:08, 7.60%/s]
Propagation: 40%|████ | 40.4/100 [00:05<00:07, 7.69%/s]
Propagation: 42%|████▏ | 41.8/100 [00:05<00:07, 7.78%/s]
Propagation: 43%|████▎ | 43.2/100 [00:05<00:07, 7.86%/s]
Propagation: 45%|████▍ | 44.6/100 [00:05<00:06, 7.94%/s]
Propagation: 46%|████▌ | 46.0/100 [00:05<00:06, 8.02%/s]
Propagation: 47%|████▋ | 47.4/100 [00:05<00:06, 8.09%/s]
Propagation: 49%|████▉ | 48.8/100 [00:05<00:06, 8.16%/s]
Propagation: 50%|█████ | 50.2/100 [00:06<00:06, 8.23%/s]
Propagation: 52%|█████▏ | 51.6/100 [00:06<00:05, 8.30%/s]
Propagation: 53%|█████▎ | 53.0/100 [00:06<00:05, 8.36%/s]
Propagation: 54%|█████▍ | 54.3/100 [00:06<00:05, 8.42%/s]
Propagation: 56%|█████▌ | 55.7/100 [00:06<00:05, 8.48%/s]
Propagation: 57%|█████▋ | 57.1/100 [00:06<00:05, 8.53%/s]
Propagation: 59%|█████▊ | 58.5/100 [00:06<00:04, 8.58%/s]
Propagation: 60%|█████▉ | 59.9/100 [00:06<00:04, 8.63%/s]
Propagation: 61%|██████▏ | 61.3/100 [00:07<00:04, 8.68%/s]
Propagation: 63%|██████▎ | 62.7/100 [00:07<00:04, 8.73%/s]
Propagation: 64%|██████▍ | 64.1/100 [00:07<00:04, 8.78%/s]
Propagation: 65%|██████▌ | 65.5/100 [00:07<00:03, 8.82%/s]
Propagation: 67%|██████▋ | 66.9/100 [00:07<00:03, 8.87%/s]
Propagation: 68%|██████▊ | 68.3/100 [00:07<00:03, 8.91%/s]
Propagation: 70%|██████▉ | 69.7/100 [00:07<00:03, 8.95%/s]
Propagation: 71%|███████ | 71.1/100 [00:07<00:03, 9.00%/s]
Propagation: 72%|███████▏ | 72.5/100 [00:08<00:03, 9.03%/s]
Propagation: 74%|███████▍ | 73.9/100 [00:08<00:02, 9.07%/s]
Propagation: 75%|███████▌ | 75.2/100 [00:08<00:02, 9.11%/s]
Propagation: 77%|███████▋ | 76.6/100 [00:08<00:02, 9.14%/s]
Propagation: 78%|███████▊ | 78.0/100 [00:08<00:02, 9.18%/s]
Propagation: 79%|███████▉ | 79.4/100 [00:08<00:02, 9.21%/s]
Propagation: 81%|████████ | 80.8/100 [00:08<00:02, 9.25%/s]
Propagation: 82%|████████▏ | 82.2/100 [00:08<00:01, 9.28%/s]
Propagation: 84%|████████▎ | 83.6/100 [00:08<00:01, 9.31%/s]
Propagation: 85%|████████▌ | 85.0/100 [00:09<00:01, 9.34%/s]
Propagation: 86%|████████▋ | 86.4/100 [00:09<00:01, 9.37%/s]
Propagation: 88%|████████▊ | 87.8/100 [00:09<00:01, 9.40%/s]
Propagation: 89%|████████▉ | 89.2/100 [00:09<00:01, 9.42%/s]
Propagation: 91%|█████████ | 90.6/100 [00:09<00:00, 9.45%/s]
Propagation: 92%|█████████▏| 92.0/100 [00:09<00:00, 9.48%/s]
Propagation: 93%|█████████▎| 93.4/100 [00:09<00:00, 9.51%/s]
Propagation: 95%|█████████▍| 94.8/100 [00:09<00:00, 9.53%/s]
Propagation: 96%|█████████▌| 96.1/100 [00:10<00:00, 9.56%/s]
Propagation: 98%|█████████▊| 97.5/100 [00:10<00:00, 9.58%/s]
Propagation: 99%|█████████▉| 98.9/100 [00:10<00:00, 9.60%/s]
Propagation: 100%|██████████| 100/100 [00:10<00:00, 9.45%/s]
Time spent to solve : 10.57990850799979 s (CPU)
import numpy as np
from NLSE import NLSE
PRECISION_COMPLEX = np.complex64
PRECISION_REAL = np.float32
def main():
N = 2048
n2 = -1.6e-9
waist = 2.23e-3
window = 4 * waist
puiss = 1.05
Isat = 10e4 # saturation intensity in W/m^2
L = 1e-3
alpha = 20
nl_length = 60e-6
simu_2d = NLSE(
alpha,
puiss,
window,
n2,
None,
L,
NX=N,
NY=N,
Isat=Isat,
nl_length=nl_length,
backend="CUPY",
)
E_0 = np.exp(-(simu_2d.XX**2 + simu_2d.YY**2) / waist**2).astype(PRECISION_COMPLEX)
simu_2d.out_field(
E_0,
L,
verbose=True,
plot=True,
splitting="lie",
)
if __name__ == "__main__":
main()
Total running time of the script: (0 minutes 12.390 seconds)