Skip to content
Open
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,6 @@ dmypy.json

# Built Sphinx documentation
docs/_build/

# cross section data
data/emissionCS.csv
data/absorptionCS.csv
8 changes: 4 additions & 4 deletions examples/plot_Raman_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import numpy as np
import matplotlib.pyplot as plt
import gnlse
import gnlse_main


if __name__ == '__main__':
Expand All @@ -26,13 +26,13 @@
T = np.linspace(-time_window / 2, time_window / 2, n)

# K. J. Blow and D. Wood Raman response
fr, RT1 = gnlse.raman_blowwood(T)
fr, RT1 = gnlse_main.raman_blowwood(T)
RT1 = RT1 / np.max(RT1)
# Q. Lin and Govind P. Agrawal Raman response
fr2, RT2 = gnlse.raman_linagrawal(T)
fr2, RT2 = gnlse_main.raman_linagrawal(T)
RT2 = RT2 / np.max(RT2)
# D. Hollenbeck and C. D. Cantrell Raman response
fr3, RT3 = gnlse.raman_holltrell(T)
fr3, RT3 = gnlse_main.raman_holltrell(T)
RT3 = RT3 / np.max(RT3)

plt.plot(T, RT1, label="Blow-Wood")
Expand Down
10 changes: 5 additions & 5 deletions examples/plot_input_pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np
import matplotlib.pyplot as plt

import gnlse
import gnlse_main

if __name__ == '__main__':
# time full with half maximum of pulse
Expand All @@ -19,13 +19,13 @@
Pmax = 100

# Amplitude envelope of gaussina pulse
A1 = gnlse.GaussianEnvelope(Pmax, FWHM).A(T)
A1 = gnlse_main.GaussianEnvelope(Pmax, FWHM).A(T)
# Amplitude envelope of hiperbolic secans pulse
A2 = gnlse.SechEnvelope(Pmax, FWHM).A(T)
A2 = gnlse_main.SechEnvelope(Pmax, FWHM).A(T)
# Amplitude envelope of lorentzian pulse
A3 = gnlse.LorentzianEnvelope(Pmax, FWHM).A(T)
A3 = gnlse_main.LorentzianEnvelope(Pmax, FWHM).A(T)
# Amplitude envelope of continious wave
A4 = gnlse.CWEnvelope(Pmax).A(T)
A4 = gnlse_main.CWEnvelope(Pmax).A(T)

plt.figure(figsize=(12, 8))
plt.subplot(1, 2, 1)
Expand Down
16 changes: 8 additions & 8 deletions examples/test_3rd_order_soliton.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import numpy as np
import matplotlib.pyplot as plt

import gnlse
import gnlse_main

if __name__ == '__main__':
setup = gnlse.gnlse.GNLSESetup()
setup = gnlse_main.gnlse.GNLSESetup()

# Numerical parameters
# number of grid time points
Expand Down Expand Up @@ -52,18 +52,18 @@
# Fiber length [m]
setup.fiber_length = .5
# Type of pulse: hyperbolic secant
setup.pulse_model = gnlse.SechEnvelope(power, 0.050)
setup.pulse_model = gnlse_main.SechEnvelope(power, 0.050)
# Loss coefficient [dB/m]
loss = 0
# Type of dyspersion operator: build from Taylor expansion
setup.dispersion_model = gnlse.DispersionFiberFromTaylor(loss, betas)
setup.dispersion_model = gnlse_main.DispersionFiberFromTaylor(loss, betas)

# Set type of Ramman scattering function and selftepening
simulation_type = {
'3rd order soliton': (False, None),
'3rd order soliton\nwith self-steepening': (True, None),
'Raman induced fission\nof 3rd order soliton': (True,
gnlse.raman_blowwood)
gnlse_main.raman_blowwood)
}

count = len(simulation_type)
Expand All @@ -73,15 +73,15 @@
raman_model))) in enumerate(simulation_type.items()):
setup.raman_model = raman_model
setup.self_steepening = self_steepening
solver = gnlse.GNLSE(setup)
solver = gnlse_main.GNLSE(setup)
solution = solver.run()

