Exemplo n.º 1
0
def run_simulation(caller=None, prop=False):
    bRun.label.set_text('Setting up...')
    drawnow()

    # Grab the parameters from the text boxes:
    pump_pulse_length = float(bPulse.text)
    centerwl = float(bWave.text)  # in nm
    pump_power = float(bPower.text) * 1e3
    GDD = float(bGDD.text)
    TOD = float(bTOD.text)

    window = float(bWindow.text)
    steps = int(bSteps.text)
    npoints = int(eval(bPoints.text))

    fiber_length = float(bLength.text) * 1e-3
    gamma = float(bGamma.text)
    beta2 = float(bBeta2.text)
    beta3 = float(bBeta3.text)
    beta4 = float(bBeta4.text)
    fibWL = float(bFibWL.text)

    isNotRaman = np.logical_not(bCheck.lines[0][0].get_visible())
    isNotSteep = np.logical_not(bCheck.lines[1][0].get_visible())

    # set up the pulse parameters
    pulse = SechPulse(pump_power,
                      pump_pulse_length,
                      centerwl,
                      time_window=window,
                      GDD=GDD,
                      TOD=TOD,
                      NPTS=npoints,
                      frep_MHz=100,
                      power_is_avg=False)

    fiber1 = fiber.FiberInstance()
    fiber1.generate_fiber(fiber_length,
                          center_wl_nm=fibWL,
                          betas=(beta2, beta3, beta4),
                          gamma_W_m=gamma * 1e-3,
                          gvd_units='ps^n/km')

    # fiber1.load_from_db(fiber_length, 'dudley')

    print 'Parameters\n------------------'
    print '--Pulse--'
    print 'Duration (ps)  %f' % pump_pulse_length
    print 'Center wl (nm) %g' % centerwl
    print 'Pump power (W) %g' % pump_power
    print '  Energy (nJ)  %f' % (pulse.calc_epp() * 1e9)
    print 'GDD (ps^2)     %f' % (GDD)
    print 'TOD (ps^3)     %f' % (TOD)
    print '--Simulation--'
    print 'Window (ps)    %f' % window
    print 'Steps          %i' % steps
    print 'Time points    %i' % npoints
    print '--Fiber--'
    print 'Length (mm)     %f' % (fiber_length * 1e3)
    print 'Gamma (W-1km-1) %f' % (gamma)
    print 'Beta2 (ps^2/km) %f' % (beta2)
    print 'Beta3 (ps^3/km) %f' % (beta3)
    print 'Beta4 (ps^4/km) %f' % (beta4)

    print 'FiberWL (nm)    %f' % (fibWL)

    W = pulse.W_mks
    F = W / (2 * np.pi)
    T = pulse.T_ps
    xW = W[W > 0]

    D = fiber1.Beta2_to_D(pulse)
    beta = fiber1.Beta2(pulse) * 1e3

    # Plot the dispersion in the left plots
    lineL1.set_data(F[W > 0][::10], D[W > 0][::10])
    lineL2.set_data(F[W > 0][::10], beta[W > 0][::10])

    # plot the pulse in the top plots
    line1a.set_data(F[W > 0], dB(pulse.AW[W > 0]))
    line2a.set_data(T, dB(pulse.AT))

    laser_freq = 3e8 / (centerwl * 1e-9)
    fiber_freq = 3e8 / (fibWL * 1e-9)
    vline1a.set_xdata((laser_freq, laser_freq))
    vline1b.set_xdata((fiber_freq, fiber_freq))
    vline2a.set_xdata((laser_freq, laser_freq))
    vline2b.set_xdata((fiber_freq, fiber_freq))

    if prop == False:
        bRun.label.set_text('Run simulation')
        drawnow()
        return  # stop here unless we've actually pressed the "Run" button

    ######################## Propagation
    t = time.time()
    bRun.label.set_text('Running...')
    drawnow()

    # set up the propagation parameters
    evol = SSFM.SSFM(local_error=0.001,
                     USE_SIMPLE_RAMAN=True,
                     disable_Raman=isNotRaman,
                     disable_self_steepening=isNotSteep)

    # propagate the pulse!
    y, AW, AT, pulse1 = evol.propagate(pulse_in=pulse,
                                       fiber=fiber1,
                                       n_steps=steps)

    zW_in = np.transpose(AW)[:, (W > 0)]
    zT_in = np.transpose(AT)
    zW = dB(zW_in)
    zT = dB(zT_in)

    bRun.label.set_text('Drawing plots...')
    drawnow()

    line1b.set_data(F[F > 0], zW[-1])
    line2b.set_data(T, zT[-1])

    for ax in (ax3, ax4):
        ax.clear()

    extent = (np.min(F[F > 0]), np.max(F[F > 0]), np.min(y), np.max(y[:-1]))
    ax3.imshow(zW,
               extent=extent,
               vmin=np.max(zW) - 60.0,
               vmax=np.max(zW),
               aspect='auto',
               origin='lower')
    ax3.set_xlabel('Frequency (Hz)')
    ax3.set_ylabel('Distance (m)')

    extent = (np.min(T), np.max(T), np.min(y), np.max(y[:-1]))
    ax4.imshow(zT,
               extent=extent,
               vmin=np.max(zT) - 60.0,
               vmax=np.max(zT),
               aspect='auto',
               origin='lower')
    ax4.set_xlabel('Delay (ps)')

    print 'Total time: %.2f sec' % (time.time() - t)

    reset_plots()
    bRun.label.set_text('Run simulation')
    drawnow()
