beta=[0.0, 1.0, -19.83, 0.031], gamma=4.3, nl_approx=nl_approx, SPM=True, f_R=0.0, XPM=False, SS=False, RS=False, approx_type=1, steps=steps, save=True) lt.link((pulse[0], fiber[0])) lt.run(pulse) lt.reset() # Plot parameters and get waves x_datas.append(fiber[1][0].time) y_datas.append(temporal_power(fiber[1][0].channels)) plot_groups.append(0) plot_labels.extend(nlse_methods) plot_titles.extend(["NLSE pde solvers test with n={}".format(str(steps))]) # -------------------- Plotting results ---------------------------- plot.plot2d(x_datas, y_datas, plot_groups=plot_groups, plot_titles=plot_titles, x_labels=['t'], y_labels=['P_t'], plot_labels=plot_labels, opacity=0.3)
order = [1, 2, 1] chirp = [0.0, 0.5, 0.1] init_phi = [0.0, 1.0, 0.0] gssn = Gaussian(channels=channels, center_lambda=center_lambda, position=position, width=width, peak_power=peak_power, bit_rate=bit_rate, offset_nu=offset_nu, order=order, chirp=chirp, init_phi=init_phi, save=True) lt.run(gssn) x_datas = [gssn[0][0].time, gssn[0][0].nu] y_datas = [ temporal_power(gssn[0][0].channels), spectral_power(gssn[0][0].channels) ] plot.plot2d(x_datas, y_datas, x_labels=["t", "nu"], y_labels=["P_t", "P_nu"], plot_titles=["Gaussian pulse"], split=True)
arms = 3 ratios = [round(random.uniform(0, 1), 2) for i in range(arms)] divider = IdealDivider(arms=arms, ratios=ratios, save=True) lt.link((pulse[0], divider[0])) lt.run(pulse) plot_titles = ([ "Original pulse", "Pulses coming out of the {} with " "ratios {}".format(default_name, str(ratios)) ]) plot_groups: List[int] = [0] + [1 for i in range(arms)] plot_labels: List[Optional[str]] = [None] plot_labels.extend(["port {}".format(str(i)) for i in range(arms)]) fields = [temporal_power(pulse.fields[0].channels)] times = [pulse.fields[0].time] for i in range(1, arms + 1): fields.append(temporal_power(divider.fields[i].channels)) times.append(divider.fields[i].time) plot.plot(times, fields, plot_groups=plot_groups, plot_titles=plot_titles, x_labels=['t'], y_labels=['P_t'], plot_labels=plot_labels, opacity=0.3)
plot_labels: List[Optional[str]] = [None] plot_groups: List[Optional[int]] = [0] plot_titles: List[Optional[str]] = ["Original pulse"] fields = [] time = [] for i in range(4): # Propagation coupler = IdealFiberCoupler(ratios_ports=[ratios_ports[i]]) lt.link((pulse[0], coupler[i])) lt.run(pulse) lt.reset() # Plot parameters and get waves port_saved = ((i | 1) + 2) % 4 fields.append(temporal_power(coupler.fields[port_saved - 1].channels)) fields.append(temporal_power(coupler.fields[port_saved].channels)) time.append(coupler.fields[port_saved - 1].time) time.append(coupler.fields[port_saved].time) plot_labels += [ "port " + str(port_saved - 1), "port " + str(port_saved) ] plot_groups += [i + 1, i + 1] plot_titles += [ "Pulses coming out of the {} from input port {} with " "ratios {}".format(default_name, i, ratios_ports[i]) ] fields = [temporal_power(pulse.fields[0].channels)] + fields time = [pulse.fields[0].time] + time
solver_order='alternating', error=error, propagate_pump=True, save_all=True) lt.link((pulse[0], fiber[0]), (pump[0], fiber[2])) lt.run(pulse, pump) x_datas = [ pulse[0][0].nu, pump[0][0].nu, pulse[0][0].time, pump[0][0].time, np.vstack((fiber[1][0].nu, fiber[1][1].nu)), np.vstack((fiber[1][0].time, fiber[1][1].time)) ] y_datas = [ spectral_power(pulse[0][0].channels), spectral_power(pump[0][0].channels), temporal_power(pulse[0][0].channels), temporal_power(pump[0][0].channels), spectral_power(np.vstack( (fiber[1][0].channels, fiber[1][1].channels))), temporal_power(np.vstack((fiber[1][0].channels, fiber[1][1].channels))) ] x_labels = ['nu', 't', 'nu', 't'] y_labels = ['P_nu', 'P_t', 'P_nu', 'P_t'] plot.plot2d(x_datas, y_datas, x_labels=x_labels, y_labels=y_labels, plot_groups=[0, 0, 1, 1, 2, 3], opacity=0.3)
channels = 3 center_lambda = [1552.0, 1549.0, 1596.0] position = [0.3, 0.5] width = [5.3, 6] peak_power = [1e-3, 2e-3, 6e-3] bit_rate = [0.03, 0.04] offset_nu = [1.56, -1.6] chirp = [0.5, 0.1] init_phi = [1.0, 0.0] sech = Sech(channels=channels, center_lambda=center_lambda, position=position, width=width, peak_power=peak_power, bit_rate=bit_rate, offset_nu=offset_nu, chirp=chirp, init_phi=init_phi, save=True) lt.run(sech) plot.plot([sech.fields[0].time, sech.fields[0].nu], [ temporal_power(sech.fields[0].channels), spectral_power(sech.fields[0].channels) ], ["t", "nu"], ["P_t", "P_nu"], plot_titles=["Sech pulse"], split=True)
import optcom.domain as domain from optcom.utils.utilities_user import temporal_power lt = layout.Layout() pulse = gaussian.Gaussian(channels=1, peak_power=[10.0]) gain = 3.0 amp = IdealAmplifier(gain=gain) lt.link((pulse[0], amp[0])) lt.run(pulse) plot_titles = ([ "Original pulse", "Pulses coming out of the {} with gain " "{} dB.".format(default_name, gain) ]) fields = [ temporal_power(pulse.fields[0].channels), temporal_power(amp.fields[1].channels) ] times = [pulse.fields[0].time, amp.fields[1].time] pulse = gaussian.Gaussian(channels=1, peak_power=[10.0]) peak_power = 15.0 amp = IdealAmplifier(gain=5.6, peak_power=peak_power) lt.reset() lt.link((pulse[0], amp[0])) lt.run(pulse) plot_titles.extend([ "Pulses coming out of the {} with target peak power " "{} W.".format(default_name, peak_power) ]) fields.extend([temporal_power(amp.fields[1].channels)])
phase lt = layout.Layout(Domain(samples_per_bit=4096)) channels = 3 center_lambda = [1552.0, 1549.0, 1596.0] peak_power = [1e-3, 2e-3, 6e-3] offset_nu = [0.0, 1.56, -1.6] init_phi = [1.0, 1.0, 0.0] cw = CW(channels=channels, center_lambda=center_lambda, peak_power=peak_power, offset_nu=offset_nu, init_phi=init_phi, save=True) lt.run(cw) plot_titles = [ "CW pulse temporal power", "CW pulse spectral power", "CW pulse phase" ] plot.plot([cw.fields[0].time, cw.fields[0].nu, cw.fields[0].time], [ temporal_power(cw.fields[0].channels), spectral_power(cw.fields[0].channels), phase(cw.fields[0].channels) ], ["t", "nu", "t"], ["P_t", "P_nu", "phi"], plot_titles=plot_titles, split=True)
cw = CW(channels=channels, center_lambda=center_lambda, peak_power=peak_power, offset_nu=offset_nu, init_phi=init_phi, save=True) lt.run(cw) plot_titles = [ "CW pulse temporal power", "CW pulse spectral power", "CW pulse phase" ] x_datas = [cw[0][0].time, cw[0][0].nu, cw[0][0].time] y_datas = [ temporal_power(cw[0][0].channels), spectral_power(cw[0][0].channels), phase(cw[0][0].channels) ] #plot.plot2d(x_datas, y_datas, x_labels=["t","nu","t"], # y_labels=["P_t", "P_nu", "phi"], plot_titles=plot_titles, # split=True, opacity=0.2) samples = int(2**(10)) bit_width = 3. lt = layout.Layout(Domain(samples_per_bit=samples, bit_width=bit_width)) channels = 1 center_lambda = [1552.0, 1549.0, 1596.0] peak_power = [1e-3, 2e-3, 6e-3]
bit_rate = [0.03, 0.04] offset_nu = [1.56, -1.6] chirp = [0.5, 0.1] init_phi = [1.0, 0.0] sech = Sech(channels=channels, center_lambda=center_lambda, position=position, width=width, peak_power=peak_power, bit_rate=bit_rate, offset_nu=offset_nu, chirp=chirp, init_phi=init_phi, save=True) lt.run(sech) x_datas = [sech[0][0].time, sech[0][0].nu] y_datas = [ temporal_power(sech[0][0].channels), spectral_power(sech[0][0].channels) ] plot.plot2d(x_datas, y_datas, x_labels=["t", "nu"], y_labels=["P_t", "P_nu"], plot_titles=["Sech pulse"], split=True)
ASYM=True, COUP=True, approx_type=1, method='ssfm_super_sym', steps=steps, save=True, wait=False) lt.link((pulse_1[0], coupler[0])) lt.link((pulse_2[0], coupler[1])) lt.run(pulse_1) #lt.run(pulse_1, pulse_2) y_datas = [ temporal_power(pulse_1[0][0].channels), temporal_power(coupler[2][0].channels), temporal_power(coupler[3][0].channels) ] x_datas = [pulse_1[0][0].time, coupler[2][0].time, coupler[3][0].time] plot_groups = [0, 1, 2] plot_titles = [ "Original pulse", "Pulse coming out of the coupler with " + "Lk = {}".format(str(round(length * kappa_, 2))) ] plot_titles.append(plot_titles[-1]) plot_labels = ["port 0", "port 2", "port 3"] plot.plot2d(x_datas, y_datas,
center_lambda = [1552.0, 1549.0, 976.0] position = [0.3, 0.5, 0.4] width = [5.3, 6] bit_rate = [0.03, 0.04] offset_nu = [1.56, -1.6] order = [2, 1] init_phi = [1.0, 0.0] beta_2 = [-19.0, -17.0] gamma = [4.3, 4.6] soli = Soliton(channels=channels, center_lambda=center_lambda, position=position, width=width, bit_rate=bit_rate, offset_nu=offset_nu, order=order, init_phi=init_phi, beta_2=beta_2, gamma=gamma, save=True) lt.run(soli) plot.plot([soli.fields[0].time, soli.fields[0].nu], [ temporal_power(soli.fields[0].channels), spectral_power(soli.fields[0].channels) ], ["t", "nu"], ["P_t", "P_nu"], plot_titles=["Soliton pulse"], split=True)
ASYM=True, COUP=True, approx_type=1, method='ssfm_super_sym', steps=steps, save=True, wait=False) lt.link((pulse_1[0], coupler[0])) lt.link((pulse_2[0], coupler[1])) lt.run(pulse_1) #lt.run(pulse_1, pulse_2) fields = [ temporal_power(pulse_1.fields[0].channels), temporal_power(coupler.fields[2].channels), temporal_power(coupler.fields[3].channels) ] time = [ pulse_1.fields[0].time, coupler.fields[2].time, coupler.fields[3].time ] plot_groups = [0, 1, 2] plot_titles = [ "Original pulse", "Pulse coming out of the coupler with " + "Lk = {}".format(str(round(length * kappa_, 2))) ] plot_titles.append(plot_titles[-1]) plot_labels = ["port 0", "port 2", "port 3"]
import optcom.domain as domain from optcom.utils.utilities_user import temporal_power lt = layout.Layout() pulse = gaussian.Gaussian(channels=1, peak_power=[10.0]) gain = 3.0 amp = IdealAmplifier(gain=gain) lt.link((pulse[0], amp[0])) lt.run(pulse) plot_titles = ([ "Original pulse", "Pulses coming out of the {} with gain " "{} dB.".format(default_name, gain) ]) y_datas = [ temporal_power(pulse[0][0].channels), temporal_power(amp[1][0].channels) ] x_datas = [pulse[0][0].time, amp[1][0].time] pulse = gaussian.Gaussian(channels=1, peak_power=[10.0]) peak_power = 15.0 amp = IdealAmplifier(gain=5.6, peak_power=peak_power) lt.reset() lt.link((pulse[0], amp[0])) lt.run(pulse) plot_titles.extend([ "Pulses coming out of the {} with target peak power " "{} W.".format(default_name, peak_power) ]) y_datas.extend([temporal_power(amp[1][0].channels)])
combiner = IdealCombiner(arms=3, combine=False, ratios=[2.0, 1.5, 0.5]) lt.link((pulse_1[0], combiner[0]), (pulse_2[0], combiner[1]), (pulse_3[0], combiner[2]), (combiner[3], pm[0])) lt.run(pulse_1, pulse_2, pulse_3) plot_titles = ([ "Original pulses", "Pulses coming out of the {} with 'comibne=False'".format(default_name) ]) plot_groups = [0, 0, 0, 1] plot_labels = ['port 0', 'port 1', 'port 2', None] fields = [ temporal_power(pulse_1.fields[0].channels), temporal_power(pulse_2.fields[0].channels), temporal_power(pulse_3.fields[0].channels), temporal_power(pm.fields[1].channels) ] times = [ pulse_1.fields[0].time, pulse_2.fields[0].time, pulse_3.fields[0].time, pm.fields[1].time ] lt.reset() pm = modulator.IdealPhaseMod() pulse_1 = gaussian.Gaussian(peak_power=[1.0], center_lambda=[1550.0]) pulse_2 = gaussian.Gaussian(channels=2,
arms = 3 ratios = [round(random.uniform(0, 1), 2) for i in range(arms)] divider = IdealDivider(arms=arms, ratios=ratios, save=True) lt.link((pulse[0], divider[0])) lt.run(pulse) plot_titles = ([ "Original pulse", "Pulses coming out of the {} with " "ratios {}".format(default_name, str(ratios)) ]) plot_groups: List[int] = [0] + [1 for i in range(arms)] plot_labels: List[Optional[str]] = [None] plot_labels.extend(["port {}".format(str(i)) for i in range(arms)]) y_datas = [temporal_power(pulse[0][0].channels)] x_datas = [pulse[0][0].time] for i in range(1, arms + 1): y_datas.append(temporal_power(divider[i][0].channels)) x_datas.append(divider[i][0].time) plot.plot2d(x_datas, y_datas, plot_groups=plot_groups, plot_titles=plot_titles, x_labels=['t'], y_labels=['P_t'], plot_labels=plot_labels, opacity=0.3)
random_phase = random() * math.pi random_phase_bis = random() * math.pi phase_shifts = [[random_phase, random_phase], [math.pi/2,0.0], [random_phase, random_phase_bis]] fields = [] plot_titles = ["Original pulse"] for i, phase_shift in enumerate(phase_shifts): # Propagation mz = IdealMZ(phase_shift=phase_shift, loss=loss) lt.link((pulse[0], mz[0])) lt.run(pulse) lt.reset() # Plot parameters and get waves fields.append(temporal_power(mz.fields[1].channels)) if (isinstance(phase_shift[0], float)): temp_phase = phase_shift else: temp_phase = [phase_shift[0](0), phase_shift[1](0)] plot_titles += ["Pulses coming out of the {} with phase " "shift {} and {}" .format(default_name, str(round(temp_phase[0], 2)), str(round(temp_phase[1], 2)))] v_pi = [1.0] v_mod = [lambda t: math.sin(math.pi*t), lambda t: math.sin(math.pi/2.0*t)] v_bias = [1.2, 2.1] mz = IdealMZ(v_pi=v_pi, v_mod=v_mod, v_bias=v_bias) lt.link((pulse[0], mz[0])) lt.run(pulse)
combiner = IdealCombiner(arms=3, combine=False, ratios=[2.0, 1.5, 0.5]) lt.link((pulse_1[0], combiner[0]), (pulse_2[0], combiner[1]), (pulse_3[0], combiner[2]), (combiner[3], pm[0])) lt.run(pulse_1, pulse_2, pulse_3) plot_titles = ([ "Original pulses", "Pulses coming out of the {} with 'comibne=False'".format(default_name) ]) plot_groups = [0, 0, 0, 1] plot_labels = ['port 0', 'port 1', 'port 2', None] y_datas = [ temporal_power(pulse_1[0][0].channels), temporal_power(pulse_2[0][0].channels), temporal_power(pulse_3[0][0].channels), temporal_power(pm[1][0].channels) ] x_datas = [ pulse_1[0][0].time, pulse_2[0][0].time, pulse_3[0][0].time, pm[1][0].time ] lt.reset() pm = modulator.IdealPhaseMod() pulse_1 = gaussian.Gaussian(peak_power=[1.0], center_lambda=[1550.0]) pulse_2 = gaussian.Gaussian(channels=2,
init_phi = [1.0, 0.0] beta_2 = [-19.0, -17.0] gamma = [4.3, 4.6] soli = Soliton(channels=channels, center_lambda=center_lambda, position=position, width=width, bit_rate=bit_rate, offset_nu=offset_nu, order=order, init_phi=init_phi, beta_2=beta_2, gamma=gamma, save=True) lt.run(soli) x_datas = [soli[0][0].time, soli[0][0].nu] y_datas = [ temporal_power(soli[0][0].channels), spectral_power(soli[0][0].channels) ] plot.plot2d(x_datas, y_datas, x_labels=["t", "nu"], y_labels=["P_t", "P_nu"], plot_titles=["Soliton pulse"], split=True)
alpha=[0.046], beta=[0.0, 1.0, -19.83, 0.031], gamma=4.3, nl_approx=nl_approx, SPM=True, XPM=False, SS=False, RS=False, approx_type=1, steps=steps, save=True) lt.link((pulse[0], fiber[0])) lt.run(pulse) lt.reset() # Plot parameters and get waves times.append(fiber.fields[1].time) fields.append(temporal_power(fiber.fields[1].channels)) plot_groups.append(0) plot_labels.extend(nlse_methods) plot_titles.extend(["NLSE pde solvers test with n={}".format(str(steps))]) # -------------------- Plotting results ---------------------------- plot.plot(times, fields, plot_groups=plot_groups, plot_titles=plot_titles, x_labels=['t'], y_labels=['P_t'], plot_labels=plot_labels, opacity=0.3)
plot_labels: List[Optional[str]] = [None] plot_groups: List[Optional[int]] = [0] plot_titles: List[Optional[str]] = ["Original pulse"] y_datas = [] x_datas = [] for i in range(4): # Propagation coupler = IdealFiberCoupler(ratios_ports=[ratios_ports[i]]) lt.link((pulse[0], coupler[i])) lt.run(pulse) lt.reset() # Plot parameters and get waves port_saved = ((i | 1) + 2) % 4 y_datas.append(temporal_power(coupler[port_saved - 1][0].channels)) y_datas.append(temporal_power(coupler[port_saved][0].channels)) x_datas.append(coupler[port_saved - 1][0].time) x_datas.append(coupler[port_saved][0].time) plot_labels += [ "port " + str(port_saved - 1), "port " + str(port_saved) ] plot_groups += [i + 1, i + 1] plot_titles += [ "Pulses coming out of the {} from input port {} with " "ratios {}".format(default_name, i, ratios_ports[i]) ] y_datas = [temporal_power(pulse[0][0].channels)] + y_datas x_datas = [pulse[0][0].time] + x_datas
random_phase = random() * math.pi random_phase_bis = random() * math.pi phase_shifts = [[random_phase, random_phase], [math.pi / 2, 0.0], [random_phase, random_phase_bis]] y_datas = [] plot_titles = ["Original pulse"] for i, phase_shift in enumerate(phase_shifts): # Propagation mz = IdealMZ(phase_shift=phase_shift, loss=loss) lt.link((pulse[0], mz[0])) lt.run(pulse) lt.reset() # Plot parameters and get waves y_datas.append(temporal_power(mz[1][0].channels)) if (isinstance(phase_shift[0], float)): temp_phase = phase_shift else: temp_phase = [phase_shift[0](0), phase_shift[1](0)] plot_titles += [ "Pulses coming out of the {} with phase " "shift {} and {}".format(default_name, str(round(temp_phase[0], 2)), str(round(temp_phase[1], 2))) ] v_pi = [1.0] v_mod = [ lambda t: math.sin(math.pi * t), lambda t: math.sin(math.pi / 2.0 * t) ]
center_lambda = [1552.0, 1549.0, 1596.0] position = [0.5, 0.3, 0.5] width = [2.0, 5.3, 6] peak_power = [1e-3, 2e-3, 6e-3] bit_rate = [0.0, 0.03, 0.04] offset_nu = [0.0, 1.56, -1.6] order = [1, 2, 1] chirp = [0.0, 0.5, 0.1] init_phi = [0.0, 1.0, 0.0] gssn = Gaussian(channels=channels, center_lambda=center_lambda, position=position, width=width, peak_power=peak_power, bit_rate=bit_rate, offset_nu=offset_nu, order=order, chirp=chirp, init_phi=init_phi, save=True) lt.run(gssn) plot.plot([gssn.fields[0].time, gssn.fields[0].nu], [ temporal_power(gssn.fields[0].channels), spectral_power(gssn.fields[0].channels) ], ["t", "nu"], ["P_t", "P_nu"], plot_titles=["Gaussian pulse"], split=True)
CSVFit lt = layout.Layout(domain.Domain(samples_per_bit=512,bit_width=20.0)) pulse = gaussian.Gaussian(channels=2, peak_power=[10.0, 10e-1], width=[1.0, 5.0], center_lambda=[1050.0, 1048.0]) gamma_data = CSVFit('./data/gamma_test.txt') fiber = Fiber(length=.10, method="ssfm_symmetric", alpha=[0.046], alpha_order=4, beta_order=4, gamma=1.5, nl_approx=False, ATT=True, DISP=True, SPM=True, XPM=False, SS=False, RS=False, approx_type=1, steps=1000, medium='sio2') lt.link((pulse[0], fiber[0])) lt.run(pulse) x_datas = [pulse.fields[0].nu, fiber.fields[1].nu, pulse.fields[0].time, fiber.fields[1].time] y_datas = [spectral_power(pulse.fields[0].channels), spectral_power(fiber.fields[1].channels), temporal_power(pulse.fields[0].channels), temporal_power(fiber.fields[1].channels)] x_labels = ['nu', 'nu', 't', 't'] y_labels = ['P_nu', 'P_nu', 'P_t', 'P_t'] plot_titles = ["Original Pulse", "Pulse at the end of the fiber"] plot_titles.extend(plot_titles) plot.plot(x_datas, y_datas, x_labels = x_labels, y_labels = y_labels, plot_titles=plot_titles, plot_groups=[0,1,2,3], opacity=0.3)
CSVFit lt = layout.Layout(domain.Domain(samples_per_bit=512,bit_width=20.0)) pulse = gaussian.Gaussian(channels=2, peak_power=[10.0, 10e-1], width=[1.0, 5.0], center_lambda=[1050.0, 1048.0]) gamma_data = CSVFit('./data/gamma_test.txt') fiber = Fiber(length=.10, method="ssfm_symmetric", alpha=[0.046], alpha_order=4, beta_order=4, gamma=1.5, nl_approx=False, ATT=True, DISP=True, SPM=True, XPM=False, SS=False, RS=False, approx_type=1, steps=1000, medium='sio2') lt.link((pulse[0], fiber[0])) lt.run(pulse) x_datas = [pulse[0][0].nu, fiber[1][0].nu, pulse[0][0].time, fiber[1][0].time] y_datas = [spectral_power(pulse[0][0].channels), spectral_power(fiber[1][0].channels), temporal_power(pulse[0][0].channels), temporal_power(fiber[1][0].channels)] x_labels = ['nu', 'nu', 't', 't'] y_labels = ['P_nu', 'P_nu', 'P_t', 'P_t'] plot_titles = ["Original Pulse", "Pulse at the end of the fiber"] plot_titles.extend(plot_titles) plot.plot2d(x_datas, y_datas, x_labels=x_labels, y_labels=y_labels, plot_titles=plot_titles, plot_groups=[0,1,2,3], opacity=0.3)