예제 #1
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "broken-dam-old.inp")
    gold = tenv.output("broken-dam-old_golden/broken-dam-old.h5")
    time = output.time(2)

    # test final cycle number
    cycle = output.cycle(2)
    cycleg = gold.cycle(2)
    status = "PASS" if cycle == cycleg else "FAIL"
    print("{:s} : matching final cycle numbers".format(status))
    if cycle != cycleg: nfail += 1

    # test final fluid volume fraction
    vof = output.field(2, "VOF")[:, 0]
    vofg = gold.field(2, "VOF")[:, 0]
    nfail += truchas.compare_max(vof, vofg, 1e-9, "vof", time)

    # test final velocity
    vel = output.field(2, "Z_VC")
    velg = gold.field(2, "Z_VC")
    nfail += truchas.compare_max(vel[:, 0], velg[:, 0], 1e-9, "vel-x", time)
    nfail += truchas.compare_max(vel[:, 1], velg[:, 1], 1e-9, "vel-y", time)

    truchas.report_summary(nfail)
    return nfail
예제 #2
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "diverging-duct-old-1c.inp")
    xc = output.centroids()
    time = output.time(2)

    # pressure
    pressure = output.field(2, "Z_P")
    pex = 2.5 - 2 / (xc[:, 1]**2 + 0.5 * (xc[:, 0] + xc[:, 2])**2)
    nfail += truchas.compare_max_rel(pressure, pex, 0.16, "pressure", time)

    # velocity
    velocity = output.field(2, "Z_VC")
    uex = 0.5 * (xc[:, 0] + xc[:, 2]) / (xc[:, 1]**2 + 0.5 *
                                         (xc[:, 0] + xc[:, 2])**2)
    vex = xc[:, 1] / (xc[:, 1]**2 + 0.5 * (xc[:, 0] + xc[:, 2])**2)
    uerr = (velocity[:, 0] - uex) / max(abs(uex))
    verr = (velocity[:, 1] - vex) / max(abs(vex))
    werr = (velocity[:, 2] - uex) / max(abs(uex))
    nfail += truchas.compare_max(uerr, 0, 0.02, "x-velocity", time)
    nfail += truchas.compare_max(verr, 0, 0.1, "y-velocity", time)
    nfail += truchas.compare_max(werr, 0, 0.1, "z-velocity", time)

    truchas.report_summary(nfail)
    return nfail
예제 #3
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "inflow-bc-2.inp")

    xc = output.centroids()
    time = output.time(2)

    # pressure
    pressure = output.field(2, "Z_P")
    nfail += truchas.compare_max(pressure, 0, 1e-15, "pressure", time)

    # vof
    vof = output.field(2, "VOF")[:, 0]
    p = 0.25 * time - 0.375
    vofex = sp.array([
        1 if x + 0.125 < p else 0 if x - 0.125 > p else 4 * (p - (x - 0.125))
        for x in xc[:, 0]
    ])
    nfail += truchas.compare_max(vof, vofex, 1e-15, "vof", time)

    # the x-velocity is 0.25 in cells containing fluid
    vel = output.field(2, "Z_VC")
    velex = sp.array([[0.25 if vf > 0 else 0, 0, 0] for vf in vof])
    nfail += truchas.compare_max(vel, velex, 1e-15, "velocity", time)

    # temperature is 2 in cells containing fluid
    temp = output.field(2, "Z_TEMP")
    tempex = sp.array([2 if vf > 0 else 0 for vf in vof])
    nfail += truchas.compare_max(temp, tempex, 1e-15, "temperature", time)

    truchas.report_summary(nfail)
    return nfail
