def Ofmaxmass(p3): eos = EOS_BPSwithPoly([ baryon_density0, p1, baryon_density1, causality_p2(p1), baryon_density2, p3, baryon_density3 ]) maxmass = Maxmass(Preset_Pressure_final, Preset_rtol, eos)[2] print maxmass return maxmass - ofmaxmass
def Calculation_maxmass(eos_i): try: maxmass_result = Maxmass(Preset_Pressure_final, Preset_rtol, eos_i)[1:3] maxmass_result += [eos_i.eosCs2(maxmass_result[0])] except RuntimeWarning: print('Runtimewarning happens at calculating max mass:') print(eos_i.args) return maxmass_result
def causality_p3(p1,p2): p3=opt.newton(causality_center,p2*6.5,tol=1e-1,args=(p1,p2)) a=EOS_BPSwithPoly([baryon_density0,p1,baryon_density1,p2,baryon_density2,p3,baryon_density3]) pc_max=Maxmass(Preset_Pressure_final,Preset_rtol,a)[1] return p3,pc_max
def causality_center(p3,p1,p2): a=EOS_BPSwithPoly([baryon_density0,p1,baryon_density1,p2,baryon_density2,p3,baryon_density3]) return a.eosCs2(Maxmass(Preset_Pressure_final,Preset_rtol,a)[1])-1
def Calculation_maxmass(eos, i): maxmass_result = Maxmass(Preset_Pressure_final, Preset_rtol, eos[i])[1:3] return maxmass_result + [eos[i].eosCs2(maxmass_result[0])]
# popt, pcov = curve_fit(fitting_f, eos[i].eos_array[1,logic], eos[i].eos_array[2,logic], bounds=([index_bondary, 0, 0], [10, 10, index_bondary])) # abcd=[get_A(*popt)]+list(popt) # print(abcd) # plt.plot(eos[i].eos_array[1,logic],eos[i].eos_array[2,logic]) # plt.plot(eos[i].eos_array[1,logic],fitting_f(*([eos[i].eos_array[1,logic]]+list(popt)))) # ============================================================================= from FindMaxmass import Maxmass from MassRadius_hadronic import MassRadius from Find_OfMass import Properity_ofmass MRBIT_LIST=[] eos_properity=[] for eos_i in eos: #print len(MRBIT_LIST) MRBIT_LIST.append([]) pc_max,maxmass=Maxmass(1e-8,1e-5,eos_i)[1:3] print(pc_max,maxmass) onepointfour_result=Properity_ofmass(1.4,10,pc_max,MassRadius,1e-8,1e-5,1,eos_i) pc_min=Properity_ofmass(1.0,10,pc_max,MassRadius,1e-8,1e-5,1,eos_i)[0] pc_min=10 pc=pc_min*np.exp(np.linspace(0,np.log(pc_max/pc_min),50)) eos_properity.append([pc_max,maxmass,onepointfour_result[0],onepointfour_result[2],onepointfour_result[7]]) for pc_i in pc: MRBIT_LIST[-1].append(MassRadius(pc_i,1e-8,1e-5,'MRBIT',eos_i)) MRBIT_LIST=np.array(MRBIT_LIST) eos_properity=np.array(eos_properity) for i in range(len(eos)): plt.plot(MRBIT_LIST[i,:,1],MRBIT_LIST[i,:,0],'.') np.savetxt(path+EOS_LIST[i]+'_TOV_result',MRBIT_LIST[i]) np.savetxt(path+EOS_LIST[i]+'_EOS_data',eos[i].eos_array.transpose()) plt.xlabel('radius(km)')
pressure1 = 30 pressure2 = causality_p2(pressure1) Preset_Pressure_final = 1e-8 Preset_rtol = 1e-6 pressure3 = opt.newton(caulality_central_pressure_at_peak, trial_p3(pressure1, pressure2), tol=0.1, args=(pressure1, pressure2, Preset_Pressure_final, Preset_rtol)) upper_bound_eos.append( EOS_BPSwithPoly([ baryon_density0, pressure1, baryon_density1, pressure2, baryon_density2, pressure3, baryon_density3 ])) upper_bound_pc.append( Maxmass(Preset_Pressure_final, 1e-4, upper_bound_eos[-1])[1]) print upper_bound_eos[-1].args pressure1 = 8.4 pressure2, pressure3, pressure_center = p2p3_ofmaxmass(2.0, Maxmass, Preset_Pressure_final, Preset_rtol, pressure1) lower_bound_eos.append( EOS_BPSwithPoly([ baryon_density0, pressure1, baryon_density1, pressure2, baryon_density2, pressure3, baryon_density3 ])) lower_bound_pc.append( Maxmass(Preset_Pressure_final, 1e-4, lower_bound_eos[-1])[1]) print lower_bound_eos[-1].args baryon_density1 = 1.85 * 0.16