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")
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"], x_range=(-1.0, 1.0), X_range=(146.1, 240.1), filename="4-21b")
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"])
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 double_plot(nu, P_nu_normalised, Lambda, P_lambda_normalised, labels['nu'], labels['P_nu'], labels['Lambda'], labels['P_lambda'], x_range=(192.6, 193.7),
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"])
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")
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")
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")
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), filename="7-7")
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"])
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"], )