예제 #4
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "steady-flow-6a.inp")

    # From a special run to compute vof for final exact configuration
    gold = tenv.output("steady-flow-6a_golden/steady-flow-6a.h5")

    # Test final VOFs against golden output
    vof_output = output.field(2, "VOF")[:, 0]
    vof_gold = gold.field(1, "VOF")[:, 0]
    nfail += truchas.compare_max(vof_output, vof_gold, 0.09, "VOF",
                                 output.time(2))

    # max <= l2 <= sqrt(ncell)*max = 31*max
    nfail += truchas.compare_l2(vof_output, vof_gold, 3 * 0.09, "VOF",
                                output.time(2))

    # Test final velocity against exact
    velocity = output.field(2, "Z_VC")
    velocity[:, 0] -= 4
    velocity[:, 1] -= 3
    nfail += truchas.compare_max(velocity, 0, 1e-13, "velocity",
                                 output.time(2))

    # Test pressure against exact
    nfail += truchas.compare_max(output.field(1, "Z_P"), 0, 1e-10, "pressure",
                                 output.time(1))
    nfail += truchas.compare_max(output.field(2, "Z_P"), 0, 1e-10, "pressure",
                                 output.time(2))

    truchas.report_summary(nfail)
    return nfail
예제 #5
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "tangential-surface-tension-couette.inp")

    xc = output.centroids()

    # verify final fields
    sid = 2
    time = output.time(sid)

    # temperature
    test = output.field(sid, "Z_TEMP")
    minx = min(xc[:, 0]) - 0.5
    Tref = 1 + (xc[:, 0] - minx)
    nfail += truchas.compare_max(test, Tref, 1e-8, "temp", time)

    # pressure
    test = output.field(sid, "Z_P")
    nfail += truchas.compare_max(test, 0, 1e-8, "pressure", time)

    # velocity
    test = output.field(sid, "Z_VC")
    dsig_dx = -1
    viscosity = 20
    minz = min(xc[:, 2]) - 0.5
    nfail += truchas.compare_max(test[:, 0],
                                 dsig_dx / viscosity * (xc[:, 2] - minz), 1e-7,
                                 "x-velocity", time)
    nfail += truchas.compare_max(test[:, 1], 0, 1e-10, "y-velocity", time)
    nfail += truchas.compare_max(test[:, 2], 0, 1e-10, "z-velocity", time)

    truchas.report_summary(nfail)
    return nfail
예제 #6
0
def velocity_test(velocity, tol, time):
    nfail = 0
    nfail += truchas.compare_max((velocity[:, 0] - 2 * time) / (2 * time), 0,
                                 tol, "x-velocity", time)
    nfail += truchas.compare_max(velocity[:, 1], 0, tol, "y-velocity", time)
    nfail += truchas.compare_max(velocity[:, 2], 0, tol, "z-velocity", time)
    return nfail
예제 #7
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "gap-rad-flow.inp")

    probe_names = ["left end", "right end", "gap left", "gap right"]
    probe_golden = {"left end":  [1.499998474,  1.371828885],
                    "right end": [0.500001526,  0.628171115],
                    "gap left":  [1.498533630,  1.370837833],
                    "gap right": [0.5014663700, 0.629162167]}

    # verify initial probe data
    time = output.probe(probe_names[0], "TEMP")[0, 1] # 0 is first cycle, 1 is time index
    for pname in probe_names:
        probe_data = output.probe(pname, "TEMP")[0,-1] # 0 for first cycle, -1 for temp data
        nfail += truchas.compare_max(probe_data, probe_golden[pname][0], 1e-9, pname, time)

    # verify final probe data
    # get the last cycle
    time = output.probe(probe_names[0], "TEMP")[-1, 1] # -1 is last cycle, 1 is time index
    for pname in probe_names:
        probe_data = output.probe(pname, "TEMP")[-1,-1] # -1 for last cycle, -1 for temp data
        nfail += truchas.compare_max(probe_data, probe_golden[pname][1], 5e-5, pname, time)

    truchas.report_summary(nfail)
    return nfail
