-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplot_entropy_1d_window.py
94 lines (81 loc) · 2.78 KB
/
plot_entropy_1d_window.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
from matplotlib import animation
from pylab import *
import pyPLUTO.pload as pp # importing the pyPLUTO pload module.
import pyPLUTO.ploadparticles as pr # importing the pyPLUTO ploadparticles module.
from matplotlib.animation import FuncAnimation
from getScalarArray_1d import getScalarArray_1d
def plot_entropy_1d_window(ntot, w_dir, UNIT_DENSITY, UNIT_LENGTH, UNIT_VELOCITY, xmin1, xmax1, datatype, axis = 1, point1 = 0.5, point2 = 0.5):
plt.rcParams.update({'font.size': 15})
#plt.rcParams['text.usetex'] = True
f1 = plt.figure(figsize=[10,8])
plt.rcParams["figure.dpi"] = 500
ax = f1.add_subplot(111)
gam = 5.0/3.0
D = pp.pload(ntot, varNames = ['rho','prs'], w_dir = w_dir, datatype=datatype) # Load fluid data.
Rho = getScalarArray_1d(D.rho, UNIT_DENSITY, axis, point1, point2)
Prs = getScalarArray_1d(D.prs, UNIT_DENSITY*UNIT_VELOCITY*UNIT_VELOCITY, axis, point1, point2)
nx = Rho.shape[0]
S = np.zeros([nx])
for i in range(nx):
S[i] = Prs[i] / pow(Rho[i], gam)
minS = np.amin(S)
maxS = np.amax(S)
N1 = 0
N2 = 1
if(axis == 1):
xmin = D.x1.min()*UNIT_LENGTH
xmax = D.x1.max()*UNIT_LENGTH
dx = (xmax - xmin) / Rho.shape[0]
x = dx * range(Rho.shape[0]) + xmin
N1 = 0
N2 = Rho.shape[0]-1
for i in range(Rho.shape[0]):
if(x[i] > xmin1):
N1 = i;
break;
for i in range(Rho.shape[0]):
if(x[i] > xmax1):
N2 = i-1;
break;
elif(axis == 2):
xmin = D.x2.min() * UNIT_LENGTH
xmax = D.x2.max() * UNIT_LENGTH
dx = (xmax - xmin) / Rho.shape[0]
x = dx * range(Rho.shape[0]) + xmin
N1 = 0
N2 = Rho.shape[0] - 1
for i in range(Rho.shape[0]):
if(x[i] > xmin1):
N1 = i;
break;
for i in range(Rho.shape[0]):
if(x[i] > xmax1):
N2 = i-1;
break;
elif(axis == 3):
xmin = D.x3.min() * UNIT_LENGTH
xmax = D.x3.max() * UNIT_LENGTH
dx = (xmax - xmin) / Rho.shape[0]
x = dx * range(Rho.shape[0]) + xmin
N1 = 0
N2 = Rho.shape[0] - 1
for i in range(Rho.shape[0]):
if(x[i] > xmin1):
N1 = i;
break;
for i in range(Rho.shape[0]):
if(x[i] > xmax1):
N2 = i-1;
break;
else:
print("wrong axis")
return
ax.set_xlabel(r'$x~cm$', fontsize=40, fontweight='bold')
ax.set_ylabel(r'$S$', fontsize=40,fontweight='bold')
ax.minorticks_on()
ax.set_yscale("log")
#plt.axis([0.0,1.0,0.0,1.0])
plt.plot(x[N1:N2], S[N1:N2])
#plt.show()
plt.savefig('density_1d_window.png')
plt.close()