Skip to content

Commit 906fc9d

Browse files
authored
fix detonation plotting script for nuc massfractions (#3200)
previously it was reading in the plot file for plotting every isotope. Now read in the plot file and do plotting for all species.
1 parent a0a0ebd commit 906fc9d

File tree

2 files changed

+35
-26
lines changed

2 files changed

+35
-26
lines changed

Exec/science/Detonation/analysis/profiles.py

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def plot_nuc_frac(prefix, nums, skip, limitlabels, xmin, xmax):
156156
f = plt.figure()
157157
f.set_size_inches(32.0, 20.0)
158158

159-
# Get set of colors to use and apply to plot
159+
# color setup
160160
numplots = int(len(nums) / skip)
161161
cm = plt.get_cmap('nipy_spectral')
162162
clist = [cm(0.95*i/numplots) for i in range(numplots + 1)]
@@ -165,45 +165,53 @@ def plot_nuc_frac(prefix, nums, skip, limitlabels, xmin, xmax):
165165
if limitlabels > 1:
166166
skiplabels = int(numplots / limitlabels)
167167
elif limitlabels < 0:
168-
print("Illegal value for limitlabels: %.0f" % limitlabels)
169-
sys.exit()
168+
raise ValueError("Illegal value for limitlabels")
170169
else:
171170
skiplabels = 1
172171

173-
pfile = f"{prefix}{nums[1]}"
174-
ds = yt.load(pfile, hint="castro")
172+
# load a dataset to discover species
173+
ds = yt.load(f"{prefix}{nums[0]}", hint="castro")
175174

176-
nuc_list = [f[1] for f in ds.field_list if f[1][0] == "X"]
175+
nuc_list = [f[1] for f in ds.field_list if f[1].startswith("X")]
177176
nuc_list.sort(key=nuc_list_filter)
178-
N = len(nuc_list)
177+
N_SPECIES = len(nuc_list)
179178

180-
nrows = math.ceil(math.sqrt(N))
181-
ncols = math.ceil(math.sqrt(N))
179+
nrows = math.ceil(math.sqrt(N_SPECIES))
180+
ncols = math.ceil(math.sqrt(N_SPECIES))
182181

183-
for i in range(N):
184-
ax = f.add_subplot(nrows, ncols, i+1)
182+
# create axes
183+
axes = []
184+
for i in range(N_SPECIES):
185+
ax = f.add_subplot(nrows, ncols, i + 1)
185186
ax.set_prop_cycle(cycler('color', hexclist))
187+
ax.set_ylabel(nuc_list[i])
188+
ax.set_yscale("log")
189+
if xmax > 0:
190+
ax.set_xlim(xmin, xmax)
191+
axes.append(ax)
186192

187-
index = 0
188-
for n in range(0, len(nums), skip):
193+
# Loop over different plot files
194+
index = 0
195+
for n in range(0, len(nums), skip):
189196

190-
pfile = f"{prefix}{nums[n]}"
197+
pfile = f"{prefix}{nums[n]}"
198+
time, x, nuc_prof = get_nuc_profile(pfile)
191199

192-
time, x, nuc_prof = get_nuc_profile(pfile)
200+
label = None
201+
if index % skiplabels == 0:
202+
label = f"t = {time:6.4g} s"
193203

194-
if i == 0 and index % skiplabels == 0:
195-
ax.plot(x, nuc_prof[i], label=f"t = {time:6.4g} s")
204+
# For each plot file, loop over axes to
205+
# plot the species
206+
for i, ax in enumerate(axes):
207+
if label is not None and i == 0:
208+
ax.plot(x, nuc_prof[i], label=label)
196209
else:
197210
ax.plot(x, nuc_prof[i])
198211

199-
index = index + 1
200-
201-
ax.legend(frameon=False)
202-
ax.set_ylabel(nuc_list[i])
203-
ax.set_yscale("log")
212+
index += 1
204213

205-
if xmax > 0:
206-
ax.set_xlim(xmin, xmax)
214+
axes[0].legend(frameon=False)
207215

208216
f.tight_layout()
209217
f.savefig("det_nuc.png")

Exec/science/Detonation/inputs-det-x.nse_net

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,11 @@ integrator.atol_spec = 1.e-8
106106
integrator.rtol_enuc = 1.e-8
107107
integrator.atol_enuc = 1.e-8
108108

109-
integrator.jacobian = 2
109+
integrator.jacobian = 1
110110
integrator.ode_max_steps = 1500000
111111

112112
nse.nse_molar_independent = 0
113113
nse.nse_dx_independent = 0
114114
nse.ase_tol = 0.1
115-
nse.nse_skip_molar = 0
115+
nse.nse_skip_molar = 0
116+
nse.solve_nse_e_mode = 2

0 commit comments

Comments
 (0)