.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_tutorials/tools/plot_01_compressor_pairs.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_tutorials_tools_plot_01_compressor_pairs.py: Grating spacing and prism insertion =================================== Recover known compressor settings from synthetic chirped pulses. No propagation is needed: an inverse pair phase makes a test input and the bounded compressor finds the physical stage setting that removes it. Independent ray and dispersion references, rather than this round trip, establish the phase model in the test suite. A fixed working band selects the same spectrum for every trial. The prism search moves only the second prism, perpendicular to its base, at fixed separation stage. .. GENERATED FROM PYTHON SOURCE LINES 19-20 Build a small envelope grid and a transform-limited 15 fs pulse. .. GENERATED FROM PYTHON SOURCE LINES 20-60 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from solprop import fourier from solprop.grid import EnvelopeGrid from solprop.optics import ( GratingPair, PrismGeometry, PrismPair, brewster_angle, brewster_apex, littrow_angle, stored_factor, ) from solprop.physdata import fused_silica from solprop.processing import compress_gratings, compress_prisms from solprop.pulses import GaussianPulse wavelength = 800e-9 grid = EnvelopeGrid.from_limits(1e-3, wavelength, (400e-9, 2e-6), 2e-12) clean = GaussianPulse(wavelength=wavelength, fwhm=15e-15, energy=1e-6).build(grid) band = (600e-9, 1100e-9) gratings = GratingPair( 600e3, 400e-6, littrow_angle(600e3, wavelength), wavelength, band=band ) glass = fused_silica(model="malitson_1965/sellmeier") prisms = PrismPair( glass, PrismGeometry( separation=0.6, insertion=0.015, first_face_distance=0.003, apex_angle=brewster_apex(glass, wavelength), incidence_angle=brewster_angle(glass, wavelength), ), wavelength, band=band, ) .. GENERATED FROM PYTHON SOURCE LINES 61-63 Stored spectra use the internal Fourier convention. The conjugate of ``stored_factor`` applies the inverse phase and the same fixed band selection. .. GENERATED FROM PYTHON SOURCE LINES 63-74 .. code-block:: Python grating_input = clean * stored_factor(grid, gratings).conj() prism_input = clean * stored_factor(grid, prisms).conj() grating_fit = compress_gratings( grid=grid, spectrum=grating_input, pair=gratings, separation_range=(0.0, 1e-3) ) prism_fit = compress_prisms( grid=grid, spectrum=prism_input, pair=prisms, insertion_range=(0.008, 0.021) ) assert grating_fit.success and prism_fit.success assert min(grating_fit.quality, prism_fit.quality) >= 1 - 1e-6 .. GENERATED FROM PYTHON SOURCE LINES 75-77 Compare the selected pulses before and after compression. Both fitted settings recover the transform-limited pulse. Absolute CEP and transit time were removed. .. GENERATED FROM PYTHON SOURCE LINES 77-95 .. code-block:: Python figure, axes = plt.subplots(1, 2, figsize=(9, 3.4), sharey=True) for axis, stored, fitted, title in zip( axes, (grating_input, prism_input), (grating_fit, prism_fit), ("Gratings: tune normal spacing", "Prisms: tune second-prism insertion"), strict=True, ): for label, transfer in (("Before", None), ("Compressed", fitted.transfer)): factor = 1.0 if transfer is None else stored_factor(grid, transfer) field = fourier.inverse(stored * factor, kind="envelope") power = np.sum(abs(field) ** 2, axis=(0, 1)) axis.plot(grid.t * 1e15, power * 1e-6, label=label) axis.set(xlim=(-200, 200), xlabel="Time (fs)", title=title) axis.legend(frameon=False) axes[0].set_ylabel("Power (MW)") figure.tight_layout() .. image-sg:: /auto_tutorials/tools/images/sphx_glr_plot_01_compressor_pairs_001.png :alt: Gratings: tune normal spacing, Prisms: tune second-prism insertion :srcset: /auto_tutorials/tools/images/sphx_glr_plot_01_compressor_pairs_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 96-102 Related reading --------------- Continue with :doc:`/guide/workflows/compression` for the model, options and limits, and :doc:`/guide/numerics/accuracy` for convergence checks. For a paced propagation lesson, return to :doc:`/introduction/lessons/plot_02_soliton`. .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.239 seconds) .. _sphx_glr_download_auto_tutorials_tools_plot_01_compressor_pairs.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_compressor_pairs.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_compressor_pairs.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_compressor_pairs.zip `