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
          'c40p0': 'r',
          'cold': 'm',
          'c30p5': 'c',
          'c30p10': 'k'}

symbols = {'c30p0': 's',
           'c20p0': 'v',
           'c40p0': '^',
           'c30p5': 'p',
           'c30p10': 'H',
           'cold': '*'}
scriptsList = ['c40p0', '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)
tempFuncsDict = {scriptsList[i]: tempFuncs[i] for i in range(len(scriptsList))}


#############################################################
# First plot
#############################################################
filters = ('edMax>2.0e14', 'ToverW<0.25', 'baryMass<2.6')
plotList = []
# coldTovSet = cstDataset('cold', eosName, ye, sourceDb)
# coldTovSeq = cstSequence(coldTovSet, tovSlice, filters)
# theEos.resetCachedBetaEqYeVsRhobs(tempFuncsDict['cold'], 13.5, 16.0)
# coldTovPlot = \
#     coldTovSeq.getSeqPlot([xVar], yVars, filters, \
#       xcolFunc=lambda x: theEos.rhobFromEnergyDensityWithTofRho(x, ye, tempFuncsDict['cold']),
Beispiel #3
0
    'c30p5': 'p',
    'c30p10': 'H',
    'cold': '*'
}
scriptsList = ['c40p0', '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)
tempFuncsDict = {scriptsList[i]: tempFuncs[i] for i in range(len(scriptsList))}

#############################################################
# First plot
#############################################################
filters = ('edMax>2.0e14', 'ToverW<0.25', 'baryMass<2.6')
plotList = []
# coldTovSet = cstDataset('cold', eosName, ye, sourceDb)
# coldTovSeq = cstSequence(coldTovSet, tovSlice, filters)
# theEos.resetCachedBetaEqYeVsRhobs(tempFuncsDict['cold'], 13.5, 16.0)
# coldTovPlot = \
#     coldTovSeq.getSeqPlot([xVar], yVars, filters, \
#       xcolFunc=lambda x: theEos.rhobFromEnergyDensityWithTofRho(x, ye, tempFuncsDict['cold']),
#       ycolFunc=yFunc)
symbols = {'c30p0': 's',
           'c20p0': 'v',
           'c40p0': '^',
           'c30p5': 'p',
           'c30p10': 'H',
           'cold': '*'}

slicesToPlot = [a7, diffMaxRotSlice]
plateauPlots = True

tFuncs = []
scripts = []
if plateauPlots:
    scripts = ['c30p10', 'c30p5', 'cold']
    tFuncs = [kentaDataTofLogRhoFit1(),
              kentaDataTofLogRhoFit2(),
              lambda x: 0.01]
else:
    params40 = (40.0, 14.18, 0.5,)
    params20 = (20.0, 13.93, 0.25,)
    scripts = ['c40p0', 'c20p0', 'cold']
    tFuncs = [getTRollFunc(params40[0], 0.01, params40[1], params40[2]),
              getTRollFunc(params20[0], 0.01, params20[1], params20[2]),
              lambda x: 0.01]



ye = 'BetaEq'
colorLegs = []
for i, script in enumerate(scripts):
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
    theEos.setState({'rho': rho, 'ye': ye, 'temp': thisT})
    lps.append(theEos.queryTrappedNuPress() / pFull )

pBetaList.append(lpsBeta)
lrsList.append(logrhos)
legends = ["c40p0", "c30p0", "c20p0"]
legends.append("c30p10")
mpl.semilogy(logrhos, lps, c=escolors[i + 1])

####
# Manual entry 2
####

lpsBeta = []
lps = []
tRollFunc = kentaDataTofLogRhoFit2()
for lr in logrhos:
    thisT = tRollFunc(lr)
    rho = numpy.power(10.0, lr)
    theEos.setState({'rho': rho, 'ye': ye, 'temp': thisT})
    pFull = theEos.query('logpress', deLog10Result=True)
    theEos.setNuFullBetaEqState({'rho': rho, 'temp': thisT})
    pBetaFull = theEos.query('logpress', deLog10Result=True)


    ts.append(thisT)
    theEos.setNuFullBetaEqState({'rho': rho, 'temp': thisT})
    lpsBeta.append(theEos.queryTrappedNuPress() / pFull )

    theEos.setState({'rho': rho, 'ye': ye, 'temp': thisT})
    lps.append(theEos.queryTrappedNuPress() / pFull )
Beispiel #7
0
xaxisData, xlabels = readFile('/home/jeff/work/Shen135135_x_v2.dat')
#yaxisData, ylabels = readFile('/home/jeff/work/Shen135135_y_v2.dat')
#zaxisData, zlabels = readFile('/home/jeff/work/Shen135135_z_v2.dat')

##############################################################################
#Paper temperature plot
##############################################################################
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)

