Raman: linear interpolation of channel NLI

The Raman engine computes NLI just for a subset of channels; this is an
important speed optimization because the computation is rather CPU
heavy. However, the code just left NaNs in place for NLI of those
channels which were not explicitly simulated.

This is wrong because these NaNs propagate all the way to the total
input/output powers per the whole spectrum, etc, leading to NaNs being
shown to the user.

This patch uses a very simple linear approximation just in order to
prevent these NaNs.

fixes #288
This commit is contained in:
Jan Kundrát
2019-09-01 21:59:35 +02:00
parent 1862ce9104
commit 54bf426472

View File

@@ -191,17 +191,21 @@ def propagate_raman_fiber(fiber, *carriers):
attenuation_out = db2lin(fiber.con_out)
nli_solver = NliSolver(nli_params=nli_params, fiber_params=fiber_params)
nli_solver.stimulated_raman_scattering = stimulated_raman_scattering
new_carriers = []
for carrier, attenuation, rmn_ase in zip(carriers, fiber_attenuation, raman_ase):
nli_frequencies = []
computed_nli = []
for carrier in (c for c in carriers if c.channel_number in sim_params.raman_computed_channels):
resolution_param = frequency_resolution(carrier, carriers, sim_params, fiber_params)
f_cut_resolution, f_pump_resolution, _, _ = resolution_param
nli_params.f_cut_resolution = f_cut_resolution
nli_params.f_pump_resolution = f_pump_resolution
nli_frequencies.append(carrier.frequency)
computed_nli.append(nli_solver.compute_nli(carrier, *carriers))
new_carriers = []
for carrier, attenuation, rmn_ase in zip(carriers, fiber_attenuation, raman_ase):
carrier_nli = np.interp(carrier.frequency, nli_frequencies, computed_nli)
pwr = carrier.power
if carrier.channel_number in sim_params.raman_computed_channels:
carrier_nli = nli_solver.compute_nli(carrier, *carriers)
else:
carrier_nli = np.nan
pwr = pwr._replace(signal=pwr.signal/attenuation/attenuation_out,
nli=(pwr.nli+carrier_nli)/attenuation/attenuation_out,
ase=((pwr.ase/attenuation)+rmn_ase)/attenuation_out)