|
6 | 6 | import numpy as np
|
7 | 7 | from yt.frontends.boxlib.api import CastroDataset
|
8 | 8 |
|
9 |
| -''' |
10 |
| -This file tracks the flame front and writes them into a txt file. |
11 | 9 |
|
12 |
| -Usage: ./front_tracker.py plotFiles_* |
13 |
| -''' |
14 |
| - |
15 |
| -def track_flame_front(ds): |
| 10 | +def track_flame_front(ds, metric): |
16 | 11 | '''
|
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. |
20 | 22 | '''
|
21 | 23 |
|
22 | 24 | time = ds.current_time.in_units("ms")
|
23 | 25 |
|
24 |
| - # How to determine the flame front? |
| 26 | + |
| 27 | + ad = ds.all_data() |
| 28 | + |
| 29 | + |
25 | 30 | # 1) Global max temperature: this can be used to track initial
|
26 | 31 | # 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 |
28 | 34 |
|
29 | 35 |
|
30 | 36 | return timeTheta
|
31 | 37 |
|
32 | 38 |
|
33 | 39 | if __name__ == "__main__":
|
| 40 | + parser = argparse.ArgumentParser(description=""" |
| 41 | + This file tracks the flame front and writes them into a txt file. |
| 42 | + """) |
34 | 43 |
|
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.""") |
36 | 53 |
|
| 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) |
37 | 64 | timeThetaArray = []
|
38 |
| - for fname in ts: |
| 65 | + |
| 66 | + for fname in args.fnames: |
39 | 67 | ds = CastroDataset(fname)
|
40 | 68 |
|
41 | 69 | # Get tuple in form (theta, time)
|
42 |
| - timeTheta= track_flame_front(ds) |
| 70 | + timeTheta= track_flame_front(ds, metric) |
43 | 71 | timeThetaArray.append(timeTheta)
|
44 | 72 |
|
45 | 73 | # Sort array by time and write to file
|
|
0 commit comments