Exemplo n.º 1
0
            res = math.sqrt(res)
        else:   # numpy.ndarray
            res = np.ones(Lambda.shape)
            for i in range(len(self._Bs)):
                res += (self._Bs[i]*Lambda**2) / (Lambda**2 - self._Cs[i])
            res = np.sqrt(res)

        return res


if __name__ == "__main__":

    import optcom.utils.plot as plot
    from optcom.domain import Domain

    sellmeier = Sellmeier("sio2")

    center_omega = Domain.lambda_to_omega(1050.0)
    print(sellmeier.n(center_omega))

    Lambda = np.linspace(120, 2120, 2000)
    omega = Domain.lambda_to_omega(Lambda)
    n = sellmeier.n(omega)

    x_labels = ['Lambda']
    y_labels = ['Refractive index']
    plot_titles = ["Refractive index of Silica from Sellmeier equations"]

    plot.plot2d(Lambda, n, x_labels=x_labels, y_labels=y_labels,
                plot_titles=plot_titles, opacity=0.0)
Exemplo n.º 2
0
    print(
        NLCoefficient.calc_nl_coefficient(omega,
                                          nl_index=nl_index,
                                          eff_area=eff_area))

    # With numpy ndarray
    lambdas = np.linspace(900, 1550, 10)
    omegas = Domain.lambda_to_omega(lambdas)
    n_core = np.linspace(1.42, 1.43, 10)
    n_clad = np.linspace(1.415, 1.425, 10)

    eff_area = EffectiveArea.calc_effective_area(omegas,
                                                 core_radius=core_radius,
                                                 n_core=n_core,
                                                 n_clad=n_clad)
    nl_index = NLIndex.calc_nl_index(omega, medium=medium)
    res = NLCoefficient.calc_nl_coefficient(omegas,
                                            nl_index=nl_index,
                                            eff_area=eff_area)

    x_labels = ['Lambda']
    y_labels = ['gamma']
    plot_titles = ["Non linear coefficient of Silica"]

    plot.plot2d(lambdas,
                res,
                x_labels=x_labels,
                y_labels=y_labels,
                plot_titles=plot_titles,
                opacity=0.0)
Exemplo n.º 3
0
    beta_2 = Dispersion.calc_beta_deriv(omega, 2, "SiO2")
    x_data = [Lambda]
    y_data = [beta_2]

    x_labels = ['Lambda']
    y_labels = ['beta2']
    plot_titles = ["Group velocity dispersion coefficients in Silica"]

    disp = Dispersion.calc_dispersion(Lambda, beta_2)
    x_data.append(Lambda)
    y_data.append(disp)
    x_labels.append('Lambda')
    y_labels.append('dispersion')
    plot_titles.append('Dispersion of Silica')

    beta_3 = Dispersion.calc_beta_deriv(omega, 3, "Sio2")
    slope = Dispersion.calc_dispersion_slope(Lambda, beta_2, beta_3)
    x_data.append(Lambda)
    y_data.append(slope)
    x_labels.append('Lambda')
    y_labels.append('dispersion_slope')
    plot_titles.append('Dispersion slope of Silica')

    plot.plot2d(x_data,
                y_data,
                x_labels=x_labels,
                y_labels=y_labels,
                plot_titles=plot_titles,
                split=True,
                opacity=0.0)
Exemplo n.º 4
0
            temp_phase = [phase_shift[0](0), phase_shift[1](0)]
        plot_titles += [
            "Pulses coming out of the {} with phase "
            "shift {} and {}".format(default_name, str(round(temp_phase[0],
                                                             2)),
                                     str(round(temp_phase[1], 2)))
        ]

    v_pi = [1.0]
    v_mod = [
        lambda t: math.sin(math.pi * t), lambda t: math.sin(math.pi / 2.0 * t)
    ]
    v_bias = [1.2, 2.1]
    mz = IdealMZ(v_pi=v_pi, v_mod=v_mod, v_bias=v_bias)
    lt.link((pulse[0], mz[0]))
    lt.run(pulse)
    # Plot parameters and get waves
    y_datas.append(temporal_power(mz[1][0].channels))
    plot_titles += ["Pulses coming out of the {}".format(default_name)]

    y_datas = [temporal_power(pulse[0][0].channels)] + y_datas
    x_datas = [pulse[0][0].time, mz[1][0].time]

    plot.plot2d(x_datas,
                y_datas,
                split=True,
                plot_titles=plot_titles,
                x_labels=['t'],
                y_labels=['P_t'],
                opacity=0.3)