예제 #8
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "pipe-flow-3a.inp")

    flow_region = output.region(1)
    xc = output.centroids()[flow_region]

    # pressure
    pex = 3 * (0.5 - xc[:, 0])
    nfail += truchas.compare_max(
        output.field(1, "Z_P")[flow_region], pex, 1e-13, "pressure",
        output.time(1))
    nfail += truchas.compare_max(
        output.field(2, "Z_P")[flow_region], pex, 1e-11, "pressure",
        output.time(2))

    # velocity
    test = output.field(2, "Z_VC")[flow_region]
    uex = (1 - xc[:, 1]**2) / 2

    time = output.time(2)
    nfail += truchas.compare_max(test[:, 0], uex, 1.3e-3, "x-velocity", time)
    nfail += truchas.compare_max(test[:, 1], 0, 1e-13, "y-velocity", time)
    nfail += truchas.compare_max(test[:, 2], 0, 1e-13, "z-velocity", time)

    truchas.report_summary(nfail)
    return nfail
예제 #9
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "inviscid-pipe-flow-1d.inp")

    # early velocity
    time = output.time(2)
    velocity = output.field(2, "Z_VC")
    velex = sp.sqrt(2) * time
    nfail += truchas.compare_max_rel(velocity[:, 0], velex, 1e-11,
                                     "x-velocity", time)
    nfail += truchas.compare_max_rel(velocity[:, 1], velex, 1e-11,
                                     "y-velocity", time)
    nfail += truchas.compare_max(velocity[:, 2], 0, 1e-12, "z-velocity", time)

    # final velocity
    time = output.time(3)
    velocity = output.field(3, "Z_VC")
    velex = sp.sqrt(2) * time
    nfail += truchas.compare_max(velocity[:, 0], velex, 1e-12, "x-velocity",
                                 time)
    nfail += truchas.compare_max(velocity[:, 1], velex, 1e-12, "y-velocity",
                                 time)
    nfail += truchas.compare_max(velocity[:, 2], 0, 1e-13, "z-velocity", time)

    truchas.report_summary(nfail)
    return nfail
예제 #10
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "sloshing-flow.inp")
    golden = tenv.output("sloshing-flow_pgolden/sloshing-flow.h5")

    sid = 2
    time = output.time(sid)

    # cycle number
    cycle = output.cycle(sid)
    cycleg = golden.cycle(sid)
    status = "PASS" if cycle == cycleg else "FAIL"
    print("{:s}: matching cycle numbers {:d}".format(status, cycle))
    if cycle != cycleg: nfail += 1

    # temperature
    test = output.field(sid, "Z_TEMP")
    gold = golden.field(sid, "Z_TEMP")
    nfail += truchas.compare_max(test, gold, 1e-6, "temp", time)

    # fluid volume fraction
    test = output.field(sid, "VOF")[:,0]
    gold = golden.field(sid, "VOF")[:,0]
    nfail += truchas.compare_max(test, gold, 1e-6, "vof", time)

    truchas.report_summary(nfail)
    return nfail
예제 #11
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "free-surf-flow-4.inp")
    golden = tenv.output("free-surf-flow-4_golden/free-surf-flow-4.h5")

    # initial
    time = output.time(1)

    test = output.field(1, "VOF")[:, 0]
    gold = golden.field(1, "VOF")[:, 0]
    nfail += truchas.compare_max(test, gold, 0, "vof", time)

    test = output.field(1, "Z_P")
    gold = golden.field(1, "Z_P")
    nfail += truchas.compare_max(test, gold, 1e-13, "pressure", time)

    # final time
    time = output.time(2)

    test = output.field(2, "VOF")[:, 0]
    gold = golden.field(2, "VOF")[:, 0]
    nfail += truchas.compare_max(test, gold, 1e-13, "vof", time)

    test = output.field(2, "Z_P")
    gold = golden.field(2, "Z_P")
    nfail += truchas.compare_max(test, gold, 1e-13, "pressure", time)

    test = output.field(2, "Z_VC")
    gold = golden.field(2, "Z_VC")
    nfail += truchas.compare_max(test, gold, 1e-13, "velocity", time)

    truchas.report_summary(nfail)
    return nfail