Exemplo n.º 2
0
plt.close('all')

steps = 100

centerwl = 1550.0
gamma = 2e-3

fiber_length = 2500.0
P0 = 10.0
T0 = 0.1
nPoints = 2**13

pulse = SechPulse(P0, T0, centerwl, NPTS=nPoints)

fiber1 = fiber.FiberInstance()
fiber1.generate_fiber(fiber_length, centerwl, [0, 0], gamma, 0)

evol = FourWaveMixing.SSFM.SSFM(disable_Raman=True,
                                disable_self_steepening=True,
                                local_error=0.1,
                                suppress_iteration=True)

y = np.zeros(steps)
AW = np.complex64(np.zeros((pulse.NPTS, steps)))
AT = np.complex64(np.copy(AW))

y, AW, AT, pulse1, = evol.propagate(pulse_in=pulse,
                                    fiber=fiber1,
                                    n_steps=steps)
Exemplo n.º 3
0
L_SMF1 = 3
L_SMF2 = 2.5
L_ysfhi = 0.5  #NALM增益纤

OutRadio = 0.7
CRatio = 0.45

g_nalm = 8
g_main = 2.2
Esat_main = 3e-9
Esat_nalm = 1e-9
omeg = 30  # nm
## 滤波器
band = 2  #nm

Fiber1 = fiber.FiberInstance()
Fiber2 = fiber.FiberInstance()
Fiber3 = fiber.FiberInstance()
Fiber4 = fiber.FiberInstance()
FiberYsfLo = fiber.FiberInstance()
FiberOut = fiber.FiberInstance()
FiberSmf1 = fiber.FiberInstance()
FiberSmf2 = fiber.FiberInstance()
FiberYsfHi = fiber.FiberInstance()

Fiber1.generate_fiber(L1, center_wl_nm=pulseWL, betas=betas,\
                              gamma_W_m=Gamma , gvd_units='ps^n/km', gain=-alpha)
Fiber2.generate_fiber(L2, center_wl_nm=pulseWL, betas=betas,\
                              gamma_W_m=Gamma , gvd_units='ps^n/km', gain=-alpha)
Fiber3.generate_fiber(L3, center_wl_nm=pulseWL, betas=betas,\
                              gamma_W_m=Gamma , gvd_units='ps^n/km', gain=-alpha)