Exemplo n.º 5
0
    ]
    y_datas = [
        spectral_power(pulse[0][0].channels),
        spectral_power(pump[0][0].channels),
        temporal_power(pulse[0][0].channels),
        temporal_power(pump[0][0].channels),
        spectral_power(np.vstack(
            (fiber[1][0].channels, fiber[1][1].channels))),
        temporal_power(np.vstack((fiber[1][0].channels, fiber[1][1].channels)))
    ]
    x_labels = ['nu', 't', 'nu', 't']
    y_labels = ['P_nu', 'P_t', 'P_nu', 'P_t']

    plot.plot2d(x_datas,
                y_datas,
                x_labels=x_labels,
                y_labels=y_labels,
                plot_groups=[0, 0, 1, 1, 2, 3],
                opacity=0.3)

    x_data_raw = np.linspace(0.0, length, steps)
    x_data = np.zeros((0, len(x_data_raw)))
    for i in range(nbr_ch_s + 2 + nbr_ch_p):
        x_data = np.vstack((x_data, x_data_raw))

    x_data = [x_data, x_data_raw.reshape((1, -1))]

    power_signal = fiber.power_signal_forward + fiber.power_signal_backward
    power_ase_forward = np.sum(fiber.power_ase_forward, axis=0)
    power_ase_backward = np.sum(fiber.power_ase_backward, axis=0)
    power_pump = fiber.power_pump_forward + fiber.power_pump_backward
    powers = np.vstack(
Exemplo n.º 6
0
    a = 5.0
    d = 15.0
    n_0 = 1.02
    norm_d = d / a
    cpl = Coupling(V=V, a=a, d=d, n_0=n_0)

    Lambda = 1550.0
    omega = Domain.lambda_to_omega(Lambda)
    print(cpl.get_kappa(omega))

    Lambda = np.linspace(900, 1600, 3)
    omega = Domain.lambda_to_omega(Lambda)
    print(cpl.get_kappa(omega))

    Lambda = np.linspace(900, 1600, 1000)
    omega = Domain.lambda_to_omega(Lambda)
    kappas = cpl.get_kappa(omega)

    plot_titles = [
        'Coupling coefficient as a function of the wavelength '
        'for norm. spacing = {}'.format(norm_d)
    ]

    plot.plot2d(Lambda,
                kappas,
                x_labels=['Lambda'],
                y_labels=['Kappa km^{-1}'],
                plot_titles=plot_titles,
                split=True,
                opacity=0.0)
Exemplo n.º 7
0
    import numpy as np

    import optcom.utils.plot as plot
    from optcom.domain import Domain

    # With float
    omega = Domain.lambda_to_omega(1552.0)

    nl_index = NLIndex(medium="SiO2")
    print(nl_index(omega))
    print(nl_index.calc_nl_index(omega, medium="SiO2"))

    # With numpy ndarray
    lambdas = np.linspace(500, 1600, 1000)
    omegas = Domain.lambda_to_omega(lambdas)

    nl_index = NLIndex(medium="SiO2")
    res = nl_index(omegas)

    x_labels = ['Lambda']
    y_labels = ['n_2']
    plot_titles = ["Non linear index of Silica from fitting formula"]

    plot.plot2d(lambdas,
                res,
                x_labels=x_labels,
                y_labels=y_labels,
                plot_titles=plot_titles,
                opacity=0.0,
                y_ranges=[(2.5 * 1e-20, 3.2 * 1e-20)])
Exemplo n.º 8
0
    lt.run(pulse_1, pulse_2, pulse_3)

    plot_titles.extend([
        "Original pulses",
        "Pulses coming out of the {} with 'combine=True'".format(default_name)
    ])
    plot_groups.extend([2, 2, 2, 3])
    plot_labels.extend(['port 0', 'port 1', 'port 2', None])

    y_datas.extend([
        temporal_power(pulse_1[0][0].channels),
        temporal_power(pulse_2[0][0].channels),
        temporal_power(pulse_3[0][0].channels),
        temporal_power(pm[1][0].channels)
    ])

    x_datas.extend([
        pulse_1[0][0].time, pulse_2[0][0].time, pulse_3[0][0].time,
        pm[1][0].time
    ])

    plot.plot2d(x_datas,
                y_datas,
                plot_labels=plot_labels,
                plot_groups=plot_groups,
                plot_titles=plot_titles,
                x_labels=['t'],
                y_labels=['P_t'],
                opacity=0.3)
Exemplo n.º 9
0
        sigmas = stimu.get_cross_section(omegas, center_omega, N_0, N_1, T)
        x_data.append(lambdas)
        y_data.append(sigmas)
        dopant_name = dopant[0].upper() + dopant[1:]
        plot_titles.append("Cross sections {} from formula and McCumber "
                           "relations".format(dopant_name))

    for i, file in enumerate(files):
        nbr_samples = 1000
        lambdas = np.linspace(file_range[i][0], file_range[i][1], nbr_samples)
        omegas = Domain.lambda_to_omega(lambdas)
        file_name = folder + file + '.txt'
        predict = CSVFit(file_name=file_name, conv_factor=[1e9, 1e18])  # in nm
        stimu = StimulatedEmission(predict=predict)
        sigmas = stimu.get_cross_section(omegas)
        x_data.append(lambdas)
        y_data.append(sigmas)
        dopant_name = file[0].upper() + file[1:]
        plot_titles.append(
            "Emission ross sections {} from data file".format(dopant_name))

    plot.plot2d(x_data,
                y_data,
                x_labels=['Lambda'],
                y_labels=['sigma_e'],
                split=True,
                plot_colors='red',
                plot_titles=plot_titles,
                plot_linestyles='-.',
                opacity=0.0)
Exemplo n.º 10
0
    order = [1, 2, 1]
    chirp = [0.0, 0.5, 0.1]
    init_phi = [0.0, 1.0, 0.0]

    gssn = Gaussian(channels=channels,
                    center_lambda=center_lambda,
                    position=position,
                    width=width,
                    peak_power=peak_power,
                    bit_rate=bit_rate,
                    offset_nu=offset_nu,
                    order=order,
                    chirp=chirp,
                    init_phi=init_phi,
                    save=True)

    lt.run(gssn)

    x_datas = [gssn[0][0].time, gssn[0][0].nu]
    y_datas = [
        temporal_power(gssn[0][0].channels),
        spectral_power(gssn[0][0].channels)
    ]

    plot.plot2d(x_datas,
                y_datas,
                x_labels=["t", "nu"],
                y_labels=["P_t", "P_nu"],
                plot_titles=["Gaussian pulse"],
                split=True)
Exemplo n.º 11
0
    f_c: float = cst.F_C
    x_data.append(time)
    h_R = Raman.calc_h_R(time, f_a=f_a, f_b=f_b, f_c=f_c)
    y_data.append(h_R)
    plot_labels.append('Isotropic and anisotropic part')
    f_a = 1.0
    f_b = 0.0
    f_c = 1.0
    x_data.append(time)
    h_R = Raman.calc_h_R(time, f_a=f_a, f_b=f_b, f_c=f_c)
    y_data.append(h_R)
    plot_labels.append('W/o anisotropic part')
    f_a = 0.0
    f_b = 1.0
    f_c = 0.0
    x_data.append(time)
    h_R = Raman.calc_h_R(time, f_a=f_a, f_b=f_b, f_c=f_c)
    y_data.append(h_R)
    plot_labels.append('W/o isotropic part')

    plot_titles = ['Raman response function', 'Raman gain']

    plot.plot2d(x_data,
                y_data,
                x_labels=['t'],
                y_labels=['h_R'],
                plot_groups=[0, 0, 0],
                plot_titles=plot_titles,
                opacity=0.0,
                plot_labels=plot_labels)
Exemplo n.º 12
0
                 conv_func=[domain.Domain.lambda_to_omega],
                 root_dir=root_dir)
    Lambda = 976.0
    omega = domain.Domain.lambda_to_omega(Lambda)
    print(csv(omega, 1))

    Lambda = np.arange(300) + 850.
    omega = domain.Domain.lambda_to_omega(Lambda)
    res_1 = csv(omega, 0)

    root_dir = "./data/fiber_amp/cross_section/emission/"
    file_name = ('yb.txt')
    csv = CSVFit(file_name, ',', conv_factor=[1e9, 1e18],
                 conv_func=[domain.Domain.lambda_to_omega],
                 root_dir=root_dir)
    res_2 = csv(omega, 0)
    print('1010 : ', csv(domain.Domain.lambda_to_omega(1010.), 0))
    print('1015 : ', csv(domain.Domain.lambda_to_omega(1015.), 0))
    print('1020 : ', csv(domain.Domain.lambda_to_omega(1020.), 0))
    print('1025 : ', csv(domain.Domain.lambda_to_omega(1025.), 0))
    print('1030 : ', csv(domain.Domain.lambda_to_omega(1030.), 0))
    Lambda_temp = np.arange(150) + 1000.
    omega_temp = domain.Domain.lambda_to_omega(Lambda_temp)
    res_temp = csv(omega_temp, 0)
    print('max at ',
          domain.Domain.omega_to_lambda(omega_temp[np.argmax(res_temp)]),
          ' : ', np.amax(res_temp))

    plot.plot2d([Lambda], [res_1, res_2], x_labels=['Lambda'],
                y_labels=['sigma_a'], line_labels=['absorption', 'emission'])
