def layout(channels, peak_powers, widths, center_lambdas):
        domain = Domain(bit_width=100.0, samples_per_bit=2048)
        lt = Layout(domain)
        dtime = domain.dtime
        out_temporal_power = []
        out_spectral_power = []
        gssn = Gaussian(channels=channels,
                        peak_power=peak_powers,
                        width=widths,
                        center_lambda=center_lambdas)
        for i in range(2):
            if (i):
                cfg.RK4IP_OPTI_GNLSE = True
            else:
                cfg.RK4IP_OPTI_GNLSE = False
            fiber = Fiber(length=0.2,
                          nlse_method='rk4ip',
                          alpha=[0.5],
                          beta_order=3,
                          nl_approx=False,
                          ATT=True,
                          DISP=True,
                          SPM=True,
                          XPM=True,
                          SS=True,
                          RS=True,
                          steps=1000,
                          save=True)
            lt.add_link(gssn[0], fiber[0])
            lt.run(gssn)
            lt.reset()
            out_temporal_power.append(temporal_power(fiber[1][0].channels))
            out_spectral_power.append(spectral_power(fiber[1][0].channels))

        return (out_temporal_power, out_spectral_power)
Exemple #2
0
    def layout(starter, ATT, DISP, SPM, SS, RS, approx):
        domain = Domain()
        lt = Layout(domain)
        dtime = domain.dtime
        domega = domain.domega
        out_temporal_power = []
        out_spectral_power = []
        out_temporal_fwhm = []
        out_spectral_fwhm = []
        nlse_method = "ssfm_symmetric"
        flag = True
        till_nbr = 4 if approx else 5
        for i in range(1, till_nbr):
            if (i == 4):
                flag = False
            fiber = Fiber(length=1.0,
                          nlse_method=nlse_method,
                          alpha=[0.046],
                          nl_approx=flag,
                          ATT=ATT,
                          DISP=DISP,
                          SPM=SPM,
                          SS=SS,
                          RS=RS,
                          steps=1000,
                          save=True,
                          approx_type=i)
            lt.add_link(starter[0], fiber[0])
            lt.run(starter)
            lt.reset()
            out_temporal_power.append(temporal_power(fiber[1][0].channels))
            out_spectral_power.append(spectral_power(fiber[1][0].channels))
            out_temporal_fwhm.append(fwhm(out_temporal_power[-1], dtime))
            out_spectral_fwhm.append(fwhm(out_spectral_power[-1], domega))
        in_temporal_power = temporal_power(starter[0][0].channels)
        in_spectral_power = spectral_power(starter[0][0].channels)
        in_temporal_fwhm = fwhm(in_temporal_power, dtime)
        in_spectral_fwhm = fwhm(in_spectral_power, domega)

        return (in_temporal_power, in_spectral_power, in_temporal_fwhm,
                in_spectral_fwhm, out_temporal_power, out_spectral_power,
                out_temporal_fwhm, out_spectral_fwhm)
def test_combine_output_diff_omega_and_rep_freq(nbr_channels, ratios):
    """Should fail if the different omega and repetition frequencies
    are added to each other.
    """
    # Environment creation
    back_up_flag_omega = cfg.get_field_op_matching_omega()
    back_up_flag_rep_freq = cfg.get_field_op_matching_rep_freq()
    cfg.set_field_op_matching_omega(True)
    cfg.set_field_op_matching_rep_freq(True)
    gssns = []
    nbr_arms = len(ratios)
    base_power = 10.0
    for i in range(nbr_arms):
        gssns.append(
            Gaussian(channels=nbr_channels,
                     save=True,
                     peak_power=[(j + 1) * base_power
                                 for j in range(nbr_channels)],
                     center_lambda=[(1500. + j) * (i + 1)
                                    for j in range(nbr_channels)],
                     rep_freq=[(1e-2 + (j * 1e-4)) * (i + 1)
                               for j in range(nbr_channels)]))
    combiner = IdealCombiner(arms=nbr_arms,
                             ratios=ratios,
                             save=True,
                             combine=True)
    lt = Layout()
    for i in range(nbr_arms):
        lt.add_link(gssns[i][0], combiner[i])
    lt.run_all()
    lt.reset()
    # Testing
    init_fields = []
    for i in range(0, nbr_arms):
        init_fields.extend(gssns[i][0].fields)
    output_fields = combiner[nbr_arms].fields
    assert len(output_fields) == 1
    assert len(output_fields[0]) == (nbr_channels * nbr_arms)
    # Reset
    cfg.set_field_op_matching_omega(back_up_flag_omega)
    cfg.set_field_op_matching_rep_freq(back_up_flag_rep_freq)
Exemple #4
0
def test_interplay_dispersion_and_spm():
    """Should fail if (i) fwhm of temporal output powers for small
    N square number is greater than fwhm of initial pulse or (ii)
    fwhm of temporal output powers for big N square number is
    greater than initial fwhm in case of positive GVD and smaller
    than initial fwhm in case of negative GVD.

    Notes
    -----
    Test case::

    gssn ___ fiber

    """
    # Environment creation
    domain = Domain()
    lt = Layout(domain)
    dtime = domain.dtime
    fwhms_pos_gvd = []
    fwhms_neg_gvd = []
    time_pos_gvd = []
    time_neg_gvd = []
    nlse_method = "ssfm_symmetric"
    # Make sure to have a positive GVD to pass the test
    gssn = Gaussian(channels=1, peak_power=[1.0], center_lambda=[1030.])
    flag = True
    for i in range(1, 5):
        if (i == 4):
            flag = False
        fiber = Fiber(length=1.0,
                      nlse_method=nlse_method,
                      alpha=[0.46],
                      gamma=2.0,
                      nl_approx=flag,
                      ATT=False,
                      DISP=True,
                      SPM=True,
                      SS=False,
                      RS=False,
                      steps=1000,
                      save=True,
                      approx_type=i,
                      beta=[1e5, 1e3, 20.0])
        lt.add_link(gssn[0], fiber[0])
        lt.run(gssn)
        lt.reset()
        time_pos_gvd.append(fiber[1][0].time)
        fwhms_pos_gvd.append(fwhm(temporal_power(fiber[1][0].channels), dtime))
    flag = True
    for i in range(1, 5):
        if (i == 4):
            flag = False
        fiber = Fiber(length=1.0,
                      nlse_method=nlse_method,
                      alpha=[0.46],
                      gamma=2.0,
                      nl_approx=flag,
                      ATT=False,
                      DISP=True,
                      SPM=True,
                      SS=False,
                      RS=False,
                      steps=1000,
                      save=True,
                      approx_type=i,
                      beta=[1e5, 1e3, -20.0])
        lt.add_link(gssn[0], fiber[0])
        lt.run(gssn)
        lt.reset()
        time_neg_gvd.append(fiber[1][0].time)
        fwhms_neg_gvd.append(fwhm(temporal_power(fiber[1][0].channels), dtime))
    fwhm_temporal_gssn = fwhm(temporal_power(gssn[0][0].channels), dtime)
    time_gssn = gssn[0][0].time
    # Testing
    for i in range(len(fwhms_neg_gvd)):
        assert_array_less(time_gssn, time_pos_gvd[i])
        assert_array_less(time_gssn, time_neg_gvd[i])
        assert fwhm_temporal_gssn[0] < fwhms_pos_gvd[i][0]
        assert fwhms_neg_gvd[i][0] < fwhm_temporal_gssn[0]