Eta300_TBL_a = (1 - Table4_dat[1:,0]) #should not compute V now, since V0 is changing every time V0 = rho_to_vol(param_dic['Jam_ref']['rho0']) #unit Ang^3/unitcell param0_a = np.array([V0, 100.0, 4.0]) #initial guess for ref_param Jam_ref_a = fit_ref_vinet(param0_a,P300_TBL_a,Eta300_TBL_a) #put parameter values into dictioanry print "Jam_ref_a", Jam_ref_a param_dic['Jam_ref']['V0'] = Jam_ref_a[0][0] param_dic['Jam_ref']['K0'] = Jam_ref_a[0][1] param_dic['Jam_ref']['K0p'] = Jam_ref_a[0][2] V0 = param_dic['Jam_ref']['V0'] #now all V0 start using the inferred one: ['Jam_ref']['V0'] V300_a = Eta300_TBL_a * V0 P_TBL_mod = press_vinet(V300_a,param_dic['Jam_ref']) print "P300 difference: ", P_TBL_mod-P300_TBL_a #compute Vinet Pressure P300 = press_vinet(V, param_dic['Jam_ref']) mask_a = P > P300 #get rid of errorous data points #print "P300 difference: ", P300-P300_TBL_a T_P = infer_mgd_temp_P(P-P300,rho,param_dic) print "T_P",T_P #compute Vinet Energy E300 = energy_vinet(V,param_dic['Jam_ref'],300.0) E_test = energy_vinet(V0,param_dic['Jam_ref'],300.0) mask_a = E > E300 T_E = infer_mgd_temp_E(E-E300,rho,param_dic) print P
def fit_vinet(param0_a,P0 = P,V0 = V): param_dic = {'V0':param0_a[0],'K0':param0_a[1],'K0p':param0_a[2]} Pmod_a = press_vinet(V,param_dic) resid_a = P-Pmod_a return resid_a
Eta300_TBL_a = (1 - Table4_dat[1:,0]) #should not compute V now, since V0 is changing every time V0 = rho_to_vol(param_dic['Jam_ref']['rho0']) #unit Ang^3/unitcell param0_a = np.array([V0, 100.0, 4.0]) #initial guess for ref_param Jam_ref_a = fit_ref_vinet(param0_a,P300_TBL_a,Eta300_TBL_a) #put parameter values into dictioanry print "Jam_ref_a", Jam_ref_a param_dic['Jam_ref']['V0'] = Jam_ref_a[0][0] param_dic['Jam_ref']['K0'] = Jam_ref_a[0][1] param_dic['Jam_ref']['K0p'] = Jam_ref_a[0][2] V0 = param_dic['Jam_ref']['V0'] #now all V0 start using the inferred one: ['Jam_ref']['V0'] V300_a = Eta300_TBL_a * V0 P_TBL_mod = press_vinet(V300_a,param_dic['Jam_ref']) print "P300 difference: ", P_TBL_mod-P300_TBL_a #compute Vinet Pressure P300 = press_vinet(V, param_dic['Jam_ref']) mask_a = P > P300 #get rid of errorous data points #print "P300 difference: ", P300-P300_TBL_a T_P = infer_mgd_temp_P(P-P300,rho,param_dic) print "T_P",T_P #compute Vinet Energy E300 = energy_vinet(V,param_dic['Jam_ref'],300.0) E_test = energy_vinet(V0,param_dic['Jam_ref'],300.0) mask_a = E > E300 T_E = infer_mgd_temp_E(E-E300,rho,param_dic) print "T_E",T_E
rho, P, E = calc_hugoniot(Up,Us,param_dic) V = rho_to_vol(rho) #Ang^3/unitcell #print vol_to_rho(v) #read Jamison's table to fit vinet model V0 = rho_to_vol(param_dic['const']['rho_Pt']) #unit Ang^3/unitcell dat = np.loadtxt("Fig.txt", delimiter = ",", skiprows = 1) V300_a = (1 - dat[:,2]) * V0 P300_a = dat[:,1] param0_a = np.array([V0, 100.0, 4.0]) #initial guess for ref_param param_dic['Jam_ref'] = dict() ref_a = fit_ref_vinet(param0_a,P300_a,V300_a) #compute Vinet Pressure P300 = press_vinet(V, param_dic['Jam_ref']) mask_a = P > P300 #get rid of errorous data points T_P = infer_mgd_temp_P(P-P300,rho,param_dic) print T_P #compute Vinet Energy E300 = energy_vinet(V,param_dic['Jam_ref'],300.0) E_test = energy_vinet(V0,param_dic['Jam_ref'],300.0) mask_a = E > E300 T_E = infer_mgd_temp_E(E-E300,rho,param_dic) print T_E V0 = param_dic['Jam_ref']['V0'] K0 = param_dic['Jam_ref']['K0'] K0p = param_dic['Jam_ref']['K0p']
def V_fit(param_a, P_a=P300_a, V_a=V300_a): param_d = {'V0':param_a[0],'K0':param_a[1],'K0p':param_a[2]} Pmod_a = press_vinet(V_a,param_d) resid_a = P_a-Pmod_a return resid_a
print V_fit(param0_a) paramfit_a = optimize.leastsq( V_fit, param0_a ) print "%%%%%%%%%%%%" print "paramfit_a" print paramfit_a paramtrue_a = paramfit_a[0] print "true params: ", paramtrue_a #set true dictionary for Jam's vinet model paramtrue = dict() paramtrue = {'V0':paramtrue_a[0],'K0':paramtrue_a[1],'K0p':paramtrue_a[2]} #using computed V_a to find the corresponding P_vinet V_a = 195*param_d['const']['Natom']/atompermol/rho2 #unit Ang^3/unitcell print "V_a: " , V_a P300 = press_vinet(V_a, paramtrue) print "P300 is: ", P300 #get the thermal pressure Pth = p2-P300 print "pth ", Pth #plt.plot(p2,V_a) #plt.show() mask_a = p2 > P300 print "now p2 is: ", p2 def findT(T, Pth,rho2):
def fit_vinet(param0_a, P0=P, V0=V): param_dic = {"V0": param0_a[0], "K0": param0_a[1], "K0p": param0_a[2]} Pmod_a = press_vinet(V, param_dic) resid_a = P - Pmod_a return resid_a
rho, P, E = calc_hugoniot(Up, Us, param_dic) V = rho_to_vol(rho) # Ang^3/unitcell # print vol_to_rho(v) # read Jamison's table to fit vinet model V0 = rho_to_vol(param_dic["const"]["rho_Pt"]) # unit Ang^3/unitcell dat = np.loadtxt("Fig.txt", delimiter=",", skiprows=1) V300_a = (1 - dat[:, 2]) * V0 P300_a = dat[:, 1] param0_a = np.array([V0, 100.0, 4.0]) # initial guess for ref_param param_dic["Jam_ref"] = dict() ref_a = fit_ref_vinet(param0_a, P300_a, V300_a) # compute Vinet Pressure P300 = press_vinet(V, param_dic["Jam_ref"]) mask_a = P > P300 # get rid of errorous data points T_P = infer_mgd_temp_P(P - P300, rho, param_dic) print T_P # compute Vinet Energy E300 = energy_vinet(V, param_dic["Jam_ref"], 300.0) E_test = energy_vinet(V0, param_dic["Jam_ref"], 300.0) mask_a = E > E300 T_E = infer_mgd_temp_E(E - E300, rho, param_dic) print T_E V0 = param_dic["Jam_ref"]["V0"] K0 = param_dic["Jam_ref"]["K0"] K0p = param_dic["Jam_ref"]["K0p"]