From ffd53af10ea6cf084d4c0695345a8b2138785c4a Mon Sep 17 00:00:00 2001 From: Sylwia Majchrowska Date: Tue, 26 Apr 2022 23:18:39 +0200 Subject: [PATCH] refactor to v2.0.0 --- README.md | 23 +++++++---- docs/code_documentation.rst | 2 +- docs/envelopes.rst | 2 +- docs/examples/example_dispersive_wave.rst | 4 +- docs/examples/example_effective_mode_area.rst | 4 +- docs/examples/example_soliton.rst | 4 +- docs/examples/example_supercontinuum.rst | 14 +++---- docs/gnlse_intro.rst | 41 +++++++++---------- examples/plot_input_pulse.py | 14 +++---- examples/test_3rd_order_soliton.py | 4 +- examples/test_Dudley.py | 14 +++---- examples/test_dispersion.py | 4 +- examples/test_gvd.py | 4 +- examples/test_import_export.py | 2 +- examples/test_nonlinearity.py | 2 +- examples/test_raman.py | 4 +- examples/test_spm+gvd.py | 4 +- examples/test_spm.py | 4 +- gnlse/gnlse.py | 22 +++++----- requirements.txt | 3 -- 20 files changed, 88 insertions(+), 87 deletions(-) diff --git a/README.md b/README.md index 3a649cb..ff1f5b3 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ python test_Dudley.py And you expect to visualise supercontinuum generation process in use of 3 types of pulses (simulation similar to Fig.3 of Dudley et. al, RMP 78 1135 (2006)): -![supercontinuum_generation](https://github.com/WUST-FOG/gnlse-python/raw/master/data/supercontinuum_3pulses.png) +![soliton_traping](./data/supercontinuum_3pulses.png) ### Major features @@ -80,13 +80,13 @@ And you expect to visualise supercontinuum generation process in use of 3 types - **Available demos** We prepare few examples in `examples` subdirectory: - - plot_input_pulse.py: plots envelope of different impulse shapes, + - plot_input_pulse.py: plots envelope of different pulse shapes, - plot_Raman_response.py: plots different Raman in temporal domain, - test_3rd_order_soliton.py: evolution of the spectral and temporal characteristics of the 3rd order soliton, - test_dispersion.py: example of supercontinuum generation using different dispersion operators, - test_nonlinearity.py: example of supercontinuum generation using different GNLSE and M-GNLSE (take into account mode profile dispersion), - test_Dudley.py: example of supercontinuum generation with three types of input pulse, - - test_gvd.py: example of impuls broadening due to group velocity dispersion, + - test_gvd.py: example of pulse broadening due to group velocity dispersion, - test_import_export.py: example of saving file with `.mat` extension, - test_raman.py: example of soliton fision for diffrent raman response functions, - test_spm.py: example of self phase modulation, @@ -94,9 +94,12 @@ And you expect to visualise supercontinuum generation process in use of 3 types ## Release History -v1.1.3 was released in 13/2/2022. -The master branch works with **python 3.7**. +v2.0.0 was released in 26/4/2022. +The main branch works with **python 3.7**. +* **2.0.0 -> Apr 26th, 2022** + * CHANGE: Code refactor - rename envelopes module + * FIX: Fixed extrapolation for nonlinear coefficient * **1.1.3 -> Feb 13th, 2022** * FIX: Shift scalling data for interpolated dispersion * **1.1.2 -> Aug 30th, 2021** @@ -115,10 +118,10 @@ The master branch works with **python 3.7**. ## Authors -- [Adam Pawłowski](https://github.com/adampawl) - [Paweł Redman](https://redman.xyz/) -- [Daniel Szulc](http://szulc.xyz/) - [Magda Zatorska](https://github.com/magdazatorska) +- [Adam Pawłowski](https://github.com/adampawl) +- [Daniel Szulc](http://szulc.xyz/) - [Sylwia Majchrowska](https://majsylw.netlify.app/) - [Karol Tarnowski](http://www.if.pwr.wroc.pl/~tarnowski/) @@ -136,8 +139,10 @@ by J. M. Dudley and J. R. Taylor, available at ``` @misc{redman2021gnlsepython, - title={gnlse-python: Open Source Software to Simulate Nonlinear Light Propagation In Optical Fibers}, - author={Paweł Redman and Magdalena Zatorska and Adam Pawłowski and Daniel Szulc and Sylwia Majchrowska and Karol Tarnowski}, + title={gnlse-python: Open Source Software to Simulate + Nonlinear Light Propagation In Optical Fibers}, + author={Paweł Redman and Magdalena Zatorska and Adam Pawłowski + and Daniel Szulc and Sylwia Majchrowska and Karol Tarnowski}, year={2021}, eprint={2110.00298}, archivePrefix={arXiv}, diff --git a/docs/code_documentation.rst b/docs/code_documentation.rst index d3ed70c..dddfea3 100644 --- a/docs/code_documentation.rst +++ b/docs/code_documentation.rst @@ -1,7 +1,7 @@ GNLSE package documentation =========================== -Impulse envelopes +Pulse envelopes ----------------- This module allows one to model proper input envelope as the given initial diff --git a/docs/envelopes.rst b/docs/envelopes.rst index 49a37fa..dafeb68 100644 --- a/docs/envelopes.rst +++ b/docs/envelopes.rst @@ -9,7 +9,7 @@ input pulse. The below figure illustrates a modulated waves varying between an upper and a lower envelope of four types of optical signal. .. image:: _static/input_pulse.png - :alt: example_input_impulse + :alt: example_input_pulse .. autoclass:: gnlse.SechEnvelope .. autoclass:: gnlse.GaussianEnvelope diff --git a/docs/examples/example_dispersive_wave.rst b/docs/examples/example_dispersive_wave.rst index 28ffdfb..0f1095e 100644 --- a/docs/examples/example_dispersive_wave.rst +++ b/docs/examples/example_dispersive_wave.rst @@ -18,7 +18,7 @@ crystal fiber using three different models to model Raman response. :: setup.time_window = 12.5 # ps setup.z_saves = 400 - # Input impulse parameters + # Input pulse parameters peak_power = 10000 # W duration = 0.050284 # ps @@ -26,7 +26,7 @@ crystal fiber using three different models to model Raman response. :: setup.wavelength = 835 # nm setup.fiber_length = 0.15 # m setup.nonlinearity = 0.11 # 1/W/m - setup.impulse_model = gnlse.SechEnvelope(peak_power, duration) + setup.pulse_model = gnlse.SechEnvelope(peak_power, duration) setup.self_steepening = True # The dispersion model is built from a Taylor expansion with coefficients diff --git a/docs/examples/example_effective_mode_area.rst b/docs/examples/example_effective_mode_area.rst index 34538e8..7c9a730 100644 --- a/docs/examples/example_effective_mode_area.rst +++ b/docs/examples/example_effective_mode_area.rst @@ -28,12 +28,12 @@ a 15 centimeter long photonic crystal fiber. :: setup.raman_model = gnlse.raman_blowwood setup.self_steepening = True - # Input impulse parameters + # Input pulse parameters power = 10000 # pulse duration [ps] tfwhm = 0.05 # hyperbolic secant - setup.impulse_model = gnlse.SechEnvelope(power, tfwhm) + setup.pulse_model = gnlse.SechEnvelope(power, tfwhm) # The dispersion model is built from a Taylor expansion with coefficients # given below. diff --git a/docs/examples/example_soliton.rst b/docs/examples/example_soliton.rst index 4f2dbb6..04ca9a2 100644 --- a/docs/examples/example_soliton.rst +++ b/docs/examples/example_soliton.rst @@ -51,8 +51,8 @@ higher-order N = 3 soliton in three cases: Z0 = np.pi * LD / 2 # Fiber length [m] setup.fiber_length = .5 - # Type of impulse: hyperbolic secant - setup.impulse_model = gnlse.SechEnvelope(power, 0.050) + # Type of pulse: hyperbolic secant + setup.pulse_model = gnlse.SechEnvelope(power, 0.050) # Loss coefficient [dB/m] loss = 0 # Type of dyspersion operator: build from Taylor expansion diff --git a/docs/examples/example_supercontinuum.rst b/docs/examples/example_supercontinuum.rst index b0cacbe..2d51ff3 100644 --- a/docs/examples/example_supercontinuum.rst +++ b/docs/examples/example_supercontinuum.rst @@ -36,28 +36,28 @@ different input shape of input pulse's envelopes. ]) setup.dispersion_model = gnlse.DispersionFiberFromTaylor(loss, betas) - # Input impulse parameters + # Input pulse parameters peak_power = 10000 # W duration = 0.050 # ps # This example extends the original code with additional simulations for - impulse_models = [ + pulse_models = [ gnlse.SechEnvelope(peak_power, duration), gnlse.GaussianEnvelope(peak_power, duration), gnlse.LorentzianEnvelope(peak_power, duration) ] - count = len(impulse_models) + count = len(pulse_models) plt.figure(figsize=(14, 8), facecolor='w', edgecolor='k') - for i, impulse_model in enumerate(impulse_models): - print('%s...' % impulse_model.name) + for i, pulse_model in enumerate(pulse_models): + print('%s...' % pulse_model.name) - setup.impulse_model = impulse_model + setup.pulse_model = pulse_model solver = gnlse.GNLSE(setup) solution = solver.run() plt.subplot(2, count, i + 1) - plt.title(impulse_model.name) + plt.title(pulse_model.name) gnlse.plot_wavelength_vs_distance(solution, WL_range=[400, 1400]) plt.subplot(2, count, i + 1 + count) diff --git a/docs/gnlse_intro.rst b/docs/gnlse_intro.rst index af8bb2b..7fac3ce 100644 --- a/docs/gnlse_intro.rst +++ b/docs/gnlse_intro.rst @@ -17,11 +17,7 @@ Installation ``git clone https://github.com/WUST-FOG/gnlse-python.git`` - 4. Install the requirements: - - ``pip install -r requirements.txt`` - - 5. Install the package: + 4. Install the package with all requirements: ``pip install .`` @@ -85,7 +81,7 @@ Major features and calculated from effective refractive indices. * A number of example scripts in the ``examples`` subdirectory: - * ``plot_input_pulse.py``, plotting various input impulse envelopes, + * ``plot_input_pulse.py``, plotting various input pulse envelopes, * ``plot_Raman_response.py``, plotting supported Raman response functions in the time domain, * ``test_3rd_order_soliton.py``, demonstrating the evolution of spectral @@ -96,8 +92,8 @@ Major features different GNLSE and M-GNLSE (take into account mode profile dispersion), * ``test_Dudley``, an example of supercontinuum generation using - different input impulse envelopes, - * ``test_gvd``, showing impulse broadening due to group velocity + different input pulse envelopes, + * ``test_gvd``, showing pulse broadening due to group velocity dispersion, * ``test_import_export.py``, an example of saving and loading simulation results to and from a \*.mat file. @@ -110,21 +106,24 @@ Major features Release information ------------------- -v1.1.2 was released on August 30, 2021. The master branch works with +v2.0.0 was released on April 26, 2022. The master branch works with **Python 3.7.** -======= =============== ==================================================== -Version Date Notes -======= =============== ==================================================== -1.1.2 August 30, 2021 * ADD: Continious wave envelope - * FIX: Shift scalling data for nonlinear coefficient -1.1.1 August 28, 2021 * CHANGE: Minor bug fix with scaling - * CHANGE: Few minor changes in the documentation -1.1.0 August 21, 2021 * Modified-GNLSE extension - * CHANGE: Code refactor - relocate attribiutes -1.0.0 August 13, 2020 * The first proper release - * CHANGE: Complete documentation and code. -======= =============== ==================================================== +======= ================= ==================================================== +Version Date Notes +======= ================= ==================================================== +2.0.0 April 26, 2022 * CHANGE: Code refactor - rename modules + * FIX: Fixed extrapolation for nonlinear coefficient +1.1.3 February 13, 2022 * FIX: Fix scaling for interpolated dispersion +1.1.2 August 30, 2021 * ADD: Continious wave envelope + * FIX: Shift scalling data for nonlinear coefficient +1.1.1 August 28, 2021 * CHANGE: Minor bug fix with scaling + * CHANGE: Few minor changes in the documentation +1.1.0 August 21, 2021 * Modified-GNLSE extension + * CHANGE: Code refactor - relocate attribiutes +1.0.0 August 13, 2020 * The first proper release + * CHANGE: Complete documentation and code. +======= ================= ==================================================== Authors ******* diff --git a/examples/plot_input_pulse.py b/examples/plot_input_pulse.py index 773684f..a56f0a8 100644 --- a/examples/plot_input_pulse.py +++ b/examples/plot_input_pulse.py @@ -1,7 +1,7 @@ -"""Calculates envelopes of various impulses and plots them. -Based on the chosen envelopes impulse, the aplitude envelope is +"""Calculates envelopes of various pulses and plots them. +Based on the chosen envelopes pulse, the aplitude envelope is calculated and shown on the graph. There are three -available envelopes impulses models: +available envelopes pulses models: hyperbolic secant, gaussian and lorentzian. """ @@ -11,18 +11,18 @@ import gnlse if __name__ == '__main__': - # time full with half maximum of impulse + # time full with half maximum of pulse FWHM = 2 # Time grid [ps] T = np.linspace(-2 * FWHM, 2 * FWHM, 1000 * FWHM) # peak power [W] Pmax = 100 - # Amplitude envelope of gaussina impulse + # Amplitude envelope of gaussina pulse A1 = gnlse.GaussianEnvelope(Pmax, FWHM).A(T) - # Amplitude envelope of hiperbolic secans impulse + # Amplitude envelope of hiperbolic secans pulse A2 = gnlse.SechEnvelope(Pmax, FWHM).A(T) - # Amplitude envelope of lorentzian impulse + # Amplitude envelope of lorentzian pulse A3 = gnlse.LorentzianEnvelope(Pmax, FWHM).A(T) # Amplitude envelope of continious wave A4 = gnlse.CWEnvelope(Pmax).A(T) diff --git a/examples/test_3rd_order_soliton.py b/examples/test_3rd_order_soliton.py index 60a08d5..4a43016 100644 --- a/examples/test_3rd_order_soliton.py +++ b/examples/test_3rd_order_soliton.py @@ -51,8 +51,8 @@ Z0 = np.pi * LD / 2 # Fiber length [m] setup.fiber_length = .5 - # Type of impulse: hyperbolic secant - setup.impulse_model = gnlse.SechEnvelope(power, 0.050) + # Type of pulse: hyperbolic secant + setup.pulse_model = gnlse.SechEnvelope(power, 0.050) # Loss coefficient [dB/m] loss = 0 # Type of dyspersion operator: build from Taylor expansion diff --git a/examples/test_Dudley.py b/examples/test_Dudley.py index 7ff7221..fef21bc 100644 --- a/examples/test_Dudley.py +++ b/examples/test_Dudley.py @@ -39,28 +39,28 @@ ]) setup.dispersion_model = gnlse.DispersionFiberFromTaylor(loss, betas) - # Input impulse parameters + # Input pulse parameters peak_power = 10000 # W duration = 0.050 # ps # This example extends the original code with additional simulations for - impulse_models = [ + pulse_models = [ gnlse.SechEnvelope(peak_power, duration), gnlse.GaussianEnvelope(peak_power, duration), gnlse.LorentzianEnvelope(peak_power, duration) ] - count = len(impulse_models) + count = len(pulse_models) plt.figure(figsize=(14, 8), facecolor='w', edgecolor='k') - for i, impulse_model in enumerate(impulse_models): - print('%s...' % impulse_model.name) + for i, pulse_model in enumerate(pulse_models): + print('%s...' % pulse_model.name) - setup.impulse_model = impulse_model + setup.pulse_model = pulse_model solver = gnlse.GNLSE(setup) solution = solver.run() plt.subplot(2, count, i + 1) - plt.title(impulse_model.name) + plt.title(pulse_model.name) gnlse.plot_wavelength_vs_distance(solution, WL_range=[400, 1400]) plt.subplot(2, count, i + 1 + count) diff --git a/examples/test_dispersion.py b/examples/test_dispersion.py index 3e81ab6..8a67c09 100644 --- a/examples/test_dispersion.py +++ b/examples/test_dispersion.py @@ -38,12 +38,12 @@ betas = np.array([-0.024948815481502, 8.875391917212998e-05, -9.247462376518329e-08, 1.508210856829677e-10]) - # Input impulse parameters + # Input pulse parameters power = 10000 # pulse duration [ps] tfwhm = 0.05 # hyperbolic secant - setup.impulse_model = gnlse.SechEnvelope(power, tfwhm) + setup.pulse_model = gnlse.SechEnvelope(power, tfwhm) # Type of dyspersion operator: build from interpolation of given neffs # read mat file for neffs diff --git a/examples/test_gvd.py b/examples/test_gvd.py index 05bca20..822b90e 100644 --- a/examples/test_gvd.py +++ b/examples/test_gvd.py @@ -48,8 +48,8 @@ power = 1 # value can be choosen arbitrarily # Fiber length [m] setup.fiber_length = 4 * LD - # Type of impulse: gaussian - setup.impulse_model = gnlse.GaussianEnvelope(power, tFWHM) + # Type of pulse: gaussian + setup.pulse_model = gnlse.GaussianEnvelope(power, tFWHM) # Loss coefficient [dB/m] loss = 0 # Type of dyspersion operator: build from Taylor expansion diff --git a/examples/test_import_export.py b/examples/test_import_export.py index 838212f..66aec4a 100644 --- a/examples/test_import_export.py +++ b/examples/test_import_export.py @@ -12,7 +12,7 @@ setup.z_saves = 200 setup.fiber_length = 0.15 # m setup.wavelength = 835 # nm - setup.impulse_model = gnlse.GaussianEnvelope(1, 0.1) + setup.pulse_model = gnlse.GaussianEnvelope(1, 0.1) solver = gnlse.GNLSE(setup) solution = solver.run() diff --git a/examples/test_nonlinearity.py b/examples/test_nonlinearity.py index ff7b781..8319615 100644 --- a/examples/test_nonlinearity.py +++ b/examples/test_nonlinearity.py @@ -42,7 +42,7 @@ # pulse duration [ps] tfwhm = 0.05 # hyperbolic secant - setup.impulse_model = gnlse.SechEnvelope(power, tfwhm) + setup.pulse_model = gnlse.SechEnvelope(power, tfwhm) # The dispersion model is built from a Taylor expansion with coefficients # given below. diff --git a/examples/test_raman.py b/examples/test_raman.py index 3d7112b..29a17d0 100644 --- a/examples/test_raman.py +++ b/examples/test_raman.py @@ -21,7 +21,7 @@ setup.time_window = 12.5 # ps setup.z_saves = 400 - # Input impulse parameters + # Input pulse parameters peak_power = 10000 # W duration = 0.050284 # ps @@ -29,7 +29,7 @@ setup.wavelength = 835 # nm setup.fiber_length = 0.15 # m setup.nonlinearity = 0.11 # 1/W/m - setup.impulse_model = gnlse.SechEnvelope(peak_power, duration) + setup.pulse_model = gnlse.SechEnvelope(peak_power, duration) setup.self_steepening = True # The dispersion model is built from a Taylor expansion with coefficients diff --git a/examples/test_spm+gvd.py b/examples/test_spm+gvd.py index cbfa6f2..689bea7 100644 --- a/examples/test_spm+gvd.py +++ b/examples/test_spm+gvd.py @@ -51,8 +51,8 @@ power = 1 / (LNL * setup.nonlinearity) # Fiber length [m] setup.fiber_length = 10 * LD - # Type of impulse: gaussian - setup.impulse_model = gnlse.GaussianEnvelope(power, tFWHM) + # Type of pulse: gaussian + setup.pulse_model = gnlse.GaussianEnvelope(power, tFWHM) # Loss coefficient [dB/m] loss = 0 # Type of dyspersion operator: build from Taylor expansion diff --git a/examples/test_spm.py b/examples/test_spm.py index 0eb15b6..24e7ac4 100644 --- a/examples/test_spm.py +++ b/examples/test_spm.py @@ -47,8 +47,8 @@ LNL = 1 / (power * setup.nonlinearity) # Fiber length [m] setup.fiber_length = 3.5 * np.pi * LNL - # Type of impulse: gaussian - setup.impulse_model = gnlse.GaussianEnvelope(power, tFWHM) + # Type of pulse: gaussian + setup.pulse_model = gnlse.GaussianEnvelope(power, tFWHM) # Loss coefficient [dB/m] loss = 0 # Type of dyspersion operator: build from Taylor expansion diff --git a/gnlse/gnlse.py b/gnlse/gnlse.py index 1c09aad..a714b21 100644 --- a/gnlse/gnlse.py +++ b/gnlse/gnlse.py @@ -19,7 +19,7 @@ class GNLSESetup: time_window : float [ps] Width of the time window. wavelength : float [nm] - Central wavelength of the input impulse. + Central wavelength of the input pulse. fiber_length : float [m] Length of the simulated optical fiber. z_saves : int @@ -27,8 +27,8 @@ class GNLSESetup: more memory to store the result. nonlinearity : float [1/W/m] Effective nonlinearity. - impulse_model : Envelope - Input impulse envelope model. + pulse_model : Envelope + Input pulse envelope model. dispersion_model : Dispersion, optional Fiber dispersion model or ``None`` to model a dispersionless fiber. raman_model : function, optional @@ -51,7 +51,7 @@ def __init__(self): self.z_saves = 200 self.nonlinearity = 0 - self.impulse_model = None + self.pulse_model = None self.dispersion_model = None self.raman_model = None self.self_steepening = False @@ -121,7 +121,7 @@ def from_file(self, path): class GNLSE: """ - Models propagation of an optical impulse in a fiber by integrating + Models propagation of an optical pulse in a fiber by integrating the generalized non-linear Schrödinger equation. Attributes @@ -142,8 +142,8 @@ def __init__(self, setup): raise ValueError("'wavelength' not set") if setup.fiber_length is None: raise ValueError("'fiber_length' not set") - if setup.impulse_model is None: - raise ValueError("'impulse_model' not set") + if setup.pulse_model is None: + raise ValueError("'pulse_model' not set") # simulation parameters self.fiber_length = setup.fiber_length @@ -201,11 +201,11 @@ def __init__(self, setup): else: self.D = np.zeros(self.V.shape) - # Input impulse - if hasattr(setup.impulse_model, 'A'): - self.A = setup.impulse_model.A(self.t) + # Input pulse + if hasattr(setup.pulse_model, 'A'): + self.A = setup.pulse_model.A(self.t) else: - self.A = setup.impulse_model + self.A = setup.pulse_model def run(self): """ diff --git a/requirements.txt b/requirements.txt index 6c681da..90e9a69 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,5 @@ matplotlib>=2.2.2 -numba>=0.38.0 numpy>=1.14.3 -pep8>=1.7.1 -pytest>=3.5.1 scipy>=1.1.0 pyfftw>=0.10.0 hdf5storage>=0.1.15