Exemplo n.º 13
0
    channels = 1
    center_lambda = [1552.0, 1549.0, 1596.0]
    peak_power = [1e-3, 2e-3, 6e-3]
    total_power = [1e-3]
    offset_nu = [0.0, 1.56, -1.6]
    init_phi = [1.0, 1.0, 0.0]

    cw = CW(channels=channels,
            center_lambda=center_lambda,
            peak_power=peak_power,
            offset_nu=offset_nu,
            init_phi=init_phi,
            save=True)

    lt.run(cw)

    plot_titles = ["CW pulse spectral power"]
    x_datas = [cw[0][0].nu]
    y_datas = [spectral_power(cw[0][0].channels)]

    for i in range((int(samples / 2) - 4), (int(samples / 2) + 4)):
        print(y_datas[0][0][i])

    plot.plot2d(x_datas,
                y_datas,
                x_labels=["nu"],
                y_labels=["P_nu"],
                plot_titles=plot_titles,
                split=True,
                opacity=0.2)
Exemplo n.º 14
0
                               RS=False,
                               XPM=False,
                               ASYM=True,
                               COUP=True,
                               approx_type=1,
                               nlse_method='ssfm_super_sym',
                               steps=steps,
                               ode_method=method,
                               save=True,
                               wait=False,
                               NOISE=True)
        lt.add_link(pulse[0], coupler[0])
        lt.run(pulse)
        lt.reset()
        # Plot parameters and get waves
        x_datas.append(coupler[2][0].time)
        y_datas.append(Field.temporal_power(coupler[2][0].channels))
        plot_groups.append(0)

    line_labels.extend(ode_methods)
    plot_titles.extend(["ODE solvers test with n={}".format(str(steps))])
    # -------------------- Plotting results ------------------------
    plot.plot2d(x_datas,
                y_datas,
                plot_groups=plot_groups,
                plot_titles=plot_titles,
                x_labels=['t'],
                y_labels=['P_t'],
                line_labels=line_labels,
                line_opacities=[0.1])
