def generate_overview_plots(domain): """ Generate single, map, and waterfall plots of the soliton collision. """ system = System(domain) system.add(Sech(peak_power=8.8e-3, width=(1.0 / 0.44), position=0.625)) system.add(Sech(peak_power=8.8e-3, width=(1.0 / 0.44), position=0.375, offset_nu=-0.8)) system.add(Fibre(length=400.0, beta=[0.0, 0.0, -0.1, 0.0], gamma=2.2, total_steps=400, traces=100, method='ARK4IP', local_error=1e-6)) system.run() storage = system['fibre'].stepper.storage (x, y, z) = storage.get_plot_data(reduced_range=(140.0, 360.0)) # Split step_sizes (list of tuples) into separate lists; # distances and steps: (distances, steps) = list(zip(*storage.step_sizes)) print(np.sum(steps)) single_plot(distances, steps, labels["z"], "Step size, h (km)", filename="soliton_collision_steps") map_plot(x, y, z, labels["t"], labels["P_t"], labels["z"], filename="soliton_collision_map") waterfall_plot(x, y, z, labels["t"], labels["z"], labels["P_t"], filename="soliton_collision_waterfall", y_range=(0.0, 0.02))
def save_simulations(domain, data_directory, methods, target_errors): """ Save simulation data for each method to file. """ for method in methods: print("%s" % method) for target_error in target_errors: print("\t%.1e" % target_error) method_error = "-".join([method, "%.0e" % (target_error)]) filename = os.path.join(data_directory, method_error) system = System(domain) system.add( Sech(peak_power=8.8e-3, width=(1.0 / 0.44), position=0.625)) system.add( Sech(peak_power=8.8e-3, width=(1.0 / 0.44), position=0.375, offset_nu=-0.8)) system.add( Fibre("fibre", length=400.0, beta=[0.0, 0.0, -0.1, 0.0], gamma=2.2, method=method, local_error=target_error)) system.run() A_calc = system.fields['fibre'] storage = system["fibre"].stepper.storage np.savez(filename, field=A_calc, ffts=storage.fft_total)
def generate_overview_plots(domain): """ Generate single, map, and waterfall plots of the soliton collision. """ system = System(domain) system.add(Sech(peak_power=8.8e-3, width=(1.0 / 0.44), position=0.625)) system.add(Sech(peak_power=8.8e-3, width=(1.0 / 0.44), position=0.375, offset_nu=-0.8)) system.add(Fibre(length=400.0, beta=[0.0, 0.0, -0.1, 0.0], gamma=2.2, total_steps=400, traces=100, method='ARK4IP', local_error=1e-6)) system.run() storage = system['fibre'].stepper.storage (x, y, z) = storage.get_plot_data(reduced_range=(140.0, 360.0)) # Split step_sizes (list of tuples) into separate lists; # distances and steps: (distances, steps) = zip(*storage.step_sizes) print np.sum(steps) single_plot(distances, steps, labels["z"], "Step size, h (km)", filename="soliton_collision_steps") map_plot(x, y, z, labels["t"], labels["P_t"], labels["z"], filename="soliton_collision_map") waterfall_plot(x, y, z, labels["t"], labels["z"], labels["P_t"], filename="soliton_collision_waterfall", y_range=(0.0, 0.02))
def save_simulations(domain, data_directory, methods, target_errors): """ Save simulation data for each method to file. """ for method in methods: print "%s" % method for target_error in target_errors: print "\t%.1e" % target_error method_error = "-".join([method, "%.0e" % (target_error)]) filename = os.path.join(data_directory, method_error) system = System(domain) system.add(Sech(peak_power=8.8e-3, width=(1.0 / 0.44), position=0.625)) system.add(Sech(peak_power=8.8e-3, width=(1.0 / 0.44), position=0.375, offset_nu=-0.8)) system.add(Fibre("fibre", length=400.0, beta=[0.0, 0.0, -0.1, 0.0], gamma=2.2, method=method, local_error=target_error)) system.run() A_calc = system.fields['fibre'] storage = system["fibre"].stepper.storage np.savez(filename, field=A_calc, ffts=storage.fft_total)
def generate_map_and_waterfall_plots(domain): """ Generate map and waterfall plots to visualise pulse propagation. """ system = System(domain) system.add(Sech(peak_power=4.0, width=1.0)) system.add( Fibre("fibre", length=0.5 * np.pi, beta=[0.0, 0.0, -1.0, 0.0], gamma=1.0, method="rk4ip", total_steps=1000, traces=50)) system.run() storage = system['fibre'].stepper.storage (x, y, z) = storage.get_plot_data(reduced_range=(95.0, 105.0)) map_plot(x, y, z, labels["t"], labels["P_t"], labels["z"], filename="soliton_map") waterfall_plot(x, y, z, labels["t"], labels["z"], labels["P_t"], filename="soliton_waterfall", y_range=(0.0, 16.0))
def save_simulations(domain, data_directory, methods, target_errors): """ Save data for each method and target error to file. """ for method in methods: print("%s" % method) for target_error in target_errors: print("\t%.1e" % target_error) method_error = "-".join([method, "%.0e" % (target_error)]) filename = os.path.join(data_directory, method_error) system = System(domain) system.add(Sech(peak_power=4.0, width=1.0)) system.add( Fibre("fibre", length=0.5 * np.pi, beta=[0.0, 0.0, -1.0, 0.0], gamma=1.0, method=method, local_error=target_error)) system.run() A_calc = system.fields['fibre'] storage = system["fibre"].stepper.storage np.savez(filename, field=A_calc, ffts=storage.fft_total)
def generate_reference(domain, data_directory): """ Generate a reference field (to machine precision), used as A_true. """ system = System(domain) system.add(Sech(peak_power=8.8e-3, width=(1.0 / 0.44), position=0.125)) system.add(Sech(peak_power=8.8e-3, width=(1.0 / 0.44), position=-0.125, offset_nu=-0.8)) system.add(Fibre("fibre", length=400.0, beta=[0.0, 0.0, -0.1, 0.0], gamma=2.2, method="ark4ip", local_error=1e-14)) system.run() A_true = system.field filename = os.path.join(data_directory, "reference_field") np.save(filename, A_true)
def generate_reference(domain, data_directory): """ Generate a reference field (to machine precision), used as A_true. """ system = System(domain) system.add(Sech(peak_power=8.8e-3, width=(1.0 / 0.44), position=0.625)) system.add(Sech(peak_power=8.8e-3, width=(1.0 / 0.44), position=0.375, offset_nu=-0.8)) system.add(Fibre("fibre", length=400.0, beta=[0.0, 0.0, -0.1, 0.0], gamma=2.2, method="ark4ip", local_error=1e-14)) system.run() A_true = system.field filename = os.path.join(data_directory, "reference_field") np.save(filename, A_true)
def save_simulations(domain, data_directory, methods, steps): """ Save data for each method and step to file. """ for method in methods: print "%s" % method for step in steps: print "\t%d" % step method_step = "-".join([method, str(step)]) filename = os.path.join(data_directory, method_step) system = System(domain) system.add(Sech(peak_power=4.0, width=1.0)) system.add( Fibre("fibre", length=0.5 * np.pi, beta=[0.0, 0.0, -1.0, 0.0], gamma=1.0, method=method, total_steps=step)) system.run() A_calc = system.fields['fibre'] np.save(filename, A_calc)
def save_simulations(domain, data_directory, methods, target_errors): """ Save data for each method and target error to file. """ for method in methods: print "%s" % method for target_error in target_errors: print "\t%.1e" % target_error method_error = "-".join([method, "%.0e" % (target_error)]) filename = os.path.join(data_directory, method_error) system = System(domain) system.add(Sech(peak_power=4.0, width=1.0)) system.add(Fibre("fibre", length=0.5 * np.pi, beta=[0.0, 0.0, -1.0, 0.0], gamma=1.0, method=method, local_error=target_error)) system.run() A_calc = system.fields['fibre'] storage = system["fibre"].stepper.storage np.savez(filename, field=A_calc, ffts=storage.fft_total)
def save_simulations(domain, data_directory, methods, steps): """ Save data for each method and step to file. """ for method in methods: print "%s" % method for step in steps: print "\t%d" % step method_step = "-".join([method, str(step)]) filename = os.path.join(data_directory, method_step) system = System(domain) system.add(Sech(peak_power=4.0, width=1.0)) system.add( Fibre( "fibre", length=0.5 * np.pi, beta=[0.0, 0.0, -1.0, 0.0], gamma=1.0, method=method, total_steps=step ) ) system.run() A_calc = system.fields["fibre"] np.save(filename, A_calc)
def generate_map_and_waterfall_plots(domain): """ Generate map and waterfall plots to visualise pulse propagation. """ system = System(domain) system.add(Sech(peak_power=4.0, width=1.0)) system.add( Fibre( "fibre", length=0.5 * np.pi, beta=[0.0, 0.0, -1.0, 0.0], gamma=1.0, method="rk4ip", total_steps=1000, traces=50, ) ) system.run() storage = system["fibre"].stepper.storage (x, y, z) = storage.get_plot_data(reduced_range=(95.0, 105.0)) map_plot(x, y, z, labels["t"], labels["P_t"], labels["z"], filename="soliton_map") waterfall_plot(x, y, z, labels["t"], labels["z"], labels["P_t"], filename="soliton_waterfall", y_range=(0.0, 16.0))
D = 16.0 beta_2 = convert_dispersion_to_physical(D)[0] delta_3 = 0.03 beta_3 = 6.0 * np.abs(beta_2) * width * delta_3 beta = [0.0, 0.0, beta_2, beta_3] L_D = (width**2) / np.abs(beta_2) length = 4.0 * L_D N = 2.0 P_0 = 1.0 gamma = (N**2) / (L_D * P_0) system = System(domain) system.add(Sech(peak_power=P_0, width=width)) system.add( Fibre(length=length, gamma=gamma, beta=beta, rs_factor=T_R, raman_scattering=True, self_steepening=True, total_steps=200, traces=100, method='ARK4IP')) system.run() storage = system['fibre'].stepper.storage (x, y, z_temp) = storage.get_plot_data(False, (71.9, 314.9), True)
phase = self.initial_phase phase -= 2.0 * pi * self.offset_nu * domain.t sechh = 1./np.cosh(t_normalised) sechh = np.where(sechh != 0, np.power(sechh, 1+1j*self.C), 0.) magnitude = sqrt(self.peak_power)*sechh if domain.channels > 1: self.field[self.channel] += magnitude * exp(1j * phase) else: self.field += magnitude * exp(1j * phase) return self.field if __name__ == "__main__": """ Plot a default Diss_soliton in temporal and spectral domain """ from pyofss import Domain, System, Diss_soliton from pyofss import temporal_power, spectral_power, inst_freq from pyofss import double_plot, labels sys = System(Domain(bit_width=500.0)) sys.add(Diss_soliton()) sys.run() double_plot(sys.domain.t, temporal_power(sys.field), sys.domain.nu, spectral_power(sys.field, True), labels["t"], labels["P_t"], labels["nu"], labels["P_nu"], inst_freq = inst_freq(sys.field, sys.domain.dt), y2_label=labels["inst_nu"])
Output information on Gaussian. """ output_string = [ 'position = {0:f}', 'width = {1:f} ps', 'fwhm = {2:f} ps', 'peak_power = {3:f} W', 'offset_nu = {4:f} THz', 'm = {5:d}', 'C = {6:f}', 'initial_phase = {7:f} rad', 'channel = {8:d}' ] return "\n".join(output_string).format(self.position, self.width, self.calculate_fwhm(), self.peak_power, self.offset_nu, self.m, self.C, self.initial_phase, self.channel) if __name__ == "__main__": """ Plot a default Gaussian in temporal and spectral domain """ from pyofss import Domain, System, Gaussian from pyofss import temporal_power, spectral_power from pyofss import double_plot, labels sys = System(Domain(bit_width=500.0)) sys.add(Gaussian()) sys.run() double_plot(sys.domain.t, temporal_power(sys.field), sys.domain.nu, spectral_power(sys.field, True), labels["t"], labels["P_t"], labels["nu"], labels["P_nu"])
(at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import sys from pyofss import Domain, System, Gaussian, Fibre from pyofss import map_plot, waterfall_plot, animated_plot, labels system = System(Domain(bit_width=600.0, samples_per_bit=4096)) system.add(Gaussian(peak_power=1.0, width=1.0, m=3)) system.add(Fibre(length=6.0, beta=[0.0, 0.0, 0.0, 1.0], traces=100, total_steps=200, method='RK4IP')) system.run() storage = system['fibre'].stepper.storage (x, y, z) = storage.get_plot_data(reduced_range=(290.0, 340.0)) map_plot(x, y, z, labels["t"], labels["P_t"], labels["z"], filename="3-7_map") waterfall_plot(x, y, z, labels["t"], labels["z"], labels["P_t"], filename="3-7_waterfall") if (len(sys.argv) > 1) and (sys.argv[1] == 'animate'): animated_plot(x, y, z, labels["t"], labels["P_t"], r"$z = {0:7.3f} \, km$",
GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ from pyofss import Domain, System, Sech, Fibre from pyofss import temporal_power, multi_plot, labels domain = Domain(bit_width=0.4, samples_per_bit=4096) s = 0.2 width = 1.0 / (s * domain.centre_omega) beta_2 = width ** 2 P_ts = [] zs = [0.0, 5.0, 10.0] for z in zs: system = System(domain) system.add(Sech(peak_power=1.0, width=width)) system.add(Fibre(length=z, gamma=1.0, total_steps=200, self_steepening=True, beta=[0.0, 0.0, -beta_2])) system.run() field = system.fields['fibre'] P_ts.append(temporal_power(field)) multi_plot(system.domain.t, P_ts, zs, labels["t"], labels["P_t"], [r"$z = {0:.0f} \, km$"], (0.175, 0.225), filename="5-18")
GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import sys from pyofss import Domain, System, Sech, Fibre from pyofss import map_plot, waterfall_plot, animated_plot, labels domain = Domain(bit_width=0.4, samples_per_bit=4096) s = 0.2 width = 1.0 / (s * domain.centre_omega) beta_2 = width**2 system = System(domain) system.add(Sech(peak_power=1.0, width=width)) system.add( Fibre(length=4.0, beta=[0.0, 0.0, -beta_2], gamma=4.0, self_steepening=True, traces=100, method='ARK4IP')) system.run() storage = system['fibre'].stepper.storage (x, y, z) = storage.get_plot_data(False, (0.0, 600.0), normalised=True) map_plot(x, y,
GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import sys from pyofss import Domain, System, Sech, Fibre from pyofss import map_plot, waterfall_plot, animated_plot, labels domain = Domain(bit_width=0.4, samples_per_bit=4096) s = 0.2 width = 1.0 / (s * domain.centre_omega) beta_2 = width ** 2 system = System(domain) system.add(Sech(peak_power=1.0, width=width)) system.add(Fibre(length=4.0, beta=[0.0, 0.0, -beta_2], gamma=4.0, self_steepening=True, traces=100, method='ARK4IP')) system.run() storage = system['fibre'].stepper.storage (x, y, z) = storage.get_plot_data(False, (0.0, 600.0), normalised=True) map_plot(x, y, z, labels["nu"], labels["P_nu"], labels["z"], filename="5-19_map_nu") waterfall_plot(x, y, z, labels["nu"], labels["z"], labels["P_nu"], filename="5-19_waterfall_nu", y_range=(0.0, 1.1)) if (len(sys.argv) > 1) and (sys.argv[1] == 'animate'):
along with this program. If not, see <http://www.gnu.org/licenses/>. """ from pyofss import Domain, System, Gaussian, Fibre from pyofss import temporal_power, multi_plot, labels domain = Domain(bit_width=2.0, samples_per_bit=4096) s = 0.01 width = 1.0 / (s * domain.centre_omega) P_ts = [] zs = [0.0, 10.0, 20.0] for z in zs: system = System(domain) system.add(Gaussian(peak_power=1.0, width=width)) system.add( Fibre(length=z, gamma=1.0, total_steps=200, self_steepening=True, method="RK4IP")) system.run() field = system.fields['fibre'] P_ts.append(temporal_power(field)) multi_plot(system.domain.t, P_ts, zs,
D = 16.0 beta_2 = convert_dispersion_to_physical(D)[0] delta_3 = 0.03 beta_3 = 6.0 * np.abs(beta_2) * width * delta_3 beta = [0.0, 0.0, beta_2, beta_3] L_D = (width ** 2) / np.abs(beta_2) length = 4.0 * L_D N = 2.0 P_0 = 1.0 gamma = (N ** 2) / (L_D * P_0) system = System(domain) system.add(Sech(peak_power=P_0, width=width)) system.add(Fibre(length=length, gamma=gamma, beta=beta, rs_factor=T_R, raman_scattering=True, self_steepening=True, total_steps=200, traces=100, method='ARK4IP')) system.run() storage = system['fibre'].stepper.storage (x, y, z_temp) = storage.get_plot_data(False, (71.9, 314.9), True) z_label = r"Fibre length, $z \, (cm)$" z = z_temp * 1.0e5 map_plot(x, y, z, labels["nu"], labels["P_nu"], z_label, filename="5-23_map_nu") waterfall_plot(x, y, z, labels["nu"], z_label, labels["P_nu"],
GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ from pyofss.domain import nu_to_omega from pyofss import Domain, System, Gaussian, Fibre from pyofss import temporal_power, spectral_power, double_plot, labels nu_0 = 193.1 nu_1 = 1.2 * nu_0 offset_nu = 0.2 * 193.1 system = System(Domain(bit_width=30.0, samples_per_bit=8192, channels=2)) system.add(Gaussian(width=1.0, peak_power=100.0, channel=0)) system.add(Gaussian(width=1.0, peak_power=1.0, channel=1, offset_nu=offset_nu)) system.add( Fibre('fibre', length=0.4, gamma=[1.0, 1.2], beta=[[0.0, 0.0, 1.0, 0.0], [0.0, 10.0, 1.0, 0.0]], centre_omega=(nu_to_omega(nu_0), nu_to_omega(nu_1)), sim_type='wdm', method='ARK4IP')) system.run() A_fs = system.fields['fibre'] P_t0 = temporal_power(A_fs[0])
along with this program. If not, see <http://www.gnu.org/licenses/>. """ from pyofss.domain import nu_to_omega from pyofss import Domain, System, Gaussian, Fibre from pyofss import temporal_power, double_plot, labels domain = Domain(bit_width=20.0, samples_per_bit=8192, channels=2) nu_0 = 193.1 nu_1 = 1.2 * nu_0 offset_nu = 0.2 * 193.1 offset = 2.5 / domain.bit_width system = System(domain) system.add(Gaussian(width=1.0, peak_power=1000.0, channel=0)) system.add(Gaussian(width=1.0, peak_power=0.1, channel=1, position=0.5 - offset, offset_nu=offset_nu)) system.add(Fibre('fibre', length=0.2, gamma=[0.1, 0.12], beta=[[0.0, 0.0, 1.0, 0.0], [0.0, 10.0, 1.0, 0.0]], centre_omega=(nu_to_omega(nu_0), nu_to_omega(nu_1)), sim_type='wdm', method='ARK4IP')) system.run() A_fs = system.fields['fibre'] P_t0 = temporal_power(A_fs[0]) P_t1 = temporal_power(A_fs[1]) double_plot(system.domain.t, P_t0, system.domain.t, P_t1,
def __str__(self): """ :return: Information string :rtype: string Output information on Sech. """ output_string = [ 'position = {0:f}', 'width = {1:f} ps', 'fwhm = {2:f} ps', 'peak_power = {3:f} W', 'offset_nu = {4:f} THz', 'C = {5:f}', 'initial_phase = {6:f} rad', 'channel = {7:d}'] return "\n".join(output_string).format( self.position, self.width, self.calculate_fwhm(), self.peak_power, self.offset_nu, self.C, self.initial_phase, self.channel) if __name__ == "__main__": """ Plot a default Sech in temporal and spectral domain """ from pyofss import Domain, System, Sech from pyofss import temporal_power, spectral_power from pyofss import double_plot, labels sys = System(Domain(bit_width=500.0)) sys.add(Sech()) sys.run() double_plot(sys.domain.t, temporal_power(sys.field), sys.domain.nu, spectral_power(sys.field, True), labels["t"], labels["P_t"], labels["nu"], labels["P_nu"])
""" from pyofss import Domain, System, Sech, Fibre from pyofss import temporal_power, multi_plot, labels domain = Domain(bit_width=0.4, samples_per_bit=4096) s = 0.2 width = 1.0 / (s * domain.centre_omega) beta_2 = width**2 P_ts = [] zs = [0.0, 5.0, 10.0] for z in zs: system = System(domain) system.add(Sech(peak_power=1.0, width=width)) system.add( Fibre(length=z, gamma=1.0, total_steps=200, self_steepening=True, beta=[0.0, 0.0, -beta_2])) system.run() field = system.fields['fibre'] P_ts.append(temporal_power(field)) multi_plot(system.domain.t, P_ts, zs,
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import sys import numpy as np from pyofss import Domain, System, Sech, Fibre from pyofss import map_plot, waterfall_plot, animated_plot, labels system = System(Domain(bit_width=100.0, samples_per_bit=2048)) absolute_separation = 3.5 offset = absolute_separation / system.domain.bit_width system.add(Sech(peak_power=1.0, width=1.0, position=0.5 - offset)) system.add(Sech(peak_power=1.0, width=1.0, position=0.5 + offset, initial_phase=np.pi / 4.0)) system.add(Fibre(length=90.0, beta=[0.0, 0.0, -1.0, 0.0], gamma=1.0, total_steps=200, traces=100, method='ARK4IP')) system.run() storage = system['fibre'].stepper.storage (x, y, z) = storage.get_plot_data(reduced_range=(40.0, 60.0))
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ from pyofss import Domain, System, Sech, Fibre from pyofss import temporal_power, spectral_power, double_plot, labels system = System(Domain(bit_width=800.0, samples_per_bit=4096)) system.add(Sech(peak_power=1.0, width=30.0)) system.add(Fibre(length=72.0, beta=[0.0, 0.0, 1.0, 0.0], gamma=1.0, total_steps=200)) system.run() P_t = temporal_power(system.fields['fibre']) P_nu_normalised = spectral_power(system.fields['fibre'], True) double_plot(system.domain.t, P_t, system.domain.nu, P_nu_normalised, labels['t'], labels['P_t'], labels['nu'], labels['P_nu'], x_range=(-150.0, 150.0), X_range=(192.8, 193.4), filename="4-12")
the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ from pyofss import Domain, System, Gaussian, Fibre from pyofss import temporal_power, spectral_power, double_plot, labels system = System(Domain(bit_width=200.0, samples_per_bit=2048)) system.add(Gaussian(peak_power=1.0, width=1.0)) system.add( Fibre(length=5.0, beta=[0.0, 0.0, 0.0, 1.0], gamma=1.0, total_steps=100)) system.run() print system.domain P_t = temporal_power(system.fields['fibre']) P_nu_normalised = spectral_power(system.fields['fibre'], True) P_lambda_normalised = P_nu_normalised t = system.domain.t nu = system.domain.nu Lambda = system.domain.Lambda
def __str__(self): """ :return: Information string :rtype: string Output information on Gaussian. """ output_string = [ 'position = {0:f}', 'width = {1:f} ps', 'fwhm = {2:f} ps', 'peak_power = {3:f} W', 'offset_nu = {4:f} THz', 'm = {5:d}', 'C = {6:f}', 'initial_phase = {7:f} rad', 'channel = {8:d}'] return "\n".join(output_string).format( self.position, self.width, self.calculate_fwhm(), self.peak_power, self.offset_nu, self.m, self.C, self.initial_phase, self.channel) if __name__ == "__main__": """ Plot a default Gaussian in temporal and spectral domain """ from pyofss import Domain, System, Gaussian from pyofss import temporal_power, spectral_power from pyofss import double_plot, labels sys = System(Domain(bit_width=500.0)) sys.add(Gaussian()) sys.run() double_plot(sys.domain.t, temporal_power(sys.field), sys.domain.nu, spectral_power(sys.field, True), labels["t"], labels["P_t"], labels["nu"], labels["P_nu"])
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ from pyofss import Domain, System, Gaussian, Fibre from pyofss import spectral_power, double_plot, labels nu_0 = 193.1 nu_1 = 1.2 * nu_0 offset_nu = 0.2 * 193.1 system = System(Domain(bit_width=30.0, samples_per_bit=8192, channels=2)) system.add(Gaussian(width=1.0, peak_power=100.0, channel=0)) system.add(Gaussian(width=1.0, peak_power=1.0, channel=1, offset_nu=offset_nu)) system.add(Fibre('fibre', length=0.4, gamma=[1.0, 1.2], beta=[[0.0, 0.0, 0.0, 0.0], [0.0, 10.0, 0.0, 0.0]], sim_type='wdm', method='ARK4IP')) system.run() A_fs = system.fields['fibre'] P_nu0 = spectral_power(A_fs[0], True) P_nu1 = spectral_power(A_fs[1], True) double_plot(system.domain.nu, P_nu0, system.domain.nu, P_nu1, labels["nu"], labels["P_nu"], labels["nu"], labels["P_nu"], x_range=(nu_0 - 8.0, nu_0 + 8.0), X_range=(nu_1 - 8.0, nu_1 + 8.0),
the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ from pyofss import Domain, System, Gaussian from pyofss import phase, chirp, double_plot, labels system = System(Domain(bit_width=10.0)) t = system.domain.t nu = system.domain.nu window_nu = system.domain.window_nu system.add(Gaussian(initial_phase=3.0, width=1.0)) system.run() double_plot(t, phase(system.field), t, chirp(system.field, window_nu), labels["t"], labels["phi"], labels["t"], labels["chirp"], filename="1 - phase_offset") system.clear(True) system.add(Gaussian(offset_nu=0.5, width=1.0)) system.run()
(at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import sys from pyofss import Domain, System, Sech, Fibre from pyofss import map_plot, waterfall_plot, animated_plot, labels system = System(Domain(bit_width=100.0, samples_per_bit=2048)) system.add(Sech(peak_power=1.0, width=1.0)) system.add(Fibre(length=10.0, beta=[0.0, 0.0, -1.0, 0.0], gamma=1.44, traces=50, method='ARK4IP')) system.run() storage = system['fibre'].stepper.storage (x, y, z) = storage.get_plot_data(reduced_range=(44.0, 56.0)) map_plot(x, y, z, labels["t"], labels["P_t"], labels["z"], filename="5-8_map_t") waterfall_plot(x, y, z, labels["t"], labels["z"], labels["P_t"], filename="5-8_waterfall_t", y_range=(0.0, 1.64)) if (len(sys.argv) > 1) and (sys.argv[1] == 'animate'):
the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ from pyofss import Domain, System, Gaussian, Fibre from pyofss import spectral_power, double_plot, labels system = System(Domain(bit_width=200.0, samples_per_bit=4096, channels=2)) system.add(Gaussian(width=1.0, peak_power=1.0, channel=0)) system.add(Gaussian(width=1.0, peak_power=0.5, channel=1)) system.add(Fibre('fibre', length=40.0, gamma=[1.0, 1.2], beta=[[0.0, 0.0, 0.0, 0.0], [0.0, 0.125, 0.0, 0.0]], sim_type='wdm', total_steps=400, method='RK4IP')) system.run() A_fs = system.fields['fibre'] P_nu0 = spectral_power(A_fs[0], True) P_nu1 = spectral_power(A_fs[1], True) double_plot(system.domain.nu, P_nu0, system.domain.nu, P_nu1, labels["nu"], labels["P_nu"], labels["nu"], labels["P_nu"], x_range=(181.1, 204.1), X_range=(181.1, 204.1), filename="7-2")
(at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import sys from pyofss import Domain, System, Gaussian, Fibre from pyofss import map_plot, waterfall_plot, animated_plot, labels system = System(Domain(bit_width=600.0, samples_per_bit=4096)) system.add(Gaussian(peak_power=1.0, width=1.0, m=3)) system.add( Fibre(length=6.0, beta=[0.0, 0.0, 0.0, 1.0], traces=100, total_steps=200, method='RK4IP')) system.run() storage = system['fibre'].stepper.storage (x, y, z) = storage.get_plot_data(reduced_range=(-10.0, 40.0)) map_plot(x, y, z, labels["t"], labels["P_t"], labels["z"], filename="3-7_map") waterfall_plot(x,
(at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import sys from pyofss import Domain, System, Sech, Fibre from pyofss import map_plot, waterfall_plot, animated_plot, labels system = System(Domain(bit_width=100.0, samples_per_bit=4096)) system.add(Sech(peak_power=1.0, width=1.0)) system.add( Fibre(length=4.0, beta=[0.0, 0.0, 0.0, 1.0], gamma=4.0, traces=100, method='ARK4IP')) system.run() storage = system['fibre'].stepper.storage (x, y, z) = storage.get_plot_data(False, (192.1, 194.1), normalised=True) map_plot(x, y, z,
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ from pyofss import Domain, System, Gaussian, Fibre from pyofss import temporal_power, chirp, multi_plot, labels P_ts = [] chirps = [] zs = [0.0, 2.0, 4.0] for z in zs: system = System(Domain(bit_width=200.0, samples_per_bit=2048)) system.add(Gaussian(peak_power=1.0, width=1.0)) system.add(Fibre(length=z, beta=[0.0, 0.0, -1.0, 0.0])) system.run() field = system.fields['fibre'] P_ts.append(temporal_power(field)) temp = [f if abs(f) >= 5e-12 else 0.0 for f in field] chirps.append(chirp(temp, system.domain.window_nu)) multi_plot(system.domain.t, P_ts, zs, labels["t"], labels["P_t"], [r"$z = {0:.0f} \, km$"], (90.0, 110.0), filename="3-1") multi_plot(system.domain.t, chirps, zs, labels["t"], labels["chirp"], [r"$z = {0:.0f} \, km$"],
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import sys from pyofss import Domain, System, Gaussian, Fibre from pyofss import map_plot, waterfall_plot, animated_plot, labels domain = Domain(bit_width=50.0, samples_per_bit=8192) width = 1.0 tau_R = 0.03 T_R = tau_R * width system = System(domain) system.add(Gaussian(peak_power=1.0, width=width)) system.add(Fibre(length=5.0, gamma=4.0, beta=[0.0, 0.0, -1.0], raman_scattering=True, rs_factor=T_R, total_steps=200, traces=200, method='ARK4IP')) system.run() storage = system['fibre'].stepper.storage (x, y, z) = storage.get_plot_data(False, (191.1, 195.1), normalised=True) map_plot(x, y, z, labels["nu"], labels["P_nu"], labels["z"], filename="4-23_map_nu") waterfall_plot(x, y, z, labels["nu"], labels["z"], labels["P_nu"], filename="4-23_waterfall_nu", y_range=(0.0, 1.1))
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import numpy as np from pyofss import Domain, System, Gaussian, Fibre from pyofss import spectral_power, quad_plot, labels A_fs = [] Cs = [0.0, 10.0, -10.0, -20.0] for C in Cs: system = System(Domain(bit_width=100.0, samples_per_bit=2048)) system.add(Gaussian(width=1.0, peak_power=1.0, C=C)) system.add(Fibre('fibre', length=1.0, gamma=4.5 * np.pi)) system.run() A_fs.append(system.fields['fibre']) P_nus = [spectral_power(A_f, True) for A_f in A_fs] quad_plot(system.domain.nu, P_nus, Cs, labels["nu"], labels["P_nu"], ["$C = {0:.0f}$"], (189.1, 197.1), filename="4-5")
from pyofss import Domain, System, Gaussian, Fibre from pyofss import temporal_power, spectral_power, double_plot, labels domain = Domain(bit_width=4.0, samples_per_bit=4096) s = 0.01 width = 1.0 / (s * domain.centre_omega) gamma = 100.0 / (width ** 2) P_ts = [] P_nus = [] length = [20.0 / gamma, 40.0 / gamma] for l in length: system = System(domain) system.add(Gaussian(peak_power=1.0, width=width)) system.add(Fibre(length=l, gamma=gamma, total_steps=200, self_steepening=True, beta=[0.0, 0.0, 1.0])) system.run() field = system.fields['fibre'] P_ts.append(temporal_power(field)) P_nus.append(spectral_power(field, True)) double_plot(system.domain.t, P_ts[0], system.domain.nu, P_nus[0], labels["t"], labels["P_t"], labels["nu"], labels["P_nu"], x_range=(-0.5, 0.5), X_range=(146.1, 240.1), filename="4-21a") double_plot(system.domain.t, P_ts[1], system.domain.nu, P_nus[1], labels["t"], labels["P_t"], labels["nu"], labels["P_nu"],
if __name__ == "__main__": # Compare simulations using Fibre and OpenclFibre modules. from pyofss import Domain, System, Gaussian, Fibre from pyofss import temporal_power, double_plot, labels import time TS = 4096 GAMMA = 100.0 STEPS = 800 LENGTH = 0.1 DOMAIN = Domain(bit_width=30.0, samples_per_bit=TS) SYS = System(DOMAIN) SYS.add(Gaussian("gaussian", peak_power=1.0, width=1.0)) SYS.add(Fibre("fibre", beta=[0.0, 0.0, 0.0, 1.0], gamma=GAMMA, length=LENGTH, total_steps=STEPS, method="RK4IP")) start = time.clock() SYS.run() stop = time.clock() NO_OCL_DURATION = (stop - start) / 1000.0 NO_OCL_OUT = SYS.fields["fibre"] sys = System(DOMAIN) sys.add(Gaussian("gaussian", peak_power=1.0, width=1.0)) sys.add(OpenclFibre(TS, dorf="float", length=LENGTH, total_steps=STEPS)) start = time.clock()
(at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import sys from pyofss import Domain, System, Sech, Fibre from pyofss import map_plot, waterfall_plot, animated_plot, labels system = System(Domain(bit_width=100.0, samples_per_bit=2048)) absolute_separation = 3.5 offset = absolute_separation / system.domain.bit_width system.add(Sech(peak_power=1.0, width=1.0, position=0.5 - offset)) system.add(Sech(peak_power=1.1, width=1.0, position=0.5 + offset)) system.add( Fibre(length=90.0, beta=[0.0, 0.0, -1.0, 0.0], gamma=1.0, total_steps=200, traces=100, method='ARK4IP')) system.run()
the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ from pyofss import Domain, System, Gaussian, Fibre from pyofss import spectral_power, single_plot, labels domain = Domain(bit_width=4.0, samples_per_bit=4096) s = 0.01 width = 1.0 / (s * domain.centre_omega) system = System(domain) system.add(Gaussian(peak_power=1.0, width=width)) system.add(Fibre(length=20.0, gamma=1.0, total_steps=200, self_steepening=True, method="RK4IP")) system.run() P_nu_normalised = spectral_power(system.fields['fibre'], True) single_plot(system.domain.nu, P_nu_normalised, labels["nu"], labels["P_nu"], filename="4-20", x_range=(145.1, 256.1))
the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ from pyofss import Domain, System, Gaussian from pyofss import phase, chirp, double_plot, labels system = System(Domain(bit_width=10.0)) t = system.domain.t nu = system.domain.nu window_nu = system.domain.window_nu system.add(Gaussian(initial_phase=3.0, width=1.0)) system.run() double_plot(t, phase(system.field), t, chirp(system.field, window_nu), labels["t"], labels["phi"], labels["t"], labels["chirp"],
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import sys from pyofss.domain import nu_to_omega, lambda_to_nu from pyofss import Domain, System, Gaussian, Fibre from pyofss import map_plot, waterfall_plot, animated_plot, labels nu_0 = lambda_to_nu(1060.0) nu_1 = lambda_to_nu(1550.0) offset_nu = nu_0 - nu_1 system = System(Domain(bit_width=20.0, samples_per_bit=8192, channels=2, centre_nu=nu_0)) system.add(Gaussian(width=1.0, peak_power=1000.0, channel=0)) system.add(Gaussian(width=1.0, peak_power=0.1, channel=1, offset_nu=-offset_nu)) system.add(Fibre('fibre', length=0.05, gamma=[0.9, 0.615483871], beta=[[0.0, 0.0, 1.0, 0.0], [0.0, 0.0, -1.0, 0.0]], centre_omega=(nu_to_omega(nu_0), nu_to_omega(nu_1)), sim_type='wdm', method='ARK4IP', traces=100)) system.run() storage = system['fibre'].stepper.storage (x, y, z_temp) = storage.get_plot_data(channel=0) z_label = r"Fibre length, $z \, (m)$" z = z_temp * 1.0e3 map_plot(x, y, z, labels["t"], labels["P_t"], z_label,
(at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import sys from pyofss import Domain, System, Gaussian, Fibre from pyofss import map_plot, waterfall_plot, animated_plot, labels system = System(Domain(bit_width=400.0, samples_per_bit=2048)) system.add(Gaussian(peak_power=1.0, width=30.0)) system.add(Fibre(length=90.0, beta=[0.0, 0.0, 1.0, 0.0], gamma=1.0, traces=100)) system.run() storage = system['fibre'].stepper.storage (x, y, z) = storage.get_plot_data(False, (192.6, 193.6), normalised=True) map_plot(x, y, z, labels["nu"], labels["P_nu"], labels["z"], filename="4-11_map_nu") waterfall_plot(x, y, z, labels["nu"], labels["z"], labels["P_nu"], filename="4-11_waterfall_nu", y_range=(0.0, 0.5)) if(len(sys.argv) > 1 and sys.argv[1] == 'animate'):
Use five different methods: ss_simple, ss_symmetric, ss_sym_rk4, ss_sym_rkf, and rk4ip. Expect all five methods to produce similar results; plot traces should all overlap. Separate traces should only be seen at a high zoom level. """ from pyofss import Domain, System, Gaussian, Fibre from pyofss import temporal_power, multi_plot, labels domain = Domain(bit_width=200.0, samples_per_bit=2048) gaussian = Gaussian(peak_power=1.0, width=1.0) P_ts = [] methods = ['ss_simple', 'ss_symmetric', 'ss_sym_rk4', 'rk4ip'] for m in methods: sys = System(domain) sys.add(gaussian) sys.add( Fibre(length=5.0, method=m, total_steps=50, beta=[0.0, 0.0, 0.0, 1.0], gamma=1.0)) sys.run() P_ts.append(temporal_power(sys.field)) multi_plot(sys.domain.t, P_ts, methods, labels["t"], labels["P_t"],
the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ from pyofss import Domain, System, Gaussian, Fibre from pyofss import spectral_power, double_plot, labels system = System(Domain(bit_width=200.0, samples_per_bit=4096, channels=2)) system.add(Gaussian(width=1.0, peak_power=1.0, channel=0)) system.add(Gaussian(width=1.0, peak_power=0.5, channel=1)) system.add( Fibre('fibre', length=40.0, gamma=[1.0, 1.2], beta=[[0.0, 0.0, 0.0, 0.0], [0.0, 0.125, 0.0, 0.0]], sim_type='wdm', total_steps=400, method='RK4IP')) system.run() A_fs = system.fields['fibre'] P_nu0 = spectral_power(A_fs[0], True)
the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ from pyofss import Domain, System, Gaussian, Fibre from pyofss import temporal_power, multi_plot, labels system = System(Domain(bit_width=200.0, samples_per_bit=2048)) system.add(Gaussian("gaussian", peak_power=1.0, width=1.0)) system.run() P_ts = [temporal_power(system.fields['gaussian'])] fibres = [Fibre(length=5.0, beta=[0.0, 0.0, 0.0, 1.0], total_steps=100), Fibre(length=5.0, beta=[0.0, 0.0, 1.0, 1.0], total_steps=100)] for fibre in fibres: system = System(Domain(bit_width=200.0, samples_per_bit=2048)) system.add(Gaussian(peak_power=1.0, width=1.0)) system.add(fibre) system.run() P_ts.append(temporal_power(system.fields['fibre']))
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import sys from pyofss import Domain, System, Gaussian, Fibre from pyofss import map_plot, waterfall_plot, animated_plot, labels for m in [1, 3]: system = System(Domain(bit_width=200.0, samples_per_bit=2048)) system.add(Gaussian(peak_power=1.0, width=1.0, m=m)) system.add(Fibre(length=10.0, gamma=1.0, traces=50)) system.run() storage = system['fibre'].stepper.storage (x, y, z) = storage.get_plot_data(is_temporal=False, normalised=True) map_plot(x, y, z, labels["nu"], labels["P_nu"], labels["z"], filename="4-4_map_m-{0:d}".format(m)) waterfall_plot(x, y, z, labels["nu"], labels["z"], labels["P_nu"], filename="4-4_waterfall_m-{0:d}".format(m)) if (len(sys.argv) > 1) and (sys.argv[1] == 'animate'): animated_plot(x, y, z, labels["nu"], labels["P_nu"],
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import sys import numpy as np from pyofss import Domain, System, Sech, Fibre from pyofss import map_plot, waterfall_plot, animated_plot, labels system = System(Domain(bit_width=100.0, samples_per_bit=4096)) system.add(Sech(peak_power=1.0, width=1.0)) system.add(Fibre(length=0.5 * np.pi, beta=[0.0, 0.0, -1.0, 0.0], gamma=9.0, traces=100, method='ARK4IP')) system.run() storage = system['fibre'].stepper.storage (x, y, z) = storage.get_plot_data(False, (191.1, 195.1), normalised=True) map_plot(x, y, z, labels["nu"], labels["P_nu"], labels["z"], filename="5-6_map_nu") waterfall_plot(x, y, z, labels["nu"], labels["z"], labels["P_nu"], filename="5-6_waterfall_nu", y_range=(0.0, 1.0)) if (len(sys.argv) > 1) and (sys.argv[1] == 'animate'):
the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ import numpy as np from pyofss import Domain, System, Gaussian, Fibre from pyofss import spectral_power, quad_plot, labels A_fs = [] Cs = [0.0, 10.0, -10.0, -20.0] for C in Cs: system = System(Domain(bit_width=100.0, samples_per_bit=2048)) system.add(Gaussian(width=1.0, peak_power=1.0, C=C)) system.add(Fibre('fibre', length=1.0, gamma=4.5 * np.pi)) system.run() A_fs.append(system.fields['fibre']) P_nus = [spectral_power(A_f, True) for A_f in A_fs] quad_plot(system.domain.nu, P_nus, Cs, labels["nu"], labels["P_nu"], ["$C = {0:.0f}$"], (189.1, 197.1), filename="4-5")
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ from pyofss import Domain, System, Gaussian, Fibre from pyofss import temporal_power, spectral_power, double_plot, labels system = System(Domain(bit_width=200.0, samples_per_bit=2048)) system.add(Gaussian(peak_power=1.0, width=1.0)) system.add(Fibre(length=5.0, beta=[0.0, 0.0, 0.0, 1.0], gamma=1.0, total_steps=100)) system.run() P_t = temporal_power(system.fields['fibre']) P_nu_normalised = spectral_power(system.fields['fibre'], True) double_plot(system.domain.t, P_t, system.domain.nu, P_nu_normalised, labels['t'], labels['P_t'], labels['nu'], labels['P_nu'], x_range=(95.0, 120.0), X_range=(192.6, 193.7), filename="4-15")
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ from pyofss import Domain, System, Gaussian, Fibre from pyofss import temporal_power, chirp, multi_plot, labels P_ts = [] chirps = [] zs = [0.0, 2.0, 4.0] for z in zs: system = System(Domain(bit_width=200.0, samples_per_bit=2048)) system.add(Gaussian(peak_power=1.0, width=1.0)) system.add(Fibre(length=z, beta=[0.0, 0.0, -1.0, 0.0])) system.run() field = system.fields['fibre'] P_ts.append(temporal_power(field)) temp = [f if abs(f) >= 5e-12 else 0.0 for f in field] chirps.append(chirp(temp, system.domain.window_nu)) multi_plot(system.domain.t, P_ts, zs, labels["t"], labels["P_t"], [r"$z = {0:.0f} \, km$"], (-10.0, 10.0),
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ # Note that although the temporal waterfall plot does not match that in # Agrawal's "Nonlinear Fiber Optics" book (which uses the "NLSE" simulation # software), it does match results using "LaserFOAM" simulation program. import sys from pyofss import Domain, System, Sech, Fibre from pyofss import map_plot, waterfall_plot, animated_plot, labels system = System(Domain(bit_width=100.0, samples_per_bit=2048)) system.add(Sech(peak_power=1.0, width=1.0, C=0.5)) system.add(Fibre(length=20.0, beta=[0.0, 0.0, -1.0, 0.0], gamma=1.0, traces=100, method="ARK4IP")) system.run() storage = system["fibre"].stepper.storage (x, y, z) = storage.get_plot_data(reduced_range=(40.0, 60.0)) map_plot(x, y, z, labels["t"], labels["P_t"], labels["z"], filename="5-9_map_t") waterfall_plot(x, y, z, labels["t"], labels["z"], labels["P_t"], filename="5-9_waterfall_t", y_range=(0.0, 1.64)) if (len(sys.argv) > 1) and (sys.argv[1] == "animate"): animated_plot( x, y,
the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. """ from pyofss import Domain, System, Gaussian, Fibre from pyofss import temporal_power, multi_plot, labels system = System(Domain(bit_width=200.0, samples_per_bit=2048)) system.add(Gaussian("gaussian", peak_power=1.0, width=1.0)) system.run() P_ts = [temporal_power(system.fields['gaussian'])] fibres = [ Fibre(length=5.0, beta=[0.0, 0.0, 0.0, 1.0], total_steps=100), Fibre(length=5.0, beta=[0.0, 0.0, 1.0, 1.0], total_steps=100) ] for fibre in fibres: system = System(Domain(bit_width=200.0, samples_per_bit=2048)) system.add(Gaussian(peak_power=1.0, width=1.0)) system.add(fibre) system.run()
return self.nonlinearity.exp_non(A, h, B) if __name__ == "__main__": """ Plot the result of a Gaussian pulse propagating through optical fibre. Simulates both (third-order) dispersion and nonlinearity. Use five different methods: ss_simple, ss_symmetric, ss_sym_rk4, ss_sym_rkf, and rk4ip. Expect all five methods to produce similar results; plot traces should all overlap. Separate traces should only be seen at a high zoom level. """ from pyofss import Domain, System, Gaussian, Fibre from pyofss import temporal_power, multi_plot, labels domain = Domain(bit_width=200.0, samples_per_bit=2048) gaussian = Gaussian(peak_power=1.0, width=1.0) P_ts = [] methods = ['ss_simple', 'ss_symmetric', 'ss_sym_rk4', 'rk4ip'] for m in methods: sys = System(domain) sys.add(gaussian) sys.add(Fibre(length=5.0, method=m, total_steps=50, beta=[0.0, 0.0, 0.0, 1.0], gamma=1.0)) sys.run() P_ts.append(temporal_power(sys.field)) multi_plot(sys.domain.t, P_ts, methods, labels["t"], labels["P_t"], methods, x_range=(80.0, 140.0))