
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/build/qip/plot_qip_amplitude_noise.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        Click :ref:`here <sphx_glr_download_gallery_build_qip_plot_qip_amplitude_noise.py>`
        to download the full example code

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_build_qip_plot_qip_amplitude_noise.py:


Control Amplitude Noise
=======================

This example demonstrates how to add Gaussian noise to the control pulse.

.. GENERATED FROM PYTHON SOURCE LINES 7-34



.. rst-class:: sphx-glr-horizontal


    *

      .. image-sg:: /gallery/build/qip/images/sphx_glr_plot_qip_amplitude_noise_001.png
         :alt: Original control amplitude
         :srcset: /gallery/build/qip/images/sphx_glr_plot_qip_amplitude_noise_001.png
         :class: sphx-glr-multi-img

    *

      .. image-sg:: /gallery/build/qip/images/sphx_glr_plot_qip_amplitude_noise_002.png
         :alt: Noisy control amplitude
         :srcset: /gallery/build/qip/images/sphx_glr_plot_qip_amplitude_noise_002.png
         :class: sphx-glr-multi-img


.. rst-class:: sphx-glr-script-out

 Out:

 .. code-block:: none


    [<matplotlib.lines.Line2D object at 0x7f16bf462c60>]





|

.. code-block:: default

    import numpy as np
    import matplotlib.pyplot as plt
    from qutip.qip.device import Processor
    from qutip.qip.noise import RandomNoise
    from qutip.operators import sigmaz, sigmay

    # add control Hamiltonians
    processor = Processor(N=1)
    processor.add_control(sigmaz(), targets=0)

    # define pulse coefficients and tlist for all pulses
    processor.pulses[0].coeff = np.array([0.3, 0.5, 0. ])
    processor.set_all_tlist(np.array([0., np.pi/2., 2*np.pi/2, 3*np.pi/2]))

    # define noise, loc and scale are keyword arguments for np.random.normal
    gaussnoise = RandomNoise(
                dt=0.01, rand_gen=np.random.normal, loc=0.00, scale=0.02)
    processor.add_noise(gaussnoise)

    # Plot the ideal pulse
    processor.plot_pulses(title="Original control amplitude", figsize=(5,3))

    # Plot the noisy pulse
    qobjevo, _ = processor.get_qobjevo(noisy=True)
    noisy_coeff = qobjevo.to_list()[1][1] + qobjevo.to_list()[2][1]
    fig2, ax2 = processor.plot_pulses(title="Noisy control amplitude", figsize=(5,3))
    ax2[0].step(qobjevo.tlist, noisy_coeff)


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** ( 0 minutes  0.121 seconds)


.. _sphx_glr_download_gallery_build_qip_plot_qip_amplitude_noise.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: plot_qip_amplitude_noise.py <plot_qip_amplitude_noise.py>`



  .. container:: sphx-glr-download sphx-glr-download-jupyter

     :download:`Download Jupyter notebook: plot_qip_amplitude_noise.ipynb <plot_qip_amplitude_noise.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