Exemplo n.º 15
0
        CSVFit


    lt = layout.Layout(domain.Domain(samples_per_bit=512,bit_width=20.0))
    pulse = gaussian.Gaussian(channels=2, peak_power=[10.0, 10e-1],
                              width=[1.0, 5.0], center_lambda=[1050.0, 1048.0])
    gamma_data = CSVFit('./data/gamma_test.txt')
    fiber = Fiber(length=.10, method="ssfm_symmetric", alpha=[0.046],
                  alpha_order=4, beta_order=4, gamma=1.5,
                  nl_approx=False, ATT=True, DISP=True,
                  SPM=True, XPM=False, SS=False, RS=False, approx_type=1,
                  steps=1000, medium='sio2')
    lt.link((pulse[0], fiber[0]))
    lt.run(pulse)

    x_datas = [pulse[0][0].nu, fiber[1][0].nu,
               pulse[0][0].time, fiber[1][0].time]

    y_datas = [spectral_power(pulse[0][0].channels),
               spectral_power(fiber[1][0].channels),
               temporal_power(pulse[0][0].channels),
               temporal_power(fiber[1][0].channels)]

    x_labels = ['nu', 'nu', 't', 't']
    y_labels = ['P_nu', 'P_nu', 'P_t', 'P_t']
    plot_titles = ["Original Pulse", "Pulse at the end of the fiber"]
    plot_titles.extend(plot_titles)

    plot.plot2d(x_datas, y_datas, x_labels=x_labels, y_labels=y_labels,
                plot_titles=plot_titles, plot_groups=[0,1,2,3], opacity=0.3)