前面输入以及提取部分同前两个代码相同,带入后面的计算函数。
计算函数:
calc = PairStateInteractions(atom, n0, l, j, n0, l, j, j1, j2)
calc.getC6perturbatively (角度(弧度制).,0,5,3.000000e+10)
import sys, os
from arc import *
from arc.web_functionality import *
def transitTime (beam_waist,mean_speed):
# in s
beam_fwhm = beam_waist / 0.8493218
return sqrt(pi)*beam_fwhm/(2.*mean_speed)
import re
# 输入字符串
input_str = input("请输入: ")
#Rb 82 D_{3/2} 3/2 3/2 C6
# 定义匹配模式
pattern = r"([A-Za-z]+) (\d+) ([A-Za-z]+)_{(\d+)/(\d+)} (\d+)/(\d+) (\d+)/(\d+) C6"
# 使用 re.search 匹配模式
match = re.search(pattern, input_str)
if match:
# 提取匹配的信息
element = match.group(1)
n0 = int(match.group(2))
l = match.group(3)
j = float(match.group(4))/float(match.group(5))
j1 = float(match.group(6))/float(match.group(7))
j2 = float(match.group(8))/float(match.group(9))
# 打印提取的信息
print("Element:", element)
print("N0:", n0)
print("L:", l)
print("J:", j)
print("J1:", j1)
print("J2:", j2)
if element=='Cs':
atom = Caesium()
else:
atom = Rubidium()
# 判断子能级字母并转换为相应的数值
if l == "S":
l = 0
elif l == "P":
l = 1
elif l == "D":
l = 2
elif l == "F":
l = 3
l = int(l)
j = float(j)
j1 = float(j1)
j2 = float(j2)
else:
print("No match found.")
if __name__ == '__main__':
#calculation = PairStateInteractions(Rubidium(), n0, l0, j0, n0, l0, j0, mj0, mj0)
calc = PairStateInteractions(atom, n0, l, j, n0, l, j, j1, j2)
#C6 = calculation.getC6perturbatively(theta, phi, dn, deltaMax)
print('c6(0) = ',calc.getC6perturbatively(0,0,5,3.000000e+10),'GHz (mu m)^6')
print('c6(30) = ', calc.getC6perturbatively(pi/6.,0,5,3.000000e+10),'GHz (mu m)^6')
print('c6(45) = ', calc.getC6perturbatively(pi/4.,0,5,3.000000e+10),'GHz (mu m)^6')
print('c6(60) = ', calc.getC6perturbatively(pi/3.,0,5,3.000000e+10),'GHz (mu m)^6')
print('c6(90) = ', calc.getC6perturbatively(pi/2.,0,5,3.000000e+10),'GHz (mu m)^6')