.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/devices/example_001_number_state_source.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_examples_devices_example_001_number_state_source.py: Number State Source Example =========================== This example demonstrates the use of the :class:`~symop.devices.models.sources.number_state_source.NumberStateSource` with the polynomial state. .. GENERATED FROM PYTHON SOURCE LINES 9-20 .. code-block:: Python from __future__ import annotations from symop.devices.models.sources import NumberStateSource from symop.modes.labels import Path, Polarization from symop.modes.envelopes import GaussianEnvelope from symop.polynomial.state import KetPolyState # Visualization Package import symop.viz as VI .. GENERATED FROM PYTHON SOURCE LINES 21-22 **Setup: set up a mode labels and then the single photon source** .. GENERATED FROM PYTHON SOURCE LINES 22-29 .. code-block:: Python src_env = GaussianEnvelope(omega0=2.0, sigma=1.0, tau=0.0) src_pol = Polarization.H() src_dev = NumberStateSource(envelope=src_env, polarization=src_pol, n=1) .. GENERATED FROM PYTHON SOURCE LINES 30-33 **1) Generate the state** - Generate the vacuum state for the source to populate - For populating the vacuum ``__call__()`` can be used or ``.apply()`` .. GENERATED FROM PYTHON SOURCE LINES 33-40 .. code-block:: Python vac = KetPolyState.vacuum() single_photon_state = src_dev( vac, ports={"out": Path("src_out")}, ) .. GENERATED FROM PYTHON SOURCE LINES 41-42 **2) Inspect state** .. GENERATED FROM PYTHON SOURCE LINES 42-44 .. code-block:: Python VI.plot(single_photon_state) VI.display(single_photon_state) .. image-sg:: /examples/devices/images/sphx_glr_example_001_number_state_source_001.png :alt: $\hat{a}_{1[\mathrm{src\_out}]}^\dagger$, mode 1 :srcset: /examples/devices/images/sphx_glr_example_001_number_state_source_001.png :class: sphx-glr-single-img .. raw:: html
2026-04-24T11:36:44.107077 image/svg+xml Matplotlib v3.10.9, https://matplotlib.org/


.. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.357 seconds) .. _sphx_glr_download_examples_devices_example_001_number_state_source.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_001_number_state_source.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_001_number_state_source.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: example_001_number_state_source.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_