plt.subplot(2, count, i + 1)
plt.title(name)
gnlse.plot_wavelength_vs_distance(solution, WL_range=[400, 1400])
gnlse_main.plot_wavelength_vs_distance(solution, WL_range=[400, 1400])

plt.subplot(2, count, i + 1 + count)
gnlse.plot_delay_vs_distance(solution, time_range=[-.25, .25])
gnlse_main.plot_delay_vs_distance(solution, time_range=[-.25, .25])

plt.tight_layout()
plt.show()
20 changes: 10 additions & 10 deletions examples/test_Dudley.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import numpy as np
import matplotlib.pyplot as plt

import gnlse
import gnlse_main


if __name__ == '__main__':
setup = gnlse.GNLSESetup()
setup = gnlse_main.GNLSESetup()

# Numerical parameters
setup.resolution = 2**14
Expand All @@ -27,7 +27,7 @@
setup.wavelength = 835 # nm
setup.fiber_length = 0.15 # m
setup.nonlinearity = 0.11 # 1/W/m
setup.raman_model = gnlse.raman_blowwood
setup.raman_model = gnlse_main.raman_blowwood
setup.self_steepening = True

# The dispersion model is built from a Taylor expansion with coefficients
Expand All @@ -37,17 +37,17 @@
-11.830e-3, 8.1038e-5, -9.5205e-8, 2.0737e-10, -5.3943e-13, 1.3486e-15,
-2.5495e-18, 3.0524e-21, -1.7140e-24
])
setup.dispersion_model = gnlse.DispersionFiberFromTaylor(loss, betas)
setup.dispersion_model = gnlse_main.DispersionFiberFromTaylor(loss, betas)

# Input pulse parameters
peak_power = 10000 # W
duration = 0.050 # ps

# This example extends the original code with additional simulations for
pulse_models = [
gnlse.SechEnvelope(peak_power, duration),
gnlse.GaussianEnvelope(peak_power, duration),
gnlse.LorentzianEnvelope(peak_power, duration)
gnlse_main.SechEnvelope(peak_power, duration),
gnlse_main.GaussianEnvelope(peak_power, duration),
gnlse_main.LorentzianEnvelope(peak_power, duration)
]

count = len(pulse_models)
Expand All @@ -56,15 +56,15 @@
print('%s...' % pulse_model.name)

setup.pulse_model = pulse_model
solver = gnlse.GNLSE(setup)
solver = gnlse_main.GNLSE(setup)
solution = solver.run()

plt.subplot(2, count, i + 1)
plt.title(pulse_model.name)
gnlse.plot_wavelength_vs_distance(solution, WL_range=[400, 1400])
gnlse_main.plot_wavelength_vs_distance(solution, WL_range=[400, 1400])

plt.subplot(2, count, i + 1 + count)
gnlse.plot_delay_vs_distance(solution, time_range=[-0.5, 5])
gnlse_main.plot_delay_vs_distance(solution, time_range=[-0.5, 5])

plt.tight_layout()
plt.show()
20 changes: 10 additions & 10 deletions examples/test_dispersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
import numpy as np
import matplotlib.pyplot as plt

import gnlse
import gnlse_main

import os

if __name__ == '__main__':
setup = gnlse.GNLSESetup()
setup = gnlse_main.GNLSESetup()

# Numerical parameters
setup.resolution = 2**14
Expand All @@ -29,7 +29,7 @@
setup.wavelength = 835 # nm
setup.fiber_length = 0.15 # m
setup.nonlinearity = 0.0 # 1/W/m
setup.raman_model = gnlse.raman_blowwood
setup.raman_model = gnlse_main.raman_blowwood
setup.self_steepening = True

# The dispersion model is built from a Taylor expansion with coefficients
Expand All @@ -43,13 +43,13 @@
# pulse duration [ps]
tfwhm = 0.05
# hyperbolic secant
setup.pulse_model = gnlse.SechEnvelope(power, tfwhm)
setup.pulse_model = gnlse_main.SechEnvelope(power, tfwhm)

# Type of dyspersion operator: build from interpolation of given neffs
# read mat file for neffs
mat_path = os.path.join(os.path.dirname(__file__), '..',
'data', 'neff_pcf.mat')
mat = gnlse.read_mat(mat_path)
mat = gnlse_main.read_mat(mat_path)
# neffs
neff = mat['neff'][:, 1]
# wavelengths in nm
Expand All @@ -60,25 +60,25 @@

