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
def run_test(tenv): nfail = 0 stdout, output = tenv.truchas(4, "ds6.inp") golden = tenv.output("ds6_pgolden/ds6.h5") for sid in (2, 3): 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-10, "temp", time) test = output.field(sid, "phi1") gold = golden.field(sid, "phi1") nfail += truchas.compare_max_rel(test, gold, 1e-10, "phi1", time) test = output.field(sid, "phi2") gold = golden.field(sid, "phi2") nfail += truchas.compare_max_rel(test, gold, 1e-10, "phi2", 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, "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, "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, "turbulence.inp") # Empirically determined velocities :( MAC # The pressure values are from the linear pressure profile # The min/max velocity values are essentially "golden" values umin_gold = 632.852 umax_gold = 2062.587 pmin_gold = 25000.0 pmax_gold = 75000.0 # umin velocity # final x-velocity: order is (cycle#,time,vx,vy,vz) filename = os.path.join(output.directory, "umin.dat") data = numpy.loadtxt(filename) time = data[-1, 0] umin = data[-1, 1] nfail += truchas.compare_max_rel(umin, umin_gold, 1.2e-6, "umin x-velocity", time) # umax velocity # final x-velocity: order is (cycle#,time,vx,vy,vz) filename = os.path.join(output.directory, "umax.dat") data = numpy.loadtxt(filename) time = data[-1, 0] umax = data[-1, 1] nfail += truchas.compare_max_rel(umax, umax_gold, 1.2e-6, "umax x-velocity", time) # umax pressure # final pressure: order is (cycle#,time,p) filename = os.path.join(output.directory, "umaxp.dat") data = numpy.loadtxt(filename) time = data[-1, 0] pmax = data[-1, 1] nfail += truchas.compare_max_rel(pmax, pmax_gold, 1e-9, "umax pressure", time) # pdown pressure # final pressure: order is (cycle#,time,p) filename = os.path.join(output.directory, "pdown.dat") data = numpy.loadtxt(filename) time = data[-1, 0] pmin = data[-1, 1] nfail += truchas.compare_max_rel(pmin, pmin_gold, 1e-9, "pdown pressure", 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, "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, "turbulence.inp") # Empirically determined velocities :( MAC # The pressure values are from the linear pressure profile # The min/max velocity values are essentially "golden" values umin_gold = 632.876 umax_gold = 2062.680 pmin_gold = 25000.0 pmax_gold = 75000.0 # umin velocity # final x-velocity: order is (cycle#,time,vx,vy,vz) data = output.probe("umin", "VC") time = data[-1, 1] umin = data[-1, 2] nfail += truchas.compare_max_rel(umin, umin_gold, 1.2e-6, "umin x-velocity", time) # umax velocity # final x-velocity: order is (cycle#,time,vx,vy,vz) data = output.probe("umax", "VC") time = data[-1, 1] umax = data[-1, 2] nfail += truchas.compare_max_rel(umax, umax_gold, 1.2e-6, "umax x-velocity", time) # umax pressure # final pressure: order is (cycle#,time,p) data = output.probe("umax", "P") time = data[-1, 1] pmax = data[-1, 2] nfail += truchas.compare_max_rel(pmax, pmax_gold, 1e-9, "umax pressure", time) # pdown pressure # final pressure: order is (cycle#,time,p) data = output.probe("pdown", "P") time = data[-1, 1] pmin = data[-1, 2] nfail += truchas.compare_max_rel(pmin, pmin_gold, 1e-9, "pdown pressure", time) truchas.report_summary(nfail) return nfail
def run_test(tenv): nfail = 0 stdout, output = tenv.truchas(4, "diverging-duct-td.inp") xc = output.centroids() # time 0 sid = output.series_id(207) #141 #115 time = output.time(sid) # pressure pressure = output.field(sid, "Z_P") pex = exact_pressure(xc[:, 0], time) nfail += truchas.compare_max_rel(pressure, pex, 3e-3, "pressure", time) # velocity velx = output.field(sid, "Z_VC")[:, 0] velxex = exact_velocity(xc[:, 0], time) nfail += truchas.compare_max_rel(velx, velxex, 1e-3, "x-velocity", time) # time 1 sid = output.series_id(422) #248 #169 time = output.time(sid) # velocity velx = output.field(sid, "Z_VC")[:, 0] velxex = exact_velocity(xc[:, 0], time) nfail += truchas.compare_max_rel(velx, velxex, 3e-3, "x-velocity", time) # time 2 sid = output.series_id(647) #364 #225 time = output.time(sid) # pressure pressure = output.field(sid, "Z_P") pex = exact_pressure(xc[:, 0], time) nfail += truchas.compare_max_rel(pressure, pex, 1e-3, "pressure", time) # velocity velx = output.field(sid, "Z_VC")[:, 0] velxex = exact_velocity(xc[:, 0], time) nfail += truchas.compare_max_rel(velx, velxex, 1e-3, "x-velocity", time) truchas.report_summary(nfail) return nfail
def run_test(tenv): nfail = 0 stdout, output = tenv.truchas(4, "shear-constr-heat.inp") # verify fields at initial time sid = 1 time = output.time(sid) # stress test = output.field(sid, "sigma") nfail += truchas.compare_max(test[:, 0], 0, 1e-8, "sigma_xx", time) nfail += truchas.compare_max(test[:, 1], 0, 1e-8, "sigma_yy", time) nfail += truchas.compare_max_rel(test[:, 2], -152.533333333, 1e-8, "sigma_zz", time) nfail += truchas.compare_max(test[:, 3], 0, 1e-8, "sigma_xy", time) nfail += truchas.compare_max_rel(test[:, 4], 500, 1e-8, "sigma_xz", time) nfail += truchas.compare_max(test[:, 5], 0, 1e-8, "sigma_xx", time) # strain test = output.field(sid, "epsilon") nfail += truchas.compare_max_rel(test[:, 0], 2.93333333333e-3, 1e-8, "epsilon_xx", time) nfail += truchas.compare_max_rel(test[:, 1], 2.93333333333e-3, 1e-8, "epsilon_yy", time) nfail += truchas.compare_max(test[:, 2], 0, 1e-8, "epsilon_zz", time) nfail += truchas.compare_max(test[:, 3], 0, 1e-8, "epsilon_xy", time) nfail += truchas.compare_max_rel(test[:, 4], 500 / 5.2e4, 1e-8, "epsilon_xz", time) nfail += truchas.compare_max(test[:, 5], 0, 1e-8, "epsilon_xx", time) # displacement xn = output.node_coordinates() xgold = 2.93333333333e-3 * xn[:, 0] + (2 * 500.0 / 5.2e4) * xn[:, 2] ygold = 2.93333333333e-3 * xn[:, 1] test = output.field(sid, "Displacement") nfail += truchas.compare_max(test[:, 0], xgold, 1e-10, "x-displacement", time) nfail += truchas.compare_max(test[:, 1], ygold, 1e-10, "y-displacement", time) nfail += truchas.compare_max(test[:, 2], 0, 1e-10, "z-displacement", time) truchas.report_summary(nfail) return nfail
def run_test(tenv): nfail = 0 stdout, output = tenv.truchas(4, "diverging-duct-old-0.inp") xc = output.centroids() sid = output.series_id(274) # pressure pressure = output.field(sid, "Z_P") exact = 1 - 0.5 / (1 + 0.025 * xc[:,0])**2 print(max(exact), min(exact)) nfail += truchas.compare_max_rel(pressure, exact, 5e-3, "pressure", output.time(2)) # velocity velx = output.field(sid, "Z_VC")[:,0] exact = 1 / (1 + 0.025 * xc[:,0]) print(max(exact), min(exact)) nfail += truchas.compare_max_rel(velx, exact, 5e-3, "x-velocity", output.time(2)) truchas.report_summary(nfail) return nfail
def run_test(tenv): nfail = 0 stdout, output = tenv.truchas(4, "em3.inp") golden = tenv.output("em3_pgolden/em3.h5") # joule heat test = output.field(1, "Joule_P") gold = golden.field(1, "Joule_P") nfail += truchas.compare_max_rel(test, gold, 1e-6, "joule heat", output.time(1)) # final temperature sid = output.series_id(30) test = output.field(sid, "Z_TEMP") gold = golden.field(sid, "Z_TEMP") nfail += truchas.compare_max_rel(test, gold, 1e-6, "temperature", output.time(sid)) truchas.report_summary(nfail) return nfail
def run_test(tenv): nfail = 0 stdout, output = tenv.truchas(4, "diverging-duct-td.inp") xc = output.centroids() # time 0 time = output.time(3) # pressure pressure = output.field(3, "Z_P") pex = exact_pressure(xc[:, 0], time) nfail += truchas.compare_max_rel(pressure, pex, 3e-3, "pressure", time) # velocity velx = output.field(3, "Z_VC")[:, 0] velxex = exact_velocity(xc[:, 0], time) nfail += truchas.compare_max_rel(velx, velxex, 1e-3, "x-velocity", time) # time 1 time = output.time(6) # velocity velx = output.field(6, "Z_VC")[:, 0] velxex = exact_velocity(xc[:, 0], time) nfail += truchas.compare_max_rel(velx, velxex, 3e-3, "x-velocity", time) # time 2 time = output.time(11) # pressure pressure = output.field(11, "Z_P") pex = exact_pressure(xc[:, 0], time) nfail += truchas.compare_max_rel(pressure, pex, 1e-3, "pressure", time) # velocity velx = output.field(11, "Z_VC")[:, 0] velxex = exact_velocity(xc[:, 0], time) nfail += truchas.compare_max_rel(velx, velxex, 1e-3, "x-velocity", time) truchas.report_summary(nfail) return nfail
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
def run_test(tenv): nfail = 0 stdout, output = tenv.truchas(4, "evap.inp") golden = tenv.output("evap_golden/evap.h5") for sid in (1, 2, 3): test = output.field(sid, "Z_TEMP") gold = golden.field(sid, "Z_TEMP") nfail += truchas.compare_max_rel(test, gold, 1e-7, "temp", output.time(sid)) truchas.report_summary(nfail) return nfail
def run_test(tenv): nfail = 0 stdout, output = tenv.truchas(4, "simple-gap.inp") golden = tenv.output("simple-gap_golden/simple-gap.h5") true_region = output.region(1, 2) #gap_region_node = output.region_node(3, 4) # verify initial sid = 1 time = output.time(sid) # stress test = output.field(sid, "sigma")[true_region] gold = golden.field(sid, "sigma")[true_region] for j in range(6): nfail += truchas.compare_max_rel(test[:, j], gold[:, j], 1e-6, "sigma{:1d}".format(j + 1), time) # strain test = output.field(sid, "epsilon")[true_region] gold = golden.field(sid, "epsilon")[true_region] for j in range(6): nfail += truchas.compare_max_rel(test[:, j], gold[:, j], 1e-7, "epsilon{:1d}".format(j + 1), time) # traction sideset 7 test = output.field(sid, "NTRAC_07") gold = sp.ma.masked_values(golden.field(sid, "NTRAC_07"), 0) error = abs((test - gold) / gold).max() nfail += truchas.compare_max(error, 0, 1e-6, "normal traction 7", time) # traction sideset 8 test = output.field(sid, "NTRAC_08") gold = sp.ma.masked_values(golden.field(sid, "NTRAC_08"), 0) error = abs((test - gold) / gold).max() nfail += truchas.compare_max(error, 0, 1e-6, "normal traction 8", time) truchas.report_summary(nfail) return nfail
def run_test(tenv): nfail = 0 stdout, output = tenv.truchas(4, "ds3.inp") golden = tenv.output("ds3_pgolden/ds3.h5") # test final cycle number cycle = output.cycle(2) cycleg = golden.cycle(2) status = "PASS" if cycle == cycleg else "FAIL" print("{:s}: matching final cycle numbers".format(status)) if cycle != cycleg: nfail += 1 # test final temperature test = output.field(2, "Z_TEMP") gold = golden.field(2, "Z_TEMP") nfail += truchas.compare_max_rel(test, gold, 1e-10, "temp", output.time(2)) # test final concentration test = output.field(2, "phi1") gold = golden.field(2, "phi1") nfail += truchas.compare_max_rel(test, gold, 1e-10, "temp", output.time(2)) truchas.report_summary(nfail) return nfail
def run_test(tenv): nfail = 0 stdout, output = tenv.truchas(4, "ds9.inp") xc = output.centroids() # test final temp nseries = output.num_series() T = output.field(nseries, "Z_TEMP") Tref = 9 + 6 * xc[:, 0] * xc[:, 1] - xc[:, 0]**2 - xc[:, 1]**2 nfail += truchas.compare_max_rel(T, Tref, 2e-3, "temperature", output.time(nseries)) truchas.report_summary(nfail) return nfail
def run_test(tenv): nfail = 0 stdout, output = tenv.truchas(4, "vfrad1.inp") golden = tenv.output("vfrad1_pgolden/vfrad1.h5") # cycle number cycle = output.cycle(2) cycleg = golden.cycle(2) 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(2, "Z_TEMP") gold = golden.field(2, "Z_TEMP") nfail += truchas.compare_max_rel(test, gold, 1e-5, "temp", output.time(2)) truchas.report_summary(nfail) return nfail
def run_test(tenv): nfail = 0 stdout, output = tenv.truchas(4, "porous-drag.inp") sid = output.series_id(114) time = output.time(sid) # velocity velocity = output.field(sid, "Z_VC") uex = 0.5 nfail += truchas.compare_max_rel(velocity[:, 0], uex, 5e-8, "x-velocity", time) nfail += truchas.compare_max(velocity[:, 1], 0, 5e-9, "y-velocity", time) nfail += truchas.compare_max(velocity[:, 2], 0, 5e-9, "z-velocity", time) # pressure pressure = output.field(sid, "Z_P") xc = output.centroids() pex = 20000 * (1 - xc[:, 0] / 20) nfail += truchas.compare_max(pressure, pex, 5e-6, "pressure", time) truchas.report_summary(nfail) return nfail
def run_test(tenv): nfail = 0 stdout, output = tenv.truchas(4, "contact-box-close.inp") golden = tenv.output("contact-box-close_golden/contact-box-close.h5") true_region = output.region(1, 2) gap_region_node = output.region_node(3) # VERIFY INITIAL sid = 1 time = output.time(sid) # stress tol = 1e2 test = output.field(sid, "sigma")[true_region] gold = [7.62665e6, 1.90666e6, 5.71999e6, 3.81333e6, 6.60487e6, 3.30244e6] name = "sigma{:1d}" for j in range(6): nfail += truchas.compare_max(test[:, j], gold[j], tol, name.format(j + 1), time) # strain tol = 1e-8 test = output.field(sid, "epsilon")[true_region] gold = [ -1.46667e-4, -2.56666e-4, -1.83333e-4, 7.33332e-5, 1.27017e-4, 6.35085e-5 ] name = "epsilon{:1d}" for j in range(6): nfail += truchas.compare_max(test[:, j], gold[j], tol, name.format(j + 1), time) # normal traction tol = 1e-4 test = output.field(sid, "NTRAC_02")[gap_region_node] nfail += truchas.compare_max(test, 0, tol, "normal-traction", time) # VERIFY JUST BEFORE GAP CLOSING sid = 2 time = output.time(sid) # stress tol = 1e3 test = output.field(sid, "sigma")[true_region] gold = golden.field(sid, "sigma")[true_region] name = "sigma{:1d}" for j in range(6): nfail += truchas.compare_max(test[:, j], gold[:, j], tol, name.format(j + 1), time) # strain tol = 2e-8 test = output.field(sid, "epsilon")[true_region] gold = golden.field(sid, "epsilon")[true_region] name = "epsilon{:1d}" for j in range(6): nfail += truchas.compare_max(test[:, j], gold[:, j], tol, name.format(j + 1), time) # normal traction tol = 1e-4 test = output.field(sid, "NTRAC_02")[gap_region_node] nfail += truchas.compare_max(test, 0, tol, "normal-traction", time) # VERIFY JUST AFTER GAP CLOSING sid = 3 time = output.time(sid) # displacement magnitude abs_tol = 1e-9 rel_tol = 1e-4 test = output.field(sid, "Displacement") gold = golden.field(sid, "Displacement") dtest = spla.norm(test, axis=1) dgold = spla.norm(gold, axis=1) err = abs(dtest - dgold) / (abs_tol + rel_tol * abs(dgold)) nfail += truchas.compare_max(err, 0, 1, "displacement", time) # temperature tol = 1e-5 test = output.field(sid, "Z_TEMP")[true_region] gold = golden.field(sid, "Z_TEMP")[true_region] nfail += truchas.compare_max_rel(test, gold, tol, "temperature", time) # VERIFY FINAL sid = 4 time = output.time(sid) # stress tol = 1 test = output.field(sid, "sigma")[true_region] gold = [-2.288e7, -5.720e6, -1.716e7, 0, 0, -9.90733e6] name = "sigma{:1d}" for j in range(6): nfail += truchas.compare_max(test[:, j], gold[j], tol, name.format(j + 1), time) # strain tol = 1e-9 test = output.field(sid, "epsilon")[true_region] gold = [0, 3.3e-4, 1.1e-4, 0, 0, -1.90526e-4] name = "epsilon{:1d}" for j in range(6): nfail += truchas.compare_max(test[:, j], gold[j], tol, name.format(j + 1), time) # normal traction tol = 1e-6 test = output.field(sid, "NTRAC_02")[gap_region_node] gold = -2.288e7 nfail += truchas.compare_max_rel(test, gold, tol, "normal-traction", time) # temperature tol = 1e-8 test = output.field(sid, "Z_TEMP")[true_region] gold = 308 nfail += truchas.compare_max_rel(test, gold, tol, "temperature", time) truchas.report_summary(nfail) return nfail
def run_test(tenv): nfail = 0 stdout, output = tenv.truchas(4, "em1.inp") golden = tenv.output("em1_pgolden/em1.h5") conducting_region = output.region(11, 12) # initial joule heat sid = 1 test = output.field(sid, "Joule_P")[conducting_region] gold = golden.field(sid, "Joule_P")[conducting_region] nfail += truchas.compare_max_rel(test, gold, 1e-8, "joule heat", output.time(sid)) # cycles 1 - 5 should be identical to the initial joule heat gold = test for cycle in range(1, 6): sid = output.series_id(cycle) time = output.time(sid) test = output.field(sid, "Joule_P")[conducting_region] nfail += truchas.compare_max(test, gold, 0, "joule heat", output.time(sid)) # # scaled joule heat # sid = output.series_id(6) # gold = 4 * test # test = output.field(sid, "Joule_P")[conducting_region] # nfail += truchas.compare_max_rel(test, gold, 1e-15, "joule heat", output.time(sid)) # # cycles 7 - 11 should be identical to the cycle 6 joule heat # gold = test # for cycle in range(7,12): # sid = output.series_id(cycle) # test = output.field(sid, "Joule_P")[conducting_region] # nfail += truchas.compare_max(test, gold, 0, "joule heat", output.time(sid)) # # zero joule heat # for cycle in range(11,16): # sid = output.series_id(cycle) # test = output.field(sid, "Joule_P")[conducting_region] # nfail += truchas.compare_max(test, 0, 0, "joule heat", output.time(sid)) # # final joule heat # sid = output.series_id(16) # test = output.field(sid, "Joule_P")[conducting_region] # gold = golden.field(sid, "Joule_P")[conducting_region] # nfail += truchas.compare_max_rel(test, gold, 1e-8, "joule heat", output.time(sid)) # # cycles 17-20 should be identical to the cycle 16 joule heat # gold = test # for cycle in range(17,21): # sid = output.series_id(cycle) # test = output.field(sid, "Joule_P")[conducting_region] # nfail += truchas.compare_max(test, gold, 0, "joule heat", output.time(sid)) # # free space joule heat # free_space_region = output.region(10) # for cycle in range(0,21): # sid = output.series_id(cycle) # test = output.field(sid, "Joule_P")[free_space_region] # nfail += truchas.compare_max(test, 0, 0, "free-space joule heat", output.time(sid)) # # final temperature # test = output.field(sid, "Z_TEMP")[conducting_region] # goldf = golden.field(sid, "Z_TEMP")[conducting_region] # nfail += truchas.compare_max_rel(test, goldf, 1e-8, "temp", output.time(sid)) truchas.report_summary(nfail) return nfail
def run_test(tenv): nfail = 0 stdout, output = tenv.truchas(4, "tm-pc.inp") golden = tenv.output("tm-pc_pgolden/tm-pc.h5") # test final fields sid = 2 time = output.time(sid) # temperature temp = output.field(sid, "Z_TEMP") gold = golden.field(sid, "Z_TEMP") nfail += truchas.compare_max_rel(temp, gold, 2e-4, "temperature", time) # thermal strain against value calculated from temperature # Here we compare with a calculated solution where the material has not seen # any non-isothermal phase change, and a golden solution where it has. # The non-isothermal thermal strain is a simple explicit integration of # a nonlinear equation. ncell = 18 cte = [2.2e-5, 2.1e-5, 2.0e-5] T0 = 500 Ti = 400 Th = 375 Tl = 350 pcstrain = [1.15013007E-03, -1.57897042E-03] epstherm = output.field(sid, "epstherm")[:,0] gold = golden.field(sid, "epstherm")[:,0] epsref = sp.array([ (T-T0)*cte[0] if T >= Ti else pcstrain[0] + (T-Ti)*cte[1] if T >= Th else epsgold if T >= Tl else pcstrain[1] + (T-Tl)*cte[2] for T,epsgold in zip(temp, gold)]) nfail += truchas.compare_max_rel(epstherm, epsref, 1e-8, "thermal strain", time) # stress test = output.field(sid, "sigma") l1 = 5.20e+10 l2 = 2.60e+10 XXref = -epstherm * (2*l1 + 2*l2 - 2*l1**2 / (l1 + 2*l2)) nfail += truchas.compare_max_rel(test[:,0], XXref, 1e-8, "sigma_xx", time) nfail += truchas.compare_max_rel(test[:,1], XXref, 1e-8, "sigma_yy", time) nfail += truchas.compare_max(test[:,2], 0, 2, "sigma_zz", time) nfail += truchas.compare_max(test[:,3], 0, 2, "sigma_xy", time) nfail += truchas.compare_max(test[:,4], 0, 2, "sigma_xz", time) nfail += truchas.compare_max(test[:,5], 0, 2, "sigma_xx", time) # strain test = output.field(sid, "epsilon") ZZref = epstherm * (1 + 2 * l1/(l1 + 2*l2)) nfail += truchas.compare_max(test[:,0], 0, 1e-10, "epsilon_xx", time) nfail += truchas.compare_max(test[:,1], 0, 1e-10, "epsilon_yy", time) nfail += truchas.compare_max_rel(test[:,2], ZZref, 1e-8, "epsilon_zz", time) nfail += truchas.compare_max(test[:,3], 0, 1e-10, "epsilon_xy", time) nfail += truchas.compare_max(test[:,4], 0, 1e-10, "epsilon_xz", time) nfail += truchas.compare_max(test[:,5], 0, 1e-10, "epsilon_xx", time) truchas.report_summary(nfail) return nfail