Telecominfraproject / oopt-gnpy

Optical Route Planning Library, Based on a Gaussian Noise Model
http://telecominfraproject.com
BSD 3-Clause "New" or "Revised" License
201 stars 87 forks source link

voa in function: set_egress-amplifier #370

Open Tobelightbeam opened 3 years ago

Tobelightbeam commented 3 years ago

In gnpy.core.network, the function set_egress-amplifier is defined to set the parameters of EDFAs. It sets delta_p or target_gain of an EDFA according to previous node's dp, out_voa and span loss. However, the process to iterate out_voa one by one seems wrong.

To be detailed: In line 262, voa = node.out_voa if node.out_voa else 0,voa is set as current node's out_voa. Then, in line 308, set_amplifier_voa(node, power_target, power_mode), current node's out_voa is adjusted. However, in line 310 - 313, where the current node begins to be transformed into a "previous" node,prev_voa = voa, prev_voa is set as voa, rather than node.out_voa.

It seems that node.out_voa is not passed to prev_voa correctly.

ojnas commented 3 years ago

The set_amplifier_voa method also updates the current Edfas delta_p to compensate for the voa, which is not reflected in prev_dp = dp. I think these two "errors" cancel each other when the target gain of the next Edfa is calculated, no? But the code definitely is a bit confusing.

Tobelightbeam commented 3 years ago

hi @ojnas , I got your idea. It's true that there is a balance between delta_p and out_voa for the set_amplifier_voa method. But prev_dp = node.delta_p and prev_voa = node.out_voa are more direct than prev_dp = dp and prev_voa = voa, I think. So maybe we can consider to do this to improve readability.