def eval_budget(sim): print("evaluating budgets...") from budget_file_compare import eval_bud_diff # get ia/ja from binary grid file fname = "{}.dis.grb".format(os.path.basename(sim.name)) fpth = os.path.join(sim.simpath, fname) grbobj = flopy.mf6.utils.MfGrdFile(fpth) ia = grbobj._datadict["IA"] - 1 fname = "{}.cbc".format(os.path.basename(sim.name)) # open first cbc file fpth = os.path.join(sim.simpath, fname) cobj0 = flopy.utils.CellBudgetFile(fpth, precision="double") # open second cbc file fpth = os.path.join(sim.simpath, "mf6", fname) cobj1 = flopy.utils.CellBudgetFile(fpth, precision="double") # define file path and evaluate difference fname = "{}.cbc.cmp.out".format(os.path.basename(sim.name)) fpth = os.path.join(sim.simpath, fname) eval_bud_diff(fpth, cobj0, cobj1, ia, dtol=0.1) return
def eval_flows(sim): idx = sim.idxsim name = ex[idx] print("evaluating flow results..." f"({name})") fpth = os.path.join(exdirs[idx], f"{name}.dis.grb") ia = flopy.mf6.utils.MfGrdFile(fpth).ia fpth = os.path.join(exdirs[idx], f"{name}.cbc") b0 = flopy.utils.CellBudgetFile(fpth, precision="double") fpth = os.path.join(exdirs[idx], "mf6", f"{name}.cbc") b1 = flopy.utils.CellBudgetFile(fpth, precision="double") fpth = os.path.join(exdirs[idx], f"{name}.cbc.cmp.out") eval_bud_diff(fpth, b0, b1, ia=ia) # close the budget files b0.close() b1.close()
def eval_model(sim): print("evaluating model budgets...") from budget_file_compare import eval_bud_diff # get ia/ja from binary grid file fname = "{}.dis.grb".format(os.path.basename(sim.name)) fpth = os.path.join(sim.simpath, fname) grbobj = flopy.utils.MfGrdFile(fpth) ia = grbobj._datadict["IA"] - 1 fname = "{}.cbc".format(os.path.basename(sim.name)) # open first gwf cbc file fpth = os.path.join(sim.simpath, fname) cobj0 = flopy.utils.CellBudgetFile(fpth, precision="double") # open second gwf cbc file fpth = os.path.join(sim.simpath, "mf6", fname) cobj1 = flopy.utils.CellBudgetFile(fpth, precision="double") # define file path and evaluate difference fname = "{}.cbc.cmp.out".format(os.path.basename(sim.name)) fpth = os.path.join(sim.simpath, fname) eval_bud_diff(fpth, cobj0, cobj1, ia) # evaluate the sfr package budget file fname = "{}.{}.cbc".format(os.path.basename(sim.name), paktest) # open first sfr cbc file fpth = os.path.join(sim.simpath, fname) cobj0 = flopy.utils.CellBudgetFile(fpth, precision="double") # open second sfr cbc file fpth = os.path.join(sim.simpath, "mf6", fname) cobj1 = flopy.utils.CellBudgetFile(fpth, precision="double") # define file path and evaluate difference fname = "{}.{}.cbc.cmp.out".format(os.path.basename(sim.name), paktest) fpth = os.path.join(sim.simpath, fname) eval_bud_diff(fpth, cobj0, cobj1) # do some spot checks on the first sfr cbc file v0 = cobj0.get_data(totim=1.0, text="FLOW-JA-FACE")[0] q = [] for idx, node in enumerate(v0["node"]): if node > 5: q.append(v0["q"][idx]) v0 = np.array(q) check = np.ones(v0.shape, dtype=float) * 5e-2 check[-2] = 4e-2 assert np.allclose(v0, check), "FLOW-JA-FACE failed" v0 = cobj0.get_data(totim=1.0, text="EXT-OUTFLOW")[0] v0 = v0["q"][4:] check = np.array([-0.80871, -5e-2, -2.5e-2, -5e-2, -2.0e-2, -5e-2]) assert np.allclose(v0, check), "EXT-OUTFLOW failed" v0 = cobj0.get_data(totim=1.0, text="FROM-MVR")[0] v0 = v0["q"][4:] check = np.array([4.5e-2, 0.0, 0.0, 0.0, 0.0, 0.0]) assert np.allclose(v0, check), "FROM-MVR failed" v0 = cobj0.get_data(totim=1.0, text="TO-MVR")[0] v0 = v0["q"][4:] check = np.array([0.0, 0.0, -2.5e-2, 0.0, -2.0e-2, 0.0]) assert np.allclose(v0, check), "FROM-MVR failed" return