Skip to content

Commit 45adae7

Browse files
committed
update
1 parent 0284c2a commit 45adae7

File tree

2 files changed

+44
-14
lines changed

2 files changed

+44
-14
lines changed

Diff for: Exec/science/xrb_spherical/analysis/front_tracker.py

+42-14
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,68 @@
66
import numpy as np
77
from yt.frontends.boxlib.api import CastroDataset
88

9-
'''
10-
This file tracks the flame front and writes them into a txt file.
119

12-
Usage: ./front_tracker.py plotFiles_*
13-
'''
14-
15-
def track_flame_front(ds):
10+
def track_flame_front(ds, metric):
1611
'''
17-
This script tracks the flame front position for a given dataset.
18-
It returns a tuple of the form: (Time, Theta)
19-
Note: time is in milisecond.
12+
This function tracks the flame front position for a given dataset.
13+
It returns a tuple of the form: (Time (in ms), Theta)
14+
15+
Procedure to determine flame front:
16+
1) User selects e a quantity to use as a metric: enuc or Temp
17+
2) Determine the global max of that quantity
18+
3) Determine the theta position of the cell that contains the global max
19+
4) Do a radial average of the data set to convert to 1D as a function of theta
20+
5) Determine flame front at theta where the metric quantity drops to
21+
metric_number * global_max of that quantity.
2022
'''
2123

2224
time = ds.current_time.in_units("ms")
2325

24-
# How to determine the flame front?
26+
27+
ad = ds.all_data()
28+
29+
2530
# 1) Global max temperature: this can be used to track initial
2631
# detonation resulted from the initial temperature perturbation
27-
# 2) Use vertically averaged max enuc to determine the actual flame front
32+
# 2) Use radially averaged enuc then find flame front is determined by
33+
# when the averaged enuc drops below some percentage of max global enuc
2834

2935

3036
return timeTheta
3137

3238

3339
if __name__ == "__main__":
40+
parser = argparse.ArgumentParser(description="""
41+
This file tracks the flame front and writes them into a txt file.
42+
""")
3443

35-
ts = sys.argv[1:]
44+
parser.add_argument('--fnames', nargs='+', type=str,
45+
help="Dataset file names for tracking flame front.")
46+
parser.add_argument('--field', '-f', default="enuc", type=str,
47+
metavar="{enuc, Temp}",
48+
help="""field parameter used as metric to determine flame front.
49+
Choose between {enuc, Temp}""")
50+
parser.add_argument('--percent', '-p', default=0.001, type=float,
51+
help="""Float number between (0, 1]. Representing the percent of
52+
the global maximum of the field quantity used to track the flame.""")
3653

54+
args = parser.parse_args()
55+
56+
metric_quantities = ["enuc", "Temp"]
57+
if args.field not in metric_quantities:
58+
parser.error("field must be either enuc or Temp")
59+
60+
if args.percent <= 0.0 or args.percent > 1.0:
61+
parser.error("metric must be a float between (0, 1]")
62+
63+
metric = (args.field, args.percent)
3764
timeThetaArray = []
38-
for fname in ts:
65+
66+
for fname in args.fnames:
3967
ds = CastroDataset(fname)
4068

4169
# Get tuple in form (theta, time)
42-
timeTheta= track_flame_front(ds)
70+
timeTheta= track_flame_front(ds, metric)
4371
timeThetaArray.append(timeTheta)
4472

4573
# Sort array by time and write to file

Diff for: Exec/science/xrb_spherical/analysis/r_profile.py

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
for theta in thetas:
4242
# simply go from (rmin, theta) -> (rmax, theta). Doesn't need to convert to physical R-Z
4343
ray = ds.ray((rmin, theta, 0*cm), (rmax, theta, 0*cm))
44+
45+
# sort by "t", which goes from 0 to 1 representing the spatial order.
4446
isrt = np.argsort(ray["t"])
4547
axes[i].plot(ray['r'][isrt], ray[f][isrt], label=r"$\theta$ = {:.4f}".format(float(theta)))
4648

0 commit comments

Comments
 (0)