From 54bd48dca97249a43be1f66b94012c5efb3aeede Mon Sep 17 00:00:00 2001 From: zhi Date: Tue, 27 Jan 2026 11:06:13 -0500 Subject: [PATCH 1/2] update nuc frac plot to make it efficient and update input --- Exec/science/Detonation/analysis/profiles.py | 48 ++++++++++++-------- Exec/science/Detonation/inputs-det-x.nse_net | 5 +- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/Exec/science/Detonation/analysis/profiles.py b/Exec/science/Detonation/analysis/profiles.py index 6aea8b768a..0095dca279 100755 --- a/Exec/science/Detonation/analysis/profiles.py +++ b/Exec/science/Detonation/analysis/profiles.py @@ -156,7 +156,7 @@ def plot_nuc_frac(prefix, nums, skip, limitlabels, xmin, xmax): f = plt.figure() f.set_size_inches(32.0, 20.0) - # Get set of colors to use and apply to plot + # color setup numplots = int(len(nums) / skip) cm = plt.get_cmap('nipy_spectral') 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): if limitlabels > 1: skiplabels = int(numplots / limitlabels) elif limitlabels < 0: - print("Illegal value for limitlabels: %.0f" % limitlabels) - sys.exit() + raise ValueError("Illegal value for limitlabels") else: skiplabels = 1 - pfile = f"{prefix}{nums[1]}" - ds = yt.load(pfile, hint="castro") + # load a dataset to discover species + ds = yt.load(f"{prefix}{nums[0]}", hint="castro") - nuc_list = [f[1] for f in ds.field_list if f[1][0] == "X"] + nuc_list = [f[1] for f in ds.field_list if f[1].startswith("X")] nuc_list.sort(key=nuc_list_filter) N = len(nuc_list) nrows = math.ceil(math.sqrt(N)) ncols = math.ceil(math.sqrt(N)) + # create axes + axes = [] for i in range(N): - ax = f.add_subplot(nrows, ncols, i+1) + ax = f.add_subplot(nrows, ncols, i + 1) ax.set_prop_cycle(cycler('color', hexclist)) + ax.set_ylabel(nuc_list[i]) + ax.set_yscale("log") + if xmax > 0: + ax.set_xlim(xmin, xmax) + axes.append(ax) - index = 0 - for n in range(0, len(nums), skip): + # Loop over different plot files + index = 0 + for n in range(0, len(nums), skip): - pfile = f"{prefix}{nums[n]}" + pfile = f"{prefix}{nums[n]}" + time, x, nuc_prof = get_nuc_profile(pfile) - time, x, nuc_prof = get_nuc_profile(pfile) + label = None + if index % skiplabels == 0: + label = f"t = {time:6.4g} s" - if i == 0 and index % skiplabels == 0: - ax.plot(x, nuc_prof[i], label=f"t = {time:6.4g} s") + # For each plot file, loop over axes to + # plot the species + for i, ax in enumerate(axes): + if label is not None and i == 0: + ax.plot(x, nuc_prof[i], label=label) else: ax.plot(x, nuc_prof[i]) - index = index + 1 - - ax.legend(frameon=False) - ax.set_ylabel(nuc_list[i]) - ax.set_yscale("log") + index += 1 - if xmax > 0: - ax.set_xlim(xmin, xmax) + axes[0].legend(frameon=False) f.tight_layout() f.savefig("det_nuc.png") diff --git a/Exec/science/Detonation/inputs-det-x.nse_net b/Exec/science/Detonation/inputs-det-x.nse_net index 22d83f3865..75fa2ee044 100644 --- a/Exec/science/Detonation/inputs-det-x.nse_net +++ b/Exec/science/Detonation/inputs-det-x.nse_net @@ -106,10 +106,11 @@ integrator.atol_spec = 1.e-8 integrator.rtol_enuc = 1.e-8 integrator.atol_enuc = 1.e-8 -integrator.jacobian = 2 +integrator.jacobian = 1 integrator.ode_max_steps = 1500000 nse.nse_molar_independent = 0 nse.nse_dx_independent = 0 nse.ase_tol = 0.1 -nse.nse_skip_molar = 0 \ No newline at end of file +nse.nse_skip_molar = 0 +nse.solve_nse_e_mode = 2 \ No newline at end of file From 07dedbe514c286dd22b95f18e78aaea12c4ae89d Mon Sep 17 00:00:00 2001 From: zhi Date: Tue, 27 Jan 2026 16:53:44 -0500 Subject: [PATCH 2/2] change var name --- Exec/science/Detonation/analysis/profiles.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Exec/science/Detonation/analysis/profiles.py b/Exec/science/Detonation/analysis/profiles.py index 0095dca279..d34fe941f2 100755 --- a/Exec/science/Detonation/analysis/profiles.py +++ b/Exec/science/Detonation/analysis/profiles.py @@ -174,14 +174,14 @@ def plot_nuc_frac(prefix, nums, skip, limitlabels, xmin, xmax): nuc_list = [f[1] for f in ds.field_list if f[1].startswith("X")] nuc_list.sort(key=nuc_list_filter) - N = len(nuc_list) + N_SPECIES = len(nuc_list) - nrows = math.ceil(math.sqrt(N)) - ncols = math.ceil(math.sqrt(N)) + nrows = math.ceil(math.sqrt(N_SPECIES)) + ncols = math.ceil(math.sqrt(N_SPECIES)) # create axes axes = [] - for i in range(N): + for i in range(N_SPECIES): ax = f.add_subplot(nrows, ncols, i + 1) ax.set_prop_cycle(cycler('color', hexclist)) ax.set_ylabel(nuc_list[i])