예제 #12
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "hydrostatic-10.inp")

    xc = output.centroids()

    # pressure
    pex = (-2 + 0.05 * xc[:, 1]) * xc[:, 1]
    pex -= sp.mean(pex)
    Tex = 1.5 + xc[:, 1] / 10
    for sid in (1, 2):
        time = output.time(sid)

        pressure = output.field(sid, "Z_P")
        pressure -= sp.mean(pressure)
        nfail += truchas.compare_max(pressure, pex, 1e-10, "pressure", time)

        nfail += truchas.compare_max(output.field(sid, "Z_TEMP"), Tex, 1e-14,
                                     "temperature", time)

    # final velocity zero everywhere
    nfail += truchas.compare_max(output.field(2, "Z_VC"), 0, 1e-13, "velocity",
                                 output.time(2))

    truchas.report_summary(nfail)
    return nfail
예제 #13
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "gap-rad-flow-old.inp")

    probe_names = ["left_end", "right_end", "gap_left", "gap_right"]
    probe_golden = {"left_end":  [1.499998474,  1.371828885],
                    "right_end": [0.500001526,  0.628171115],
                    "gap_left":  [1.498533630,  1.370837833],
                    "gap_right": [0.5014663700, 0.629162167]}

    # verify initial probe data
    for pname in probe_names:
        filename = os.path.join(output.directory,pname + ".dat")
        data = numpy.loadtxt(filename)
        time = data[0,0]
        probe_data = data[0,1]
        nfail += truchas.compare_max(probe_data, probe_golden[pname][0], 1e-9, pname, time)

    # verify final probe data
    # get the last cycle
    for pname in probe_names:
        filename = os.path.join(output.directory,pname + ".dat")
        data = numpy.loadtxt(filename)
        time = data[-1,0]
        probe_data = data[-1,1]
        nfail += truchas.compare_max(probe_data, probe_golden[pname][1], 5e-5, pname, time)

    truchas.report_summary(nfail)
    return nfail
예제 #14
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "htvoid4-old.inp")
    golden = tenv.output("htvoid4-old_pgolden/htvoid4-old.h5")

    # checking final values
    sid = output.num_series()
    time = output.time(sid)

    # cycle number
    cycle = output.cycle(sid)
    cycleg = golden.cycle(sid)
    status = "PASS" if cycle == cycleg else "FAIL"
    print("{:s}: matching cycle numbers {:d}".format(status, cycle))
    if cycle != cycleg: nfail += 1

    # temperature
    test = output.field(sid, "Z_TEMP")
    gold = golden.field(sid, "Z_TEMP")
    nfail += truchas.compare_max(test, gold, 1e-6, "temp", time)

    # solid fraction
    test = output.field(sid, "VOF")[:,1]
    gold = golden.field(sid, "VOF")[:,1]
    nfail += truchas.compare_max(test, gold, 1e-6, "vof", time)

    truchas.report_summary(nfail)
    return nfail
예제 #15
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "free-surf-flow-7.inp")
    golden = tenv.output("free-surf-flow-7_golden/free-surf-flow-7.h5")

    # final time
    time = output.time(2)

    vof = output.field(2, "VOF")[:, 0]
    gold = golden.field(2, "VOF")[:, 0]
    nfail += truchas.compare_max(vof, gold, 4e-2, "vof", time)

    test = output.field(2, "Z_P")
    gold = golden.field(2, "Z_P")
    nfail += truchas.compare_max(test, gold, 1e-10, "pressure", time)

    # the x-velocity is 1 in cells containing fluid
    test = output.field(2, "Z_VC")
    uerror = max(
        abs(u - 2 / 3 * time) if vf > 0.0 else abs(u)
        for u, vf in zip(test[:, 0], vof))
    nfail += truchas.compare_max(uerror, 0, 1e-11, "x-velocity", time)
    nfail += truchas.compare_max(test[:, 1], 0, 1e-11, "y-velocity", time)
    nfail += truchas.compare_max(test[:, 2], 0, 1e-11, "z-velocity", time)

    truchas.report_summary(nfail)
    return nfail
