def b_vec_fun_no_a(b_vec,binval,delmval,p): bval=b_vec[0]+1j*b_vec[1] Omega=p['Omega'] rho=np.array(rho_broad_full(0,bval, 0,delmval,p)) p['Omega']=0 rho_no_pump=np.array(rho_broad_full(0,bval, 0,delmval,p)) p['Omega']=Omega #S12val=rho[1,0]*p['Nm']*p['gm'] S12val=rho[2,1]*p['No']*p['gm']+rho_no_pump[2,1]*(p['Nm']-p['No'])*p['gm'] bval1=(-1j*S12val+np.sqrt(p['gammamc'])*binval)/((p['gammamc']+p['gammami'])/2-1j*delmval) return [bval1.real, bval1.imag]-b_vec
def S12_4(Bval,bval,delmval,p): p['No']=p['No_total'] p['Nm']=p['Nm_total'] omegaao=omegaao4_from_I(B_val,p) p['sd_delao']=sd_delao4_from_I(B_val,p) p['mean_delao']=deltaao_from_I(B_val,omegaao,p) p['mean_delam']=deltamac_from_I(B_val,p) p['nbath']=nbath_from_T(T,p,p['mean_delam']) p['Omega']= Omega_from_PdBm(P_pump,p) rho=np.array(rho_broad_full(0,bval, 0,delmval, p)) p['Omega']=0 rho_no_pump=np.array(rho_broad_full(0,bval, 0,delmval, p)) return rho[2,1]*p['No']*p['gm']+rho_no_pump[2,1]*(p['Nm']-p['No'])*p['gm']
def S12_2(Bval,bval,delmval,p): p['No']=p['No_total']/(np.exp(B_val*p['Gg']*6.63e-34/(1.38e-23*T))-1) p['Nm']=p['Nm_total']/(np.exp(B_val*p['Gg']*6.63e-34/(1.38e-23*T))-1) omegaao=omegaao2_from_I(B_val,p) p['sd_delao']=sd_delao2_from_I(B_val,p) p['mean_delao']=deltaao_from_I(B_val,omegaao,p) p['mean_delam']=deltamac_from_I(B_val,p) p['nbath']=nbath_from_T(T,p,p['mean_delam']) p['Omega']= Omega_from_PdBm(P_pump,p) rho=np.array(rho_broad_full(0,bval, 0,delmval, p)) p['Omega']=0 rho_no_pump=np.array(rho_broad_full(0,bval, 0,delmval, p)) return rho[2,1]*p['No']*p['gm']+rho_no_pump[2,1]*(p['Nm']-p['No'])*p['gm']
def b_vec_fun_no_a(b_vec, binval, delmval, p): bval = b_vec[0] + 1j * b_vec[1] rho = np.array(rho_broad_full(0, bval, 0, delmval, p)) #S12val=rho[1,0]*p['Nm']*p['gm'] S12val = rho[1, 0] * p['No'] * p['gm'] bval1 = (-1j * S12val + np.sqrt(p['gammamc']) * binval) / ( (p['gammamc'] + p['gammami']) / 2 - 1j * delmval) return [bval1.real, bval1.imag] - b_vec
elif ii==0: #start_guess_vec_bout=[boutvals[ii,jj-1].real,boutvals[ii,jj-1].imag] start_guess_vec_b=[bvals[0,jj-1].real,bvals[0,jj-1].imag] #start_guess_vec_b2=[bvals2[ii,jj-1].real,bvals2[ii,jj-1].imag,avals[ii,jj-1].real,avals[ii,jj-1].imag] elif jj==0: start_guess_vec_b=[bvals[ii-1,0].real,bvals[ii-1,0].imag] else: start_guess_complex_b=(bvals[ii,jj-1]+bvals[ii-1,jj])/2 start_guess_vec_b=[start_guess_complex_b.real,start_guess_complex_b.imag] # for pkey in p: # print(pkey +' = '+str(type(p[pkey]))) #print(type(binval)) #print(type(deltamval)) bvals[ii,jj] = find_b_no_a(binval,deltamval,p,start_guess_vec_b) rho_out[:,:,ii,jj]=rho_broad_full(0,bvals[ii,jj],0,deltamval,p) calc_time[ii,jj]=time.time()-time1 elapsed_time=time.time()-start_time print(' ' + filename + ': '+ str(ii) +', Time: ' + time.ctime() +', Elapsed: '+ str(elapsed_time)) np.savez(filename,binvals=binvals,B_vals=B_vals,deltamvals=deltamvals,p=p,bvals=bvals,rho_out=rho_out,P_pump=P_pump,P_mu=P_mu,T=T,elapsed_time=elapsed_time,avals=avals,calc_time=calc_time)#,deltaoval=deltaoval) print(' ===========================Complete===========================') boutvals=bvals*np.sqrt(p['gammamc']) aoutvals=avals*np.sqrt(p['gammaoc']) rho13_background=10.0**(-22) rho13=rho_out[0,2,:,:] rho_abs2=np.abs(rho13**2) rho_abs2[rho_abs2<rho13_background]=rho13_background
else: start_guess_complex_b=(bvals[ii,jj-1]+bvals[ii-1,jj])/2 start_guess_vec_b=[start_guess_complex_b.real,start_guess_complex_b.imag] #start_guess_vec_b=[0,0] bvals[ii,jj]=find_b_4_3lvl(binval,deltamval,B_val,p,start_guess_vec_b) #rho_out_b[:,:,ii,jj]=S12_2(B_val,bvals[ii,jj],deltamval,p)#+S12_2(B_val,bvals[ii,jj],deltamval,p)+S12_3(B_val,bvals[ii,jj],deltamval,p)+S12_4(B_val,bvals[ii,jj],deltamval,p) p['No']=p['No_total']/(np.exp(B_val*p['Gg']*6.63e-34/(1.38e-23*T))-1) p['Nm']=p['Nm_total']/(np.exp(B_val*p['Gg']*6.63e-34/(1.38e-23*T))-1) omegaao=omegaao1_from_I(B_val,p) p['sd_delao']=sd_delao1_from_I(B_val,p) p['mean_delao']=deltaao_from_I(B_val,omegaao,p) p['mean_delam']=deltamac_from_I(B_val,p) p['nbath']=nbath_from_T(T,p,deltamacval=p['mean_delam']) p['Omega']= Omega_from_PdBm(P_pump,p) #bvals[ii,jj]=find_b_no_a(binval,deltamval,p,start_guess_vec_b) rho_out_b[:,:,ii,jj]=np.array(rho_broad_full(0,bvals[ii,jj], 0,deltamval, p))*p['No_total']/(np.exp(B_val*p['Gg']*6.63e-34/(1.38e-23*T))-1) p['No']=p['No_total']/(np.exp(B_val*p['Gg']*6.63e-34/(1.38e-23*T))-1) p['Nm']=p['Nm_total']/(np.exp(B_val*p['Gg']*6.63e-34/(1.38e-23*T))-1) omegaao=omegaao2_from_I(B_val,p) p['sd_delao']=sd_delao2_from_I(B_val,p) p['mean_delao']=deltaao_from_I(B_val,omegaao,p) p['mean_delam']=deltamac_from_I(B_val,p) p['nbath']=nbath_from_T(T,p,p['mean_delam']) p['Omega']= Omega_from_PdBm(P_pump,p) rho_out_b[:,:,ii,jj]=rho_out_b[:,:,ii,jj]+np.array(rho_broad_full(0,bvals[ii,jj], 0,deltamval, p))*p['No_total']/(np.exp(B_val*p['Gg']*6.63e-34/(1.38e-23*T))-1) p['No']=p['No_total'] p['Nm']=p['Nm_total'] omegaao=omegaao3_from_I(B_val,p)
elif ii == 0: #start_guess_vec_bout=[boutvals[ii,jj-1].real,boutvals[ii,jj-1].imag] start_guess_vec_b = [bvals[0, jj - 1].real, bvals[0, jj - 1].imag] #start_guess_vec_b2=[bvals2[ii,jj-1].real,bvals2[ii,jj-1].imag,avals[ii,jj-1].real,avals[ii,jj-1].imag] elif jj == 0: start_guess_vec_b = [bvals[ii - 1, 0].real, bvals[ii - 1, 0].imag] else: start_guess_complex_b = (bvals[ii, jj - 1] + bvals[ii - 1, jj]) / 2 start_guess_vec_b = [ start_guess_complex_b.real, start_guess_complex_b.imag ] start_guess_vec_b = [0, 0] #boutvals[ii,jj]=find_output_no_a(binval,deltamval,p,start_guess_vec_bout)#=start_guess_vec) bvals[ii, jj] = find_b_no_a(binval, deltamval, p, start_guess_vec_b) #rho_out_bout1[:,:,ii,jj]=rho_broad_full(0,(boutvals[ii,jj])*np.sqrt(p['gammamc'])+(binval), 0,deltamval,p) rho_out_b[:, :, ii, jj] = rho_broad_full(0, (bvals[ii, jj]), 0, deltamval, p) #rho_out_b[:,:,ii,jj]=rho_broad_full(0,bvals[ii,jj]+binval/np.sqrt(p['gammamc']), 0,deltamval,p) #bvals2[ii,jj], avals[ii,jj]=find_b_a_rho13(binval,deltamval,p,start_guess_vec_b2) #rho_outm[:,:,ii,jj]=rho_broad_full(0,boutvals[ii,jj]*np.sqrt(p['gammamc']), 0,deltamval,p) #rho_outd[:,:,ii,jj]=rho_broad_full(0,boutvals[ii,jj], 0,deltamval,p) elapsed_time = time.time() - start_time #print('aout = ' +str(aoutvals[ii,jj])+', bout = ' + str(boutvals[ii,jj])) print(' ' + str(ii) + ', Time: ' + time.ctime() + ', Elapsed: ' + str(elapsed_time)) #np.savez(filename,boutvals=boutvals,binval=binval,deltamacvals=deltamacvals,deltamvals=deltamvals,p=p,rho_out_b=rho_out_b, rho_out_bout=rho_out_bout,bvals=bvals,bvals2=bvals2,rho13_out_b2=rho13_out_b2) np.savez(filename, binvals=binvals,
bvals[ii, jj] = find_b_4_3lvl(binval, deltamval, B_val, p, start_guess_vec_b) #rho_out_b[:,:,ii,jj]=S12_2(B_val,bvals[ii,jj],deltamval,p)#+S12_2(B_val,bvals[ii,jj],deltamval,p)+S12_3(B_val,bvals[ii,jj],deltamval,p)+S12_4(B_val,bvals[ii,jj],deltamval,p) p['No'] = p['No_total'] / (np.exp(B_val * p['Gg'] * 6.63e-34 / (1.38e-23 * T)) - 1) p['Nm'] = p['Nm_total'] / (np.exp(B_val * p['Gg'] * 6.63e-34 / (1.38e-23 * T)) - 1) omegaao = omegaao1_from_I(B_val, p) p['sd_delao'] = sd_delao1_from_I(B_val, p) p['mean_delao'] = deltaao_from_I(B_val, omegaao, p) p['mean_delam'] = deltamac_from_I(B_val, p) p['nbath'] = nbath_from_T(T, p, deltamacval=p['mean_delam']) p['Omega'] = Omega_from_PdBm(P_pump, p) #bvals[ii,jj]=find_b_no_a(binval,deltamval,p,start_guess_vec_b) rho_out_b[:, :, ii, jj] = np.array( rho_broad_full(0, bvals[ii, jj], 0, deltamval, p)) * p[ 'No_total'] #/(np.exp(B_val*p['Gg']*6.63e-34/(1.38e-23*T))-1) p['No'] = p['No_total'] / (np.exp(B_val * p['Gg'] * 6.63e-34 / (1.38e-23 * T)) - 1) p['Nm'] = p['Nm_total'] / (np.exp(B_val * p['Gg'] * 6.63e-34 / (1.38e-23 * T)) - 1) omegaao = omegaao2_from_I(B_val, p) p['sd_delao'] = sd_delao2_from_I(B_val, p) p['mean_delao'] = deltaao_from_I(B_val, omegaao, p) p['mean_delam'] = deltamac_from_I(B_val, p) p['nbath'] = nbath_from_T(T, p, p['mean_delam']) p['Omega'] = Omega_from_PdBm(P_pump, p) rho_out_b[:, :, ii, jj] = rho_out_b[:, :, ii, jj] + np.array( rho_broad_full(0, bvals[ii, jj], 0, deltamval, p)