示例#1
0
def build_network(network, equipment, pref_ch_db, pref_total_db):
    default_span_data = equipment['Span']['default']
    max_length = int(convert_length(default_span_data.max_length, default_span_data.length_units))
    min_length = max(int(default_span_data.padding / 0.2 * 1e3), 50_000)
    bounds = range(min_length, max_length)
    target_length = max(min_length, 90_000)

    # set roadm loss for gain_mode before to build network
    fibers = [f for f in network.nodes() if isinstance(f, elements.Fiber)]
    add_connector_loss(network, fibers, default_span_data.con_in, default_span_data.con_out, default_span_data.EOL)
    add_fiber_padding(network, fibers, default_span_data.padding)
    # don't group split fiber and add amp in the same loop
    # =>for code clarity (at the expense of speed):
    for fiber in fibers:
        split_fiber(network, fiber, bounds, target_length, equipment)

    amplified_nodes = [n for n in network.nodes() if isinstance(n, elements.Fiber) or isinstance(n, elements.Roadm)]

    for node in amplified_nodes:
        add_egress_amplifier(network, node)

    roadms = [r for r in amplified_nodes if isinstance(r, elements.Roadm)]
    for roadm in roadms:
        set_egress_amplifier(network, roadm, equipment, pref_ch_db, pref_total_db)

    trx = [t for t in network.nodes() if isinstance(t, elements.Transceiver)]
    for t in trx:
        next_node = next(network.successors(t), None)
        if next_node and not isinstance(next_node, elements.Roadm):
            set_egress_amplifier(network, t, equipment, 0, pref_total_db)
 def __init__(self, **kwargs):
     try:
         self._length = convert_length(kwargs['length'],
                                       kwargs['length_units'])
         # fixed attenuator for padding
         self._att_in = kwargs['att_in'] if 'att_in' in kwargs else 0
         # if not defined in the network json connector loss in/out
         # the None value will be updated in network.py[build_network]
         # with default values from eqpt_config.json[Spans]
         self._con_in = kwargs['con_in'] if 'con_in' in kwargs else None
         self._con_out = kwargs['con_out'] if 'con_out' in kwargs else None
         if 'ref_wavelength' in kwargs:
             self._ref_wavelength = kwargs['ref_wavelength']
             self._ref_frequency = c / self.ref_wavelength
         elif 'ref_frequency' in kwargs:
             self._ref_frequency = kwargs['ref_frequency']
             self._ref_wavelength = c / self.ref_frequency
         else:
             self._ref_wavelength = 1550e-9
             self._ref_frequency = c / self.ref_wavelength
         self._dispersion = kwargs['dispersion']  # s/m/m
         self._dispersion_slope = kwargs['dispersion_slope'] if 'dispersion_slope' in kwargs else \
             -2 * self._dispersion/self.ref_wavelength  # s/m/m/m
         self._beta2 = -(self.ref_wavelength**2) * self.dispersion / (
             2 * pi * c)  # 1/(m * Hz^2)
         # Eq. (3.23) in  Abramczyk, Halina. "Dispersion phenomena in optical fibers." Virtual European University
         # on Lasers. Available online: http://mitr.p.lodz.pl/evu/lectures/Abramczyk3.pdf
         # (accessed on 25 March 2018) (2005).
         self._beta3 = (
             (self.dispersion_slope -
              (4 * pi * c / self.ref_wavelength**3) * self.beta2) /
             (2 * pi * c / self.ref_wavelength**2)**2)
         self._gamma = kwargs['gamma']  # 1/W/m
         self._pmd_coef = kwargs['pmd_coef']  # s/sqrt(m)
         if type(kwargs['loss_coef']) == dict:
             self._loss_coef = squeeze(
                 kwargs['loss_coef']
                 ['loss_coef_power']) * 1e-3  # lineic loss dB/m
             self._f_loss_ref = squeeze(
                 kwargs['loss_coef']['frequency'])  # Hz
         else:
             self._loss_coef = kwargs['loss_coef'] * 1e-3  # lineic loss dB/m
             self._f_loss_ref = 193.5e12  # Hz
         self._lin_attenuation = db2lin(self.length * self.loss_coef)
         self._lin_loss_exp = self.loss_coef / (
             10 * log10(exp(1)))  # linear power exponent loss Neper/m
         self._effective_length = (
             1 - exp(-self.lin_loss_exp * self.length)) / self.lin_loss_exp
         self._asymptotic_length = 1 / self.lin_loss_exp
         # raman parameters (not compulsory)
         self._raman_efficiency = kwargs[
             'raman_efficiency'] if 'raman_efficiency' in kwargs else None
         self._pumps_loss_coef = kwargs[
             'pumps_loss_coef'] if 'pumps_loss_coef' in kwargs else None
     except KeyError as e:
         raise ParametersError(
             f'Fiber configurations json must include {e}. Configuration: {kwargs}'
         )