Ejemplo n.º 1
0
    def test(self):
        # With initial condition y(1) = 2, solution is
        def exact(x):
            return np.power(x + x**2 * (0.5 * 2**(2. / 3.) - 1), -3)

        ystart = np.ones((1, ))
        ystart[:] = [2.0]

        rtol = 1.0e-13
        atol = 1.0e-13
        x0 = 1.0
        x1 = 4.0
        hmin = 0.0
        h1 = 0.01
        out = ode_solve.Output(1)

        a = ode_solve.ODEint(ystart, x0, x1, atol, rtol, h1,hmin, out,\
                 dopr853.StepperDopr853, integrand() )
        a.integrate()
        y_calc = a.out.ysave[a.out.count - 1]
        y_exct = exact(a.out.xsave[a.out.count - 1])
        self.assertAlmostEqual(y_calc, y_exct, delta=2 * atol * y_exct)
Ejemplo n.º 2
0
                        sgnl_in,
                        idlr_in,
                        crystal,
                        disable_SPM=True,
                        waist=beamwaist)

# Set up integrator
rtol = 1.0e-6
atol = 1.0e-6
x0 = 0.0
x1 = crystallength
hmin = 0.0
h1 = 0.00001
out = ode_solve.Output(n_saves)

a = ode_solve.ODEint(integrand.ystart, x0, x1, atol, rtol, h1,hmin, out,\
         dopr853.StepperDopr853, integrand)
a.integrate()

print 'integrated!'

pump_out = a.out.ysave[0:a.out.count, 0:npoints].T
sgnl_out = a.out.ysave[0:a.out.count, npoints:2 * npoints].T
idlr_out = a.out.ysave[0:a.out.count, 2 * npoints:3 * npoints].T
z = a.out.xsave[0:a.out.count]

pump_power_in = np.round(
    1e3 * np.trapz(abs(IFFT_t(pump_out[:, 0]))**2, pump_in.T) * pump_in.frep,
    decimals=4)
signal_power_in = np.round(
    1e3 * np.trapz(abs(IFFT_t(sgnl_out[:, 0]))**2, sgnl_in.T) * sgnl_in.frep,
    decimals=4)
Ejemplo n.º 3
0
w_1 = omega(sgnl_wl_nm)
w_2 = omega(idlr_wl_nm)
k_1 = 2*np.pi*crystal.n(sgnl_wl_nm, 'o') / ( sgnl_wl_nm * 1.0e-9)
k_2 = 2*np.pi*crystal.n(idlr_wl_nm, 'o') / ( idlr_wl_nm * 1.0e-9)

n_1 = crystal.n(sgnl_wl_nm, 'o')
n_2 = crystal.n(idlr_wl_nm, 'o')
n_3 = crystal.n(pump_wl_nm, 'mix')


A_3 = np.sqrt(pump_power) * integrand.pump_beam.rtP_to_a(crystal.n(pump_wl_nm, 'mix'))
A_1 = np.sqrt(sgnl_power) * integrand.sgnl_beam.rtP_to_a(crystal.n(sgnl_wl_nm, 'o'))

kappa = np.mean(np.sqrt( 4 * np.mean(crystal.deff)**2 * w_1**2 * w_2**2 / (k_1*k_2 * speed_of_light**4)) * A_3)

a = ode_solve.ODEint(integrand.ystart, x0, x1, atol, rtol, h1,hmin, out,\
         dopr853.StepperDopr853, integrand, dtype = np.complex128)
print 'Running'
a.integrate()
print 'integrated!'
print 'coupling length is ',1.0/kappa,'m'
print 'calculated coupling coeff. is ',kappa

print 'theoretical d idler/dz is ',A_1*A_3*(2*w_2**2*crystal.deff)/(k_2*speed_of_light**2)

pump_out = a.out.ysave[0:a.out.count, 0         : npoints].T
sgnl_out = a.out.ysave[0:a.out.count, npoints   :   2*npoints].T
idlr_out = a.out.ysave[0:a.out.count, 2*npoints :   3*npoints].T
z        = a.out.xsave[0:a.out.count]