Exemplo n.º 4
0
def run_simulation(caller=None):

    pump_pulse_length = float(bPulse.text)
    centerwl = float(bWave.text)  # in nm
    pump_power = float(bPower.text) * 1e3

    fiber_length = float(bLength.text) * 1e-3

    dz = float(bDz.text)
    steps = int(bSteps.text)

    npoints = int(eval(bPoints.text))

    print 'Running simulation with'
    print 'Pulse duration (fs): %f' % pump_pulse_length
    print 'Center wavelength (nm): %f' % centerwl
    print 'Pump power (W): %f' % pump_power

    print 'Fiber length (m): %f' % fiber_length

    print 'dz: %f' % dz
    print 'Steps: %i' % steps
    print 'Number of points: %i' % npoints

    init = SechPulse(pump_power,
                     pump_pulse_length,
                     centerwl,
                     time_window=5.0,
                     GDD=0,
                     TOD=0.0,
                     NPTS=npoints,
                     frep_MHz=100,
                     power_is_avg=False)

    fiber1 = fiber.FiberInstance()
    fiber1.load_from_db(fiber_length, 'dudley')

    evol = SSFM.SSFM(dz=dz, local_error=0.001, USE_SIMPLE_RAMAN=True)
    y = np.zeros(steps)
    AW = np.zeros((init.NPTS, steps))
    AT = np.copy(AW)

    y, AW, AT, pulse1 = evol.propagate(pulse_in=init,
                                       fiber=fiber1,
                                       n_steps=steps)

    wl = init.wl_nm

    loWL = 400
    hiWL = 1400

    iis = np.logical_and(wl > loWL, wl < hiWL)

    iisT = np.logical_and(init.T_ps > -1, init.T_ps < 5)

    xW = wl[iis]
    xT = init.T_ps[iisT]
    zW_in = np.transpose(AW)[:, iis]
    zT_in = np.transpose(AT)[:, iisT]
    zW = 10 * np.log10(np.abs(zW_in)**2)
    zT = 10 * np.log10(np.abs(zT_in)**2)
    mlIW = np.max(zW)
    mlIT = np.max(zT)

    D = fiber1.Beta2_to_D(init)
    beta = fiber1.Beta2(init)

    for ax in (ax1, ax2, ax3, ax4):
        ax.clear()

    axL1.plot(wl, D)
    axL1.set_xlim(400, 1600)
    axL1.set_ylim(-400, 300)
    axL1.set_xlabel('Wavelength (nm)')
    axL1.set_ylabel('D (ps/nm/km)')

    axL2.plot(wl, beta * 1000)
    axL2.set_xlim(400, 1600)
    axL2.set_ylim(-350, 200)
    axL2.set_xlabel('Wavelength (nm)')
    axL2.set_ylabel(r'$\beta_2$ (ps$^2$/km)')

    zW_grid = reinterpolate(xW, y[:-1], zW)
    extent = (np.min(xW), np.max(xW), np.min(y), np.max(y[:-1]))
    ax3.imshow(zW_grid,
               extent=extent,
               vmin=mlIW - 40.0,
               vmax=mlIW,
               aspect='auto',
               origin='lower')

    ax3.autoscale(tight=True)
    ax3.set_xlim([loWL, hiWL])
    ax3.set_xlabel('Wavelength (nm)')
    ax3.set_ylabel('Distance (m)')

    # plt.pcolormesh(xT, y, zT, vmin = mlIT - 40.0, vmax = mlIT)

    zT_grid = reinterpolate(xT, y[:-1], zT)
    extent = (np.min(xT), np.max(xT), np.min(y), np.max(y[:-1]))
    ax4.imshow(zT_grid,
               extent=extent,
               vmin=mlIT - 40.0,
               vmax=mlIT,
               aspect='auto',
               origin='lower')
    ax4.autoscale(tight=True)
    ax4.set_xlabel('Delay (ps)')
    # ax4.set_ylabel('Distance (m)')
    for label in ax4.get_yticklabels():
        label.set_visible(False)

    ax1.plot(xW, zW[0], color='b', label='Before')
    ax1.plot(xW, zW[-1], color='r', label='After')
    ax1.set_ylim(-40, 0)

    ax2.plot(xT, zT[0], color='b', label='Before')
    ax2.plot(xT, zT[-1], color='r', label='After')
    ax2.set_ylim(-10, 40)
