"""
A non-local interaction
=======================

``nl_length`` convolves the intensity with a kernel before it reaches the phase.
"""

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()
