.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_tutorials/photon_number_conservation/g_FMAS_S_R.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_tutorials_photon_number_conservation_g_FMAS_S_R.py: FMAS_S_R ======== This examples demonstrates photon number conservation for the simplified forward model for the analytic signal including the Raman effect (FMAS_S_R). The considered propagation model provides a proper conservation law as class method `claw`. However, for clarity, we here re-implement the conservation law and explicitly pass this user-defined function to the solver class upon initialization. As exemplary propagation scenario, the setup used in the step-by-step demo :ref:`sphx_glr_auto_tutorials_specific_g_spectrogram.py` is used. .. codeauthor:: Oliver Melchert .. GENERATED FROM PYTHON SOURCE LINES 21-42 .. code-block:: default import fmas import numpy as np from fmas.solver import IFM_RK4IP from fmas.analytic_signal import AS from fmas.grid import Grid from fmas.propagation_constant import PropConst, define_beta_fun_ESM from fmas.tools import sech, change_reference_frame, plot_claw beta_fun = define_beta_fun_ESM() pc = PropConst(beta_fun) grid = Grid(t_max=5500.0, t_num=2 ** 14) # (fs) # (-) Ns = 8.0 # (-) t0 = 7.0 # (fs) w0 = 1.7 # (rad/fs) n2 = 3.0e-8 # (micron^2/W) A0 = Ns * np.sqrt(abs(pc.beta2(w0)) * pc.c0 / w0 / n2) / t0 E_0t_fun = lambda t: np.real(A0 * sech(t / t0) * np.exp(1j * w0 * t)) Eps_0w = AS(E_0t_fun(grid.t)).w_rep .. GENERATED FROM PYTHON SOURCE LINES 43-45 As model we here consider the simplified forward model for the analytic signal including the Raman effect (FMAS_S_R) .. GENERATED FROM PYTHON SOURCE LINES 45-49 .. code-block:: default from fmas.models import FMAS_S_R model = FMAS_S_R(w=grid.w, beta_w=pc.beta(grid.w), n2=n2) .. GENERATED FROM PYTHON SOURCE LINES 50-58 For the FMAS_S_R :math:`z`-propagation model we consider a conserved quantity that is related to the classical analog of the photon number, see Eq. (24) of [AD2010] and the appendix of [BW1989]. In particular we here implement .. math:: C_p(z) = \sum_{\omega>0} \omega^{-1} |u_\omega(z)|^, which is, by default, provided as method `model.claw` . .. GENERATED FROM PYTHON SOURCE LINES 58-67 .. code-block:: default def Cp(i, zi, w, uw): _a2_w = np.divide( np.abs(uw) ** 2, w, out=np.zeros(w.size, dtype="float"), where=w > 0. ) return np.sum(_a2_w) .. GENERATED FROM PYTHON SOURCE LINES 68-76 As shown below, this conserved quantity can be provided when an instance of the desired solver is initialized. Here, for simply monitoring the conservation law we use the Runge-Kutta in the ineraction picture method. However, a proper conserved quantity is especially important when the conservation quantity error method (CQE) is used, see, e.g., demo :ref:`sphx_glr_auto_tutorials_tests_g_performance_CQE.py` .. GENERATED FROM PYTHON SOURCE LINES 76-81 .. code-block:: default solver = IFM_RK4IP(model.Lw, model.Nw, user_action=Cp) solver.set_initial_condition(grid.w, Eps_0w) solver.propagate(z_range=0.01e6, n_steps=4000, n_skip=8) # (micron) # (-) # (-) .. GENERATED FROM PYTHON SOURCE LINES 82-95 The figure below shows the dynamic evolution of the pulse in the time domain (top subfigure) and in the frequency domain (center subfigure). The subfigure at the bottom shows the conservation law (c-law) given by the normalized photon number variation .. math:: \delta_{\rm{Ph}}(z) = \frac{ C_p(z)-C_p(0)}{C_p(0)} as function of the proapgation coordinate :math:`z`. For the considered discretization of the computational domain the normalized photon number variation is of the order :math:`\delta_{\rm{Ph}}\approx 10^{-7}` and thus very small. The value can be still decreased by decreasing the stepsize :math:`\Delta z`. .. GENERATED FROM PYTHON SOURCE LINES 95-103 .. code-block:: default utz = change_reference_frame(solver.w, solver.z, solver.uwz, pc.vg(w0)) plot_claw( solver.z, grid.t, utz, solver.ua_vals, t_lim=(-25, 125), w_lim=(0.5, 4.5) ) .. image:: /auto_tutorials/photon_number_conservation/images/sphx_glr_g_FMAS_S_R_001.png :alt: g FMAS S R :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 104-113 **References:** [AD2010] Sh. Amiranashvili, A. Demircan, Hamiltonian structure of propagation equations for ultrashort optical pulses, Phys. Rev. E 10 (2010) 013812, http://dx.doi.org/10.1103/PhysRevA.82.013812. [BW1989] K. J. Blow, D. Wood, Theoretical description of transient stimulated Raman scattering in optical fibers. IEEE J. Quantum Electron., 25 (1989) 1159, https://doi.org/10.1109/3.40655. .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 33.755 seconds) .. _sphx_glr_download_auto_tutorials_photon_number_conservation_g_FMAS_S_R.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: g_FMAS_S_R.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: g_FMAS_S_R.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_