-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestrhoptemp.py
executable file
·165 lines (125 loc) · 3.39 KB
/
testrhoptemp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/usr/bin/env python2
"""
This script plots the results of testrhoptemp.c.
"""
from matplotlib import *
rcParams['font.family'] = 'serif'
from numpy import *
from matplotlib.pyplot import *
"""
Setup the plot.
"""
# Set a font
rcParams['font.family'] = 'serif'
rcParams['font.size'] = 10.0
# Legend
# mpl.rcParams['legend.handlelength'] = 2.9
rcParams['legend.handlelength'] = 0.5
rcParams['legend.frameon'] = False
rcParams['legend.numpoints'] = 1
rcParams['legend.scatterpoints'] = 1
# Adjust axes line width
rcParams['axes.linewidth'] = 0.5
# Adjust ticks
rcParams['xtick.major.size'] = 4
rcParams['xtick.minor.size'] = 2
rcParams['ytick.major.size'] = 4
rcParams['ytick.minor.size'] = 2
# Adjust Font Size
rcParams['xtick.labelsize'] = 'xx-small'
rcParams['ytick.labelsize'] = 'xx-small'
rcParams['axes.labelsize'] = 'x-small'
# Set Up Figure, Single Column MNRAS
fig = gcf()
ax = gca()
fig, ax = subplots(1,1)
fig.set_size_inches(8.27*0.39,8.27*(6./8.)*0.39)
# Physical constants used for unit convertion (cgs)
KBOLTZ = 1.38e-16 # bolzman constant in cgs
MHYDR = 1.67e-24 # mass of hydrogen atom in grams
MSOLG = 1.99e33 # solar mass in grams
GCGS = 6.67e-8 # G in cgs
KPCCM = 3.085678e21 # kiloparsec in centimeters
# These two values define the unit system we use
dKpcUnit = 2.06701e-13 # kiloparsec in code units
dMsolUnit = 4.80438e-08 # solar mass in code units
# Mass of Earth
MEarth = 5.98e27 # g
MSun = 1.989e33 # g
"""
Convert kboltz/mhydrogen to system units, assuming that
G == 1.
"""
# code energy per unit mass --> erg per g
dErgPerGmUnit = GCGS*dMsolUnit*MSOLG/(dKpcUnit*KPCCM)
# code density --> g per cc
dGmPerCcUnit = (dMsolUnit*MSOLG)/pow(dKpcUnit*KPCCM,3.0)
# code time --> seconds
dSecUnit = sqrt(1/(dGmPerCcUnit*GCGS))
# The units are not nescessary but can be derived from the quanities above
Lunit = dKpcUnit*KPCCM
Munit = dMsolUnit*MSOLG
# Reference density (material dependent)
rho0 = 2.7
us = 3.5e10
us2 = 1.8e11
"""
rho_min = 1e-4
rho_max = 10.0
u_min = 0.0
u_max = 25.0
rho_min = 1e-4
rho_max = 8.0602
u_min = 0.0
u_max = 19.8035
"""
P_min = 0.0
P_max = 1e3
T_min = 0.0
T_max = 1e3
rho_min = 1e-4
rho_max = 8.0
"""
# Convert to cgs
rho_min *= dGmPerCcUnit
rho_max *= dGmPerCcUnit
u_min *= dErgPerGmUnit
u_max *= dErgPerGmUnit
print dGmPerCcUnit
print dErgPerGmUnit
print "rho_min=", rho_min, "rho_max=", rho_max
print "u_min =", u_min, "u_max =", u_max
"""
"""
Plot rho(P, T).
"""
data = loadtxt('testrhoptemp.txt')
print where(fabs(data) < 1e-10)
imshow(data, origin='lower', extent=(P_min, P_max, T_min, T_max), aspect='auto')
xlabel("Pressure [code units]")
ylabel("Temperature [K]")
colorbar()
savefig('testrhoptemp.png', dpi=300, bbox_inches='tight')
fig.clear()
"""
Plot P(rho, T)-P.
"""
data = loadtxt('testrhoptemp_diff.txt')
print where(fabs(data) < 1e-10)
imshow(data, origin='lower', extent=(P_min, P_max, T_min, T_max), aspect='auto')
xlabel("Pressure [code units]")
ylabel("Temperature [K]")
colorbar()
savefig('testrhoptemp_diff.png', dpi=300, bbox_inches='tight')
fig.clear()
"""
Plot rho(P, T)-rho.
"""
data = loadtxt('testrhoptemp_rhot.txt')
print where(fabs(data) < 1e-10)
imshow(data, origin='lower', extent=(rho_min, rho_max, T_min, T_max), aspect='auto')
xlabel("Density [code units]")
ylabel("Temperature [K]")
colorbar()
savefig('testrhoptemp_rhot.png', dpi=300, bbox_inches='tight')
show()