Skip to content

Commit 3721ee9

Browse files
committed
update rhoX_ash as derived field
1 parent 7d32e19 commit 3721ee9

File tree

1 file changed

+40
-0
lines changed
  • Exec/science/xrb_spherical/analysis

1 file changed

+40
-0
lines changed

Exec/science/xrb_spherical/analysis/slice.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,41 @@
77
import math
88
from typing import List, Optional
99
import numpy as np
10+
import pynucastro as pyna
1011
import matplotlib.pyplot as plt
1112
from mpl_toolkits.axes_grid1 import ImageGrid
1213
from yt.frontends.boxlib.api import CastroDataset
1314
from yt.units import km
1415

16+
def _ash(field, data):
17+
'''
18+
Computes the rho X_ash.
19+
Here ash is anything heavier than Oxygen, but exclude Fe and Ni
20+
'''
21+
22+
ds = data.ds
23+
field_list = ds.field_list
24+
25+
# If X(ash) is directly stored, then just use that
26+
if ("boxlib", "X(ash)") in field_list:
27+
return data["boxlib", "X(ash)"] * data["boxlib", "density"]
28+
29+
# If we cannot find X(ash) as a available field then compute manually
30+
rhoAsh = 0
31+
for f in field_list:
32+
# If the first two letters are "X(", then we're dealing with species massfractions
33+
if f[1][:2] == "X(":
34+
# Then extract out what species we have, assuming the format is "X(...)"
35+
speciesName = f[1][2:-1]
36+
nuc = pyna.Nucleus(speciesName)
37+
38+
# Include elements beyond oxygen but don't include Ni56
39+
if nuc.Z > 8.0 and nuc.Z != 56:
40+
rhoAsh += data["boxlib", "density"] * data[f]
41+
42+
return rhoAsh
43+
44+
1545
def extract_info(ds,
1646
loc: str = "top", widthScale: float = 3.0,
1747
widthRatio: float = 1.0,
@@ -287,6 +317,12 @@ def slice(fnames:list[str], fields:list[str],
287317
theta=theta,
288318
displace_theta=displace_theta,
289319
show_full_star=show_full_star)
320+
321+
#add rhoX_ash as a derived field
322+
ds.add_field(("gas", "ash"), function=_ash,
323+
display_name=r"\rho X\left(ash\right)",
324+
units="auto", sampling_type="cell")
325+
290326
for i, field in enumerate(fields):
291327
# Plot each field parameter
292328
sp = yt.SlicePlot(ds, 'phi', field, width=box_widths, fontsize=20)
@@ -305,6 +341,10 @@ def slice(fnames:list[str], fields:list[str],
305341
sp.set_zlim(field, 4, 8)
306342
sp.set_log(field, False)
307343
sp.set_cmap(field, "plasma_r")
344+
elif f == "ash":
345+
sp.set_zlim(f, 1.e-2, 1e6)
346+
sp.set_log(f, True)
347+
sp.set_cmap(f, "plasma_r")
308348
elif field == "enuc":
309349
sp.set_zlim(field, 1.e15, 1.e20)
310350
sp.set_log(field, linthresh=1.e11)

0 commit comments

Comments
 (0)