예제 #16
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "steady-flow-2d.inp")

    # Test VOFs against exact
    xc = output.centroids()

    t = output.time(2)
    vof = output.field(2, "VOF")[:,0]
    nfail += truchas.compare_max(vof, vof_ex(xc, t), 2e-13, "VOF", t)

    t = output.time(3)
    vof = output.field(3, "VOF")[:,0]
    nfail += truchas.compare_max(vof, vof_ex(xc, t), 2e-13, "VOF", t)

    # Test final velocity against exact
    velocity = output.field(3, "Z_VC")
    velocity[:,0] -= 2.82842712474619
    velocity[:,1] -= 2.82842712474619
    nfail += truchas.compare_max(velocity, 0, 1e-13, "velocity", output.time(3))

    # Test pressure against exact
    nfail += truchas.compare_max(output.field(1, "Z_P"), 0, 1e-10, "pressure", output.time(1))
    nfail += truchas.compare_max(output.field(3, "Z_P"), 0, 1e-10, "pressure", output.time(3))

    truchas.report_summary(nfail)
    return nfail
예제 #17
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "free-surf-flow-8.inp")
    golden = tenv.output("free-surf-flow-8_golden/free-surf-flow-8.h5")

    for sid in (1, 2):
        time = output.time(sid)

        vof = output.field(sid, "VOF")[:, 0]
        gold = golden.field(sid, "VOF")[:, 0]
        nfail += truchas.compare_max(vof, gold, 1e-13, "vof", time)

        test = output.field(sid, "Z_P")
        gold = golden.field(sid, "Z_P")
        nfail += truchas.compare_max(test, gold, 1e-12, "pressure", time)

        # ensure pressure is 0 in void
        void_error = max(abs(p) for p, vf in zip(test, vof) if vf == 0)
        nfail += truchas.compare_max(void_error, 0, 1e-12, "void-pressure",
                                     time)

        test = output.field(sid, "Z_VC")
        gold = golden.field(sid, "Z_VC")
        nfail += truchas.compare_max(test, gold, 1e-11, "velocity", time)

        # the velocity is 0 in purely void cells
        uerror = max(max(abs(u)) for u, vf in zip(test, vof) if vf == 0)
        nfail += truchas.compare_max(uerror, 0, 1e-11, "void-velocity", time)

    truchas.report_summary(nfail)
    return nfail
예제 #18
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "free-surf-flow-1.inp")

    xc = output.centroids()

    # initial conditions
    vof = output.field(1, "VOF")
    nfail += vof_test(vof, xc, 5e-9, output.time(1))
    nfail += truchas.compare_max(output.field(1, "Z_P"), 0, 1e-10, "pressure",
                                 output.time(1))
    nfail += velocity_test(output.field(1, "Z_VC"), vof[:, 0], 1e-13,
                           output.time(1))

    # intermediate time
    vof = output.field(2, "VOF")
    nfail += vof_test(vof, xc, 5e-9, output.time(2))
    nfail += truchas.compare_max(output.field(2, "Z_P"), 0, 1e-14, "pressure",
                                 output.time(2))
    nfail += velocity_test(output.field(2, "Z_VC"), vof[:, 0], 1e-14,
                           output.time(2))

    # final time
    vof = output.field(3, "VOF")
    nfail += vof_test(vof, xc, 5e-9, output.time(3))
    nfail += truchas.compare_max(output.field(3, "Z_P"), 0, 1e-14, "pressure",
                                 output.time(3))
    nfail += velocity_test(output.field(3, "Z_VC"), vof[:, 0], 1e-14,
                           output.time(3))

    truchas.report_summary(nfail)
    return nfail
예제 #19
0
def velocity_test(velocity, vof, tol, time):
    # the x-velocity is 1 in cells containing fluid
    nfail = 0
    uerror = max(abs(u - 2/3*time) if vf > 0 else abs(u) for u,vf in zip(velocity[:,0],vof))
    nfail += truchas.compare_max(uerror, 0, tol, "x-velocity", time)
    nfail += truchas.compare_max(velocity[:,1], 0, tol, "y-velocity", time)
    nfail += truchas.compare_max(velocity[:,2], 0, tol, "z-velocity", time)
    return nfail
