Beispiel #1
0
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
Beispiel #2
0
def test_restart_long():
    with open(join(dirname(__file__), "LST.json")) as f:
        base = json.load(f)
    base["prefix"] = "test_restart_long"

    workdir = join(base_dir, base["prefix"])
    config = configure(base, {'name': base["prefix"]}, workdir)
    res = series(config, tusr, job_time=0.25)
    run_all([
        res,
    ], base)[0]

    with open(join(workdir, "{}-3.stdout".format(config["name"]))) as f:
        test = f.readlines()
    with open(join(dirname(__file__), "LST_ref.out")) as f:
        ref = f.readlines()

    tests = grep_log(test, "Maximum scalar")
    refs = grep_log(ref, "Maximum scalar")
    max_scalar_diff = np.max(np.abs(tests[-1] - refs[-1]))
    assert max_scalar_diff < 1.e-9

    tests = grep_log(test, "Maximum velocity")
    refs = grep_log(ref, "Maximum velocity")
    max_velocity_diff = np.max(np.abs(tests[-1] - refs[-1]))
    assert max_velocity_diff < 1.e-9

    return
Beispiel #3
0
def test_restart_long():
    with open(join(dirname(__file__), "LST.json")) as f:
        base = json.load(f)
    base["prefix"] = "test_restart_long"

    workdir = join(base_dir, base["prefix"])
    config = configure(base, {'name': base["prefix"]}, workdir)
    res = series(config, tusr, job_time = 0.25)
    run_all([res,], base)[0]

    with open(join(workdir, "{}-3.stdout".format(config["name"]))) as f:
        test = f.readlines()    
    with open(join(dirname(__file__), "LST_ref.out")) as f:
        ref = f.readlines()

    tests = grep_log(test, "Maximum scalar")
    refs  = grep_log(ref,  "Maximum scalar")
    max_scalar_diff = np.max(np.abs(tests[-1]-refs[-1]))
    assert max_scalar_diff < 1.e-9

    tests = grep_log(test, "Maximum velocity")
    refs  = grep_log(ref, "Maximum velocity")
    max_velocity_diff = np.max(np.abs(tests[-1]-refs[-1]))
    assert max_velocity_diff < 1.e-9

    return
Beispiel #4
0
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
Beispiel #5
0
def test_single():
    with open(join(dirname(__file__), "eddy_uv.json")) as f:
        base = json.load(f)
    base["prefix"] = "test_single"

    workdir = join(base_dir, base["prefix"])
    config = configure(base, {'name': base["prefix"]}, workdir)
    res = series(config, tusr)
    run_all([res,], base)[0]

    with open(join(workdir, "{}-0.stdout".format(config["name"]))) as f:
        test = f.readlines()    

    errs = grep_log(test, "X err", pos=2)[10:]
    assert np.max(np.abs(errs)) < 2.0e-08

    return
Beispiel #6
0
def old_test(name):
    with open(join(dirname(__file__), "{}.json".format(name))) as f:
        base = json.load(f)
    base["prefix"] = "test_{}".format(name)
    workdir = join(base_dir, base["prefix"])
    config = configure(base, {'name': base["prefix"]}, workdir)
    res = series(config, tusr)
    run_all([res,], base)[0]

    with open(join(workdir, "{}-0.stdout".format(base["prefix"]))) as f:
        test = f.readlines()    

    with open(join(dirname(__file__), "{}_ref.out".format(name))) as f:
        ref = f.readlines()

    ndiff(test, ref)

    return
Beispiel #7
0
def test_single():
    with open(join(dirname(__file__), "eddy_uv.json")) as f:
        base = json.load(f)
    base["prefix"] = "test_single"

    workdir = join(base_dir, base["prefix"])
    config = configure(base, {'name': base["prefix"]}, workdir)
    res = series(config, tusr)
    run_all([
        res,
    ], base)[0]

    with open(join(workdir, "{}-0.stdout".format(config["name"]))) as f:
        test = f.readlines()

    errs = grep_log(test, "X err", pos=2)[10:]
    assert np.max(np.abs(errs)) < 2.0e-08

    return