# Set type of dispersion function
simulation_type = {
'Results for Taylor expansion': gnlse.DispersionFiberFromTaylor(
'Results for Taylor expansion': gnlse_main.DispersionFiberFromTaylor(
loss, betas),
'Results for interpolation': gnlse.DispersionFiberFromInterpolation(
'Results for interpolation': gnlse_main.DispersionFiberFromInterpolation(
loss, neff, lambdas, setup.wavelength)
}

count = len(simulation_type)
plt.figure(figsize=(15, 7), facecolor='w', edgecolor='k')
for (i, (name, dispersion_model)) in enumerate(simulation_type.items()):
setup.dispersion_model = dispersion_model
solver = gnlse.GNLSE(setup)
solver = gnlse_main.GNLSE(setup)
solution = solver.run()

plt.subplot(2, count, i + 1)
plt.title(name)
gnlse.plot_wavelength_vs_distance(solution, WL_range=[400, 1400])
gnlse_main.plot_wavelength_vs_distance(solution, WL_range=[400, 1400])

plt.subplot(2, count, i + 1 + count)
gnlse.plot_delay_vs_distance(solution, time_range=[-.5, 5])
gnlse_main.plot_delay_vs_distance(solution, time_range=[-.5, 5])

plt.tight_layout()
plt.show()
14 changes: 7 additions & 7 deletions examples/test_gvd.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"""

import numpy as np
import gnlse
import gnlse_main
import matplotlib.pyplot as plt


if __name__ == '__main__':
setup = gnlse.gnlse.GNLSESetup()
setup = gnlse_main.gnlse.GNLSESetup()

# Numerical parameters
###########################################################################
Expand Down Expand Up @@ -49,27 +49,27 @@
# Fiber length [m]
setup.fiber_length = 4 * LD
# Type of pulse: gaussian
setup.pulse_model = gnlse.GaussianEnvelope(power, tFWHM)
setup.pulse_model = gnlse_main.GaussianEnvelope(power, tFWHM)
# Loss coefficient [dB/m]
loss = 0
# Type of dyspersion operator: build from Taylor expansion
setup.dispersion_model = gnlse.DispersionFiberFromTaylor(loss, betas)
setup.dispersion_model = gnlse_main.DispersionFiberFromTaylor(loss, betas)

# Type of Ramman scattering function: None (default)
# Selftepening: not accounted
setup.self_steepening = False

# Simulation
###########################################################################
solver = gnlse.gnlse.GNLSE(setup)
solver = gnlse_main.gnlse.GNLSE(setup)
solution = solver.run()

# Visualization
###########################################################################

plt.subplot(1, 2, 1)
gnlse.plot_wavelength_vs_distance(solution, WL_range=[780, 900])
gnlse_main.plot_wavelength_vs_distance(solution, WL_range=[780, 900])
plt.subplot(1, 2, 2)
gnlse.plot_delay_vs_distance(solution, time_range=[-.5, .5])
gnlse_main.plot_delay_vs_distance(solution, time_range=[-.5, .5])

plt.show()
12 changes: 6 additions & 6 deletions examples/test_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
"""

import os
import gnlse
import gnlse_main

if __name__ == '__main__':
setup = gnlse.GNLSESetup()
setup = gnlse_main.GNLSESetup()
setup.resolution = 2**13
setup.time_window = 12.5 # ps
setup.z_saves = 200
setup.fiber_length = 0.15 # m
setup.wavelength = 835 # nm
setup.pulse_model = gnlse.GaussianEnvelope(1, 0.1)
setup.pulse_model = gnlse_main.GaussianEnvelope(1, 0.1)

solver = gnlse.GNLSE(setup)
solver = gnlse_main.GNLSE(setup)
solution = solver.run()

path = 'test.mat'

solution.to_file(path)
solution = gnlse.Solution()
solution = gnlse_main.Solution()
solution.from_file(path)

gnlse.quick_plot(solution)
gnlse_main.quick_plot(solution)

os.remove(path)
Loading