def Analyse(self, parameters): """ Analyze the output and determine if the test passes. """ analyze_status = True print(os.getcwd()) sys.path.insert(1, parameters.parthenon_path + '/scripts/python') try: import phdf_diff except ModuleNotFoundError: print("Couldn't find module to compare Parthenon hdf5 files.") return False # TODO(pgrete) make sure this also works/doesn't fail for the user ret_2d = phdf_diff.compare([ 'advection_2d.out0.00001.phdf', parameters.parthenon_path + '/tst/regression/gold_standard/advection_2d.out0.00001.phdf' ]) ret_3d = phdf_diff.compare([ 'advection_3d.out0.00001.phdf', parameters.parthenon_path + '/tst/regression/gold_standard/advection_3d.out0.00001.phdf' ]) if ret_2d != 0 or ret_3d != 0: analyze_status = False return analyze_status
def Analyse(self, parameters): """ Analyze the output and determine if the test passes. """ analyze_status = True print(os.getcwd()) sys.path.insert( 1, parameters.parthenon_path + '/scripts/python/packages/parthenon_tools/parthenon_tools') try: import phdf_diff except ModuleNotFoundError: print("Couldn't find module to compare Parthenon hdf5 files.") return False # TODO(pgrete) make sure this also works/doesn't fail for the user ret_2d = phdf_diff.compare([ 'advection_2d.out0.00001.phdf', parameters.parthenon_path + '/tst/regression/gold_standard/advection_2d.out0.00001.phdf' ]) ret_3d = phdf_diff.compare([ 'advection_3d.out0.00001.phdf', parameters.parthenon_path + '/tst/regression/gold_standard/advection_3d.out0.00001.phdf' ]) if ret_2d != 0 or ret_3d != 0: analyze_status = False hst_2d = np.genfromtxt('advection_2d.hst') hst_3d = np.genfromtxt('advection_3d.hst') ref_results = [["time", 1.0, 1.0], ["dt", 1.75781e-03, 3.12500e-03], ["total", 7.06177e-02, 1.39160e-02], ["max", 9.43685e-01, 4.80914e-01], ["min", 1.67180e-10, 1.45889e-07]] # check results in last row (at the final time of the sim) for i, val in enumerate(ref_results): if hst_2d[-1:, i] != val[1]: print("Wrong", val[0], "in hst output of 2D problem") analyze_status = False if hst_3d[-1:, i] != val[2]: print("Wrong", val[0], "in hst output of 3D problem") analyze_status = False return analyze_status
def Analyse(self, parameters): sys.path.insert( 1, parameters.parthenon_path + "/scripts/python/packages/parthenon_tools/parthenon_tools", ) try: from phdf_diff import compare except ModuleNotFoundError: print("Couldn't find module to compare Parthenon hdf5 files.") return False # compare against fake sparse version, needs to match up to tolerance used for sparse allocation delta = compare( [ "sparse.out0.final.phdf", parameters.parthenon_path + "/tst/regression/gold_standard/sparse_fake.out0.final.phdf", ], one=True, tol=1e-6, # don't check metadata, because SparseInfo will differ check_metadata=False, ) if delta != 0: return False if not parameters.sparse_disabled: # compare against true sparse, needs to match to machine precision delta = compare( [ "sparse.out0.final.phdf", parameters.parthenon_path + "/tst/regression/gold_standard/sparse_true.out0.final.phdf", ], one=True, ) return delta == 0
def Analyse(self, parameters): """ Analyze the output and determine if the test passes. """ analyze_status = True print(os.getcwd()) # Determine path to parthenon installation # Fallback to relative path on failure try: parthenonPath = os.path.realpath(__file__) idx = parthenonPath.rindex('/parthenon/') parthenonPath = os.path.join(parthenonPath[:idx], 'parthenon') except ValueError: baseDir = os.path.dirname(__file__) parthenonPath = baseDir + '/../../../..' sys.path.insert(1, parthenonPath + '/scripts/python') try: import phdf_diff except ModuleNotFoundError: print("Couldn't find module to compare Parthenon hdf5 files.") return False # TODO(pgrete) make sure this also works/doesn't fail for the user ret_2d = phdf_diff.compare([ 'advection_2d.out0.00001.phdf', parthenonPath + '/tst/regression/gold_standard/advection_2d.out0.00001.phdf' ]) ret_3d = phdf_diff.compare([ 'advection_3d.out0.00001.phdf', parthenonPath + '/tst/regression/gold_standard/advection_3d.out0.00001.phdf' ]) if ret_2d != 0 or ret_3d != 0: analyze_status = False return analyze_status
def Analyse(self, parameters): sys.path.insert(1, parameters.parthenon_path + '/scripts/python') try: from phdf_diff import compare except ModuleNotFoundError: print("Couldn't find module to compare Parthenon hdf5 files.") return False delta = compare([ 'outflow.out0.00001.phdf', parameters.parthenon_path + '/tst/regression/gold_standard/outflow.out0.00001.phdf']) return delta == 0
def compare_files(name): delta = compare( [ "gold.out0.%s.rhdf" % name, "silver.out0.%s.rhdf" % name, ], one=True, ) if delta != 0: print( "ERROR: Found difference between gold and silver output '%s'." % name ) return False return True
def Analyse(self, parameters): sys.path.insert( 1, parameters.parthenon_path + "/scripts/python/packages/parthenon_tools/parthenon_tools", ) try: from phdf_diff import compare except ModuleNotFoundError: print("Couldn't find module to compare Parthenon hdf5 files.") return False delta = compare( [ "poisson.out0.00001.phdf", parameters.parthenon_path + "/tst/regression/gold_standard/poisson.out0.00001.phdf", ] ) return delta == 0
def Analyse(self, parameters): sys.path.insert( 1, parameters.parthenon_path + "/scripts/python/packages/parthenon_tools/parthenon_tools", ) try: import phdf from phdf_diff import compare except ModuleNotFoundError: print("Couldn't find modules to load Parthenon hdf5.") return False all_pass = True # Reflection: First comparing initial condition to final state res = compare( [ "advection.reflecting.00000.phdf", "advection.reflecting.00004.phdf" ], check_metadata=False, quiet=True, ) if res != 0: print("Double reflection test failed: output start != end ") all_pass = False # Compare that data in between is actually different. res = compare( [ "advection.reflecting.00000.phdf", "advection.reflecting.00002.phdf" ], check_metadata=False, quiet=True, ) if res == 0: print("Double reflection test failed: data identical during sim.") all_pass = False # Periodic: First comparing initial condition to final state res = compare( ["advection.periodic.00000.phdf", "advection.periodic.00004.phdf"], check_metadata=False, quiet=True, ) if res != 0: print("Fully periodic test failed: output start != end ") all_pass = False # Compare that data in between is actually different. res = compare( ["advection.periodic.00000.phdf", "advection.periodic.00001.phdf"], check_metadata=False, quiet=True, ) if res == 0: print("Fully periodic test failed: data identical during sim.") all_pass = False # Outflow: Check there's sth in the beginning... outflow_data_initial = phdf.phdf("advection.outflow.00000.phdf") advected_initial = outflow_data_initial.Get("advected") if np.sum(advected_initial) != 60.0: print("Unexpected initial data for outflow test.") all_pass = False # ... and nothing at the end outflow_data_final = phdf.phdf("advection.outflow.00004.phdf") advected_final = outflow_data_final.Get("advected") if np.sum(advected_final) != 0.0: print("Some 'advected' did not leave the box in outflow test.") all_pass = False return all_pass