Exemple #1
0
def test_nlse_loss():
    """Check that the loss is applied correctly in the NLSE."""
    # create a 1 meter fiber with 3.01 dB (50%) loss per meter:
    loss = 3.0102999566
    fiber = lf.Fiber(length=1, loss_dB_per_m=loss)
    pulse = lf.Pulse(epp=100e-12)  # create pulse
    results = lf.NLSE(pulse, fiber, print_status=False)

    assert np.isclose(pulse.epp * 0.5, results.pulse_out.epp, rtol=1e-11)
Exemple #2
0
def test_fiber():
    fiber = lf.Fiber(1, center_wl_nm=1550)

    def disp(z):
        return [1]

    def myfunc(z):
        return 1

    fiber.set_dispersion_function(disp)
    fiber.set_gamma_function(myfunc)
    fiber.set_alpha_function(myfunc)

    pulse = lf.Pulse(pulse_type='sech')

    assert np.all(np.isfinite(fiber.get_B(pulse, z=0.5)))
    assert fiber.get_gamma(z=0.5) == 1
    assert fiber.get_alpha(z=0.5) == 1
Exemple #3
0
def test_nlse_spectrum():
    """Check for reasonable agreement of NLSE output with old PyNLO results."""
    pulse = lf.Pulse(pulse_type='sech',
                     fwhm_ps=0.050,
                     time_window_ps=7,
                     npts=2**12,
                     center_wavelength_nm=1550.0,
                     epp=50e-12)

    fiber1 = lf.Fiber(length=8e-3,
                      center_wl_nm=1550.0,
                      gamma_W_m=1,
                      dispersion=(-0.12, 0, 5e-6))

    results = lf.NLSE(pulse,
                      fiber1,
                      raman=True,
                      shock=True,
                      nsaves=100,
                      atol=1e-5,
                      rtol=1e-5,
                      integrator='lsoda',
                      print_status=False)

    z, f, t, AW, AT = results.get_results()
    dB = 10 * np.log10(np.abs(AW[-1])**2)
    path = os.path.split(os.path.realpath(__file__))[0]
    f_prev, dB_prev = np.loadtxt(path + '/nlse_output.txt',
                                 delimiter=',',
                                 unpack=True,
                                 skiprows=1)

    # this is probably overly stringent because we are on a dB scale
    np.testing.assert_allclose(dB, dB_prev, rtol=1e-4, atol=0)

    # test that the wavelengths function works:
    z, new_wls, t, AW_wls, AT = results.get_results_wavelength()
    assert np.all(np.isfinite(AW_wls))
Exemple #4
0
pulse = lf.Pulse(pulse_type='sech',
                 power=1,
                 fwhm_ps=FWHM,
                 center_wavelength_nm=pulseWL,
                 time_window_ps=Window,
                 GDD=GDD,
                 TOD=TOD,
                 npts=Points,
                 frep_MHz=100,
                 power_is_avg=False,
                 epp=EPP)

# create the fiber!
fiber1 = lf.Fiber(Length * 1e-3,
                  center_wl_nm=pulseWL,
                  dispersion=(beta2 * 1e-3, beta3 * 1e-3, beta4 * 1e-3),
                  gamma_W_m=Gamma * 1e-3,
                  loss_dB_per_m=Alpha * 100)

t_start = time.time()
results = lf.NLSE(pulse,
                  fiber1,
                  raman=Raman,
                  shock=Steep,
                  nsaves=Steps,
                  atol=1e-5,
                  rtol=1e-5,
                  integrator='lsoda',
                  reload_fiber=False)
z, f, t, AW, AT = results.get_results()
Exemple #5
0
"""Runs a simple example of NLSE pulse propagation."""

import laserfun as lf

p = lf.Pulse(pulse_type='sech', fwhm_ps=0.05, epp=50e-12,
             center_wavelength_nm=1550, time_window_ps=7)

f = lf.Fiber(length=0.010, center_wl_nm=1550, dispersion=(-0.12, 0, 5e-6),
             gamma_W_m=1)

results = lf.NLSE(p, f, print_status=False)

if __name__ == '__main__':  # make plots if we're not running tests
    results.plot()
Exemple #6
0
import matplotlib.pyplot as plt

p = lf.Pulse(pulse_type='sech',
             power=10000,
             npts=2**13,
             fwhm_ps=0.0284 * 1.76,
             center_wavelength_nm=835,
             time_window_ps=12.5)

# betas = [beta2, beta3, ...] in units [ps^2/m, ps^3/m ...]
betas = [
    -11.830e-3, 8.1038e-5, -9.5205e-8, 2.0737e-10, -5.3943e-13, 1.3486e-15,
    -2.5495e-18, 3.0524e-21, -1.7140e-24
]

f = lf.Fiber(length=0.15, center_wl_nm=835, dispersion=betas, gamma_W_m=0.11)

r = lf.NLSE(p, f, nsaves=200, raman=True)
z, new_wls, t, AW, AT = r.get_results_wavelength(wmin=400,
                                                 wmax=1350,
                                                 wn=400,
                                                 datatype='dB')

fig, axs = plt.subplots(1, 2, figsize=(8, 5), tight_layout='True')

axs[0].imshow(AW,
              aspect='auto',
              origin='lower',
              extent=(new_wls.min(), new_wls.max(), z.min(), z.max()),
              clim=(np.max(AW) - 40, np.max(AW)),
              cmap='jet')
Gammaf = 2000   # nonlinearity (1/(W km))
Alphaf = 2      # loss (dB/cm)

Length = 10      # length in mm

fibWL = pulseWL  # Center WL of fiber (nm)

Raman = True     # Enable Raman effect?
Steep = True     # Enable self steepening?

# create the pulse
pulse = lf.Pulse(pulse_type='sech', fwhm_ps=FWHM, center_wavelength_nm=pulseWL,
                 time_window_ps=Window, GDD=GDD, TOD=TOD, npts=Points, epp=EPP)

# create the fiber!
fiber1 = lf.Fiber(Length * 1e-3, center_wl_nm=pulseWL)


def dispersion_function(z):
    """Set the dispersion."""
    frac = z/(Length*1e-3)
    beta2 = (1-frac) * beta2i + frac * beta2f
    beta3 = (1-frac) * beta3i + frac * beta3f
    beta4 = (1-frac) * beta4i + frac * beta4f
    return (beta2*1e-3, beta3*1e-3, beta4*1e-3)


def gamma_function(z):
    """Set the gamma."""
    frac = z/(Length*1e-3)
    gamma = 1e-3*((1-frac)*Gammai + frac*Gammaf)