DiPolMol-Py: A Python package for calculations for Σ 2 {}^{2}{\Sigma} ground-state molecules Journal: Computer Physics Communications Bethan Humphreys, Alex J. Matthies, Hannah J. Williams Abstract We present the python package DiPolMol-Py, which can be used to calculate the rotational and hyperfine structure of Σ 2 {}^{2}\Sigma molecules. The calculations can be performed in the presence of dc magnetic fields, dc electric fields and far off-resonant optical fields. We additionally include functions to calculate the polarisability of the molecule and the transition dipole moment between different energy eigenstates. The package is applicable to many of the molecules which can be laser cooled, specifically the alkaline earth fluorides. We provide a constants file which includes many of the required literature values for CaF, SrF and BaF. Additional species can easily be added by updating this file. PROGRAM SUMMARY Program Title: DiPolMol-Py CPC Library link to program files: (to be added by Technical Editor) Developer’s repository link: https://github.com/durham-qlm/DiPolMol Licensing provisions: BSD 3-clause Programming language: Python ≥ \geq 3.11 Nature of problem: Calculating the rotational and hyperfine structure for Σ 2 {}^{2}\Sigma ground state molecules both field free and in the presence of dc magnetic, electric and off-resonant light fields. Solution method: A Python package which calculates the eigenenergies and eigenvalues via diagonalisation of the Hamiltonian. Additional comments including restrictions and unusual features (approx. 50-250 words): This package is based on previous work for Σ 1 {}^{1}\Sigma molecules [1]. External magnetic and electric fields must be coaxial. Ultracold molecules offer many exciting opportunities from fundamental science to quantum technologies, made possible by their complex internal structure. Transitions between internal energy levels can be used as sensitive probes to search for variations in fundamental constants or beyond standard model physics, e.g. electrons electric dipole moment [ 1 , 2 , 3 , 4 ] , nuclear Schiff moment [ 5 ] , and electron-to-proton mass ratio [ 6 ] . The long-range, tuneable dipole-dipole interactions present between rotational levels allow for the entanglement of molecules [ 7 , 8 , 9 , 10 , 11 ] , which combined with long-coherence times [ 12 , 13 , 14 , 15 ] make molecules a promising platform for quantum computing and simulation [ 16 , 17 , 18 , 19 , 20 ] . The rotational level structure extends the capabilities of such platforms to include synthetic dimensions [ 21 , 22 ] or qudits [ 23 ] . With the ability to control internal and external degrees of freedom, cold molecules are also ideal for the study of cold, controlled chemistry [ 24 , 25 , 26 ] and collisions [ 27 , 28 , 29 ] . Direct laser cooling of molecules is one way of producing ultracold samples of molecules. It was first proposed in 2004 [ 30 ] , and since then the field has advanced rapidly. The first molecular magneto-optica trap (MOT) was demonstrated in 2014 using strontium monofluoride (SrF) [ 31 ] , with several further species being trapped since (CaF [ 32 , 33 ] , YO [ 34 ] , CaOH [ 35 ] , SrOH [ 36 ] , 138 BaF [ 37 ] ). Even more are being investigated currently (YbF [ 38 ] , 137 BaF [ 39 ] , CaH [ 40 ] , CaD [ 41 ] , MgF [ 42 ] , AlF [ 43 ] , TlF [ 44 ] , CH [ 45 ] ). Implementing any of the potential applications of molecules requires an accurate understanding of the internal energy level structure, both with and without the presence of external fields. A Python package diatom.py [ 46 ] was recently written to calculate the rotational and hyperfine structure of {}^{1}\Sigma molecules, applicable typically to associated, bialkali molecules. In this paper we present a complementary Python package DiPolMol.py which works for {}^{2}\Sigma molecules, and is thus applicable to many laser-coolable diatomic molecules. We provide most 1 1 1 Constants for SrF and BaF light shift and polarisability could not be found in literature. of the required constants to calculate the structure of CaF, SrF and BaF. As more species are investigated, and the required constants become known, these can be added to the programme. This could include associated molecules such as RbSr [ 47 ] , RbYb [ 48 ] , CsYb [ 49 ] or LiYb [ 50 ] which similarly have a {}^{2}\Sigma ground state. The remainder of this paper is structured as follows. Section (Theory) outlines the Hamiltonian used in the calculations; considering rotational and hyperfine structure as well as the effect of external magnetic and electric fields. Section (Package) outlines how the code is structured and how the user can perform calculations. Finally, section (Examples) demonstrates an application of the DiPolMol-Py package to CaF, SrF and BaF to calculate polarisability, Zeeman shifts, ac and dc electric field shifts and transition dipole moments between different rotational states. 1 Theory In this package we consider a molecule in the ground electronic and vibrational state. The total Hamiltonian describing such a molecule is H_{\rm tot}=H_{\rm rot}+H_{\rm hf}+H_{\rm ext}, (1) where H_{\rm rot} and H_{\rm hf} give the field-free rotational and hyperfine structure, respectively, and H_{\rm ext} describes the interaction with external electric, magnetic and off-resonant light fields. We give the Hamiltonian in Eqn. 1 using dimensionless operators for electron spin, \hat{\boldsymbol{S}} , nuclear spin, \hat{\boldsymbol{I}} and rotational angular momentum \hat{\boldsymbol{N}} . In the package we use the matrix representation of the Hamiltonian to calculate the associated energy shifts. The matrix representation for each Hamiltonian is presented in the Appendix. 1.1 Basis The electronic ground state for most molecules which are being pursued as candidates for laser cooling is {}^{2}\Sigma . The term symbol is given by {}^{2S+1}\Lambda , where S is the total electronic spin angular momentum and \Lambda is the projection of the total electronic orbital angular momentum L onto the internuclear axis. Values of \Lambda=0,1,2,... are represented by \Lambda=\Sigma,\Pi,\Delta,... Thus, molecules in {}^{2}\Sigma states have S=\frac{1}{2} and \Lambda=L=0 . Hund’s case (b) best describes this system whereby the rotational angular momentum R is first coupled to the electronic angular momentum L to make N=L+R . N is then coupled with electronic spin S to give the total angular momentum J=N+S . The coupling scheme is illustrated in figure 1 . Note that as we consider molecules in the {}^{2}\Sigma state, N only has a contribution from the rotational angular momentum, i.e., N=R . The total angular momentum J couples with the nuclear spin I , to give the hyperfine structure with F=J+I . The projection of the angular momentum F onto the internuclear axis is given by m_{F} . The natural state basis is thus the coupled regime |N,J,F,m_{F}\rangle . Figure 1: Illustration of Hund’s case (b) angular momentum couplings. The orbital angular momentum \mathbf{L} and the rotational angular momentum \mathbf{R} couple to form \mathbf{N} , which in turn couples to the spin angular momentum \mathbf{S} , forming \mathbf{J} . The projection of the orbital angular momentum onto the internuclear axis is given by \Lambda , as shown. 1.2 Rotational Hamiltonian The molecular rotation can be approximated by the rigid-rotor model, resulting in an array of rotational states spaced in energy according to E_{N}\approx B_{v}N(N+1) , where B_{v} is the rotational constant in vibrational level v . However, this approximation does not hold for large N. At faster rates of rotation there is an increase in the centrifugal force which causes the bond length to grow. This effect is captured by the centrifugal distortion coefficient D_{v} , which is typically six orders of magnitude smaller than B_{v} . The rotational Hamiltonian is [ 51 ] H_{\rm rot}=B_{v}(\hat{\boldsymbol{N}}\cdot\hat{\boldsymbol{N}})-D_{v}(\hat{\boldsymbol{N}}\cdot\hat{\boldsymbol{N}})^{2}. (2) 1.3 Hyperfine Hamiltonian In this package, we consider only those molecules where one of the constituent atoms has no nuclear spin, i.e., for a molecule AB I_{\rm A}=0 and I_{\rm AB}=I_{\rm B} . This is the case for molecules containing 40 Ca, 88 Sr or 138 Ba and covers the majority of molecules currently being investigated for laser cooling. The hyperfine Hamiltonian takes the form H_{\rm hf}=H_{\rm e~spin-rot}+H_{\rm spin-spin}+H_{\rm n~spin-rot}. (3) The first term describes the electronic spin-rotation interaction and is given by H_{\rm e~spin-rot}=\gamma\hat{\boldsymbol{S}}\cdot\hat{\boldsymbol{N}}, (4) where \gamma is the electron spin-rotational coupling constant. The second term describes the interaction between the electronic and nuclear magnetic moments and can be decomposed into a scalar and a tensor part. These are written as H_{\rm spin-spin}^{(0)}=(b+c/3)\hat{\boldsymbol{I}}\cdot\hat{\boldsymbol{S}}, (5) H_{\rm spin-spin}^{(2)}=(c/3)\sqrt{6}T^{2}(C)\cdot T^{2}(\hat{\boldsymbol{I}},\hat{\boldsymbol{S}}), (6) with spectroscopic constants b and c [ 52 ] . T^{2}(C) and T^{2}(\hat{\boldsymbol{I}},\hat{\boldsymbol{S}}) are rank-2 spherical tensors where (C) represents the renormalised spherical harmonics C_{q}^{2}(\theta,\phi) . The final term is the nuclear spin-rotation interaction, written as H_{\rm n~spin-rot}=c_{\rm F}\hat{\boldsymbol{I}}\cdot\hat{\boldsymbol{N}}. (7) The nuclear interaction is typically three orders of magnitude smaller than the others, with constant c_{\rm F} 2 2 2 Sometimes referred to as C . . 1.4 External Hamiltonian We next consider the interaction between the molecule and an external electromagnetic field. We introduce \boldsymbol{\lambda} as a unit vector along the internuclear axis in the direction from negative to positive charge (e.g., from the F to the Ca in CaF). The total external Hamiltonian can be expressed as the sum of three Hamiltonians which describe the effect of magnetic, electric and off-resonant optical fields. The total external Hamiltonian is therefore H_{\rm ext}=H_{\rm B}+H_{\rm dc}+H_{\rm ac}. (8) An external magnetic field \boldsymbol{B} leads to a splitting in energy levels described by the Zeeman Hamiltonian, which can be expressed as [ 51 ] \displaystyle H_{\rm B}=g_{\rm s}\mu_{\rm B}\hat{\boldsymbol{S}}\cdot\boldsymbol{B}+g_{\rm l}\mu_{\rm B}[\hat{\boldsymbol{S}}\cdot\boldsymbol{B}-(\hat{\boldsymbol{S}}\cdot\boldsymbol{\lambda})(\boldsymbol{B}\cdot\boldsymbol{\lambda})] \displaystyle-g_{\rm r}\mu_{\rm B}\hat{\boldsymbol{N}}\cdot\boldsymbol{B}-g_{\rm N}\mu_{\rm N}\hat{\boldsymbol{I}}\cdot\boldsymbol{B},~~~~~~~~ (9) where the first term is generally three orders of magnitude larger than the others. The four terms describe the contributions of the electron’s magnetic dipole moment, the anisotropic correction to this, the rotation of the electron, and the nuclear magnetic moment respectively. These terms are characterised by their associated g -factors g_{\rm s},g_{\rm l},g_{\rm r} and g_{\rm N} . The permanent electric dipole moment \mu_{\rm e} of a molecule couples to an external dc electric field \boldsymbol{E}_{\rm dc} . The Hamiltonian describing this interaction is H_{\rm dc}=-\mu_{\rm e}\boldsymbol{E}_{\rm dc}\cdot\boldsymbol{\lambda}. (10) Finally, we include the interactions between the molecule and a non-resonant light field. Here the dipole moment operator of the molecule \hat{\boldsymbol{d}} interacts with the ac electric field of the light \boldsymbol{E}_{\rm ac} . The associated Hamiltonian is written as H_{\rm ac}=-\hat{\boldsymbol{d}}\cdot\boldsymbol{E}_{\rm ac}. (11) When considering optical fields it is generally simplest to think about the intensity of the light, which is related to the square of the electric field. The intensity \mathcal{I} is given by \mathcal{I}=\frac{c\epsilon_{\rm{0}}}{2}{\left|\mathbf{E_{ac}}\right|}^{2}. (12) The size of the light shift depends on the polarisation of the light and the frequency-dependent polarisability of the molecule \alpha , which consists of a scalar, vector and tensor part \alpha_{k} , k={0,1,2} . The scalar polarisability leads to an equal shift of all levels, which can be expressed as U_{\rm{0}}=-\frac{\alpha_{0}}{2\epsilon_{\rm{0}}c}\mathcal{I}=-\alpha_{0}^{\prime}\mathcal{I}. (13) For simplicity we have introduced the reduced polarisability \alpha_{k}^{\prime}=\alpha_{k}/(2c\epsilon_{0}) . 2 Package The package contains two main notebooks. The first Hamiltonian , is used to build the Hamiltonians and the second Calculate uses eigenstates and eigenenergies found from diagonalising the Hamiltonian to run various calculations. We also include a file Constants which includes all of the required constants for CaF [ 53 , 54 , 55 ] , as well as the constants required to calculate the field-free, Zeeman and dc electric field effects for BaF [ 56 ] and SrF [ 54 , 57 , 58 ] . 2.1 Hamiltonian We construct the Hamiltonian as a 2d array of size d , d=(2I+1)\times(2S+1)\times\sum_{N=0}^{N_{\rm max}}(2N+1), (14) where N_{\rm max} is defined by the user as the maximum rotational level to be included in the calculation. A Hamiltonian is constucted using the build function, which takes N max (integer), Constants (dictionary) and Zeeman, dc, ac (Booleans) as parameters. The Constants term requires the importing of the chosen molecular species dictionary, e.g., ‘CaF’ from the constants file. The Zeeman, dc, ac must be set to either ‘True’ or ‘False’ depending on which external fields are needed for the calculation. If an external field value is zero, the time required for a calculation can be reduced by setting the associated Boolean to ‘False’. The full Hamiltonian can then be constructed by simply adding together H_{0}=H_{\rm rot}+H_{\rm hf} with the external Hamiltonians multiplied by their respective fields, i.e., magnetic field with H_{\rm B} , electric field with H_{\rm dc} and light intensity with H_{\rm ac} . An excerpt of code to calculate the Zeeman energies for SrF is given in the Examples section. 2.2 Calculate The calculate file contains a selection of functions which can be used to identify quantum numbers of eigenstates and calculate transition dipole moments and polarisabilities. 2.2.1 State identification The function np.linalg.eigh calculates the eigenstates and eigenenergies of the Hamiltonian and outputs these in order according to eigenenergy from lowest to highest. If two levels cross in energy, then this can lead to a misidentification of eigenstates. To overcome this we include the function sort_smooth [ 46 ] , which takes the arrays of eigenenergies and eigenstates calculated over a range of external field values as an input. Eigenstates are tracked by ensuring maximal overlap as the external field is changed, and the eigenenergies are reordered as appropriate to match. To assign the sorted eigenstates with appropriate F and m_{F} labels, the function label_FmF_states is provided within calculate . It takes the sorted set of eigenstates as an input, along with N max (integer), Constants (dictionary) and the magnetic field at which the eigenstates and eigenenergies are calculated, B (integer/float/list/array) 3 3 3 A non-zero B field must be applied to lift the Zeeman sublevel degeneracies , and returns the relevant (N,F,m_{F}) or (N,F) labels. We first generate a list of possible |N,J,F,m_{F}\rangle basis states, following the order these quantum numbers are cycled through when constructing the maxtrix representation of the Hamiltonian in the hamiltonian function. The i^{th} entry in a given eigenstate can therefore be assigned as the coefficient of the i^{th} basis state in this list. For each eigenstate, all basis states with negligible coefficients are removed. In the case when multiple basis states remain, these are checked to ensure consistency in F and m_{F} quantum numbers. If this condition is met, these values are returned as the F,m_{F} label for that eigenstate. In the case that m_{F} is not a good quantum number, only F labels will be output. For simplicity, the function solve is also provided, combining the functionality of np.linalg.eigh , sort_smooth and optionally, label_FmF_states . As inputs, this function requires H (np.array), the matrix representation of the Hamiltonian to solve, alongside N max (integer) and Constants (dictionary). (N,F,m_{F}) labels can also be generated by setting the argument label (Boolean) to True and providing an additional input, B (integer/float/list/array), the magnetic field value(s) at which the eigenstates and eigenenergies are to be calculated. Figure 2: Plot showing the effect on the accuracy of energy calculation for |N=0,F=0,m_{F}=0\rangle (blue circles) and the time to run calculation (green squares) as the maximum rotational level N_{\rm max} considered is increased, up to 8 for CaF. The calculation is done with \mathcal{I}=2.5\times 10^{9} W m -2 , E=50 kV m -1 and B=200 G. 2.2.2 Transition dipole moments A second function within calculate is transition_dipole_moment which calculates the transition dipole moment between two states. The function takes N max , Constants, M, states and gs as inputs. Here, gs is the chosen ground state, states are the other states being considered, and M is the helicity of the transition such that \texttt{M}=+1,0,-1 for \sigma^{+},\pi,\sigma^{-} transitions respectively. The function outputs the transition dipole moment in units of the molecule frame dipole moment d_{0} . The first step is to calculate the induced dipole moment operator \boldsymbol{\mu} , using function dipole , the matrix representation of which is the same as for the dc electric field effect. We then calculate the expectation value between a chosen ground state gs and every other state via matrix multiplication using np.einsum . 2.2.3 Polarisability We include a function alpha_012 which calculates the scalar ( \alpha^{\prime}_{0} ), vector ( \alpha^{\prime}_{1} ) and tensor ( \alpha^{\prime}_{2} ) components of the reduced molecular polarisability at a given wavelength. We make the assumption that only the lowest two electronic states i.e., A^{2}\Pi and B^{2}\Sigma^{+} contribute to the polarisability and don’t include higher lying states in the calculation [ 59 ] . The function takes the wavelength of the light and Constants as inputs and generates a list of \alpha_{k}^{\prime} for k=0,1,2 following the equations given in the Appendix. 2.3 Number of rotational states considered In order to accurately determine eigenenergies, it is important to include an appropriate number of rotational levels, especially when considering large electric fields which cause rotational mixing. However, increasing the number of levels, N_{\rm max} , included in the calculation also increases the size of the associated Hilbert space and hence the length of time required for a calculation. The dependence of the calculated eigenenergies on N_{\rm max} is shown in figure 2 . The blue circles show the change in the energy of the lowest energy state |N=0,F=0,m_{F}=0\rangle as N_{\rm max} is increased \Delta E=(E(N_{\rm max})-E(N_{\rm max}-1))/h . This is calculated for \mathcal{I}=2.5\times 10^{9} W m -2 , E=50 kV m -1 and B=200 G. Once N_{\rm max}\geq 4 the change in energy is less than 10^{-12} MHz with the inclusion of an additional rotational level. Also shown in figure 2 , as green squares, is the time taken to run these calculations on a laptop with 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40 GHz with 32 GB of RAM. To achieve the required accuracy with N_{\rm max}=4 , the calculation time is still reasonable at around 30 seconds. Figure 3: Plots showing (a) Zeeman effect for SrF molecules and (b) dc electric field shift for BaF molecules. The N=0 states are shown in the lower panels and N=1 states are shown in the upper panels. In each case only the plotted field is applied. The calculations include states up to N=4 . The line styles are set according to their F quantum number (labelled by the coloured number) and m_{F} levels are identified by the colour scale. 3 Examples This section includes an excerpt of the code used to build and diagonalise a Hamiltonian and example energy calculations. 3.1 Zeeman effect and dc electric field shift The first example considers the Zeeman effect for SrF. The Hamiltonian is constructed to use only the Zeeman contribution, the magnetic field values are defined and then applied to the Hamiltonian. The eigenstates, eigenenergies and state labels are then calculated using the calc.solve function. The code is as follows: ⬇ import hamiltonian as hamiltonian import calculate as calc from constants import SrF Nmax = 4 #Identify the maximum N H0 , H_B , H_dc , H_ac = hamiltonian . build ( Nmax , SrF , zeeman = True , Edc = False , Eac = False ) B = np . linspace ( 0 , 100 , 5000 ) * 1e - 4 #Tesla H = H_0 [ ..., None ] + H_B [ ..., None ] * B H = H . transpose ( 2 , 0 , 1 ) energies , states , label_list = calc . solve ( H , Nmax , SrF , label = True , B ) This code produces the data shown in figure 3 (a). The magnetic field is varied from 0 to 100 G in steps of 2 mG, with no electric or light fields present. The N=0 and N=1 rotational levels are shown in separate panels as the rotational splitting is \approx 15 GHz. In both panels, the splitting of the different m_{F} states can be clearly seen. Similarly, the dc electric field shifts can be calculated by slightly adjusting the above code. Namely, changing the arguments passed to build such that zeeman=False, Edc=True , as well as replacing H_B with H_dc in the definition of the variable H . The results of this calculation for BaF are shown in figure 3 (b). Here, the electric field is varied from 0 to 250 kV m -1 in steps of 150 V m -1 , with no magnetic or light field present. Again, the results are separated into two panels according to rotational number. Comparing these panels to those in figure 3 (a), it can be seen that the dc electric field does not lift the degeneracy between all m_{F} states. Figure 4: (a) Calculated polarisabilities for CaF in the ground electronic and vibrational state, X(v=0) . The scalar component ( \alpha^{\prime}_{0} ) is shown in the solid green line, the vector component ( \alpha^{\prime}_{1} ) in the dashed grey line and the tensor component ( \alpha^{\prime}_{2} ) in the dash-dotted blue line. (b) ac light shift for CaF in the N=1,m_{s}=-1/2 levels. Calculations are performed with a magnetic field of B=300 G, and for linearly polarised 780 nm light at an angle \beta to the B field and an intensity of \mathcal{I}=30 GW m -2 . The states are labeled by the m_{\rm N} and m_{\rm I} quantum numbers. Zero energy is defined to be the energy of the lowest energy state at \beta=0^{\circ} 3.2 Polarisability and light shift The effect of off-resonant light is becoming increasingly important to understand as molecules are regularly being loaded into conservative optical traps, such as optical dipole traps and tweezers [ 60 , 8 ] . To compute the light shift, we need the values of the polarisability components \alpha_{k}^{{}^{\prime}} , which can either be set in the constants file or calculated using the polarisability function for a given wavelength. Figure 4 (a) shows the three polarisability components calculated for CaF, using the polarisability function over a wavelength range of \lambda=500 nm to \lambda=820 nm. Additionally, the light shift can be calculated similarly to the Zeeman and dc electric field shifts by modifying the build function. Figure 4 (b) shows an example for CaF molecules. The calculations were done using linearly polarised light field of wavelength 780 nm, intensity 30 GW m -2 with a magnetic field of 300 G and no electric field. We plot the energy shift against the angle ( \beta ) between the polarisation of the light and the applied magnetic field from 0 to 90 ∘ relative to the lowest energy state at \beta=0 . Here we identify the levels by m_{N} and m_{I} . Figure 5: Table showing the transition dipole moments in units of molecular dipole between some N=1 states, shown in columns and all N=0,2 states, shown in rows for CaF. Labels are in the form (N,F,m_{F}) . The relative intensity of each transition is given by the cell value, and highlighted by the colour, with darker colours indicating stronger transitions. Red, green and blue are chosen to represent coupling fields with polarisations that drive \sigma^{+},\pi and \sigma^{-} transitions respectively. 3.3 Transition Dipole Moments Rotational transitions in molecules can readily be driven by microwave fields. To understand the strength of these transitions one needs to calculate the transition dipole moment (TDM), which can be done using the function transition_dipole_moment . Figure 5 shows the TDM from a selection of N=1 states ( |1,1,-1\rangle,|1,0,0\rangle,|1,1,1\rangle,|1,2,-2\rangle and |1,2,2\rangle ) to all states in rotational levels N=0,2 of CaF. Transitions from N=1 are considered as this is the state occupied following laser slowing. The strength of each transition is given in the cell, and highlighted by the colour. The red, green and blue sequential colour maps indicate the relative strengths for \sigma^{+},\pi and \sigma^{-} transitions respectively. The calculations were done in the presence of an magnetic field of 60 mG. 4 Conclusion We have written a Python package to construct the Hamiltonian and calculate eigenenergies and eigenstates of {}^{2}\Sigma state of molecules in the presence of external fields. The package is of particular relevance to molecules which can be laser cooled and we have provided constants for CaF, SrF and BaF molecules. As more molecular species are investigated, further constants can be added. Future iterations of the package could also be made to include an angle variable for magnetic and electric fields. 5 Code Availability and Installation The DiPolMol-Py files are available to download from the github repository [ 61 ] . 6