Beispiel #8
0
def old_test(name):
    with open(join(dirname(__file__), "{}.json".format(name))) as f:
        base = json.load(f)
    base["prefix"] = "test_{}".format(name)
    workdir = join(base_dir, base["prefix"])
    config = configure(base, {'name': base["prefix"]}, workdir)
    res = series(config, tusr)
    run_all([
        res,
    ], base)[0]

    with open(join(workdir, "{}-0.stdout".format(base["prefix"]))) as f:
        test = f.readlines()

    with open(join(dirname(__file__), "{}_ref.out".format(name))) as f:
        ref = f.readlines()

    ndiff(test, ref)

    return
Beispiel #9
0
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)
Beispiel #10
0
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)
Beispiel #11
0
#candidates = [{"nodes" : 2**x} for x in range(6)]
candidates = [{"nodes" : x} for x in job_sizes]

# Filter out the cases we don't want
overrides = []
for c in candidates:
    overrides.append(c)

# Tune the remaining cases
for ov in overrides:
    ov["name"] = work_name(base["prefix"], ov)
    ov["job_name"] = ov["name"] + "-0" 
    span_size = 16
    nelm = ov["nodes"] * 2048
    aspect = nelm*4 / span_size**3
    ov["shape_mesh"] = [span_size, span_size, int(aspect / 4 * span_size)]
    ov["extent_mesh"] = [0.5, 0.5, 1.0 * aspect]
    ov["procs"] = 64*ov["nodes"]
    ov["io_files"] = -ov["nodes"]

from os.path import join
results = []
for ov in overrides:
    workdir = join(getcwd(), ov["name"])
    config = configure(base, ov, workdir)
    input_files = prepare(config, tusr)
    res = run(config, nekmpi_path, dep=input_files)
    results.append(res)

final = run_all(results, base)
# Take simple outer product of contents of sweep file
candidates = [{"nodes": 2**x} for x in range(3)]

# Filter out the cases we don't want
overrides = []
for c in candidates:
    overrides.append(c)

# Tune the remaining cases
for ov in overrides:
    ov["name"] = work_name(base["prefix"], ov)
    ov["job_name"] = ov["name"] + "-0"
    span_size = 16
    nelm = ov["nodes"] * 2048
    aspect = nelm * 4 / span_size**3
    ov["shape_mesh"] = [span_size, span_size, int(aspect / 4 * span_size)]
    ov["extent_mesh"] = [0.5, 0.5, 1.0 * aspect]
    ov["procs"] = 64 * ov["nodes"]
    ov["io_files"] = -ov["nodes"]

from os.path import join
results = []
for ov in overrides:
    workdir = join(getcwd(), ov["name"])
    config = configure(base, ov, workdir)
    input_files = prepare(config, tusr)
    res = run(config, nekmpi_path, dep=input_files)
    results.append(res)

final = run_all(results, base)
Beispiel #13
0
base["prefix"] = "test_lsd" #sweeps["prefix"]
base["name"] = "test_lsd"
#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["shape_mesh"] = [ov["elms"], ov["elms"], aspect*ov["elms"]]
#    nodes = 1 #max(1, int(4 * (ov["order"]*ov["elms"])**3 / 8388608))
#    ov["procs"] = 4*nodes
#    ov["io_files"] = -nodes
#    ov["dt"] = (2/(ov["elms"]*(ov["order"]-1)**2))/0.0558519

from os.path import join
overrides = [base,]
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_time = 2.0) for config in configs]
final = run_all(res, base, get=get_sync)

Beispiel #14
0
# 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]
configs = [
    configure(base, override, workdir)
    for override, workdir in zip(overrides, workdirs)
]

data_table = {}

max_index = -1
height = 'H_exp'
for p, wd in zip(configs, workdirs):
    path = join(wd, "{}-results".format(p['name']))
    print(path)
    if exists(path):
        c = Chest(path=path)
        sc = CachedSlict(c)
        times = sc[:, height].keys()[:max_index]
        data_table[p['viscosity'], p['conductivity'], 'time'] = np.array(times)