Skip to content

Commit

Permalink
Computes reference input power in fiber during design
Browse files Browse the repository at this point in the history
input power is computed at design time: so let's record it and
use it instead of p_span_i for reference channel fiber loss computation.
Note that this loss parameter is only used for visualisation purpose.

Signed-off-by: EstherLerouzic <[email protected]>
Change-Id: I16bd792bd6079ce521aafadcf5e21922aa3b4c81
  • Loading branch information
EstherLerouzic committed Nov 2, 2023
1 parent e75ed54 commit f04506a
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 9 deletions.
7 changes: 7 additions & 0 deletions gnpy/core/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ def __init__(self, *args, params=None, **kwargs):
f"({1e-3 * self.params.length} km), boundaries excluded.")
self.lumped_losses = db2lin(- lumped_losses_power) # [linear units]
self.z_lumped_losses = array(z_lumped_losses) * 1e3 # [m]
self.ref_pch_in_dbm = None

@property
def to_json(self):
Expand Down Expand Up @@ -635,6 +636,12 @@ def __call__(self, spectral_info):
self._psig_in = sum(spectral_info.signal)
self.propagate(spectral_info)
self.update_pref(spectral_info)
# In case of Raman, the resulting loss of the fiber is not equivalent to self.loss
# because of Raman gain. The resulting loss is:
# power_out - power_in. We use the total signal power (sum on all channels) to compute
# this loss.
loss = round(lin2db(self._psig_in / sum(spectral_info.signal)), 2)
self.pch_out_db = self.ref_pch_in_dbm - loss
return spectral_info


Expand Down
44 changes: 37 additions & 7 deletions gnpy/core/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,33 @@ def set_roadm_input_powers(network, roadm, equipment, pref_ch_db):
)


def set_fiber_input_power(network, fiber, equipment, pref_ch_db):
"""Set reference powers at fiber input for a reference channel.
Supposes that target power out of ROADMs and amplifiers are consistent.
This is only for visualisation purpose
"""
ref_carrier = ReferenceCarrier(baud_rate=equipment['SI']['default'].baud_rate,
slot_width=equipment['SI']['default'].spacing)
loss = 0.0
node = next(network.predecessors(fiber))
while isinstance(node, elements.Fused):
loss += node.loss
previous_node = node
node = next(network.predecessors(node))
if isinstance(node, (elements.Fiber, elements.RamanFiber)) and node.ref_pch_in_dbm is not None:
fiber.ref_pch_in_dbm = node.ref_pch_in_dbm - loss - node.loss
if isinstance(node, (elements.Fiber, elements.RamanFiber)) and node.ref_pch_in_dbm is None:
set_fiber_input_power(network, node, equipment, pref_ch_db)
fiber.ref_pch_in_dbm = node.ref_pch_in_dbm - loss - node.loss
elif isinstance(node, elements.Roadm):
fiber.ref_pch_in_dbm = \
node.get_per_degree_ref_power(degree=previous_node.uid, ref_carrier=ref_carrier) - loss
elif isinstance(node, elements.Edfa):
fiber.ref_pch_in_dbm = pref_ch_db + node._delta_p - node.out_voa - loss
elif isinstance(node, elements.Transceiver):
fiber.ref_pch_in_dbm = pref_ch_db - loss


def add_roadm_booster(network, roadm):
next_nodes = [n for n in network.successors(roadm)
if not (isinstance(n, elements.Transceiver) or isinstance(n, elements.Fused) or isinstance(n, elements.Edfa))]
Expand Down Expand Up @@ -604,7 +631,7 @@ def build_network(network, equipment, pref_ch_db, pref_total_db, no_insert_edfas
# =>for code clarity (at the expense of speed):

roadms = [r for r in network.nodes() if isinstance(r, elements.Roadm)]

transceivers = [t for t in network.nodes() if isinstance(t, elements.Transceiver)]
if not no_insert_edfas:
for fiber in fibers:
split_fiber(network, fiber, bounds, target_length, equipment)
Expand All @@ -621,12 +648,15 @@ def build_network(network, equipment, pref_ch_db, pref_total_db, no_insert_edfas

for roadm in roadms:
set_roadm_per_degree_targets(roadm, network)
for roadm in roadms + transceivers:
set_egress_amplifier(network, roadm, equipment, pref_ch_db, pref_total_db)
for roadm in roadms:
set_roadm_input_powers(network, roadm, equipment, pref_ch_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)
for fiber in [f for f in network.nodes() if isinstance(f, (elements.Fiber, elements.RamanFiber))]:
set_fiber_input_power(network, fiber, equipment, pref_ch_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)
1 change: 1 addition & 0 deletions tests/test_amplifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ def test_amp_behaviour(tilt_target, delta_p):
fiber = [n for n in network.nodes() if isinstance(n, Fiber)][0]
fiber.params.con_in = 0
fiber.params.con_out = 0
fiber.ref_pch_in_dbm = 0.0
si = create_input_spectral_information(f_min=191.3e12, f_max=196.05e12, roll_off=0.15, baud_rate=64e9, power=0.001,
spacing=75e9, tx_osnr=None)
si = fiber(si)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_science_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
def test_fiber():
"""Test the accuracy of propagating the Fiber."""
fiber = Fiber(**load_json(TEST_DIR / 'data' / 'test_science_utils_fiber_config.json'))

fiber.ref_pch_in_dbm = 0.0
# fix grid spectral information generation
spectral_info_input = create_input_spectral_information(f_min=191.3e12, f_max=196.1e12, roll_off=0.15,
baud_rate=32e9, power=1e-3, spacing=50e9, tx_osnr=40.0,
Expand Down Expand Up @@ -73,7 +73,7 @@ def test_raman_fiber():
ref_carrier=ReferenceCarrier(baud_rate=32e9, slot_width=50e9))
SimParams.set_params(load_json(TEST_DIR / 'data' / 'sim_params.json'))
fiber = RamanFiber(**load_json(TEST_DIR / 'data' / 'test_science_utils_fiber_config.json'))

fiber.ref_pch_in_dbm = 0.0
# propagation
spectral_info_out = fiber(spectral_info_input)

Expand Down

0 comments on commit f04506a

Please sign in to comment.