def main(network, equipment, source, destination, req = None):
    result_dicts = {}
    network_data = [{
                    'network_name'  : str(args.filename),
                    'source'        : source.uid,
                    'destination'   : destination.uid
                    }]
    result_dicts.update({'network': network_data})
    design_data = [{
                    'power_mode'        : equipment['Spans']['default'].power_mode,
                    'span_power_range'  : equipment['Spans']['default'].delta_power_range_db,
                    'design_pch'        : equipment['SI']['default'].power_dbm,
                    'baud_rate'         : equipment['SI']['default'].baud_rate
                    }]
    result_dicts.update({'design': design_data})
    simulation_data = []
    result_dicts.update({'simulation results': simulation_data})

    power_mode = equipment['Spans']['default'].power_mode
    print('\n'.join([f'Power mode is set to {power_mode}',
                     f'=> it can be modified in eqpt_config.json - Spans']))

    pref_ch_db = lin2db(req.power*1e3) #reference channel power / span (SL=20dB)
    pref_total_db = pref_ch_db + lin2db(req.nb_channel) #reference total power / span (SL=20dB)
    build_network(network, equipment, pref_ch_db, pref_total_db)
    path = compute_constrained_path(network, req)

    spans = [s.length for s in path if isinstance(s, Fiber)]
    print(f'\nThere are {len(spans)} fiber spans over {sum(spans):.0f}m between {source.uid} and {destination.uid}')
    print(f'\nNow propagating between {source.uid} and {destination.uid}:')

    try:
        p_start, p_stop, p_step = equipment['SI']['default'].power_range_db
        p_num = abs(int(round((p_stop - p_start)/p_step))) + 1 if p_step != 0 else 1
        power_range = list(linspace(p_start, p_stop, p_num))
    except TypeError:
        print('invalid power range definition in eqpt_config, should be power_range_db: [lower, upper, step]')
        power_range = [0]

    for dp_db in power_range:
        req.power = db2lin(pref_ch_db + dp_db)*1e-3
        print(f'\nPropagating with input power = {lin2db(req.power*1e3):.2f}dBm :')
        infos = propagate2(path, req, equipment, show=len(power_range)==1)
        print(f'\nTransmission result for input power = {lin2db(req.power*1e3):.2f}dBm :')
        print(destination)

        #print(f'\n !!!!!!!!!!!!!!!!!     TEST POINT         !!!!!!!!!!!!!!!!!!!!!')
        #print(f'carriers ase output of {path[1]} =\n {list(path[1].carriers("out", "nli"))}')
        # => use "in" or "out" parameter
        # => use "nli" or "ase" or "signal" or "total" parameter

        simulation_data.append({
                    'Pch_dBm'               : pref_ch_db + dp_db,
                    'OSNR_ASE_0.1nm'        : round(mean(destination.osnr_ase_01nm),2),
                    'OSNR_ASE_signal_bw'    : round(mean(destination.osnr_ase),2),
                    'SNR_nli_signal_bw'     : round(mean(destination.osnr_nli),2),
                    'SNR_total_signal_bw'   : round(mean(destination.snr),2)
                            })
    write_csv(result_dicts, 'simulation_result.csv')
    return path, infos
def compute_path(network, equipment, pathreqlist):

    # This function is obsolete and not relevant with respect to network building: suggest either to correct
    # or to suppress it

    path_res_list = []

    for pathreq in pathreqlist:
        #need to rebuid the network for each path because the total power
        #can be different and the choice of amplifiers in autodesign is power dependant
        #but the design is the same if the total power is the same
        #TODO parametrize the total spectrum power so the same design can be shared
        p_db = lin2db(pathreq.power * 1e3)
        p_total_db = p_db + lin2db(pathreq.nb_channel)
        build_network(network, equipment, p_db, p_total_db)
        pathreq.nodes_list.append(pathreq.destination)
        #we assume that the destination is a strict constraint
        pathreq.loose_list.append('strict')
        print(f'Computing path from {pathreq.source} to {pathreq.destination}')
        print(f'with path constraint: {[pathreq.source]+pathreq.nodes_list}'
              )  #adding first node to be clearer on the output
        total_path = compute_constrained_path(network, pathreq)
        print(
            f'Computed path (roadms):{[e.uid for e in total_path  if isinstance(e, Roadm)]}\n'
        )

        if total_path:
            total_path = propagate(total_path, pathreq, equipment, show=False)
        else:
            total_path = []
        # we record the last tranceiver object in order to have th whole
        # information about spectrum. Important Note: since transceivers
        # attached to roadms are actually logical elements to simulate
        # performance, several demands having the same destination may use
        # the same transponder for the performance simaulation. This is why
        # we use deepcopy: to ensure each propagation is recorded and not
        # overwritten

        path_res_list.append(deepcopy(total_path))
    return path_res_list
Example #3
0
def main(network, equipment, source, destination, req=None):
    result_dicts = {}
    network_data = [{
        'network_name': str(args.filename),
        'source': source.uid,
        'destination': destination.uid
    }]
    result_dicts.update({'network': network_data})
    design_data = [{
        'power_mode': equipment['Spans']['default'].power_mode,
        'span_power_range': equipment['Spans']['default'].delta_power_range_db,
        'design_pch': equipment['SI']['default'].power_dbm,
        'baud_rate': equipment['SI']['default'].baud_rate
    }]
    result_dicts.update({'design': design_data})
    simulation_data = []
    result_dicts.update({'simulation results': simulation_data})

    power_mode = equipment['Spans']['default'].power_mode
    print('\n'.join([
        f'Power mode is set to {power_mode}',
        f'=> it can be modified in eqpt_config.json - Spans'
    ]))

    pref_ch_db = lin2db(req.power *
                        1e3)  #reference channel power / span (SL=20dB)
    pref_total_db = pref_ch_db + lin2db(
        req.nb_channel)  #reference total power / span (SL=20dB)
    build_network(network, equipment, pref_ch_db, pref_total_db)
    path = compute_constrained_path(network, req)

    spans = [s.length for s in path if isinstance(s, Fiber)]
    print(
        f'\nThere are {len(spans)} fiber spans over {sum(spans):.0f}m between {source.uid} and {destination.uid}'
    )
    print(f'\nNow propagating between {source.uid} and {destination.uid}:')

    try:
        power_range = list(arange(*equipment['SI']['default'].power_range_db))
        last = equipment['SI']['default'].power_range_db[-2]
        if len(power_range) == 0:  #bad input that will lead to no simulation
            power_range = [0]  #better than an error message
        else:
            power_range.append(last)
    except TypeError:
        print(
            'invalid power range definition in eqpt_config, should be power_range_db: [lower, upper, step]'
        )
        power_range = [0]

    for dp_db in power_range:
        req.power = db2lin(pref_ch_db + dp_db) * 1e-3
        print(
            f'\nPropagating with input power = {lin2db(req.power*1e3):.2f}dBm :'
        )
        propagate(path, req, equipment, show=len(power_range) == 1)
        print(
            f'\nTransmission result for input power = {lin2db(req.power*1e3):.2f}dBm :'
        )
        print(destination)
        simulation_data.append({
            'Pch_dBm':
            pref_ch_db + dp_db,
            'OSNR_ASE_0.1nm':
            round(mean(destination.osnr_ase_01nm), 2),
            'OSNR_ASE_signal_bw':
            round(mean(destination.osnr_ase), 2),
            'SNR_nli_signal_bw':
            round(mean(destination.osnr_nli), 2),
            'SNR_total_signal_bw':
            round(mean(destination.snr), 2)
        })
    write_csv(result_dicts, 'simulation_result.csv')
    return path