Beispiel #1
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 #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 ndiff(test, ref):
    tests = grep_log(test, "Maximum scalar") 
    refs  = grep_log(ref, "Maximum scalar") 
    assert tests.shape[0] == refs.shape[0]
    max_scalar_diff = np.max(np.abs(tests-refs))
    assert max_scalar_diff < 1.e-9

    tests = grep_log(test, "Maximum velocity")
    refs  = grep_log(ref, "Maximum velocity")
    assert tests.shape[0] == refs.shape[0]
    max_velocity_diff = np.max(np.abs(tests-refs))
    assert max_velocity_diff < 1.e-9
    return
Beispiel #4
0
def ndiff(test, ref):
    tests = grep_log(test, "Maximum scalar")
    refs = grep_log(ref, "Maximum scalar")
    assert tests.shape[0] == refs.shape[0]
    max_scalar_diff = np.max(np.abs(tests - refs))
    assert max_scalar_diff < 1.e-9

    tests = grep_log(test, "Maximum velocity")
    refs = grep_log(ref, "Maximum velocity")
    assert tests.shape[0] == refs.shape[0]
    max_velocity_diff = np.max(np.abs(tests - refs))
    assert max_velocity_diff < 1.e-9
    return
Beispiel #5
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 #6
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 #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 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