예제 #20
0
def compare_velocity(vel, vof, tol, time):
    # the x-direction velocity is 1 in cells which aren't solidified
    uerror = max(
        abs(u - 1.) if vf < 1. else abs(u) for u, vf in zip(vel[:, 0], vof))
    verror = max(abs(vel[:, 1]))
    werror = max(abs(vel[:, 2]))

    nfail = 0
    nfail += truchas.compare_max(uerror, 0, tol, "x-velocity", time)
    nfail += truchas.compare_max(verror, 0, tol, "y-velocity", time)
    nfail += truchas.compare_max(werror, 0, tol, "z-velocity", time)
    return nfail
예제 #21
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4,
                                  "ustruc2.inp",
                                  restart_file="ustruc1.restart.149")
    golden = tenv.output("ustruc2_pgolden/ustruc2.h5")

    time = output.time(2)  # final time

    # temperature
    test = output.field(2, "Z_TEMP")
    gold = golden.field(3, "Z_TEMP")
    nfail += truchas.compare_max_rel(test, gold, 5e-5, "temp", time)

    # G
    tol = 1e-4
    test = sp.ma.masked_values(output.field(2, "uStruc-G"), 0)
    gold = sp.ma.masked_values(golden.field(3, "uStruc-G"), 0)
    error = abs((test - gold) / (200 / tol + gold))
    nfail += truchas.compare_max(error, 0, tol, "G", time)

    # V
    tol = 1e-4
    test = sp.ma.masked_values(output.field(2, "uStruc-V"), 0)
    gold = sp.ma.masked_values(golden.field(3, "uStruc-V"), 0)
    error = abs((test - gold) / (1e-4 / tol + gold))
    nfail += truchas.compare_max(error, 0, tol, "V", time)

    # lambda1
    tol = 1e-4
    test = sp.ma.masked_values(output.field(2, "uStruc-gv1-lambda1"), 0)
    gold = sp.ma.masked_values(golden.field(3, "uStruc-gv1-lambda1"), 0)
    error = abs((test - gold) / (4e-6 / tol + gold))
    nfail += truchas.compare_max(error, 0, tol, "lambda1", time)

    # lambda2
    tol = 1e-4
    test = sp.ma.masked_values(output.field(2, "uStruc-gv1-lambda2"), 0)
    gold = sp.ma.masked_values(golden.field(3, "uStruc-gv1-lambda2"), 0)
    error = abs((test - gold) / (2e-6 / tol + gold))
    nfail += truchas.compare_max(error, 0, tol, "lambda2", time)

    # ustruc
    test = output.field(2, "uStruc-gv1-ustruc")
    gold = golden.field(3, "uStruc-gv1-ustruc")
    success = (test == gold).all()
    print("{:s}: {:s} at t={:8.2e}".format("PASS" if success else "FAIL",
                                           "ustruc", time))
    if not success: nfail += 1

    truchas.report_summary(nfail)
    return nfail
예제 #22
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "void-collapse.inp")

    # ZJJ: This velocity test looks for cycle 113, but the test only runs to cycle 30.
    # It was also written with a function name that was overwritten by the later
    # velocity test, so it was never run. As of March 2019 it would fail if renamed,
    # so I've commented it out here to skip as was done indirectly before.
    # # velocity
    # sid = output.series_id(113)
    # time = output.time(sid)

    # test = output.field(sid, "Z_VC")
    # nfail += truchas.compare_max_rel(test[:,0], 0.5, 5e-8, "x-velocity", time)
    # nfail += truchas.compare_max(test[:,1], 0, 5e-10, "y-velocity", time)
    # nfail += truchas.compare_max(test[:,2], 0, 5e-10, "z-velocity", time)

    # pressure at cycle 1
    #   This test seems to check some numerical discretization
    #   transient that I do not understand. DAK 8-24-10
    sid = output.series_id(1)
    time = output.time(sid)

    vof = output.field(sid, "VOF")[:, 0]
    test = sp.ma.masked_where(vof < 0.01, output.field(sid,
                                                       "Z_P")).compressed()
    P_anal = sp.array([
        65.9934, 55.9944, 45.9954, 35.9964, 25.9974, 15.9984, 5.9994, 0.49995
    ])
    nfail += truchas.compare_max(test, P_anal, 1e-3, "pressure", time)

    # pressure at cycle 2
    sid = output.series_id(2)
    time = output.time(sid)
    test = sp.ma.masked_where(vof < 0.01, output.field(sid,
                                                       "Z_P")).compressed()
    nfail += truchas.compare_max(test, 0, 1e-3, "pressure", time)

    # void volume fraction at cycle 30
    sid = output.series_id(30)
    time = output.time(sid)
    test = output.field(sid, "VOF")[9, 1]  # void volume fraction in cell 10
    nfail += truchas.compare_max(test, 3e-4, 1e-7, "void fraction", time)

    # x-velocity at cycle 30
    test = output.field(sid, "Z_VC")[:, 0]
    nfail += truchas.compare_max(test, 0.9999, 1e-4, "x-velocity", time)

    truchas.report_summary(nfail)
    return nfail