plateau10 = kentaDataTofLogRhoFit1()
plateau5 = kentaDataTofLogRhoFit2()
core20 = getTRollFunc(20.0, 0.01, 14.0 - .07, .25)
core30 = getTRollFunc(30.0, 0.01, 14.125 - .07, .375)
core40 = getTRollFunc(40.0, 0.01, 14.25 - 0.07, .5)

lrs = numpy.log10([xaxisData['rho'][i] for i in range(len(xaxisData['rho'])) if xaxisData['d'][i] > 0.0])
simTemps = [xaxisData['T'][i] for i in range(len(xaxisData['rho'])) if xaxisData['d'][i] > 0.0]
lrsMore = numpy.array([15.1, 15.0, 14.9, 14.8] + lrs.tolist())
fig.add_subplot(111).plot(lrs, simTemps, plot_defaults.kotzbraun, lw=4, zorder=4,
                          dashes=plot_defaults.longDashes)
fig.add_subplot(111).plot(
         lrsMore, core40(lrsMore), 'r',
         lrsMore, core30(lrsMore), 'g',
         lrsMore, core20(lrsMore), 'b',
         lrsMore, plateau10(lrsMore), 'm',
         lrsMore, plateau5(lrsMore), 'c')
Beispiel #8
0
xaxisData, xlabels = readFile("/home/jeff/work/Shen135135_x_v2.dat")
# yaxisData, ylabels = readFile('/home/jeff/work/Shen135135_y_v2.dat')
# zaxisData, zlabels = readFile('/home/jeff/work/Shen135135_z_v2.dat')

##############################################################################
# Paper temperature plot
##############################################################################
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)

plateau10 = kentaDataTofLogRhoFit1()
plateau5 = kentaDataTofLogRhoFit2()
core20 = getTRollFunc(20.0, 0.01, 14.0 - 0.07, 0.25)
core30 = getTRollFunc(30.0, 0.01, 14.125 - 0.07, 0.375)
core40 = getTRollFunc(40.0, 0.01, 14.25 - 0.07, 0.5)

