Note
Go to the end to download the full example code.
Three dimensions, with dispersion¶
NLSE_3d adds group velocity dispersion, so a pulse spreads in time as well as space.

/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))
Propagation: 0%| | 0.00/100 [00:00<?, ?%/s]
Propagation: 100%|██████████| 100/100 [00:05<00:00, 17.6%/s]
Time spent to solve : 5.67952887499996 s (CPU)
import numpy as np
from NLSE import NLSE_3d
from scipy.constants import c
PRECISION_COMPLEX = np.complex64
PRECISION_REAL = np.float32
N = 256
NZ = 128
n2 = -1.6e-9
D0 = 1e-16
vg = 1e-1 * c
waist = 2.23e-3
duration = 2e-6
waist2 = 70e-6
window = np.array([4 * waist, 8 * duration]) # 4*waist transverse, 10e-6 s temporal
energy = 1.05 * duration
Isat = 10e4 # saturation intensity in W/m^2
L = 1e-2
alpha = 20
def main():
simu = NLSE_3d(
alpha=alpha,
energy=energy,
window=window,
n2=n2,
D0=D0,
vg=vg,
V=None,
L=L,
NX=N,
NY=N,
NZ=NZ,
Isat=Isat,
backend="CUPY",
)
E_0 = np.exp(-(simu.XX**2 + simu.YY**2) / waist**2).astype(PRECISION_COMPLEX)
E_0 *= np.exp(-(simu.TT**2) / duration**2)
simu.V = -1e-4 * np.exp(-(simu.XX**2 + simu.YY**2) / waist2**2).astype(
PRECISION_COMPLEX
)
simu.out_field(E_0, L, verbose=True, plot=True, splitting="lie")
if __name__ == "__main__":
main()
Total running time of the script: (0 minutes 7.695 seconds)