Ejemplo n.º 1
0
class SechPowerTest(unittest.TestCase):
    TEST_PTS = 2**8
    power = 3.2
    fr = 2720.
    EPP = power / (fr * 1e6)

    def setUp(self):
        self.sech = SechPulse(power=self.power,
                              T0_ps=0.0100,
                              center_wavelength_nm=1064,
                              NPTS=self.TEST_PTS,
                              time_window_ps=12.345,
                              frep_MHz=self.fr,
                              power_is_avg=True)

    def tearDown(self):
        pass

    def test_wavelength_meters(self):
        self.assertAlmostEqual(self.sech.calc_epp(), self.EPP)
Ejemplo n.º 2
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()
Ejemplo n.º 3
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()