Exemplo n.º 5
0
def run_simulation(caller=None, prop=False):
    bRun.label.set_text('Setting up...')
    drawnow()

    # Grab the parameters from the text boxes:
    pump_pulse_length = float(bPulse.text)
    centerwl = float(bWave.text)  # in nm
    pump_power = float(bPower.text) * 1e3

    fiber_length = float(bLength.text) * 1e-3

    dz = float(bDz.text)
    steps = int(bSteps.text)

    npoints = int(eval(bPoints.text))

    # set up the pulse parameters
    pulse = SechPulse(pump_power,
                      pump_pulse_length,
                      centerwl,
                      time_window=10.0,
                      GDD=0,
                      TOD=0.0,
                      NPTS=npoints,
                      frep_MHz=100,
                      power_is_avg=False)

    fiber1 = fiber.FiberInstance()
    fiber1.load_from_db(fiber_length, 'dudley')

    print 'Parameters\n------------------'
    print '--Pulse--'
    print 'Duration (ps)  %f' % pump_pulse_length
    print 'Center wl (nm) %g' % centerwl
    print 'Pump power (W) %g' % pump_power
    print '  Energy (nJ)  %f' % (pulse.calc_epp() * 1e9)
    print '--Fiber--'
    print 'Length (mm)     %f' % (fiber_length * 1e3)
    print '--Simulation--'
    print 'dz             %f' % dz
    print 'Steps          %i' % steps
    print 'Time points    %i' % npoints

    W = pulse.W_mks
    T = pulse.T_ps
    xW = W[W > 0]

    D = fiber1.Beta2_to_D(pulse)
    beta = fiber1.Beta2(pulse)

    # Plot the dispersion in the left plots
    lineL1.set_data(W[W > 0], D[W > 0])
    lineL2.set_data(W[W > 0], beta[W > 0])

    # plot the pulse in the top plots
    line1a.set_data(W[W > 0], dB(pulse.AW[W > 0]))
    line2a.set_data(T, dB(pulse.AT))

    if prop == False:
        bRun.label.set_text('Run simulation')
        drawnow()
        return  # stop here unless we've actually pressed the "Run" button

    ######################## Propagation
    t = time.time()
    bRun.label.set_text('Running...')
    drawnow()

    # set up the propagation parameters
    evol = SSFM.SSFM(dz=1e100, local_error=0.001, USE_SIMPLE_RAMAN=True)

    # propagate the pulse!
    y, AW, AT, pulse1 = evol.propagate(pulse_in=pulse,
                                       fiber=fiber1,
                                       n_steps=steps)

    zW_in = np.transpose(AW)[:, (W > 0)]
    zT_in = np.transpose(AT)
    zW = dB(zW_in)
    zT = dB(zT_in)

    bRun.label.set_text('Drawing plots...')
    drawnow()

    line1b.set_data(xW, zW[-1])
    line2b.set_data(T, zT[-1])

    for ax in (ax3, ax4):
        ax.clear()

    extent = (np.min(xW), np.max(xW), np.min(y), np.max(y[:-1]))
    ax3.imshow(zW,
               extent=extent,
               vmin=np.max(zW) - 40.0,
               vmax=np.max(zW),
               aspect='auto',
               origin='lower')
    ax3.set_xlabel('Wavelength (nm)')
    ax3.set_ylabel('Distance (m)')

    extent = (np.min(T), np.max(T), np.min(y), np.max(y[:-1]))
    ax4.imshow(zT,
               extent=extent,
               vmin=np.max(zT) - 40.0,
               vmax=np.max(zT),
               aspect='auto',
               origin='lower')
    ax4.set_xlabel('Delay (ps)')

    print 'Total time: %.2f sec' % (time.time() - t)
    bRun.label.set_text('Run simulation')
    drawnow()