def fixed_temp_nfbetaeq_pnu(EOSlist,temps): for ieos in range(len(EOSlist)): myeos = eosDriver(EOSlist[ieos][1]) rhomax = (10.0e0**max(myeos.h5file['logrho']))*0.995 logrhos = linspace(log10(rhomin),log10(rhomax),nrhos) eostable = zeros((nrhos,2)) energy_shift = myeos.h5file['energy_shift'][0] energy_shift = energy_shift*eps_gf rhotrap = 10.0e0**12.5 for ii in range(len(temps)): eostablename = EOSlist[ieos][0]+\ "_eostable_NFBetaEq_pnu_T=%06.3f.dat" % \ (temps[ii]) for i in range(nrhos): temp_cold = 0.5e0 temp = temps[ii] rho = 10.0**logrhos[i] ylep = myeos.setBetaEqState({'rho': rho, 'temp': temp_cold}) ye2 = myeos.setBetaEqState({'rho': rho, 'temp': temp}) ye1 = myeos.setNuFullBetaEqState({'rho': rho, 'temp': temp},ylep) ye = ye2*(1-exp(-rhotrap/rho)) + ye1*(exp(-rhotrap/rho)) myeos.setState({'rho': rho, 'temp': temp, 'ye' : ye}) print "Making EOS: %15.6E %15.6E %15.6E %15.6E %15.6E %15.6E" %\ (10.0**logrhos[i],temp,ye,ye1,ye2,ylep) (press,eps,munu) = myeos.query(['logpress','logenergy','munu']) eta = munu/temp pnu = get_pnu(eta,temp,rho,rhotrap) epsnu = 3.0e0*pnu / rho # convert units eostable[i,0] = log10((10.0**press+pnu) * press_gf) eostable[i,1] = log10((10.0**eps+epsnu) * eps_gf) if (i>0 and eostable[i,0] < eostable[i-1,0]): eostable[i,0] = eostable[i-1,0] eostable[i,0] = eostable[i-1,0] # write EOS table eosfile=open(eostablename,"w") esstring = "%18.9E\n" % (energy_shift/eps_gf) eosfile.write(esstring) for i in range(len(eostable[:,0])): sline = "%15.6E %15.6E %15.6E\n" % \ (logrhos[i],eostable[i,0],eostable[i,1]) eosfile.write(sline) eosfile.close() del myeos
def convertRhoBaryToEnergyDense(rhos, eosPrescription, T=None): assert isinstance(eosPrescription, dict) # method here is to process each part of the eosPrescription, and # eventually reduce it to parameters just required for tempPrescription eosScript = deepcopy(eosPrescription) assert eosScript['type'] == 'tableFromEosDriver', \ "Convert to energy density from rho_b is only supported for eosDriver tables" del eosScript['type'] theEos = eosDriver(eosScript['sc.orgTableFile']) del eosScript['sc.orgTableFile'] assert 'ye' in eosScript, "Convert to enegry density requires a ye in eosPrescription" ye = eosScript['ye'] del eosScript['ye'] if ye == 'BetaEq': ye = None #prescriptionName only used to set temperature if necessary if eosScript['prescriptionName'] == 'isothermal': eosScript['T'] = T del eosScript['prescriptionName'] if isinstance(rhos, float): rhos = [rhos] eds = [] for rho in rhos: rho *= 1.e15 # fix units tempOfLog10Rhob = theEos.tempOfLog10RhobFuncFromPrescription(eosScript, ye) temp = tempOfLog10Rhob(numpy.log10(rho)) if ye is None and temp is not None: theEos.setBetaEqState({'rho': rho, 'temp': temp}) elif ye is None and temp is None: quantity = eosScript['quantity'] target = eosScript['target'] theEos.setConstQuantityAndBetaEqState({'rho': rho}, quantity, target) elif ye == 'NuFull': theEos.setNuFullBetaEqState({'rho': rho, 'temp': temp}) else: theEos.setState({'rho': rho, 'temp': temp, 'ye': ye}) logeps = theEos.query('logenergy') eps = (numpy.power(10.0, logeps) - theEos.energy_shift) \ * consts.AGEO_ERG / consts.AGEO_GRAM totalEnergyDensity = rho * (1.0 + eps) eds.append(totalEnergyDensity / 1.e15) del theEos return eds
def convertRhoBaryToEnergyDense(rhos, eosPrescription, T=None): assert isinstance(eosPrescription, dict) # method here is to process each part of the eosPrescription, and # eventually reduce it to parameters just required for tempPrescription eosScript = deepcopy(eosPrescription) assert eosScript['type'] == 'tableFromEosDriver', \ "Convert to energy density from rho_b is only supported for eosDriver tables" del eosScript['type'] theEos = eosDriver(eosScript['sc.orgTableFile']) del eosScript['sc.orgTableFile'] assert 'ye' in eosScript, "Convert to enegry density requires a ye in eosPrescription" ye = eosScript['ye'] del eosScript['ye'] if ye == 'BetaEq': ye = None #prescriptionName only used to set temperature if necessary if eosScript['prescriptionName'] == 'isothermal': eosScript['T'] = T del eosScript['prescriptionName'] if isinstance(rhos, float): rhos = [rhos] eds = [] for rho in rhos: rho *= 1.e15 # fix units tempOfLog10Rhob = theEos.tempOfLog10RhobFuncFromPrescription( eosScript, ye) temp = tempOfLog10Rhob(numpy.log10(rho)) if ye is None and temp is not None: theEos.setBetaEqState({'rho': rho, 'temp': temp}) elif ye is None and temp is None: quantity = eosScript['quantity'] target = eosScript['target'] theEos.setConstQuantityAndBetaEqState({'rho': rho}, quantity, target) elif ye == 'NuFull': theEos.setNuFullBetaEqState({'rho': rho, 'temp': temp}) else: theEos.setState({'rho': rho, 'temp': temp, 'ye': ye}) logeps = theEos.query('logenergy') eps = (numpy.power(10.0, logeps) - theEos.energy_shift) \ * consts.AGEO_ERG / consts.AGEO_GRAM totalEnergyDensity = rho * (1.0 + eps) eds.append(totalEnergyDensity / 1.e15) del theEos return eds
def special_fixed_Ye(EOSlist,temps,yes,mytype): for ieos in range(len(EOSlist)): myeos = eosDriver(EOSlist[ieos][1]) rhomax = (10.0e0**max(myeos.h5file['logrho']))*0.995 for jj in range(len(yes)): par1 = 0.0 par2 = yes[jj] print "Y_e: %15.6E" % (par2) print "Preparing EOS table: ",EOSlist[ieos][0], mytype makeeostable.makeeostable(\ nrhos,rhomin,rhomax,myeos,EOSlist[ieos][0],\ mytype,par1,par2) del myeos
def fixed_temp_betaeq(EOSlist,temps): for ieos in range(len(EOSlist)): myeos = eosDriver(EOSlist[ieos][1]) rhomax = (10.0e0**max(myeos.h5file['logrho']))*0.995 for ii in range(len(temps)): mytype = "fixed_temp_betaeq" par1 = temps[ii] par2 = 0.0 print "T = %5.2f, betaeq" % (par1) print "Preparing EOS table: ",EOSlist[ieos][0], mytype makeeostable.makeeostable(\ nrhos,rhomin,rhomax,myeos,EOSlist[ieos][0],\ mytype,par1,par2) del myeos
def special_BetaEq(EOSlist,temps,yes,mytype): for ieos in range(len(EOSlist)): myeos = eosDriver(EOSlist[ieos][1]) rhomax = (10.0e0**max(myeos.h5file['logrho']))*0.995 eostablename = EOSlist[ieos][0]+\ "_eostable_BetaEq_"+mytype+".dat" energy_shift = myeos.h5file['energy_shift'][0] if(mytype == "c30p5"): tempfunc = kentaDataTofLogRhoFit2() elif(mytype == "c30p10"): tempfunc = kentaDataTofLogRhoFit1() elif(mytype == "c30p0"): tempfunc = getTRollFunc(30.0,0.01,14.055,0.375) elif(mytype == "c20p0"): tempfunc = getTRollFunc(20.0,0.01,14.0-0.07,0.125) elif(mytype == "c40p0"): tempfunc = getTRollFunc(40.0,0.01,14.25-0.07,0.5) logrhos = linspace(log10(rhomin),log10(rhomax),nrhos) eostable = zeros((nrhos,2)) for i in range(nrhos): temp = tempfunc(logrhos[i]) ye = myeos.setBetaEqState({'rho': 10.0**logrhos[i], 'temp': temp}) (press,eps) = myeos.query(['logpress','logenergy']) # convert units eostable[i,0] = log10(10.0**press * press_gf) eostable[i,1] = log10(10.0**eps * eps_gf) if (i>0 and eostable[i,0] < eostable[i-1,0]): eostable[i,0] = eostable[i-1,0] print "Making EOS: %15.6E %15.6E %15.6E" % (10.0**logrhos[i],temp,ye) energy_shift = energy_shift*eps_gf # write EOS table eosfile=open(eostablename,"w") esstring = "%18.9E\n" % (energy_shift/eps_gf) eosfile.write(esstring) for i in range(len(eostable[:,0])): sline = "%15.6E %15.6E %15.6E\n" % \ (logrhos[i],eostable[i,0],eostable[i,1]) eosfile.write(sline) eosfile.close() del myeos
def special_NFBetaEq_pnu(EOSlist,temps,mytype): for ieos in range(len(EOSlist)): myeos = eosDriver(EOSlist[ieos][1]) rhomax = (10.0e0**max(myeos.h5file['logrho']))*0.995 eostablename = EOSlist[ieos][0]+\ "_eostable_NFBetaEq_pnu_"+mytype+".dat" energy_shift = myeos.h5file['energy_shift'][0] logrhos = linspace(log10(rhomin),log10(rhomax),nrhos) eostable = zeros((nrhos,2)) energy_shift = energy_shift*eps_gf rhotrap = 10.0e0**12.5 if(mytype == "c30p5"): tempfunc = kentaDataTofLogRhoFit2() elif(mytype == "c30p10"): tempfunc = kentaDataTofLogRhoFit1() elif(mytype == "c30p0"): tempfunc = getTRollFunc(30.0,0.01,14.055,0.375) elif(mytype == "c20p0"): tempfunc = getTRollFunc(20.0,0.01,14.0-0.07,0.125) elif(mytype == "c40p0"): tempfunc = getTRollFunc(40.0,0.01,14.25-0.07,0.5) for i in range(nrhos): temp_cold = 0.5e0 temp = tempfunc(logrhos[i]) rho = 10.0**logrhos[i] ylep = myeos.setBetaEqState({'rho': rho, 'temp': temp_cold}) ye2 = myeos.setBetaEqState({'rho': rho, 'temp': temp}) ye1 = myeos.setNuFullBetaEqState({'rho': rho, 'temp': temp},ylep) ye = ye2*(1-exp(-rhotrap/rho)) + ye1*(exp(-rhotrap/rho)) myeos.setState({'rho': rho, 'temp': temp, 'ye' : ye}) print "Making EOS: %15.6E %15.6E %15.6E %15.6E %15.6E %15.6E" %\ (10.0**logrhos[i],temp,ye,ye1,ye2,ylep) (press,eps,munu) = myeos.query(['logpress','logenergy','munu']) eta = munu/temp pnu = get_pnu(eta,temp,rho,rhotrap) epsnu = 3.0e0*pnu / rho # convert units eostable[i,0] = log10((10.0**press+pnu) * press_gf) eostable[i,1] = log10((10.0**eps+epsnu) * eps_gf) if (i>0 and eostable[i,0] < eostable[i-1,0]): eostable[i,0] = eostable[i-1,0] eostable[i,0] = eostable[i-1,0] # write EOS table eosfile=open(eostablename,"w") esstring = "%18.9E\n" % (energy_shift/eps_gf) eosfile.write(esstring) for i in range(len(eostable[:,0])): sline = "%15.6E %15.6E %15.6E\n" % \ (logrhos[i],eostable[i,0],eostable[i,1]) eosfile.write(sline) eosfile.close() del myeos
from eosDriver import eosDriver, getTRollFunc, kentaDataTofLogRhoFit1, kentaDataTofLogRhoFit2 from datasetManager import cstDataset from maxMassOrigFiles.sqlPlotRoutines import nearValueFilter shedDb = '/home/jeff/work/rotNSruns/shedRuns4-24-13.db' sourceDb = '/home/jeff/work/rotNSruns/vdenseBetaEqD5-26.db' c30p10Db = '/home/jeff/work/rotNSruns/svdense30p10A.db' shedDb = sourceDb shenEosTableFilename = '/home/jeff/work/HShenEOS_rho220_temp180_ye65_version_1.1_20120817.h5' ls220EosTableFilename = '/home/jeff/work/LS220_234r_136t_50y_analmu_20091212_SVNr26.h5' shen = eosDriver(shenEosTableFilename) ls220 = eosDriver(ls220EosTableFilename) theEos = ls220 eosName = 'HShenEOS' ye = 'BetaEq' eosText = eosName if eosName == 'HShenEOS': eosText = 'HShen' theEos = shen scriptsList = ['c40p0', 'c30p10', 'c30p5', 'c30p0', 'c20p0', 'cold'] cXXp0_params = [(40.0, 14.18, 0.5,), (30.0, 14.055, 0.375), (20.0, 13.93, 0.25)] tempFuncs = [getTRollFunc(params[0], 0.01, params[1], params[2]) for params in cXXp0_params] tempFuncs.append(kentaDataTofLogRhoFit1()) tempFuncs.append(kentaDataTofLogRhoFit2()) tempFuncs.append(lambda x: 0.01)
from plotUtilsForPaper import latexField, fixExponentialAxes, removeExponentialNotationOnAxis import plot_defaults #basics myfig = plt.figure(figsize=(10, 8)) myfig.subplots_adjust(left=0.124) myfig.subplots_adjust(bottom=0.14) myfig.subplots_adjust(top=0.967) myfig.subplots_adjust(right=0.97) sourceDb = '/home/jeff/work/rotNSruns/vdenseBetaEqOnly.db' tovSourceDb = '/home/jeff/work/rotNSruns/allRuns3-25-13.db' shenEosTableFilename = '/home/jeff/work/HShenEOS_rho220_temp180_ye65_version_1.1_20120817.h5' ls220EosTableFilename = '/home/jeff/work/LS220_234r_136t_50y_analmu_20091212_SVNr26.h5' eosName = 'LS220' theEos = eosDriver(ls220EosTableFilename) ye = 'BetaEq' #yeForInversion = 0.1 xVar = 'edMax' yVars = ['gravMass'] xLabel = r"$\rho_{b,\mathrm{max}}$ [g/cm$^3$]" xLabel = r"$E_\mathrm{max}$" yLabel = "$M_g/M_\odot$" #yLabel = "$J/M^2$" yFunc = lambda x: x a = 1.0 tovSlice = {'a': 0.0, 'rpoe': 1.0} uniformMaxRotSlice = {'a': 0.0, 'rpoe': 'min'}
#!/opt/local/bin/python import sys import numpy from units import * from numpy import linspace, zeros, log10, pi, sqrt from eosDriver import eosDriver import makeeostable from tov import * # myeos = eosDriver('LS220_234r_136t_50y_analmu_20091212_SVNr26.h5') myeos = eosDriver("HShenEOS_rho234_temp136_ye50_version2.0_20120706.h5") # make fixed temperature, Y_e sequence tovinfo = tovinfoclass() tovinfo.polyK = 100.0 tovinfo.polyG = 2.0 tovinfo.nzones = 50000 tovinfo.rmax = 50.0 tovinfo.eostype = 3 mytype = "fixed_ye_entropy" par1 = 3.0 par2 = 0.15 rhomin = 1.0e6 rhomax = 8.0e15 tovinfo.eoslrhomin = log10(rhomin * rho_gf) tovinfo.eoslrhomax = log10(rhomax * rho_gf) (tovinfo.eostable, tovinfo.eosepsshift, dlrho, tovinfo.logrhos) = makeeostable.makeeostable(
from datasetManager import cstDataset, cstSequence import plot_defaults from plotUtilsForPaper import fixExponentialAxes, removeExponentialNotationOnAxis matplotlib.rcParams['figure.subplot.left'] = 0.15 myfig = plt.figure(figsize=(10, 8)) myfig.subplots_adjust(left=0.15) myfig.subplots_adjust(bottom=0.14) myfig.subplots_adjust(top=0.967) myfig.subplots_adjust(right=0.96) sourceDb = '/home/jeff/work/rotNSruns/vdenseBetaEqOnlyMoreC.db' tovSourceDb = '/home/jeff/work/rotNSruns/allRuns3-25-13.db' shenEosTableFilename = '/home/jeff/work/HShenEOS_rho220_temp180_ye65_version_1.1_20120817.h5' ls220EosTableFilename = '/home/jeff/work/LS220_234r_136t_50y_analmu_20091212_SVNr26.h5' eosName = 'HShenEOS' theEos = eosDriver(shenEosTableFilename) tovSlice = {'a': 0.0, 'rpoe': 1.0} uniformMaxRotSlice = {'a': 0.0, 'rpoe': 'min'} diffMaxRotSlice = {'a': 1.0, 'rpoe': 'min'} a8 = {'a': 0.8, 'rpoe': 'min'} a7 = {'a': 0.7, 'rpoe': 'min'} a6 = {'a': 0.6, 'rpoe': 'min'} a5 = {'a': 0.5, 'rpoe': 'min'} a4 = {'a': 0.4, 'rpoe': 'min'} colors = {'c30p0': 'g', 'c20p0': 'b', 'c40p0': 'r', 'cold': 'k', 'c30p5': 'c',
rcParams['xtick.major.pad'] = 8 rcParams['xtick.minor.size'] = 7 rc('legend', fontsize=26) #16 rcParams['ytick.major.size'] = 13 rcParams['ytick.major.pad'] = 8 rcParams['ytick.minor.size'] = 7 fig = plt.figure(figsize=(10, 8)) fig.subplots_adjust(left=0.14) fig.subplots_adjust(bottom=0.14) fig.subplots_adjust(top=0.967) fig.subplots_adjust(right=0.97) ############################################################################## # Load Shen EOS for ye comparisons ############################################################################## shen = eosDriver.eosDriver('/home/jeff/work/HShenEOS_rho220_temp180_ye65_version_1.1_20120817.h5') ls220 = eosDriver.eosDriver('/home/jeff/work/LS220_234r_136t_50y_analmu_20091212_SVNr26.h5') theEos = shen plotBetaEq = True parametrizedTempProfile = False paramdTfunc = eosDriver.kentaDataTofLogRhoFit1() nuFullBetaEq = True colors = {'c30p0': 'g', 'c20p0': 'b', 'c40p0': 'r', 'cold': 'k', 'c30p5': 'c', 'c30p10': 'm', 'sim': plot_defaults.kotzbraun} scripts = {key: [] for key in colors.keys()}
#rcParams['ytick.major.pad'] = 5 #rcParams['xtick.major.pad'] = 10 #rcParams['figure.subplot.left'] = 0.13 ##### change a few standard settings rcParams['xtick.major.size'] = 13 rcParams['xtick.major.pad'] = 8 rcParams['xtick.minor.size'] = 7 rc('legend', fontsize=26) #16 rcParams['ytick.major.size'] = 13 rcParams['ytick.major.pad'] = 8 rcParams['ytick.minor.size'] = 7 ############################################################################## # Load Shen EOS for ye comparisons ############################################################################## shen = eosDriver.eosDriver('/home/jeff/work/HShenEOS_rho220_temp180_ye65_version_1.1_20120817.h5') plotBetaEq = True parametrizedTempProfile = False paramdTfunc = eosDriver.kentaDataTofLogRhoFit1() nuFullBetaEq = True def readFile(filename): data = {'d': [], 'rho': [], 'p': [], 's': [], 'T': [], 'Omega': [], 'ye': [], 'yeBetaEq': [], 'yeBetaParamdTemp': [], 'tableP': [], 'betaP': [], 'constP': [], 'yeNuFull': [], 'constP.08': [], 'constP.1': [], 'constP.12': [] } labels = {'d': None, 'rho': None, 'p': None, 's': None, 'T': None, 'Omega': None, 'ye': None, 'yeBetaEq': "Ye in BetaEq", 'tableP': 'Simulation', 'betaP': 'BetaEq', 'yeNuFull': "Ye in NuFull BetaEq", 'constP': 'Ye=.15', 'constP.08': 'Ye=.08', 'constP.1': 'Ye=.1', 'constP.12': 'Ye=.12' }
from eosDriver import eosDriver, getTRollFunc, kentaDataTofLogRhoFit1, kentaDataTofLogRhoFit2 from datasetManager import cstDataset from maxMassOrigFiles.sqlPlotRoutines import nearValueFilter shedDb = '/home/jeff/work/rotNSruns/shedRuns4-24-13.db' shenEosTableFilename = '/home/jeff/work/HShenEOS_rho220_temp180_ye65_version_1.1_20120817.h5' ls220EosTableFilename = '/home/jeff/work/LS220_234r_136t_50y_analmu_20091212_SVNr26.h5' shen = eosDriver(shenEosTableFilename) ls220 = eosDriver(ls220EosTableFilename) theEos = ls220 eosName = 'LS220' ye = 'BetaEq' eosText = eosName if eosName == 'HShenEOS': eosText = 'HShen' theEos = shen scriptsList = ['c40p0', 'c30p10', 'c30p5', 'c30p0', 'c20p0', 'cold'] cXXp0_params = [( 40.0, 14.18, 0.5, ), (30.0, 14.055, 0.375), (20.0, 13.93, 0.25)] tempFuncs = [ getTRollFunc(params[0], 0.01, params[1], params[2]) for params in cXXp0_params ] tempFuncs.append(kentaDataTofLogRhoFit1())
# rcParams['ytick.major.pad'] = 5 # rcParams['xtick.major.pad'] = 10 # rcParams['figure.subplot.left'] = 0.13 ##### change a few standard settings rcParams["xtick.major.size"] = 13 rcParams["xtick.major.pad"] = 8 rcParams["xtick.minor.size"] = 7 rc("legend", fontsize=26) # 16 rcParams["ytick.major.size"] = 13 rcParams["ytick.major.pad"] = 8 rcParams["ytick.minor.size"] = 7 ############################################################################## # Load Shen EOS for ye comparisons ############################################################################## shen = eosDriver.eosDriver("/home/jeff/work/HShenEOS_rho220_temp180_ye65_version_1.1_20120817.h5") plotBetaEq = True parametrizedTempProfile = False paramdTfunc = eosDriver.kentaDataTofLogRhoFit1() nuFullBetaEq = True def readFile(filename): data = { "d": [], "rho": [], "p": [], "s": [], "T": [], "Omega": [],
import datetime import plot_defaults from eosDriver import eosDriver import numpy import matplotlib.pyplot as plt from utils import lookupIndexBisect, linInterp, solveRootBisect, multidimInterp import matplotlib.pyplot as mpl startTime = datetime.datetime.now() ls220 = eosDriver('/home/jeff/work/LS220_234r_136t_50y_analmu_20091212_SVNr26.h5') shen = eosDriver('/home/jeff/work/HShenEOS_rho220_temp180_ye65_version_1.1_20120817.h5') theEos = ls220 theEos.setState({'rho': 1.0e15, 'ye': 0.15, 'temp': 30.0}) canonicalEntropy = theEos.query('entropy') print canonicalEntropy print theEos.setBetaEqState({'rho': 1.0e15, 'temp': 30.0}) canonicalEntropy = theEos.query('entropy') print canonicalEntropy canonicalEntropy = 0.9 fixedYe = 0.15 print print "---------------" print getLogRhoIndex = lambda lr: lookupIndexBisect(lr, theEos.h5file['logrho'][:]) def entropyOfT(logtemp, logrho, target): lrindex = getLogRhoIndex(logrho)
import numpy from datasetManager import cstDataset, cstSequence import plot_defaults from plotUtilsForPaper import fixExponentialAxes, removeExponentialNotationOnAxis matplotlib.rcParams['figure.subplot.left'] = 0.15 sourceDb = '/home/jeff/work/rotNSruns/vdenseBetaEqD5-26.db' c30p10Db = '/home/jeff/work/rotNSruns/svdense30p10A.db' tovSourceDb = '/home/jeff/work/rotNSruns/allRuns3-25-13.db' shenEosTableFilename = '/home/jeff/work/HShenEOS_rho220_temp180_ye65_version_1.1_20120817.h5' ls220EosTableFilename = '/home/jeff/work/LS220_234r_136t_50y_analmu_20091212_SVNr26.h5' eosName = 'HShenEOS' theEos = eosDriver(shenEosTableFilename) tovSlice = {'a': 0.0, 'rpoe': 1.0} uniformMaxRotSlice = {'a': 0.0, 'rpoe': 'min'} diffMaxRotSlice = {'a': 1.0, 'rpoe': 'min'} a8 = {'a': 0.8, 'rpoe': 'min'} a7 = {'a': 0.7, 'rpoe': 'min'} a6 = {'a': 0.6, 'rpoe': 'min'} a5 = {'a': 0.5, 'rpoe': 'min'} a4 = {'a': 0.4, 'rpoe': 'min'} colors = {'c30p0': 'g', 'c20p0': 'b', 'c40p0': 'r', 'cold': 'k', 'c30p5': 'c',
#!/opt/local/bin/python import sys from units import * from numpy import linspace, zeros, log10, pi, sqrt from eosDriver import eosDriver import makeeostable from tov import * myeos = eosDriver('LS220_234r_136t_50y_analmu_20091212_SVNr26.h5') # make fixed temperature, Y_e sequence tovinfo = tovinfoclass() tovinfo.polyK = 100.0 tovinfo.polyG = 2.0 tovinfo.nzones = 80000 tovinfo.rmax = 100.0 tovinfo.eostype = 3 yes = [0.1,0.15,0.2,0.25,0.3] tmin = 0.5 tmax = 50.0 dtemp = 0.5 ntemp = int((tmax-tmin)/dtemp)+1 temps = zeros(ntemp) for i in range(ntemp): temps[i] = 0.5 + dtemp*i
def generateEosTable(self, inputParams): """ Creates EOS table and returns nonOutputRunParams which are parameters describing the run not output by the CST code. """ nonOutputRunParams = {'a': inputParams['a'], 'ye': self.ye} isothermalParams = ('rollMid', 'rollScale', 'eosTmin', 'T') fixedQuantityParams = ('quantity', 'target') manualTofLogRhoParams = ('funcTofLogRho',) if self.eosPrescription == 'tableFromSpEC': subprocess.call(["cp", self.makeEosFile_location, "./"]) makeEosFileArgs={'-eos-opts' : self.specEosOptions, '-roll-midpoint': self.eosPrescriptionDict['rollMid'], '-roll-scale' : self.eosPrescriptionDict['rollScale'], '-roll-tmin' : self.eosPrescriptionDict['eosTmin'], '-roll-tmax' : inputParams['T'], '-ye' : self.ye } argList = [str(arg) for item in makeEosFileArgs.items() for arg in item ] #default output file name is output.EOS subprocess.call(["./MakeRotNSeosfile"] + argList) #tableFromSpEC uses isothermal with roll prescription for key in isothermalParams: if key in inputParams: nonOutputRunParams[key] = inputParams[key] elif key in self.eosPrescriptionDict: nonOutputRunParams[key] = self.eosPrescriptionDict[key] else: assert False, "Key '%s' not found in attempt to set nonOutputRunParams!" for key in fixedQuantityParams: keyForDatabase = 'fixed' + key.capitalize() nonOutputRunParams[keyForDatabase] = str(None) elif self.eosPrescription == 'tableFromEosDriver': prescriptionDict = {} prescriptionName = self.eosPrescriptionDict['prescriptionName'] if prescriptionName == 'isothermal': # isothermal has a temperature rolloff for key in isothermalParams: if key in inputParams: nonOutputRunParams[key] = inputParams[key] prescriptionDict[key] = inputParams[key] elif key in self.eosPrescriptionDict: prescriptionDict[key] = self.eosPrescriptionDict[key] nonOutputRunParams[key] = self.eosPrescriptionDict[key] else: assert False, "Key '%s' not found in attempt to set nonOutputRunParams!" for key in fixedQuantityParams: keyForDatabase = 'fixed' + key.capitalize() nonOutputRunParams[keyForDatabase] = str(None) elif prescriptionName == 'fixedQuantity': for key in isothermalParams: nonOutputRunParams[key] = str(None) for key in fixedQuantityParams: prescriptionDict[key] = self.eosPrescriptionDict[key] keyForDatabase = 'fixed' + key.capitalize() nonOutputRunParams[keyForDatabase] = \ self.eosPrescriptionDict[key] # All field quantities are 'None' for manual prescription elif prescriptionName == 'manual': for key in isothermalParams: nonOutputRunParams[key] = str(None) for key in fixedQuantityParams: keyForDatabase = 'fixed' + key.capitalize() nonOutputRunParams[keyForDatabase] = str(None) for key in manualTofLogRhoParams: prescriptionDict[key] = self.eosPrescriptionDict[key] #HACK for kentaDataTofLogRhoFit2 if self.eosPrescriptionDict['funcTofLogRho'] == 'kentaDataTofLogRhoFit2': nonOutputRunParams['eosTmin'] = 5.0 else: assert False, "Unknown eosDriver prescription type." eosTable = eosDriver(self.eosPrescriptionDict['sc.orgTableFile']) if self.ye == 'BetaEq': #None is code for BetaEq in writeRotNSeosfile eosTable.writeRotNSeosfile('output.EOS', prescriptionDict, ye=None) else: eosTable.writeRotNSeosfile('output.EOS', prescriptionDict, ye=self.ye) del eosTable subprocess.call(["mkdir", "EOS"]) subprocess.call(["cp", "output.EOS", "EOS/EOS.PP"]) return nonOutputRunParams