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

.. only:: html

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

        :ref:`Go to the end <sphx_glr_download_auto_examples_core_BCF.py>`
        to download the full example code.

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

.. _sphx_glr_auto_examples_core_BCF.py:


Bichromatic force
=================

Calculating the bichromatic force and compare BaF with CaF.

Steady state coherent force BCF...

.. GENERATED FROM PYTHON SOURCE LINES 10-13

.. code-block:: Python

    from MoleCool import System, np, plt, pi, c, open_object, save_object
    import os.path


.. GENERATED FROM PYTHON SOURCE LINES 14-16

Calculation for BaF and CaF
---------------------------

.. GENERATED FROM PYTHON SOURCE LINES 16-23

.. code-block:: Python

    if __name__ == '__main__': 
        for label, exAB in zip(['138BaF','CaF'], ['A','B']):
            if not os.path.isfile(f"BCF_{label}.pkl"):
            
                system = System(load_constants  = label,
                                description     = f"BCF_{label}")
            

.. GENERATED FROM PYTHON SOURCE LINES 24-26

Electronic states and velocity
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. GENERATED FROM PYTHON SOURCE LINES 26-36

.. code-block:: Python
   :dedent: 1

                system.levels.add_electronicstate('X', 'gs')
                system.levels.X.load_states(v=[0])
                system.levels.add_electronicstate(exAB, 'exs')
                system.levels[exAB].load_states(v=[0])
    
                system.set_v0(
                    np.arange(-120.25, 120.50, 0.5),
                    direction = 'z',
                    )
    

.. GENERATED FROM PYTHON SOURCE LINES 37-39

Lasers with right Rabi frequency
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. GENERATED FROM PYTHON SOURCE LINES 39-59

.. code-block:: Python
   :dedent: 1

    
                Gamma       = system.levels.calc_Gamma()[0]
                delta       = 75*Gamma /(2*pi)
                chi         = pi/4
                det         = {'138BaF':20e6, 'CaF':-38e6}[label]
                Isat        = system.levels.Isat.mean() # = pi*c*h*Gamma/(3*531e-9**3)
                I           = 3*Isat*(delta*2*pi/(Gamma/np.sqrt(3)))**2
            
                for s1 in [+1,-1]:
                    for s2 in [+1,-1]:
                        system.lasers.add(
                            lamb            = system.levels.wavelengths.loc[('X',0),(exAB,0)]*1e-9,
                            pol             = 'lin',
                            pol_direction   = 'z',
                            I               = I,#freq_Rabi=np.sqrt(3/2)*delta*2*pi,
                            freq_shift      = s2*delta+det,
                            k               = [0,0,s1*1],
                            phi             = -1*s1*s2*chi/2
                            )
            

.. GENERATED FROM PYTHON SOURCE LINES 60-62

Magnetic field
^^^^^^^^^^^^^^

.. GENERATED FROM PYTHON SOURCE LINES 62-69

.. code-block:: Python
   :dedent: 1


                system.Bfield.turnon(
                    strength    = {'138BaF' : 20e-4, 'CaF' : 33e-4}[label],
                    angle       = {'138BaF' : 60,    'CaF' : 63.5}[label],
                    direction   = np.array([0.,0.,1.]),
                    )
            

.. GENERATED FROM PYTHON SOURCE LINES 70-72

OBEs
^^^^

.. GENERATED FROM PYTHON SOURCE LINES 72-92

.. code-block:: Python
   :dedent: 1

                system.steadystate['t_ini'] = 2e-6
                system.steadystate['period'] = 'standingwave'
                system.steadystate['maxiters'] = 8
                system.steadystate['condition'] = [0.2,10]
                # system.multiprocessing['maxtasksperchild'] = None
                # system.multiprocessing['processes'] = 20
                system.multiprocessing['savetofile'] = True
            
                system.calc_OBEs(
                    t_int           = 4e-6,
                    dt              = 0.2e-9,
                    method          = 'RK45',
                    magn_remixing   = True,
                    verbose         = False,
                    steadystate     = True,
                    rounded         = False,
                    freq_clip_TH    = 1000,
                    )
        


.. GENERATED FROM PYTHON SOURCE LINES 93-95

Loading data and plotting
-------------------------

.. GENERATED FROM PYTHON SOURCE LINES 95-109

.. code-block:: Python
   :dedent: 1


        plt.figure()
    
        for label in ['138BaF','CaF']:
            system  = open_object(f'BCF_{label}')
            F       = system.results.vals['F']/system.hbarkG2
            v0      = system.v0[:,2]

            plt.plot(v0, F[:,2], label = label)
        
        plt.xlabel('Velocity $v$ (m/s)')
        plt.ylabel('Bichromatic force $F_{BCF}$ ($\hbar k \Gamma/2$)')
        plt.legend()
    

.. GENERATED FROM PYTHON SOURCE LINES 110-113

.. image:: /_figures/core/BCF_fig1.svg
   :alt: Demo plot
   :align: center


.. _sphx_glr_download_auto_examples_core_BCF.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

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

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

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: BCF.py <BCF.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: BCF.zip <BCF.zip>`


.. only:: html

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

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