lrs = numpy.log10([xaxisData["rho"][i] for i in range(len(xaxisData["rho"])) if xaxisData["d"][i] > 0.0])
simTemps = [xaxisData["T"][i] for i in range(len(xaxisData["rho"])) if xaxisData["d"][i] > 0.0]
lrsMore = numpy.array([15.1, 15.0, 14.9, 14.8] + lrs.tolist())
fig.add_subplot(111).plot(lrs, simTemps, plot_defaults.kotzbraun, lw=4, zorder=4, dashes=plot_defaults.longDashes)
fig.add_subplot(111).plot(
    lrsMore,
    core40(lrsMore),
    "r",
    lrsMore,
    core30(lrsMore),
    "g",
Beispiel #9
0
def makeeostable(nrhos,rhomin,rhomax,myeos,myeosname,mytype,par1,par2):
    assert isinstance(myeos, eosDriver)

    logrhos = linspace(log10(rhomin),log10(rhomax),nrhos)
    eostable = zeros((nrhos,2))
    eostable2 = zeros((nrhos,4))
    energy_shift = 0.0

    print mytype
    
    if(mytype == 'fixed_ye_temp'):

        ye = par2
        temp = par1
        
        eostablename = myeosname+"_eostable_Ye=%06.3f_T=%06.3f.dat" % \
            (par2,par1)
        energy_shift = myeos.h5file['energy_shift'][0]

        for i in range(nrhos):
            myeos.setState({'rho': 10.0**logrhos[i],
                            'ye': ye,
                            'temp': temp})
            
            press = myeos.query('logpress')

            myeos.setState({'rho': 10.0**logrhos[i],
                            'ye': ye,
                            'temp': temp})

            eps = myeos.query('logenergy')
            
            # convert units
            eostable[i,0] = log10(10.0**press * press_gf)
            eostable[i,1] = log10(10.0**eps * eps_gf)

        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()

    elif(mytype == 'c30p0_fixed_Ye'):

        ye = par2

        tempfunc = getTRollFunc(30.0,0.01,14.055,0.375)

        eostablename = myeosname+"_eostable_Ye=%06.3f_c30p0.dat" % \
            (par2)
        energy_shift = myeos.h5file['energy_shift'][0]
        
        for i in range(nrhos):
            temp = tempfunc(logrhos[i])
            myeos.setState({'rho': 10.0**logrhos[i],
                            'ye': ye,
                            'temp': temp})
            
            press = myeos.query('logpress')

            myeos.setState({'rho': 10.0**logrhos[i],
                            'ye': ye,
                            'temp': temp})

            eps = myeos.query('logenergy')
            
            # convert units
            eostable[i,0] = log10(10.0**press * press_gf)
            eostable[i,1] = log10(10.0**eps * eps_gf)

        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()

    elif(mytype == 'c20p0_fixed_Ye'):

        ye = par2

        tempfunc = getTRollFunc(20.0,0.01,14.0-0.07,0.125)

        eostablename = myeosname+"_eostable_Ye=%06.3f_c20p0.dat" % \
            (par2)
        energy_shift = myeos.h5file['energy_shift'][0]
        
        for i in range(nrhos):
            temp = tempfunc(logrhos[i])
            myeos.setState({'rho': 10.0**logrhos[i],
                            'ye': ye,
                            'temp': temp})
            
            press = myeos.query('logpress')

            myeos.setState({'rho': 10.0**logrhos[i],
                            'ye': ye,
                            'temp': temp})

            eps = myeos.query('logenergy')
            
            # convert units
            eostable[i,0] = log10(10.0**press * press_gf)
            eostable[i,1] = log10(10.0**eps * eps_gf)

        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()


    elif(mytype == 'c40p0_fixed_Ye'):

        ye = par2

        tempfunc = getTRollFunc(40.0,0.01,14.25-0.07,0.5)

        eostablename = myeosname+"_eostable_Ye=%06.3f_c40p0.dat" % \
            (par2)
        energy_shift = myeos.h5file['energy_shift'][0]
        
        for i in range(nrhos):
            temp = tempfunc(logrhos[i])
            myeos.setState({'rho': 10.0**logrhos[i],
                            'ye': ye,
                            'temp': temp})
            
            press = myeos.query('logpress')

            myeos.setState({'rho': 10.0**logrhos[i],
                            'ye': ye,
                            'temp': temp})

            eps = myeos.query('logenergy')
            
            # convert units
            eostable[i,0] = log10(10.0**press * press_gf)
            eostable[i,1] = log10(10.0**eps * eps_gf)

        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()

    elif(mytype == 'c30p10_fixed_Ye'):

        ye = par2

        tempfunc = kentaDataTofLogRhoFit1()

        eostablename = myeosname+"_eostable_Ye=%06.3f_c30p10.dat" % \
            (par2)
        energy_shift = myeos.h5file['energy_shift'][0]
        
        for i in range(nrhos):
            temp = tempfunc(logrhos[i])
            myeos.setState({'rho': 10.0**logrhos[i],
                            'ye': ye,
                            'temp': temp})
            
            press = myeos.query('logpress')

            myeos.setState({'rho': 10.0**logrhos[i],
                            'ye': ye,
                            'temp': temp})

            eps = myeos.query('logenergy')
            
            # convert units
            eostable[i,0] = log10(10.0**press * press_gf)
            eostable[i,1] = log10(10.0**eps * eps_gf)

        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()

    elif(mytype == 'c30p5_fixed_Ye'):

        ye = par2

        tempfunc = kentaDataTofLogRhoFit2()

        eostablename = myeosname+"_eostable_Ye=%06.3f_c30p5.dat" % \
            (par2)
        energy_shift = myeos.h5file['energy_shift'][0]
        
        for i in range(nrhos):
            temp = tempfunc(logrhos[i])
            myeos.setState({'rho': 10.0**logrhos[i],
                            'ye': ye,
                            'temp': temp})
            
            press = myeos.query('logpress')

            myeos.setState({'rho': 10.0**logrhos[i],
                            'ye': ye,
                            'temp': temp})

            eps = myeos.query('logenergy')
            
            # convert units
            eostable[i,0] = log10(10.0**press * press_gf)
            eostable[i,1] = log10(10.0**eps * eps_gf)

        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()


    elif(mytype == 'fixed_temp_betaeq'):
        eostablename = myeosname+"_eostable_BetaEq_T=%06.3f.dat" % (par1)

        energy_shift = myeos.h5file['energy_shift'][0]
        temp = par1
        lastPress = -1e-300
        lastEps = None
        for i in range(nrhos):
            ye = myeos.setBetaEqState({'rho': 10.0**logrhos[i],
                                       'temp': temp})
            
            (press,eps) = myeos.query(['logpress','logenergy'])
            if press < lastPress:
                print "WOW, PRESSURE DECREASE WHEN INCREASING DENSITY, THAT'S F****D"
                print "MANUALLY SETTING VALUES TO LAST VALUES"
                press = lastPress
                eps = lastEps
            lastPress = press
            lastEps = eps
            # convert units
            eostable[i,0] = log10(10.0**press * press_gf)
            eostable[i,1] = log10(10.0**eps * eps_gf)
            eostable2[i,0] = eostable[i,0]
            eostable2[i,1] = eostable[i,1]
            eostable2[i,2] = ye
            eostable2[i,3] = temp


            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(eostable2[:,0])):
            sline = "%22.14E %22.14E %22.14E %22.14E %22.14E\n" % \
                (logrhos[i],eostable2[i,0],eostable2[i,1],eostable2[i,2],eostable2[i,3])
            eosfile.write(sline)
        eosfile.close()



    elif(mytype == 'fixed_ye_entropy'):

        ye = par2
        entropy = par1
        
        energy_shift = myeos.h5file['energy_shift'][0]

        eostablename = "eostable_ye=%06.3f_s=%06.3f.dat" % (par2,par1)
        print eostablename
        try: 
            eosin = (numpy.loadtxt(eostablename))
            eostable[:,0] = eosin[:,1]
            eostable[:,1] = eosin[:,2]
            
        except IOError:
            for i in range(nrhos):
                temp = 0.0
                temp = myeos.getTemperatureFromQuantityTYe({'rho': 10.0**logrhos[i],
                                                         'ye': ye,
                                                         'temp': temp},'entropy', entropy)
                myeos.setState({'rho': 10.0**logrhos[i],
                                'ye' : ye,
                                '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)

                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")
        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()


    elif(mytype == 'fixed_entropy_betaeq'):

        energy_shift = myeos.h5file['energy_shift'][0]
        entropy = par1

        eostablename = "eostable_betaeq_s=%06.3f.dat" % (par1)
        print eostablename
        try: 
            eosin = (numpy.loadtxt(eostablename))
            eostable[:,0] = eosin[:,1]
            eostable[:,1] = eosin[:,2]

        except IOError:
            for i in range(nrhos):
                (ye,temp) = \
                    myeos.setConstQuantityAndBetaEqState({'rho': 10.0**logrhos[i]},\
                                                             'entropy',par1)
            
                (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)

                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")
        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()


    elif(mytype == 'poly_G2_K100'):
        eostable[:,0] = log10(100.0*(10.0**logrhos[:]*rho_gf)**2.0)
        eostable[:,1] = log10(10.0**eostable[:,0]/(10.0**logrhos[:]*rho_gf) )

    else:
        print "This kind of table can't be done yet: ",mytype
        sys.exit()
        

    logrhos = log10(10.0**logrhos * rho_gf)
    dlrho = logrhos[1]-logrhos[0]
    return (eostable,energy_shift,dlrho,logrhos)
Beispiel #10
0
    'c40p0': '^',
    'c30p5': 'p',
    'c30p10': 'H',
    'cold': '*'
}

slicesToPlot = [a7, diffMaxRotSlice]
plateauPlots = True

tFuncs = []
scripts = []
if plateauPlots:
    scripts = ['c30p10', 'c30p5', 'cold']
    tFuncs = [
        kentaDataTofLogRhoFit1(),
        kentaDataTofLogRhoFit2(), lambda x: 0.01
    ]
else:
    params40 = (
        40.0,
        14.18,
        0.5,
    )
    params20 = (
        20.0,
        13.93,
        0.25,
    )
    scripts = ['c40p0', 'c20p0', 'cold']
    tFuncs = [
        getTRollFunc(params40[0], 0.01, params40[1], params40[2]),
Beispiel #11
0
           'c30p10': 'H'}

scripts = {'c30p0': deepcopy(modelParamsTemplate.copy()),
           'c20p0': deepcopy(modelParamsTemplate.copy()),
           'c40p0': deepcopy(modelParamsTemplate.copy()),
           'T=00010': deepcopy(modelParamsTemplate.copy()),
           'c30p5': deepcopy(modelParamsTemplate.copy()),
           'c30p10': deepcopy(modelParamsTemplate.copy())}

shen = eosDriver.eosDriver('/home/jeff/work/HShenEOS_rho220_temp180_ye65_version_1.1_20120817.h5')

tfuncs = {'c30p0':  eosDriver.getTRollFunc(30.0, 0.01, 14.055, .375),
           'c20p0': eosDriver.getTRollFunc(20.0, 0.01, 13.93, .25),
           'c40p0': eosDriver.getTRollFunc(40.0, 0.01, 14.18, .5),
           'T=00010': lambda x: 0.01,
           'c30p5': eosDriver.kentaDataTofLogRhoFit2(),
           'c30p10': eosDriver.kentaDataTofLogRhoFit1()}

ye = 0.1
massFraction = .5

def thermalPressureSupport(rho, tfunc):
    shen.setState({'rho': rho, 'temp': 0.01, 'ye': ye})
    cold = shen.query('logpress', deLog10Result=True)

    shen.setState({'rho': rho, 'temp': tfunc(rho), 'ye': ye })
    hot = shen.query('logpress', deLog10Result=True)

    return hot/cold - 1.0

Beispiel #12
0
# print ls220.solveForQuantity({'rho': 1e7, 'temp': 1.0}, 'munu', 0., bounds=None)
# print ls220.solveForQuantity({'rho': 1e15, 'ye': 0.1}, 'entropy', 1., bounds=None)
ye = "BetaEq"
# shen.resetCachedRhobVsEds(getTRollFunc(20., .01, 13.93,.25), ye)
# print shen.cachedRhobVsEd
# mpl.loglog(numpy.power(10.0, shen.cachedRhobVsEd[1]), (numpy.power(10.0,shen.cachedRhobVsEd[0])-numpy.power(10.0, shen.cachedRhobVsEd[1]))/numpy.power(10.0, shen.cachedRhobVsEd[1]))
# mpl.show()
# exit()
shen.resetCachedBetaEqYeVsRhobs(getTRollFunc(20.0, 0.01, 13.93, 0.25), 4.0, 16.0)
shen.resetCachedRhobVsEds(getTRollFunc(20.0, 0.01, 13.93, 0.25), ye)
for ed in [3.0e14, 1.0e15, 2.0e15]:
    led = numpy.log10(ed)

    print shen.rhobFromEnergyDensityWithTofRho(ed, ye, getTRollFunc(20.0, 0.01, 13.93, 0.25))
    tempFunc = lambda x: numpy.log10(kentaDataTofLogRhoFit2()(x))
    tempFunc = lambda x: -2.0
    tempFunc = lambda x: numpy.log10(getTRollFunc(20.0, 0.01, 13.93, 0.25)(x))
    edFunc = lambda x, q: numpy.power(10.0, x) * (1.0 + (numpy.power(10.0, q) - shen.energy_shift) / CGS_C ** 2)
    result = shen.solveForQuantity(
        {"logtemp": 1.0, "ye": ye},
        "logenergy",
        ed,
        bounds=(4.0, 16.0),
        pointAsFunctionOfSolveVar=tempFunc,
        function=edFunc,
    )
    cachedResult = shen.rhobFromEdCached(ed)
    print "result, cachedResult: ", numpy.power(10.0, result), cachedResult
    shen.setBetaEqState({"logtemp": tempFunc(result), "logrho": result})
    eps = (numpy.power(10.0, shen.query("logenergy")) - shen.energy_shift) / CGS_C ** 2