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
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
def run_test(tenv): nfail = 0 stdout, output = tenv.truchas(4, "em2.inp") golden = tenv.output("em2_pgolden/em2.h5") # Three Joule heat calculations, used for the following cycle groups. group = [range(0,5), range(5,16), range(16,21)] for g in group: cycle = g[0] sid = output.series_id(cycle) test = output.field(sid, "Joule_P") gold = golden.field(sid, "Joule_P") nfail += truchas.compare_max_rel(test, gold, 1e-8, "joule heat", output.time(sid)) for cycle in g[1:]: sid = output.series_id(cycle) test1 = output.field(sid, "Joule_P") nfail += truchas.compare_max(test1, test, 0, "joule heat", output.time(sid)) # final temperature sid = output.series_id(20) test = output.field(sid, "Z_TEMP") gold = golden.field(sid, "Z_TEMP") nfail += truchas.compare_max_rel(test, gold, 1e-8, "temperature", output.time(sid)) truchas.report_summary(nfail) return nfail
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
def run_test(tenv): nfail = 0 stdout, output = tenv.truchas(4, "ds5.inp") golden = tenv.output("ds5_pgolden/ds5.h5") for sid in (2, 3): # 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 # phis time = output.time(sid) phi1ex = golden.field(sid, "phi1") phi1 = output.field(sid, "phi1") phi2 = output.field(sid, "phi2") / 1.5 phi3 = output.field(sid, "phi3") / 2 nfail += truchas.compare_max_rel(phi1, phi1ex, 1e-6, "phi1", time) nfail += truchas.compare_max_rel(phi2, phi1, 1e-14, "phi2", time) nfail += truchas.compare_max_rel(phi3, phi1, 1e-14, "phi3", time) truchas.report_summary(nfail) return nfail
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
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
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
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
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
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
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
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
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
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
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
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
def run_test(tenv): nfail = 0 stdout, output = tenv.truchas(4, "advection-3b.inp") gold = tenv.output("advection-3b_pgolden/advection-3b.h5") vof_gold = gold.field(2, "VOF") # verify volume fractions at final time time = output.time(2) vof = output.field(2, "VOF") nfail += truchas.compare_max(vof, vof_gold, 5e-9, "vof", time) truchas.report_summary(nfail) return nfail