pump_power_in =    np.sum(np.abs(pump_out[:,0]))**2
sgnl_power_in =    np.sum(np.abs(sgnl_out[:,0]))**2
Ejemplo n.º 4
0
    def test_fn(self):
        npoints = 2**6
        # Physical lengths are in meters
        crystallength = 0.010
        crystal = crystals.AgGaSe2()
        crystal = crystals.AgGaSe2(length=crystallength)

        n_saves = 10

        # Wavelengths are in nanometers
        pump_wl_nm = 1560. + 10.0 * np.random.rand()
        sgnl_wl_nm = 2200. + 10.0 * np.random.rand()
        theta, idlr_wl_nm = crystal.phasematch(pump_wl_nm,
                                               sgnl_wl_nm,
                                               None,
                                               return_wavelength=True)
        crystal.set_theta(theta)

        pump_power = (1 + np.random.rand()) * 5000.0
        sgnl_power = 0.10 * np.random.rand()
        twind = 25.
        beamwaist = 100e-3

        pump_in = CWPulse(pump_power,
                          pump_wl_nm,
                          NPTS=npoints,
                          time_window_ps=twind)
        sgnl_in = CWPulse(sgnl_power,
                          sgnl_wl_nm,
                          NPTS=npoints,
                          time_window_ps=twind)

        integrand = dfg_problem(pump_in,
                                sgnl_in,
                                crystal,
                                disable_SPM=True,
                                pump_waist=beamwaist,
                                apply_gouy_phase=True)

        # Set up integrator
        rtol = 1.0e-12
        atol = 1.0e-12
        x0 = 0.0
        x1 = crystallength
        hmin = 0.0
        h1 = 0.0000001
        out = ode_solve.Output(n_saves)

        # From Boyd section 2.8, also my One Note
        omega = lambda l_nm: 2.0 * np.pi * speed_of_light / (l_nm * 1.0e-9)
        w_1 = omega(sgnl_wl_nm)
        w_2 = omega(idlr_wl_nm)
        k_1 = np.mean(2 * np.pi * crystal.n(sgnl_wl_nm, 'o') /
                      (sgnl_wl_nm * 1.0e-9))
        k_2 = np.mean(2 * np.pi * crystal.n(idlr_wl_nm, 'o') /
                      (idlr_wl_nm * 1.0e-9))

        n_1 = crystal.n(sgnl_wl_nm, 'o')
        n_2 = crystal.n(idlr_wl_nm, 'o')
        n_3 = crystal.n(pump_wl_nm, 'mix')

        A_3 = np.sqrt(pump_power) * integrand.pump_beam.rtP_to_a(
            crystal.n(pump_wl_nm, 'mix'))
        A_1 = np.sqrt(sgnl_power) * integrand.sgnl_beam.rtP_to_a(
            crystal.n(sgnl_wl_nm, 'o'))

        kappa = np.mean(
            np.sqrt(4 * crystal.deff**2 * w_1**2 * w_2**2 /
                    (k_1 * k_2 * speed_of_light**4)) * A_3)

        a = ode_solve.ODEint(integrand.ystart, x0, x1, atol, rtol, h1,hmin, out,\
                 dopr853.StepperDopr853, integrand, dtype = np.complex128)
        a.integrate()

        pump_out = a.out.ysave[0:a.out.count, 0:npoints].T
        sgnl_out = a.out.ysave[0:a.out.count, npoints:2 * npoints].T
        idlr_out = a.out.ysave[0:a.out.count, 2 * npoints:3 * npoints].T
        z = a.out.xsave[0:a.out.count]

        pump_power_in = np.sum(np.abs(pump_out[:, 0]), axis=0)**2
        sgnl_power_in = np.sum(np.abs(sgnl_out[:, ])**2, axis=0)
        idlr_power_in = np.sum(np.abs(idlr_out[:, 0]), axis=0)**2

        pump_power_out = np.sum(np.abs(pump_out[:, -1]))**2
        sgnl_power_out = np.sum(np.abs(sgnl_out[:, -1]))**2
        idlr_power_out = np.sum(np.abs(idlr_out[:, -1]))**2

        # Compare integrated and analytic values for signal power
        numeric_sgnl = np.sum(np.abs(sgnl_out[:, :])**2, axis=0)
        analytic_sgnl = sgnl_power_in * np.cosh(kappa * z)**2
        self.assertLess(
            abs(
                np.sum(numeric_sgnl - analytic_sgnl) /
                np.sum(abs(analytic_sgnl))), 0.01)

        # Compare integrated and analytic values for idler power
        numeric_idlr = np.sum(np.abs(idlr_out[:, :])**2, axis=0)
        analytic_idlr = n_1 * w_2 / (n_2 * w_1) * sgnl_power_in * np.sinh(
            kappa * z)**2
        self.assertLess(
            abs(
                np.sum(numeric_idlr - analytic_idlr) /
                np.sum(abs(analytic_idlr))), 0.02)