Commit 38606496 authored by Nicolas Nunez Barreto's avatar Nicolas Nunez Barreto

diferencias con b vs k

parents d80cf312 9bb069aa
...@@ -12,7 +12,7 @@ import numpy as np ...@@ -12,7 +12,7 @@ import numpy as np
import time import time
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from scipy.signal import argrelextrema from scipy.signal import argrelextrema
from EITfit.MM_eightLevel_2repumps_python_scripts import CPTspectrum8levels #from EITfit.MM_eightLevel_2repumps_python_scripts import CPTspectrum8levels
import random import random
from scipy.signal import savgol_filter as sf from scipy.signal import savgol_filter as sf
......
...@@ -89,7 +89,7 @@ def LtempCalculus(beta, drivefreq, forma=1): ...@@ -89,7 +89,7 @@ def LtempCalculus(beta, drivefreq, forma=1):
ampg=beta*drivefreq ampg=beta*drivefreq
ampr=beta*drivefreq*(397/866) ampr=beta*drivefreq*(397/866)
#print('fixed') print('fixed')
Hint[0,0] = ampg Hint[0,0] = ampg
Hint[1,1] = ampg Hint[1,1] = ampg
Hint[4,4] = ampr Hint[4,4] = ampr
......
...@@ -110,7 +110,7 @@ plt.errorbar([2*f*1e-6 for f in Freqs_merged], Counts_merged, yerr=np.sqrt(np.ar ...@@ -110,7 +110,7 @@ plt.errorbar([2*f*1e-6 for f in Freqs_merged], Counts_merged, yerr=np.sqrt(np.ar
#%% #%%
#from EITfit.MM_eightLevel_2repumps_AnalysisFunctions import PerformExperiment_8levels_MM, GenerateNoisyCPT_MM_fit from EITfit.MM_eightLevel_2repumps_AnalysisFunctions import PerformExperiment_8levels_MM, GenerateNoisyCPT_MM_fit
from scipy.optimize import curve_fit from scipy.optimize import curve_fit
""" """
......
...@@ -6,6 +6,9 @@ Created on Thu Jul 2 16:30:09 2020 ...@@ -6,6 +6,9 @@ Created on Thu Jul 2 16:30:09 2020
@author: oem @author: oem
""" """
"""
ESTE ES EL CODIGO QUE PLOTEA CPT CON MICROMOCION BIEN
"""
import os import os
import numpy as np import numpy as np
......
...@@ -6,6 +6,10 @@ Created on Tue Apr 7 22:30:01 2020 ...@@ -6,6 +6,10 @@ Created on Tue Apr 7 22:30:01 2020
@author: nico @author: nico
""" """
"""
ESTE ES EL CODIGO QUE PLOTEA CPT CON MICROMOCION BIEN
"""
#ESTE CODIGO ES EL PRINCIPAL PARA PLOTEAR CPT TEORICOS #ESTE CODIGO ES EL PRINCIPAL PARA PLOTEAR CPT TEORICOS
import numpy as np import numpy as np
import time import time
...@@ -90,7 +94,6 @@ def LtempCalculus(beta, drivefreq, forma=1): ...@@ -90,7 +94,6 @@ def LtempCalculus(beta, drivefreq, forma=1):
ampg=beta*drivefreq ampg=beta*drivefreq
ampr=beta*drivefreq*(397/866) ampr=beta*drivefreq*(397/866)
#ampr=beta*drivefreq #ampr=beta*drivefreq
Hint[0,0] = ampg Hint[0,0] = ampg
Hint[1,1] = ampg Hint[1,1] = ampg
Hint[4,4] = ampr Hint[4,4] = ampr
...@@ -228,9 +231,13 @@ def dopplerBroadening(wlg, wlp, alpha, T, mcalcio = 6.655e-23*1e-3): ...@@ -228,9 +231,13 @@ def dopplerBroadening(wlg, wlp, alpha, T, mcalcio = 6.655e-23*1e-3):
que forman ambos láseres. que forman ambos láseres.
""" """
kboltzmann = 1.38e-23 #J/K kboltzmann = 1.380649e-23 #J/K
gammaD = (2*np.pi)*np.sqrt((1/(wlg*wlg)) + (1/(wlp*wlp)) - 2*(1/(wlg*wlp))*np.cos(alpha))*np.sqrt(kboltzmann*T/(2*mcalcio)) gammaD = 2*np.pi*np.sqrt((1/(wlg*wlg)) + (1/(wlp*wlp)) - 2*(1/(wlg*wlp))*np.cos(alpha))*np.sqrt(kboltzmann*T/(mcalcio))
#gammaD = 2*np.sqrt((1/(wlg*wlg)) + (1/(wlp*wlp)) - 2*(1/(wlg*wlp))*np.cos(alpha))*np.sqrt(kboltzmann*T/(1*mcalcio))
#print('tuk')
return gammaD return gammaD
...@@ -245,9 +252,9 @@ def FullL_MM(rabG, rabP, gPS = 0, gPD = 0, Detg = 0, Detp = 0, u = 0, lwg = 0, l ...@@ -245,9 +252,9 @@ def FullL_MM(rabG, rabP, gPS = 0, gPD = 0, Detg = 0, Detp = 0, u = 0, lwg = 0, l
db = dopplerBroadening(0.397e-6, 0.866e-6, alpha, T) db = dopplerBroadening(0.397e-6, 0.866e-6, alpha, T)
lwg = np.sqrt(lwg**2 + db**2) lwg = np.sqrt(lwg**2 + (0.83*db)**2)
lwp = np.sqrt(lwp**2 + db**2) lwp = np.sqrt(lwp**2 + (0.17*db)**2)
CC = EffectiveL(gPS, gPD, lwg, lwp) CC = EffectiveL(gPS, gPD, lwg, lwp)
...@@ -283,7 +290,7 @@ def FullL_MM(rabG, rabP, gPS = 0, gPD = 0, Detg = 0, Detp = 0, u = 0, lwg = 0, l ...@@ -283,7 +290,7 @@ def FullL_MM(rabG, rabP, gPS = 0, gPD = 0, Detg = 0, Detp = 0, u = 0, lwg = 0, l
L0 = np.array(np.matrix(Lfullpartial) + M) L0 = np.array(np.matrix(Lfullpartial) + M)
#ESTA PARTE ES CUANDO AGREGAS MICROMOCION #ESTA PARTE ES CUANDO AGREGAS MICROMOCION
nmax = 3 nmax = 5
#print(nmax) #print(nmax)
Ltemp, Omega = LtempCalculus(beta, drivefreq) Ltemp, Omega = LtempCalculus(beta, drivefreq)
...@@ -324,7 +331,7 @@ def CPTspectrum8levels_MM(sg, sp, gPS, gPD, Detg, u, lwg, lwp, Temp, alpha, phid ...@@ -324,7 +331,7 @@ def CPTspectrum8levels_MM(sg, sp, gPS, gPD, Detg, u, lwg, lwp, Temp, alpha, phid
DetProbeVector = 2*np.pi*np.arange(freqMin*1e6, freqMax*1e6+0*freqStep*1e6, freqStep*1e6) DetProbeVector = 2*np.pi*np.arange(freqMin*1e6, freqMax*1e6+0*freqStep*1e6, freqStep*1e6)
Detg = 2*np.pi*Detg*1e6 Detg = 2*np.pi*Detg*1e6
#lwg, lwr, lwp = 2*np.pi*lwg*1e6, 2*np.pi*lwr*1e6, 2*np.pi*lwp*1e6 #lwg, lwr, lwp = 2*np.pi*lwg*1e6, 2*np.pi*lwr*1e6, 2*np.pi*lwp*1e6
lwg, lwp = lwg*1e6, lwp*1e6 lwg, lwp = 2*np.pi*lwg*1e6, 2*np.pi*lwp*1e6
rabG = sg*gPS rabG = sg*gPS
rabP = sp*gPD rabP = sp*gPD
......
...@@ -110,7 +110,7 @@ plt.xlabel('Frecuencia (MHz)') ...@@ -110,7 +110,7 @@ plt.xlabel('Frecuencia (MHz)')
plt.ylabel('counts') plt.ylabel('counts')
plt.grid() plt.grid()
plt.legend() plt.legend()
plt.savefig('Ejemplo_CPT_temperaturas_distintas.png')
#%% #%%
from EITfit.threeLevel_2repumps_AnalysisFunctions import CalculoTeoricoDarkResonances_8levels, GetMinimaInfo, GetPlotsofFluovsAngle_8levels, PerformExperiment_8levels, FindDRFrequencies, FindRelativeFluorescencesOfDR, GenerateNoisyCPT, SmoothNoisyCPT, GetFinalMaps, GenerateNoisyCPT_fixedRabi, GenerateNoisyCPT_fit from EITfit.threeLevel_2repumps_AnalysisFunctions import CalculoTeoricoDarkResonances_8levels, GetMinimaInfo, GetPlotsofFluovsAngle_8levels, PerformExperiment_8levels, FindDRFrequencies, FindRelativeFluorescencesOfDR, GenerateNoisyCPT, SmoothNoisyCPT, GetFinalMaps, GenerateNoisyCPT_fixedRabi, GenerateNoisyCPT_fit
from EITfit.threeLevel_2repumps_AnalysisFunctions import MeasureRelativeFluorescenceFromCPT, IdentifyPolarizationCoincidences, RetrieveAbsoluteCoincidencesBetweenMaps, GetClosestIndex from EITfit.threeLevel_2repumps_AnalysisFunctions import MeasureRelativeFluorescenceFromCPT, IdentifyPolarizationCoincidences, RetrieveAbsoluteCoincidencesBetweenMaps, GetClosestIndex
......
...@@ -17,20 +17,82 @@ from MM_eightLevel_2repumps_python_scripts import CPTspectrum8levels,CPTspectrum ...@@ -17,20 +17,82 @@ from MM_eightLevel_2repumps_python_scripts import CPTspectrum8levels,CPTspectrum
from scipy.optimize import curve_fit from scipy.optimize import curve_fit
import random import random
from scipy.signal import savgol_filter as sf from scipy.signal import savgol_filter as sf
from scipy.stats import norm
def prob_energia(E,T):
kboltz = 1.380649e-23
mcalcio = 6.655e-23*1e-3
prob = np.exp(-E/(kboltz*T)) #*E**2
return prob
def PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, beta, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=None):
def PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, betag, betap, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=None, dephasing = False, boltzmann = False):
""" """
solvemode=1: resuelve con np.linalg.solve solvemode=1: resuelve con np.linalg.solve
solvemode=2: resuelve invirtiendo L con la funcion np.linalg.inv solvemode=2: resuelve invirtiendo L con la funcion np.linalg.inv
""" """
tinicial = time.time() kboltz = 1.380649e-23
ProbeDetuningVectorL, Fluovector = CPTspectrum8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, circularityprobe, beta, drivefreq, freqMin=freqMin, freqMax=freqMax, freqStep=freqStep, plot=False, solvemode=1) m = 6.6551079e-26
tfinal = time.time() kg = np.pi * 2/397 *1e9
kp = np.pi * 2/866 *1e9
if detpvec is None:
detpvec = np.arange(freqMin,freqMax,freqStep)
if boltzmann == True:
FluorescencesVel = []
sigmaT = np.sqrt(kboltz*T/m)
velvec = np.linspace(-4*sigmaT,4*sigmaT,100)
MBprobVec = norm.pdf(velvec,loc = 0, scale = sigmaT)
MBprobVec = MBprobVec/np.trapz(MBprobVec,velvec)
for i in range(len(velvec)):
detVel = detpvec - kp*velvec[i]/(2*np.pi*1e6)
_, Fluorescence = CPTspectrum8levels( sg, sp, gPS, gPD, DetDoppler-kg*velvec[i]/(2*np.pi*1e6),u, DopplerLaserLinewidth, ProbeLaserLinewidth, 0,alpha, phidoppler, titadoppler, phiprobe, titaprobe,circularityprobe, betag, betap, drivefreq, freqMin=freqMin, freqMax=freqMax, freqStep=freqStep, plot=False,detpvec=detVel)
FluorescencesVel.append(Fluorescence)
FluorescencesVel = np.array(FluorescencesVel)
MBprobMat = np.tile(MBprobVec,(FluorescencesVel.shape[1],1)).T
Fluorescence = np.trapz(FluorescencesVel*MBprobMat,velvec,axis = 0)
ProbeDetuningVectorL = np.arange(freqMin,freqMax,freqStep)
elif dephasing == True:
tinicial = time.time()
ProbeDetuningVectorL, Fluorescence = CPTspectrum8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, circularityprobe, betag, betap, drivefreq, freqMin=freqMin, freqMax=freqMax, freqStep=freqStep, detpvec = detpvec, plot=False, solvemode=1)
tfinal = time.time()
else:
drivefreq =2*np.pi* 0.6e6
FluorescencesVel = []
sigmaT = np.sqrt(T*kboltz/m)
velvec = np.linspace(-4*sigmaT,4*sigmaT,100)
MBprobVec = norm.pdf(velvec,loc = 0, scale = sigmaT)
Evec = np.linspace(0,8*kboltz*T,100)
velvec = np.zeros(2*len(Evec))
velvec= np.sqrt(2 * Evec/m)
MBprobVec = prob_energia(Evec, T)
MBprobVec = MBprobVec/np.trapz(MBprobVec,Evec)
betagVec = velvec*kg/drivefreq
betapVec = velvec*kp/drivefreq
for i in range(len(betagVec)):
betag,betap = betagVec[i],betapVec[i]
Frequencies, Fluorescence = CPTspectrum8levels( sg, sp, gPS, gPD, DetDoppler,u, DopplerLaserLinewidth, ProbeLaserLinewidth, 0,alpha, phidoppler, titadoppler, phiprobe, titaprobe,circularityprobe, betag, betap, drivefreq, freqMin=freqMin, freqMax=freqMax, freqStep=freqStep, plot=False,detpvec=detpvec)
FluorescencesVel.append(Fluorescence)
FluorescencesVel = np.array(FluorescencesVel)
MBprobMat = np.tile(MBprobVec,(FluorescencesVel.shape[1],1)).T
Fluorescence = np.trapz(FluorescencesVel*MBprobMat,Evec,axis = 0)
ProbeDetuningVectorL = Frequencies
#print('Done, Total time: ', round((tfinal-tinicial), 2), "s") #print('Done, Total time: ', round((tfinal-tinicial), 2), "s")
return ProbeDetuningVectorL, Fluovector return ProbeDetuningVectorL, Fluorescence
def PerformExperiment_8levels_vel(velvect,titavect,phivect,velprob,sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, beta, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=None): def PerformExperiment_8levels_vel(velvect,titavect,phivect,velprob,sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, beta, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=None):
""" """
...@@ -63,15 +125,25 @@ def SmoothNoisyCPT(Fluo, window=11, poly=3): ...@@ -63,15 +125,25 @@ def SmoothNoisyCPT(Fluo, window=11, poly=3):
def fitCPT_8levels_db(Freq,Fluo,sg,sp,gPS,gPD,DetDoppler,u,DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe,beta, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False): def fitCPT_8levels(Freq,Fluo,sg,sp,gPS,gPD,DetDoppler,u,DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe,betag,betar, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False,dephasing = False, boltzmann = False ):
def SpectrumForFit(Freq,sg,sp,T,DetDoppler): def SpectrumForFit(Freq,sg,sp,T,DetDoppler,A,bgnd,f0):
freq,spectra = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, beta, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=None) Freq = Freq - f0
return spectra freq,spectra = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, betag,betar, drivefreq, freqMin, freqMax, freqStep,circularityprobe=1, plot=False, detpvec=Freq, dephasing = dephasing, boltzmann = boltzmann)
return spectra*A + bgnd
popt,pcov = curve_fit(SpectrumForFit,Freq,Fluo,p0 = [sg,sp,T,DetDoppler],bounds = ([0.01,0.01,0.00001,-50e6],[1,20,1,30e6])) popt,pcov = curve_fit(SpectrumForFit,Freq,Fluo,p0 = [sg,sp,T,DetDoppler,20000,800,432],bounds = ([0.1,1,0.5e-3,-30,10000,0,420],[0.8,10,10e-3,0,100000,1000,500]))
fitted_spectra = SpectrumForFit(Freq,*popt) fitted_spectra = SpectrumForFit(Freq,*popt)
return Freq, fitted_spectra,popt,pcov return Freq, fitted_spectra,popt,pcov
def try_fitCPT_8levels(A,bgnd,f0,Freq,Fluo,sg,sp,gPS,gPD,DetDoppler,u,DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe,betag,betar, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False,dephasing = False, boltzmann = False ):
def SpectrumForFit(Freq,sg,sp,T,DetDoppler,A,bgnd,f0):
Freq = Freq - f0
freq,spectra = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, betag,betar, drivefreq, freqMin, freqMax, freqStep,circularityprobe=1, plot=False, detpvec=Freq, dephasing = dephasing, boltzmann = boltzmann)
return spectra*A + bgnd
return SpectrumForFit(Freq, sg, sp, T, DetDoppler, A, bgnd, f0)
\ No newline at end of file
...@@ -105,12 +105,12 @@ def HImatrix(rabG, rabP, phidoppler, titadoppler, phiprobe, titaprobe, circulari ...@@ -105,12 +105,12 @@ def HImatrix(rabG, rabP, phidoppler, titadoppler, phiprobe, titaprobe, circulari
return HI return HI
def LtempCalculus(beta, drivefreq, forma=1): def LtempCalculus(betag,betap, drivefreq, forma=1):
Hint = np.zeros((8, 8), dtype=np.complex_) Hint = np.zeros((8, 8), dtype=np.complex_)
ampg=beta*drivefreq ampg=betag*drivefreq
ampr=beta*drivefreq ampr=betap*drivefreq
Hint[0,0] = ampg Hint[0,0] = ampg
Hint[1,1] = ampg Hint[1,1] = ampg
Hint[4,4] = ampr Hint[4,4] = ampr
...@@ -250,13 +250,13 @@ def dopplerBroadening(wlg, wlp, alpha, T, mcalcio = 6.655e-23*1e-3): ...@@ -250,13 +250,13 @@ def dopplerBroadening(wlg, wlp, alpha, T, mcalcio = 6.655e-23*1e-3):
kboltzmann = 1.38e-23 #J/K kboltzmann = 1.38e-23 #J/K
gammaD = (2*np.pi)*np.sqrt((1/(wlg*wlg)) + (1/(wlp*wlp)) - 2*(1/(wlg*wlp))*np.cos(alpha))*np.sqrt(kboltzmann*T/(2*mcalcio)) gammaD = (2*np.pi)*np.sqrt((1/(wlg*wlg)) + (1/(wlp*wlp)) - 2*(1/(wlg*wlp))*np.cos(alpha))*np.sqrt(kboltzmann*T/(mcalcio))
return gammaD return gammaD
def FullL(rabG, rabP, gPS = 0, gPD = 0, Detg = 0, Detp = 0, u = 0, lwg = 0, lwp = 0, def FullL(rabG, rabP, gPS = 0, gPD = 0, Detg = 0, Detp = 0, u = 0, lwg = 0, lwp = 0,
phidoppler=0, titadoppler=0, phiprobe=0, titaprobe=0, beta=0, drivefreq=2*np.pi*22.135*1e6, T = 0, alpha = 0, circularityprobe=1): phidoppler=0, titadoppler=0, phiprobe=0, titaprobe=0, betag=0,betap = 0, drivefreq=2*np.pi*22.135*1e6, T = 0, alpha = 0, circularityprobe=1):
""" """
Calcula el Liouvilliano total de manera explícita índice a índice. Suma aparte las componentes de las matrices M. Calcula el Liouvilliano total de manera explícita índice a índice. Suma aparte las componentes de las matrices M.
...@@ -264,11 +264,17 @@ def FullL(rabG, rabP, gPS = 0, gPD = 0, Detg = 0, Detp = 0, u = 0, lwg = 0, lwp ...@@ -264,11 +264,17 @@ def FullL(rabG, rabP, gPS = 0, gPD = 0, Detg = 0, Detp = 0, u = 0, lwg = 0, lwp
""" """
db = dopplerBroadening(0.397e-6, 0.866e-6, alpha, T) kg = 397e9
kp = 866e9
fg = kg**2/(kg**2+kp**2)
fp = kp**2/(kg**2+kp**2)
lwg = np.sqrt(lwg**2 + (db/2)**2)/2 db = dopplerBroadening(0.397e-6, 0.866e-6, alpha, T)
lwp = np.sqrt(lwp**2 + (db/2)**2)/2
lwg = np.sqrt(lwg**2 + (fg*db)**2)
lwp = np.sqrt(lwp**2 + (fp*db)**2)
...@@ -306,15 +312,18 @@ def FullL(rabG, rabP, gPS = 0, gPD = 0, Detg = 0, Detp = 0, u = 0, lwg = 0, lwp ...@@ -306,15 +312,18 @@ def FullL(rabG, rabP, gPS = 0, gPD = 0, Detg = 0, Detp = 0, u = 0, lwg = 0, lwp
M = CalculateSingleMmatrix(gPS, gPD, lwg, lwp) M = CalculateSingleMmatrix(gPS, gPD, lwg, lwp)
L0 = np.array(np.matrix(Lfullpartial) + M) L0 = np.array(np.matrix(Lfullpartial) + M)
#ESTA PARTE ES CUANDO AGREGAS MICROMOCION
nmax = 7
#print(nmax)
Ltemp, Omega = LtempCalculus(beta, drivefreq)
#print(factor)
L1 = GetL1(Ltemp, L0, Omega, nmax)
Lfull = L0 + L1 #ESA CORRECCION ESTA EN L1
#HASTA ACA
if betag !=0 and betap !=0:
#ESTA PARTE ES CUANDO AGREGAS MICROMOCION
nmax = 2*int(betag)
#print(nmax)
Ltemp, Omega = LtempCalculus(betag,betap, drivefreq)
#print(factor)
L1 = GetL1(Ltemp, L0, Omega, nmax)
Lfull = L0 + L1 #ESA CORRECCION ESTA EN L1
#HASTA ACA
else:
Lfull = L0
#NORMALIZACION DE RHO #NORMALIZACION DE RHO
i = 0 i = 0
while i < 64: while i < 64:
...@@ -334,8 +343,6 @@ def FullLvel(vel,tita,phi,rabG, rabP, gPS = 0, gPD = 0, Detg = 0, Detp = 0, u = ...@@ -334,8 +343,6 @@ def FullLvel(vel,tita,phi,rabG, rabP, gPS = 0, gPD = 0, Detg = 0, Detp = 0, u =
Calcula el Liouvilliano total de manera explícita índice a índice. Suma aparte las componentes de las matrices M. Calcula el Liouvilliano total de manera explícita índice a índice. Suma aparte las componentes de las matrices M.
Es la más eficiente hasta ahora. Es la más eficiente hasta ahora.
""" """
db = dopplerBroadening(0.397e-6, 0.866e-6, alpha, T) db = dopplerBroadening(0.397e-6, 0.866e-6, alpha, T)
...@@ -406,7 +413,7 @@ Scripts para correr un experimento y hacer el análisis de los datos ...@@ -406,7 +413,7 @@ Scripts para correr un experimento y hacer el análisis de los datos
""" """
def CPTspectrum8levels(sg, sp, gPS, gPD, Detg, u, lwg, lwp, Temp, alpha, phidoppler, titadoppler, phiprobe, titaprobe, Circularityprobe, beta, drivefreq, freqMin=-100, freqMax=100, freqStep=1e-1, detpvec = None,plot=False, solvemode=1): def CPTspectrum8levels(sg, sp, gPS, gPD, Detg, u, lwg, lwp, Temp, alpha, phidoppler, titadoppler, phiprobe, titaprobe, Circularityprobe, betag,betap, drivefreq, freqMin=-100, freqMax=100, freqStep=1e-1, detpvec = None,plot=False, solvemode=1):
""" """
ESTA ES LA FUNCION QUE ESTAMOS USANDO ESTA ES LA FUNCION QUE ESTAMOS USANDO
...@@ -418,12 +425,16 @@ def CPTspectrum8levels(sg, sp, gPS, gPD, Detg, u, lwg, lwp, Temp, alpha, phidopp ...@@ -418,12 +425,16 @@ def CPTspectrum8levels(sg, sp, gPS, gPD, Detg, u, lwg, lwp, Temp, alpha, phidopp
phidoppler, titadoppler = phidoppler*(np.pi/180), titadoppler*(np.pi/180) phidoppler, titadoppler = phidoppler*(np.pi/180), titadoppler*(np.pi/180)
phiprobe, titaprobe = phiprobe*(np.pi/180), titaprobe*(np.pi/180) phiprobe, titaprobe = phiprobe*(np.pi/180), titaprobe*(np.pi/180)
if detpvec == None: if detpvec is None:
DetProbeVector = 2*np.pi*np.arange(freqMin*1e6, freqMax*1e6, freqStep*1e6) DetProbeVector = 2*np.pi*np.arange(freqMin*1e6, freqMax*1e6, freqStep*1e6)
else: else:
DetProbeVector = detpvec*1e6 * 2*np.pi DetProbeVector = detpvec*1e6 * 2*np.pi
Detg = 2*np.pi*Detg*1e6 Detg = 2*np.pi*Detg*1e6
#lwg, lwr, lwp = 2*np.pi*lwg*1e6, 2*np.pi*lwr*1e6, 2*np.pi*lwp*1e6 #lwg, lwr, lwp = 2*np.pi*lwg*1e6, 2*np.pi*lwr*1e6, 2*np.pi*lwp*1e6
lwg, lwp = lwg*1e6, lwp*1e6 lwg, lwp = lwg*1e6, lwp*1e6
...@@ -440,7 +451,7 @@ def CPTspectrum8levels(sg, sp, gPS, gPD, Detg, u, lwg, lwp, Temp, alpha, phidopp ...@@ -440,7 +451,7 @@ def CPTspectrum8levels(sg, sp, gPS, gPD, Detg, u, lwg, lwp, Temp, alpha, phidopp
for Detp in DetProbeVector: for Detp in DetProbeVector:
L = FullL(rabG, rabP, gPS, gPD, Detg, Detp, u, lwg, lwp, phidoppler, titadoppler, phiprobe, titaprobe, beta, drivefreq, Temp, alpha, Circularityprobe) L = FullL(rabG, rabP, gPS, gPD, Detg, Detp, u, lwg, lwp, phidoppler, titadoppler, phiprobe, titaprobe, betag,betap, drivefreq, Temp, alpha, Circularityprobe)
if solvemode == 1: if solvemode == 1:
rhovectorized = np.linalg.solve(L, np.array([int(i==0) for i in range(64)])) rhovectorized = np.linalg.solve(L, np.array([int(i==0) for i in range(64)]))
...@@ -464,7 +475,7 @@ def CPTspectrum8levels(sg, sp, gPS, gPD, Detg, u, lwg, lwp, Temp, alpha, phidopp ...@@ -464,7 +475,7 @@ def CPTspectrum8levels(sg, sp, gPS, gPD, Detg, u, lwg, lwp, Temp, alpha, phidopp
plt.plot(DetProbeVectorMHz, [100*f for f in Fluovector], label=str(titaprobe) + 'º, T: ' + str(Temp*1e3) + ' mK') plt.plot(DetProbeVectorMHz, [100*f for f in Fluovector], label=str(titaprobe) + 'º, T: ' + str(Temp*1e3) + ' mK')
plt.legend() plt.legend()
return DetProbeVectorMHz, Fluovector return DetProbeVectorMHz, np.array(Fluovector)
def CPTspectrum8levels_vel(velvect,titavec,phivec,probvel,sg, sp, gPS, gPD, Detg, u, lwg, lwp, Temp, alpha, phidoppler, titadoppler, phiprobe, titaprobe, Circularityprobe, beta, drivefreq, freqMin=-100, freqMax=100, freqStep=1e-1, plot=False, solvemode=1): def CPTspectrum8levels_vel(velvect,titavec,phivec,probvel,sg, sp, gPS, gPD, Detg, u, lwg, lwp, Temp, alpha, phidoppler, titadoppler, phiprobe, titaprobe, Circularityprobe, beta, drivefreq, freqMin=-100, freqMax=100, freqStep=1e-1, plot=False, solvemode=1):
...@@ -614,7 +625,7 @@ def CPTspectrum8levels_vel(velvect,titavec,phivec,probvel,sg, sp, gPS, gPD, Detg ...@@ -614,7 +625,7 @@ def CPTspectrum8levels_vel(velvect,titavec,phivec,probvel,sg, sp, gPS, gPD, Detg
plt.plot(DetProbeVectorMHz, [100*f for f in Fluovector], label=str(titaprobe) + 'º, T: ' + str(Temp*1e3) + ' mK') plt.plot(DetProbeVectorMHz, [100*f for f in Fluovector], label=str(titaprobe) + 'º, T: ' + str(Temp*1e3) + ' mK')
plt.legend() plt.legend()
return DetProbeVectorMHz, Fluovector return DetProbeVectorMHz, np.array(Fluovector)
if __name__ == "__main__": if __name__ == "__main__":
......
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 2 16:30:09 2020
@author: oem
"""
"""
ESTE ES EL CODIGO QUE PLOTEA CPT CON MICROMOCION BIEN
"""
import os
import numpy as np
import time
import matplotlib.pyplot as plt
from scipy.signal import argrelextrema
#from EITfit.MM_eightLevel_2repumps_python_scripts import CPTspectrum8levels_MM
import random
from scipy.signal import savgol_filter as sf
def PerformExperiment_8levels_MM(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, beta, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=None):
"""
solvemode=1: resuelve con np.linalg.solve
solvemode=2: resuelve invirtiendo L con la funcion np.linalg.inv
"""
#tinicial = time.time()
ProbeDetuningVectorL, Fluovector = CPTspectrum8levels_MM(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, circularityprobe, beta, drivefreq, freqMin=freqMin, freqMax=freqMax, freqStep=freqStep, plot=False, solvemode=1)
#tfinal = time.time()
#print('Done, Total time: ', round((tfinal-tinicial), 2), "s")
return ProbeDetuningVectorL, Fluovector
def GenerateNoisyCPT_MM(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobeVec, kg, kr, v0, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=None, noiseamplitude=0.001):
Frequencyvector, Fluovector = PerformExperiment_8levels_MM(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobeVec, kg, kr, v0, drivefreq, freqMin, freqMax, freqStep, circularityprobe, plot=False, solvemode=1, detpvec=None)
NoisyFluovector = [fluo+noiseamplitude*(2*random.random()-1) for fluo in Fluovector]
return Frequencyvector, NoisyFluovector
def GenerateNoisyCPT_MM_fit(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobeVec, beta, drivefreq, freqs, circularityprobe=1, plot=False, solvemode=1, detpvec=None, noiseamplitude=0.001):
Frequencyvector, Fluovector = PerformExperiment_8levels_MM(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobeVec, beta, drivefreq, freqs[0], freqs[-1], freqs[1]-freqs[0], circularityprobe, plot=False, solvemode=1, detpvec=None)
#NoisyFluovector = [fluo+noiseamplitude*(2*random.random()-1) for fluo in Fluovector]
return Frequencyvector, Fluovector
def SmoothNoisyCPT(Fluo, window=11, poly=3):
SmoothenFluo = sf(Fluo, window, poly)
return SmoothenFluo
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 1 17:58:39 2020
@author: nico
"""
import os
import numpy as np
#os.chdir('/home/oem/Nextcloud/G_liaf/liaf-TrampaAnular/Código General/EIT-CPT/Buenos Aires/Experiment Simulations/CPT scripts/Eight Level 2 repumps')
#from MM_eightLevel_2repumps_AnalysisFunctions import PerformExperiment_8levels, GenerateNoisyCPT, SmoothNoisyCPT
import matplotlib.pyplot as plt
import time
#from threeLevel_2repumps_AnalysisFunctions import MeasureRelativeFluorescenceFromCPT, IdentifyPolarizationCoincidences, RetrieveAbsoluteCoincidencesBetweenMaps, GetClosestIndex
import seaborn as sns
#C:\Users\Usuario\Nextcloud\G_liaf\liaf-TrampaAnular\Código General\EIT-CPT\Buenos Aires\Experiment Simulations\CPT scripts\Eight Level 2 repumps
ub = 9.27e-24 #magneton de bohr
h = 6.63e-34 #cte de planck
c = (ub/h)*1e-4 #en unidades de MHz/G
u = 2e6 #proportional to the magnetic field of around 5 G
B = (u/(2*np.pi))/c
gPS, gPD, = 2*np.pi*21.58e6, 2*np.pi*1.35e6 #anchos de linea de las transiciones
lw = 0. #linewidth of the lasers, 0.1 MHz are the actual linewidths of both lasers
DopplerLaserLinewidth, ProbeLaserLinewidth = lw, lw #ancho de linea de los laseres
TempVec = [0e-3] #Temperature vector
alpha = 0 #angle between lasers, which is zero
#Polarization angles (we can keep it fixed in 90)
phidoppler, titadoppler = 0, 90
titaprobe = 90
phiprobe = 0
#este es el desfasaje exp(i.phi) de la componente de la polarizacion y respecto a la x. Con 1 la polarizacion es lineal
CircPr = 1 #this has to do with the circularity of the polarizations and since both are linear it is one
#Simulation parameters
center = -10
span = 200
freqMin = center-span*0.5
freqMax = center+span*0.5
freqStep = 2e-1
noiseamplitude = 0 #i dont know what it is
#parametros de saturacion de los laseres. g: doppler. p: probe (un rebombeo que scanea), r: repump (otro rebombeo fijo)
"""
Good case: sg=0.6, sp=9, DetDoppler=-15
"""
DetDoppler = -25 #nice range: -30 to 0
sgvec = [0.6] #nice range: 0.1 to 10 #g is for green but is the doppler
sp = 8 #nice range: 0.1 to 20 #p is for probe but is the repump
drivefreq=2*np.pi*22.135*1e6 #ignore it
#betavec = np.arange(0,1.1,0.1) #ignore it
betavec=[0] #ignore it
alphavec = [0] #ignore it
fig1, ax1 = plt.subplots()
FrequenciesVec = []
FluorescencesVec = []
for sg in sgvec:
for T in TempVec:
for alpha in alphavec:
for beta in betavec:
Frequencies, Fluorescence = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, beta, drivefreq, freqMin, freqMax, freqStep, circularityprobe=CircPr, plot=False, solvemode=1, detpvec=None)
FrequenciesVec.append(Frequencies)
FluorescencesVec.append(Fluorescence)
ax1.plot(Frequencies, [100*f for f in Fluorescence], label=fr'$\alpha={int(alpha*180/np.pi)}°$')
ax1.set_xlabel('Detuning Rebombeo (MHz)')
ax1.set_ylabel('Fluorescencia (AU)')
ax1.set_title(f'Sdop: {sg}, Spr: {sp}, Temp: {int(T*1e3)} mK')
#ax1.legend()
ax1.grid()
#%%
import seaborn as sns
paleta=sns.color_palette('mako')
plt.figure()
plt.plot(Frequencies, [100*f for f in Fluorescence], color=paleta[1], linewidth=3)
plt.grid()
plt.axvline(-25,color=paleta[2], linestyle='dashed')
plt.xlabel(r'$\Delta_2$ (MHz)', fontsize=25, fontname='STIXgeneral')
plt.ylabel('Fluorescence', fontsize=18, fontname='STIXgeneral')
#%%
#Este bloque ajusta a las curvas con un beta de micromocion de 0
from scipy.optimize import curve_fit
def FitEIT_MM(freqs, Temp):
BETA = 0
scale=1
offset=0
Detunings, Fluorescence = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, Temp, alpha, phidoppler, titadoppler, phiprobe, titaprobe, BETA, drivefreq, freqMin, freqMax, freqStep, circularityprobe=CircPr, plot=False, solvemode=1, detpvec=None)
ScaledFluo = [f*scale + offset for f in Fluorescence]
return ScaledFluo
TempMedidas = []
FittedEIT_fluosVec = []
for j in range(len(betavec)):
SelectedFluo = FluorescencesVec[j]
SelectedFreqs = FrequenciesVec[j]
popt_mm, pcov_mm = curve_fit(FitEIT_MM, SelectedFreqs, SelectedFluo, p0=[1e-3], bounds=((0), (10e-3)))
TempMedidas.append(1e3*popt_mm[2])
print(popt_mm)
FittedEIT_fluo = FitEIT_MM(SelectedFreqs, *popt_mm)
FittedEIT_fluosVec.append(FittedEIT_fluo)
plt.figure()
plt.plot(SelectedFreqs, SelectedFluo, 'o')
plt.plot(SelectedFreqs, FittedEIT_fluo)
plt.figure()
for i in range(len(FluorescencesVec)):
plt.plot(SelectedFreqs, FluorescencesVec[i], 'o', markersize=3)
plt.plot(SelectedFreqs, FittedEIT_fluosVec[i])
plt.figure()
plt.plot(betavec, TempMedidas, 'o', markersize=10)
plt.xlabel('Beta')
plt.ylabel('Temperatura medida (mK)')
plt.axhline(T*1e3, label='Temperatura real', linestyle='--', color='red')
plt.legend()
plt.grid()
\ No newline at end of file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 1 17:58:39 2020
@author: oem
"""
import os
import numpy as np
#os.chdir('/home/oem/Nextcloud/G_liaf/liaf-TrampaAnular/Código General/EIT-CPT/Buenos Aires/Experiment Simulations/CPT scripts/Eight Level 2 repumps')
from threeLevel_2repumps_AnalysisFunctions import CalculoTeoricoDarkResonances_8levels, GetMinimaInfo, GetPlotsofFluovsAngle_8levels, PerformExperiment_8levels, FindDRFrequencies, FindRelativeFluorescencesOfDR, GenerateNoisyCPT, SmoothNoisyCPT, GetFinalMaps, GenerateNoisyCPT_fixedRabi, GenerateNoisyCPT_fit
import matplotlib.pyplot as plt
import time
from threeLevel_2repumps_AnalysisFunctions import MeasureRelativeFluorescenceFromCPT, IdentifyPolarizationCoincidences, RetrieveAbsoluteCoincidencesBetweenMaps, GetClosestIndex
#C:\Users\Usuario\Nextcloud\G_liaf\liaf-TrampaAnular\Código General\EIT-CPT\Buenos Aires\Experiment Simulations\CPT scripts\Eight Level 2 repumps
ub = 9.27e-24
h = 6.63e-34
c = (ub/h)*1e-4 #en unidades de MHz/G
#u = 1e6
u = 33.5e6
B = (u/(2*np.pi))/c
#sg, sp = 0.6, 5 #parámetros de control, saturación del doppler y repump
#rabG, rabP = sg*gPS, sp*gPD #frecuencias de rabi
gPS, gPD, = 2*np.pi*21.58e6, 2*np.pi*1.35e6 #anchos de linea de las transiciones
lw = 0.1
DopplerLaserLinewidth, RepumpLaserLinewidth, ProbeLaserLinewidth = lw, lw, lw #ancho de linea de los laseres
DetDoppler = -36 #42
DetRepumpVec = [DetDoppler+29.6]
Tvec = [0.7] #temperatura en mK
alpha = 0*(np.pi/180) #angulo entre los láseres
phidoppler, titadoppler = 0, 90
phirepump, titarepump = 0, 0
phiprobe = 0
titaprobe = 90
#Calculo las resonancias oscuras teóricas
#ResonanciasTeoricas, DRPositivas = CalculoTeoricoDarkResonances_8levels(u/(2*np.pi*1e6), titadoppler, DetDoppler, DetRepump)
#Parametros de la simulacion cpt
center = -45
span = 80
freqMin = center-span*0.5
freqMax = center+span*0.5
""" parametros para tener espectros coherentes
freqMin = -56
freqMax = 14
"""
freqStep = 1e-1
noiseamplitude = 0
RelMinMedido0Vector = []
RelMinMedido1Vector = []
RelMinMedido2Vector = []
RelMinMedido3Vector = []
RelMinMedido4Vector = []
#Sr = np.arange(0, 10, 0.2)
#Sg = np.arange(0.01, 1, 0.05)
#Sp = np.arange(0.1, 6.1, 1)
#Sg = [0.6**2]
#Sp = [2.3**2]
Sg = [1.4]
Sp = [6]
Sr = [11]
i = 0
save = False
showFigures = True
if not showFigures:
plt.ioff()
else:
plt.ion()
fig1, ax1 = plt.subplots()
offsetx = 464
ax1.plot([f-offsetx for f in FreqsDR], CountsDR, 'o')
run = True
Scale = 730
Offset = 600 #600 para 20k cuentas aprox
MaxCoherenceValue = []
for sg in Sg:
for sp in Sp:
rabG, rabP = sg*gPS, sp*gPD
for Ti in Tvec:
T = Ti*1e-3
for DetRepump in DetRepumpVec:
print(T)
for sr in Sr:
rabR = sr*gPD
#MeasuredFreq, MeasuredFluo = GenerateNoisyCPT(rabG, rabR, rabP, gPS, gPD, DetDoppler, DetRepump, u, DopplerLaserLinewidth, RepumpLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, [titaprobe], phirepump, titarepump, freqMin, freqMax, freqStep, plot=False, solvemode=1, detpvec=None, noiseamplitude=noiseamplitude)
if run:
MeasuredFreq4, MeasuredFluo4 = GenerateNoisyCPT_fixedRabi(sg, sr, sp, gPS, gPD, DetDoppler, DetRepump, u, DopplerLaserLinewidth, RepumpLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, [titaprobe], phirepump, titarepump, freqMin, freqMax, freqStep, plot=False, solvemode=1, detpvec=None, noiseamplitude=noiseamplitude)
#SmoothFluo = SmoothNoisyCPT(MeasuredFluo, window=9, poly=2)
SmoothFluo4 = MeasuredFluo4
#Scale = max(BestC)/max([100*s for s in SmoothFluo4])
ax1.plot(MeasuredFreq4, [Scale*100*f + Offset for f in SmoothFluo4], label=f'Sr = {sr}')
ax1.axvline(DetDoppler, linestyle='--', linewidth=1)
#if sr != 0:
#ax1.axvline(DetRepump, linestyle='--', linewidth=1)
MaxCoherenceValue.append(np.max(SmoothFluo4))
#print(titaprobe)
ax1.set_xlabel('Detuning Rebombeo (MHz)')
ax1.set_ylabel('Fluorescencia (AU)')
ax1.set_title(f'B: {round(B, 2)} G, Sdop: {round(sg, 2)}, Sp: {round(sp, 2)}, Sr: {round(sr, 2)}, lw: {lw} MHz, T: {Ti} mK')
#ax1.set_ylim(0, 8)
#ax1.axvline(DetDoppler, linestyle='dashed', color='red', linewidth=1)
#ax1.axvline(DetRepump, linestyle='dashed', color='black', linewidth=1)
#ax1.set_title('Pol Doppler y Repump: Sigma+ Sigma-, Pol Probe: PI')
#ax1.legend()
ax1.grid()
print (f'{i+1}/{len(Sg)*len(Sp)}')
i = i + 1
if save:
plt.savefig(f'Mapa_plots_100k_1mk/CPT_SMSM_sdop{round(sg, 2)}_sp{round(sp, 2)}_sr{round(sr, 2)}.jpg')
ax1.legend()
"""
plt.figure()
plt.plot(Sr, MaxCoherenceValue, 'o')
plt.xlabel('Sr')
plt.ylabel('Coherence')
"""
"""
plt.figure()
plt.plot(MeasuredFreq, [100*f for f in SmoothFluo], color='darkred')
plt.xlabel('Desintonía 866 (MHz)')
plt.ylabel('Fluorescencia (A.U.)')
plt.axvline(-30, color='darkblue', linewidth=1.2, linestyle='--')
plt.yticks(np.arange(0.4, 1.8, 0.2))
plt.ylim(0.5, 1.6)
plt.grid()
plt.figure()
plt.plot(MeasuredFreq4, [100*f for f in SmoothFluo4], color='darkred')
plt.xlabel('Desintonía 866 (MHz)')
plt.ylabel('Fluorescencia (A.U.)')
plt.axvline(-30, color='darkblue', linewidth=1.2, linestyle='--')
plt.yticks(np.arange(0.8, 2.4, 0.4))
plt.grid()
"""
#%%
from scipy.optimize import curve_fit
T = 0.5e-3
sg = 0.7
sp = 6
sr = 0
DetDoppler = -14
DetRepump = 0
FitsSp = []
FitsOffset = []
Sg = [0.87]
def FitEIT(freqs, SP, offset):
MeasuredFreq, MeasuredFluo = GenerateNoisyCPT_fit(0.87, sr, SP, gPS, gPD, DetDoppler, DetRepump, u, DopplerLaserLinewidth, RepumpLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, [titaprobe], phirepump, titarepump, freqs, plot=False, solvemode=1, detpvec=None, noiseamplitude=noiseamplitude)
FinalFluo = [f*43000 + 2685 for f in MeasuredFluo]
return FinalFluo
freqs = [f-offsetx+32 for f in FreqsDR]
freqslong = np.arange(min(freqs), max(freqs)+freqs[1]-freqs[0], 0.1*(freqs[1]-freqs[0]))
popt, pcov = curve_fit(FitEIT, freqs, CountsDR, p0=[5, 700], bounds=(0, [10, 1e6]))
FitsSp.append(popt[0])
FitsOffset.append(popt[1])
print(popt)
FittedEIT = FitEIT(freqslong, *popt)
plt.figure()
plt.errorbar(freqs, CountsDR, yerr=2*np.sqrt(CountsDR), fmt='o', capsize=2, markersize=2)
plt.plot(freqslong, FitEIT(freqslong, *popt))
plt.title(f'Sdop: {round(popt[0], 2)}, Spr: {round(popt[1], 2)}, T: {T*1e3} mK, detDop: {DetDoppler} MHz')
np.savetxt('CPT_measured.txt', np.transpose([freqs, CountsDR]))
np.savetxt('CPT_fitted.txt', np.transpose([freqslong, FittedEIT]))
This diff is collapsed.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jul 2 16:30:09 2020
@author: oem
"""
"""
ESTE ES EL CODIGO QUE PLOTEA CPT CON MICROMOCION BIEN
"""
import os
import numpy as np
import time
import matplotlib.pyplot as plt
from scipy.signal import argrelextrema
#from EITfit.MM_eightLevel_2repumps_python_scripts import CPTspectrum8levels_MM
import random
from scipy.signal import savgol_filter as sf
def PerformExperiment_8levels_MM(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, beta, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=None):
"""
solvemode=1: resuelve con np.linalg.solve
solvemode=2: resuelve invirtiendo L con la funcion np.linalg.inv
"""
#tinicial = time.time()
ProbeDetuningVectorL, Fluovector = CPTspectrum8levels_MM(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, circularityprobe, beta, drivefreq, freqMin=freqMin, freqMax=freqMax, freqStep=freqStep, plot=False, solvemode=1)
#tfinal = time.time()
#print('Done, Total time: ', round((tfinal-tinicial), 2), "s")
return ProbeDetuningVectorL, Fluovector
def GenerateNoisyCPT_MM(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobeVec, kg, kr, v0, drivefreq, freqMin, freqMax, freqStep, circularityprobe=1, plot=False, solvemode=1, detpvec=None, noiseamplitude=0.001):
Frequencyvector, Fluovector = PerformExperiment_8levels_MM(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobeVec, kg, kr, v0, drivefreq, freqMin, freqMax, freqStep, circularityprobe, plot=False, solvemode=1, detpvec=None)
NoisyFluovector = [fluo+noiseamplitude*(2*random.random()-1) for fluo in Fluovector]
return Frequencyvector, NoisyFluovector
def GenerateNoisyCPT_MM_fit(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobeVec, beta, drivefreq, freqs, circularityprobe=1, plot=False, solvemode=1, detpvec=None, noiseamplitude=0.001):
Frequencyvector, Fluovector = PerformExperiment_8levels_MM(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobeVec, beta, drivefreq, freqs[0], freqs[-1], freqs[1]-freqs[0], circularityprobe, plot=False, solvemode=1, detpvec=None)
#NoisyFluovector = [fluo+noiseamplitude*(2*random.random()-1) for fluo in Fluovector]
return Frequencyvector, Fluovector
def SmoothNoisyCPT(Fluo, window=11, poly=3):
SmoothenFluo = sf(Fluo, window, poly)
return SmoothenFluo
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Sep 1 17:58:39 2020
@author: nico
"""
import os
import numpy as np
#os.chdir('/home/oem/Nextcloud/G_liaf/liaf-TrampaAnular/Código General/EIT-CPT/Buenos Aires/Experiment Simulations/CPT scripts/Eight Level 2 repumps')
#from MM_eightLevel_2repumps_AnalysisFunctions import PerformExperiment_8levels, GenerateNoisyCPT, SmoothNoisyCPT
import matplotlib.pyplot as plt
import time
#from threeLevel_2repumps_AnalysisFunctions import MeasureRelativeFluorescenceFromCPT, IdentifyPolarizationCoincidences, RetrieveAbsoluteCoincidencesBetweenMaps, GetClosestIndex
import seaborn as sns
#C:\Users\Usuario\Nextcloud\G_liaf\liaf-TrampaAnular\Código General\EIT-CPT\Buenos Aires\Experiment Simulations\CPT scripts\Eight Level 2 repumps
ub = 9.27e-24 #magneton de bohr
h = 6.63e-34 #cte de planck
c = (ub/h)*1e-4 #en unidades de MHz/G
u = 2e6 #proportional to the magnetic field of around 5 G
B = (u/(2*np.pi))/c
gPS, gPD, = 2*np.pi*21.58e6, 2*np.pi*1.35e6 #anchos de linea de las transiciones
lw = 0. #linewidth of the lasers, 0.1 MHz are the actual linewidths of both lasers
DopplerLaserLinewidth, ProbeLaserLinewidth = lw, lw #ancho de linea de los laseres
TempVec = [0e-3] #Temperature vector
alpha = 0 #angle between lasers, which is zero
#Polarization angles (we can keep it fixed in 90)
phidoppler, titadoppler = 0, 90
titaprobe = 90
phiprobe = 0
#este es el desfasaje exp(i.phi) de la componente de la polarizacion y respecto a la x. Con 1 la polarizacion es lineal
CircPr = 1 #this has to do with the circularity of the polarizations and since both are linear it is one
#Simulation parameters
center = -10
span = 200
freqMin = center-span*0.5
freqMax = center+span*0.5
freqStep = 2e-1
noiseamplitude = 0 #i dont know what it is
#parametros de saturacion de los laseres. g: doppler. p: probe (un rebombeo que scanea), r: repump (otro rebombeo fijo)
"""
Good case: sg=0.6, sp=9, DetDoppler=-15
"""
DetDoppler = -25 #nice range: -30 to 0
sgvec = [0.6] #nice range: 0.1 to 10 #g is for green but is the doppler
sp = 8 #nice range: 0.1 to 20 #p is for probe but is the repump
drivefreq=2*np.pi*22.135*1e6 #ignore it
#betavec = np.arange(0,1.1,0.1) #ignore it
betavec=[0] #ignore it
alphavec = [0] #ignore it
fig1, ax1 = plt.subplots()
FrequenciesVec = []
FluorescencesVec = []
for sg in sgvec:
for T in TempVec:
for alpha in alphavec:
for beta in betavec:
Frequencies, Fluorescence = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, T, alpha, phidoppler, titadoppler, phiprobe, titaprobe, beta, drivefreq, freqMin, freqMax, freqStep, circularityprobe=CircPr, plot=False, solvemode=1, detpvec=None)
FrequenciesVec.append(Frequencies)
FluorescencesVec.append(Fluorescence)
ax1.plot(Frequencies, [100*f for f in Fluorescence], label=fr'$\alpha={int(alpha*180/np.pi)}°$')
ax1.set_xlabel('Detuning Rebombeo (MHz)')
ax1.set_ylabel('Fluorescencia (AU)')
ax1.set_title(f'Sdop: {sg}, Spr: {sp}, Temp: {int(T*1e3)} mK')
#ax1.legend()
ax1.grid()
#%%
import seaborn as sns
paleta=sns.color_palette('mako')
plt.figure()
plt.plot(Frequencies, [100*f for f in Fluorescence], color=paleta[1], linewidth=3)
plt.grid()
plt.axvline(-25,color=paleta[2], linestyle='dashed')
plt.xlabel(r'$\Delta_2$ (MHz)', fontsize=25, fontname='STIXgeneral')
plt.ylabel('Fluorescence', fontsize=18, fontname='STIXgeneral')
#%%
#Este bloque ajusta a las curvas con un beta de micromocion de 0
from scipy.optimize import curve_fit
def FitEIT_MM(freqs, Temp):
BETA = 0
scale=1
offset=0
Detunings, Fluorescence = PerformExperiment_8levels(sg, sp, gPS, gPD, DetDoppler, u, DopplerLaserLinewidth, ProbeLaserLinewidth, Temp, alpha, phidoppler, titadoppler, phiprobe, titaprobe, BETA, drivefreq, freqMin, freqMax, freqStep, circularityprobe=CircPr, plot=False, solvemode=1, detpvec=None)
ScaledFluo = [f*scale + offset for f in Fluorescence]
return ScaledFluo
TempMedidas = []
FittedEIT_fluosVec = []
for j in range(len(betavec)):
SelectedFluo = FluorescencesVec[j]
SelectedFreqs = FrequenciesVec[j]
popt_mm, pcov_mm = curve_fit(FitEIT_MM, SelectedFreqs, SelectedFluo, p0=[1e-3], bounds=((0), (10e-3)))
TempMedidas.append(1e3*popt_mm[2])
print(popt_mm)
FittedEIT_fluo = FitEIT_MM(SelectedFreqs, *popt_mm)
FittedEIT_fluosVec.append(FittedEIT_fluo)
plt.figure()
plt.plot(SelectedFreqs, SelectedFluo, 'o')
plt.plot(SelectedFreqs, FittedEIT_fluo)
plt.figure()
for i in range(len(FluorescencesVec)):
plt.plot(SelectedFreqs, FluorescencesVec[i], 'o', markersize=3)
plt.plot(SelectedFreqs, FittedEIT_fluosVec[i])
plt.figure()
plt.plot(betavec, TempMedidas, 'o', markersize=10)
plt.xlabel('Beta')
plt.ylabel('Temperatura medida (mK)')
plt.axhline(T*1e3, label='Temperatura real', linestyle='--', color='red')
plt.legend()
plt.grid()
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment