def test_bdf4(): with open(join(dirname(__file__), "eddy_uv.json")) as f: base = json.load(f) base["prefix"] = "test_bdf4" base["torder"] = 4 sweep = {"courant" : [0.5, 0.25, 0.125]} overrides = list(outer_product(sweep)) for ov in overrides: ov["name"] = work_name(base["prefix"], ov) workdir = join(base_dir, base["prefix"]) configs = [configure(base, ov, join(base_dir, ov["name"])) for ov in overrides] res = [series(config, tusr) for config in configs] run_all(res, base) errs = {} for config in configs: with open(join(config["workdir"], "{}-0.stdout".format(config["name"]))) as f: test = f.readlines() errs[config["courant"]] = np.max(np.abs(grep_log(test, "X err", pos=2)[10:])) assert errs[.5] / errs[.25] > 12 assert errs[.5] / errs[.25] < 24 assert errs[.25] / errs[.125] > 12 assert errs[.25] / errs[.125] < 24 return
def test_bdf3(): with open(join(dirname(__file__), "eddy_uv.json")) as f: base = json.load(f) base["prefix"] = "test_bdf3" base["torder"] = 3 sweep = {"courant": [0.5, 0.25, 0.125]} overrides = list(outer_product(sweep)) for ov in overrides: ov["name"] = work_name(base["prefix"], ov) workdir = join(base_dir, base["prefix"]) configs = [ configure(base, ov, join(base_dir, ov["name"])) for ov in overrides ] res = [series(config, tusr) for config in configs] run_all(res, base) errs = {} for config in configs: with open(join(config["workdir"], "{}-0.stdout".format(config["name"]))) as f: test = f.readlines() errs[config["courant"]] = np.max( np.abs(grep_log(test, "X err", pos=2)[10:])) assert errs[.5] / errs[.25] > 6 assert errs[.5] / errs[.25] < 12 assert errs[.25] / errs[.125] > 6 assert errs[.25] / errs[.125] < 12 return
def test_sweep(): with open(join(dirname(__file__), "LST.json"), "r") as f: base = json.load(f) with open(join(dirname(__file__), "LST.sweep"), "r") as f: sweeps = json.load(f) with open(join(dirname(__file__), "LST.tusr"), "r") as f: tusr = f.read() base["prefix"] = sweeps["prefix"] del sweeps["prefix"] overrides = list(outer_product(sweeps)) for ov in overrides: ov["name"] = work_name(base["prefix"], ov) workdirs = [join(getcwd(), x["name"]) for x in overrides] configs = [configure(base, override, workdir) for override, workdir in zip(overrides, workdirs)] res = [series(config, tusr, job_step = 25) for config in configs] final = run_all(res, base)
def test_sweep(): with open(join(dirname(__file__), "LST.json"), "r") as f: base = json.load(f) with open(join(dirname(__file__), "LST.sweep"), "r") as f: sweeps = json.load(f) with open(join(dirname(__file__), "LST.tusr"), "r") as f: tusr = f.read() base["prefix"] = sweeps["prefix"] del sweeps["prefix"] overrides = list(outer_product(sweeps)) for ov in overrides: ov["name"] = work_name(base["prefix"], ov) workdirs = [join(getcwd(), "s", x["name"]) for x in overrides] configs = [configure(base, override, workdir) for override, workdir in zip(overrides, workdirs)] res = [series(config, tusr, job_step = 25) for config in configs] final = run_all(res, base)
def test_outer_product(): opts = {"foo": ["bar",], "spam": ["eggs", "spam"]} outer = list(outer_product(opts)) assert len(outer) == 2 assert outer[0]["spam"] != outer[1]["spam"]
from nekpy.dask.tasks import configure from nekpy.dask.utils import outer_product, work_name from nekpy.dask import run_all from sys import argv with open(argv[1], "r") as f: base = json.load(f) with open(argv[2], "r") as f: sweeps = json.load(f) base["prefix"] = sweeps["prefix"] del sweeps["prefix"] # Take simple outer product of contents of sweep file candidates = list(outer_product(sweeps)) # Filter out the cases we don't want overrides = [] for c in candidates: overrides.append(c) # Tune the remaining cases aspect = 4 for ov in overrides: ov["name"] = work_name(base["prefix"], ov) ov['viscosity'] = ov['nu'] * 1.0e-4 ov['conductivity'] = ov['viscosity'] / ov['Sc'] from os.path import join workdirs = [join(getcwd(), x["name"]) for x in overrides]
from nekpy.dask.tasks import configure from nekpy.dask.utils import outer_product, work_name from nekpy.dask import run_all from sys import argv with open(argv[1], "r") as f: base = json.load(f) with open(argv[2], "r") as f: sweeps = json.load(f) base["prefix"] = sweeps["prefix"] del sweeps["prefix"] # Take simple outer product of contents of sweep file candidates = list(outer_product(sweeps)) # Filter out the cases we don't want overrides = [] for c in candidates: overrides.append(c) # Tune the remaining cases aspect = 4 for ov in overrides: ov["name"] = work_name(base["prefix"], ov) ov['viscosity'] = ov['nu'] * 1.0e-4 ov['conductivity'] = ov['viscosity'] / ov['Sc'] from os.path import join workdirs = [join(getcwd(), x["name"]) for x in overrides]