diff --git a/code/sample/itape.py b/code/sample/itape.py index 51be562..5d4c11d 100644 --- a/code/sample/itape.py +++ b/code/sample/itape.py @@ -5,37 +5,75 @@ import os, sys import argparse parser = argparse.ArgumentParser() -parser.add_argument("mu_ratio", help="mu1/mu0, ratio between reaction-diffusion layer mu1 and convection-diffusion layer mu0") -parser.add_argument("c_star", help="reference c value seperate reaction-diffusion and convection-diffusion layers") -args = parser.parse_args() +file_parser = argparse.ArgumentParser() + +param_dict = { +"nx" :512, +"l_0" :4., +"int_pr" :400, +"tar_lo" :0.60, +"dt" :0.001, +"sc" :0.75, +"vis" :0.020, +"pre" :2.10E+4, +"ac" :26.7, +"bc" :3., +"u0" :0.21, +"tf" :100., +"dt_uf" :0.4, +"ctmp" :0., +"c_cut" :0.001, +"c_ref" :0.01, +"min_wr" :0., +"prof_wr" :1.0, +"rvis" :1.0, +"cstar" :1.0, +} + +file_parser.add_argument("--default", help="file containing override default values") + +file_args, others = file_parser.parse_known_args() + +if file_args.default is not None: + with open(file_args.default) as df: + try: + for line in df: + k, v = line.split()[:2] + if k in param_dict: + param_dict[k] = v + except ValueError: + pass -# with open("itape.format") as itapeform: - # format = itapeform.read() +for k, v in param_dict.iteritems(): + parser.add_argument("--"+k, default=v) -itape = ''' nx 512 - l_0 4. !3[pi] - int_pr 400 - tar_lo 0.60 - dt 0.001 - sc 0.75 - vis 0.020 !2pi(162)ref !2pi(256)mid !2pi(256)Max !2p(162)Low - pre 2.10E+4 !185.75 !185.75 !316.88 !440.5 !102.69 - ac 26.7 !22.250 !22.25 !22.56 !22.3 !22.39 - bc 3. !7.000 !7.0 !7.0 !7.0 !7.0 - u0 0.21 - tf 100. - dt_uf 0.4 - ctmp 0. !1.0e-14 - c_cut 0.001 !0.012 ! c < c_cut -> wrate = 0. - c_ref 0.01 !0.003 ! - min_wr 0. ! 5.0e-14 - prof_wr 1.0 - rvis {} - cstar {} -''' +args = parser.parse_args(others) -print itape.format( args.mu_ratio, args.c_star ) +params = vars(args) + +itape = ''' nx {0[nx]} + l_0 {0[l_0]} + int_pr {0[int_pr]} + tar_lo {0[tar_lo]} + dt {0[dt]} + sc {0[sc]} + vis {0[vis]} + pre {0[pre]} + ac {0[ac]} + bc {0[bc]} + u0 {0[u0]} + tf {0[tf]} + dt_uf {0[dt_uf]} + ctmp {0[ctmp]} + c_cut {0[c_cut]} + c_ref {0[c_ref]} + min_wr {0[min_wr]} + prof_wr {0[prof_wr]} + rvis {0[rvis]} + cstar {0[cstar]} ''' + +print itape.format( params ) # for i in range(15,60,5): # with open("itape", 'w') as itape: