Skip to content

Commit

Permalink
Merge "Feat: add offset power option for transceivers"
Browse files Browse the repository at this point in the history
  • Loading branch information
EstherLerouzic authored and gerritforge-ltd committed Oct 31, 2023
2 parents 7fd7f94 + a3edb20 commit e79f9f5
Show file tree
Hide file tree
Showing 9 changed files with 284 additions and 23 deletions.
5 changes: 4 additions & 1 deletion gnpy/core/equipment.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def trx_mode_params(equipment, trx_type_variety='', trx_mode='', error_message=F
+ f' mode "{trx_params["format"]}" has baud rate'
+ f' {trx_params["baud_rate"] * 1e-9:.3f} GHz greater than min_spacing'
+ f' {trx_params["min_spacing"] * 1e-9:.3f}.')
trx_params['equalization_offset_db'] = trx_params.get('equalization_offset_db', 0)
else:
mode_params = {"format": "undetermined",
"baud_rate": None,
Expand All @@ -42,7 +43,8 @@ def trx_mode_params(equipment, trx_type_variety='', trx_mode='', error_message=F
"roll_off": None,
"tx_osnr": None,
"min_spacing": None,
"cost": None}
"cost": None,
"equalization_offset_db": 0}
trx_params = {**mode_params}
trx_params['f_min'] = equipment['Transceiver'][trx_type_variety].frequency['min']
trx_params['f_max'] = equipment['Transceiver'][trx_type_variety].frequency['max']
Expand All @@ -68,6 +70,7 @@ def trx_mode_params(equipment, trx_type_variety='', trx_mode='', error_message=F
trx_params['roll_off'] = default_si_data.roll_off
trx_params['tx_osnr'] = default_si_data.tx_osnr
trx_params['min_spacing'] = None
trx_params['equalization_offset_db'] = 0

trx_params['power'] = db2lin(default_si_data.power_dbm) * 1e-3

Expand Down
5 changes: 3 additions & 2 deletions gnpy/core/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,15 @@ def create_arbitrary_spectral_information(frequency: Union[ndarray, Iterable, fl
raise


def create_input_spectral_information(f_min, f_max, roll_off, baud_rate, power, spacing, tx_osnr, ref_carrier=None):
def create_input_spectral_information(f_min, f_max, roll_off, baud_rate, power, spacing, tx_osnr, delta_pdb=0,
ref_carrier=None):
"""Creates a fixed slot width spectral information with flat power.
all arguments are scalar values"""
number_of_channels = automatic_nch(f_min, f_max, spacing)
frequency = [(f_min + spacing * i) for i in range(1, number_of_channels + 1)]
p_span0 = watt2dbm(power)
p_spani = watt2dbm(power)
delta_pdb_per_channel = zeros(number_of_channels)
delta_pdb_per_channel = delta_pdb * ones(number_of_channels)
label = [f'{baud_rate * 1e-9 :.2f}G' for i in range(number_of_channels)]
return create_arbitrary_spectral_information(frequency, slot_width=spacing, signal=power, baud_rate=baud_rate,
roll_off=roll_off, delta_pdb_per_channel=delta_pdb_per_channel,
Expand Down
1 change: 0 additions & 1 deletion gnpy/tools/cli_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ def path_requests_run(args=None):
# TODO power density: db2linp(ower_dbm": 0)/power_dbm": 0 * nb channels as defined by
# spacing, f_min and f_max
p_db = equipment['SI']['default'].power_dbm

p_total_db = p_db + lin2db(automatic_nch(equipment['SI']['default'].f_min,
equipment['SI']['default'].f_max, equipment['SI']['default'].spacing))
try:
Expand Down
2 changes: 1 addition & 1 deletion gnpy/tools/json_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def __init__(self, **kwargs):
for mode_params in self.mode:
penalties = mode_params.get('penalties')
mode_params['penalties'] = {}
mode_params['equalization_offset_db'] = mode_params.get('equalization_offset_db', 0)
if not penalties:
continue
for impairment in ('chromatic_dispersion', 'pmd', 'pdl'):
Expand Down Expand Up @@ -574,7 +575,6 @@ def requests_from_json(json_data, equipment):
# nb_channel is computed based on min max frequency and spacing
trx_params = trx_mode_params(equipment, params['trx_type'], params['trx_mode'], True)
params.update(trx_params)
# print(trx_params['min_spacing'])
# optical power might be set differently in the request. if it is indicated then the
# params['power'] is updated
try:
Expand Down
30 changes: 17 additions & 13 deletions gnpy/topology/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@
RequestParams = namedtuple('RequestParams', 'request_id source destination bidir trx_type'
' trx_mode nodes_list loose_list spacing power nb_channel f_min'
' f_max format baud_rate OSNR penalties bit_rate'
' roll_off tx_osnr min_spacing cost path_bandwidth effective_freq_slot')
' roll_off tx_osnr min_spacing cost path_bandwidth effective_freq_slot'
' equalization_offset_db')
DisjunctionParams = namedtuple('DisjunctionParams', 'disjunction_id relaxable link_diverse'
' node_diverse disjunctions_req')


class PathRequest:
"""the class that contains all attributes related to a request"""

def __init__(self, *args, **params):
params = RequestParams(**params)
self.request_id = params.request_id
Expand Down Expand Up @@ -72,6 +72,7 @@ def __init__(self, *args, **params):
self.N = params.effective_freq_slot['N']
self.M = params.effective_freq_slot['M']
self.initial_spectrum = None
self.offset_db = params.equalization_offset_db

def __str__(self):
return '\n\t'.join([f'{type(self).__name__} {self.request_id}',
Expand Down Expand Up @@ -351,7 +352,8 @@ def propagate(path, req, equipment):
else:
si = create_input_spectral_information(
f_min=req.f_min, f_max=req.f_max, roll_off=req.roll_off, baud_rate=req.baud_rate,
power=req.power, spacing=req.spacing, tx_osnr=req.tx_osnr, ref_carrier=ref_carrier(equipment))
power=req.power, spacing=req.spacing, tx_osnr=req.tx_osnr, delta_pdb=req.offset_db,
ref_carrier=ref_carrier(equipment))
for i, el in enumerate(path):
if isinstance(el, Roadm):
si = el(si, degree=path[i+1].uid)
Expand All @@ -369,20 +371,21 @@ def propagate(path, req, equipment):

def propagate_and_optimize_mode(path, req, equipment):
# if mode is unknown : loops on the modes starting from the highest baudrate fiting in the
# step 1: create an ordered list of modes based on baudrate
baudrate_to_explore = list(set([this_mode['baud_rate']
for this_mode in equipment['Transceiver'][req.tsp].mode
if float(this_mode['min_spacing']) <= req.spacing]))
# step 1: create an ordered list of modes based on baudrate and power offset
# order higher baudrate with higher power offset first
baudrate_offset_to_explore = list(set([(this_mode['baud_rate'], this_mode['equalization_offset_db'])
for this_mode in equipment['Transceiver'][req.tsp].mode
if float(this_mode['min_spacing']) <= req.spacing]))
# TODO be carefull on limits cases if spacing very close to req spacing eg 50.001 50.000
baudrate_to_explore = sorted(baudrate_to_explore, reverse=True)
if baudrate_to_explore:
baudrate_offset_to_explore = sorted(baudrate_offset_to_explore, reverse=True)
if baudrate_offset_to_explore:
# at least 1 baudrate can be tested wrt spacing
for this_br in baudrate_to_explore:
for (this_br, this_offset) in baudrate_offset_to_explore:
modes_to_explore = [this_mode for this_mode in equipment['Transceiver'][req.tsp].mode
if this_mode['baud_rate'] == this_br and
float(this_mode['min_spacing']) <= req.spacing]
if this_mode['baud_rate'] == this_br
and float(this_mode['min_spacing']) <= req.spacing]
modes_to_explore = sorted(modes_to_explore,
key=lambda x: x['bit_rate'], reverse=True)
key=lambda x: (x['bit_rate'], x['equalization_offset_db']), reverse=True)
# step2: computes propagation for each baudrate: stop and select the first that passes
# TODO: the case of roll off is not included: for now use SI one
# TODO: if the loop in mode optimization does not have a feasible path, then bugs
Expand All @@ -394,6 +397,7 @@ def propagate_and_optimize_mode(path, req, equipment):
spc_info = create_input_spectral_information(f_min=req.f_min, f_max=req.f_max,
roll_off=equipment['SI']['default'].roll_off,
baud_rate=this_br, power=req.power, spacing=req.spacing,
delta_pdb=this_offset,
tx_osnr=req.tx_osnr, ref_carrier=ref_carrier(equipment))
for i, el in enumerate(path):
if isinstance(el, Roadm):
Expand Down
2 changes: 1 addition & 1 deletion tests/data/eqpt_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
"tx_osnr": 45,
"min_spacing": 75e9,
"cost":1
},
},
{
"format": "mode 4",
"baud_rate": 66e9,
Expand Down
Loading

0 comments on commit e79f9f5

Please sign in to comment.