예제 #23
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "freezing-flow-1.inp")
    golden = tenv.output("freezing-flow-1_pgolden/freezing-flow-1.h5")

    # early time
    time = output.time(2)
    nfail += truchas.compare_max(output.field(2, "Z_TEMP"),
                                 golden.field(2, "Z_TEMP"), 5e-7, "temp", time)
    nfail += truchas.compare_max(output.field(2, "Z_P"), 0, 1e-10, "temp",
                                 time)
    nfail += truchas.compare_max(output.field(2, "Z_VC"), 0, 1e-10, "velocity",
                                 time)
    nfail += truchas.compare_max(
        output.field(2, "VOF")[:, 0],
        golden.field(2, "VOF")[:, 0], 5e-7, "vof", time)

    # final time
    time = output.time(3)
    nfail += truchas.compare_max(output.field(3, "Z_TEMP"),
                                 golden.field(3, "Z_TEMP"), 5e-6, "temp", time)
    nfail += truchas.compare_max(output.field(3, "Z_P"), 0, 1e-10, "temp",
                                 time)
    nfail += truchas.compare_max(output.field(3, "Z_VC"), 0, 1e-10, "velocity",
                                 time)
    nfail += truchas.compare_max(
        output.field(3, "VOF")[:, 0],
        golden.field(3, "VOF")[:, 0], 1e-10, "vof", time)

    truchas.report_summary(nfail)
    return nfail
예제 #24
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "pipe-flow-1c.inp")

    xc = output.centroids()
    uex = (1 - xc[:, 1]**2) / (2 * sp.sqrt(2))

    time = output.time(2)
    test = output.field(2, "Z_VC")
    nfail += truchas.compare_max(test[:, 0], uex, 1.3e-3, "x-velocity", time)
    nfail += truchas.compare_max(test[:, 1], 0, 5e-12, "y-velocity", time)
    nfail += truchas.compare_max(test[:, 2], uex, 1.3e-3, "z-velocity", time)

    truchas.report_summary(nfail)
    return nfail
예제 #25
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "hydrostatic-old.inp")

    xc = output.centroids()
    cycle = 20
    sid = output.series_id(cycle)
    time = output.time(sid)

    # pressure
    vof = output.field(sid, "VOF")[:, 0]
    pressure = sp.array(
        [p for p, vf in zip(output.field(sid, "Z_P"), vof) if vf > 0.99])
    pressure -= sp.mean(pressure)

    dpdz = -9.81e3
    pex = [dpdz * z for z, vf in zip(xc[:, 2], vof) if vf > 0.99]
    pex -= sp.mean(pex)

    error = spla.norm(pressure - pex) / sp.sqrt(pex.size)
    nfail += truchas.compare_l2(error, 0, 1e-5, "pressure", time)

    # velocity zero everywhere
    nfail += truchas.compare_max(output.field(sid, "Z_VC"), 0, 1e-9,
                                 "velocity", time)

    truchas.report_summary(nfail)
    return nfail
예제 #26
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "ds11.inp")
    golden = tenv.output("ds11_pgolden/ds11.h5")

    test_region = output.region(1, 2)
    gold_region = golden.region(1, 2)

    # cycle number
    for sid in (2, 4):
        cycle = output.cycle(sid)
        cycleg = golden.cycle(sid)
        status = "PASS" if cycle == cycleg else "FAIL"
        print("{:s}: matching cycle numbers {:d}".format(status, cycle))
        if cycle != cycleg: nfail += 1

    # fields
    for sid in (3, 4):
        time = output.time(sid)

        test = output.field(sid, "Z_TEMP")[test_region]
        gold = golden.field(sid, "Z_TEMP")[gold_region]
        nfail += truchas.compare_max_rel(test, gold, 1e-6, "temp", time)

        test = output.field(sid, "VOF")[:, 2]  # comp 2 is fluid
        gold = golden.field(sid, "VOF")[:, 2]
        nfail += truchas.compare_max(test, gold, 1e-7, "vof", time)

    truchas.report_summary(nfail)
    return nfail
예제 #27
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "ds10.inp")

    xc = output.centroids()

    # test final temp
    nseries = output.num_series()
    T = output.field(nseries, "Z_TEMP")

    error = sp.empty(T.shape[0])
    for j in range(error.shape[0]):
        if min(abs(xc[j, :2])) < 1e-3:
            # exclude gap cells from error calc
            error[j] = 0
        else:
            Tref = sum(xc[j, :2])
            if xc[j, 0] < 0:
                if xc[j, 1] < 0:
                    Tref += 2.5
                else:
                    Tref += 2.7
            else:
                if xc[j, 1] < 0:
                    Tref += 3.3
                else:
                    Tref += 3.5
            error[j] = abs(T[j] - Tref) / Tref

    nfail += truchas.compare_max(error, 0, 1e-7, "temperature",
                                 output.time(nseries))

    truchas.report_summary(nfail)
    return nfail
예제 #28
0
def velocity_test(velocity, tol, time):
    nfail = 0
    velex = sp.sqrt(2)*time
    nfail += truchas.compare_max_rel(velocity[:,0], velex, tol, "x-velocity", time)
    nfail += truchas.compare_max_rel(velocity[:,1], velex, tol, "y-velocity", time)
    nfail += truchas.compare_max(velocity[:,2], 0, tol, "z-velocity", time)
    return nfail
예제 #29
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "hydrostatic-old-7a.inp")

    xc = output.centroids()

    # pressure
    pex = sp.array([
        -2 * (z - sp.sqrt(3)) if z < sp.sqrt(3) else -(z - sp.sqrt(3))
        for z in xc[:, 2]
    ])
    pex -= sp.mean(pex)
    for sid in (1, 2):
        pressure = output.field(sid, "Z_P")
        pressure -= sp.mean(pressure)

        error = spla.norm(pressure - pex) / pex.size
        nfail += truchas.compare_l2(error, 0, 8e-3, "pressure",
                                    output.time(sid))

    # velocity zero everywhere
    nfail += truchas.compare_max(output.field(2, "Z_VC"), 0, 1e-13, "velocity",
                                 output.time(2))

    truchas.report_summary(nfail)
    return nfail
예제 #30
0
def run_test(tenv):
    nfail = 0
    stdout, output = tenv.truchas(4, "ds8-old.inp")
    golden = tenv.output("ds8-old_pgolden/ds8-old.h5")

    for sid in (2, 4):
        time = output.time(sid)

        # cycle number
        cycle = output.cycle(sid)
        cycleg = golden.cycle(sid)
        status = "PASS" if cycle == cycleg else "FAIL"
        print("{:s}: matching cycle numbers {:d}".format(status, cycle))
        if cycle != cycleg: nfail += 1

        # fields
        test = output.field(sid, "Z_TEMP")
        gold = golden.field(sid, "Z_TEMP")
        nfail += truchas.compare_max_rel(test, gold, 1e-6, "temp", time)

        test = output.field(sid, "Z_VC")
        gold = golden.field(sid, "Z_VC")
        nfail += truchas.compare_max(test, gold, 1e-10, "velocity", time)

    truchas.report_summary(nfail)
    return nfail