def AmanziResults(input_filename,subtests,obs_slices,overwrite=False): import run_amanzi_standard # Create emtpy dictionaries obs_scatter={} obs_data={} obs_xml={} try: for st in subtests: # modify file content old_content = open(input_filename).read() new_content = old_content.replace("explicit first-order", subtests[st]['parameters']) tmp_filename = "tmp.xml" f = open(tmp_filename, 'w') f.write(new_content) f.flush() f.close() run_amanzi_standard.run_amanzi(tmp_filename, 8, ["amanzi_dispersion_45_point_2d.exo",tmp_filename], subtests[st]['directory']) obs_xml[st]=loadInputXML(input_filename) obs_data[st]=loadDataFile(obs_xml[st],subtests[st]['directory']) # Collect observations to plot obs_scatter[st]=CollectObservations(obs_xml[st], obs_data[st], obs_slices) finally: pass return obs_xml, obs_data, obs_scatter
'bo', label='Amanzi: r=100m') axes1.legend(loc='lower right') if __name__ == "__main__": import os import run_amanzi_standard input_file = os.path.join("amanzi_boundedDomain_2d.xml") CWD = os.getcwd() try: run_amanzi_standard.run_amanzi(input_file, 16, [input_file]) obs_data = load_amanzi_obs() obsdata = [] obstimes = [] for obs in obs_data.observations.itervalues(): obsdata.append(obs.data) obstimes.append(obs.times) obsdata = numpy.transpose(numpy.array(obsdata)) obstimes = numpy.transpose(numpy.array(obstimes)) obstimes[:] = obstimes[:] / 24. / 3600. ana_data = load_ana_solution() # note: in analytical solution the drawdown (m) was given at time in days
x_crunchflow, c_crunchflow = GetXY_CrunchFlow_1D(path_to_crunchflow,root,times_CF,comp,ignore) # crunchflow OS3D path_to_crunchflow = "crunchflow/os3d" x_crunchOS3D, c_crunchOS3D = GetXY_CrunchFlow_1D(path_to_crunchflow,root,times_CF,comp,ignore) CWD = os.getcwd() local_path = "" # amanziU try: comp = 'total_component_concentration.cell.tracer conc' input_file = os.path.join("amanzi-u-1d-"+root+"-alq-pflo.xml") path_to_amanzi = "output-u-alq-pflo" run_amanzi_standard.run_amanzi(input_file, 1, ["1d-"+root+".in",root+".dat",input_file], path_to_amanzi) x_amanzi_alquimia, c_amanzi_alquimia = GetXY_AmanziU_1D(path_to_amanzi,root,comp,1) alq = len(x_amanzi_alquimia) except: alq = 0 try: comp = 'total_component_concentration.cell.tracer conc' input_file = os.path.join("amanzi-u-1d-"+root+"-alq-crunch.xml") path_to_amanzi = "output-u-alq-crunch" run_amanzi_standard.run_amanzi(input_file, 1, ["1d-"+root+"-crunch.in",root+".dbs",input_file], path_to_amanzi) x_amanzi_alquimia_crunch, c_amanzi_alquimia_crunch = GetXY_AmanziU_1D(path_to_amanzi,root,comp,1) alq_crunch = len(x_amanzi_alquimia_crunch) except:
# root name for problem root = "non_grid_aligned" nodesx = 121 nodesy = 101 local_path = "" # subplots plt.subplots(1, figsize=(11, 8)) # Amanzi + Native chemistry try: input_file = os.path.join("non_grid_aligned-u.xml") path_to_amanzi = "output-u" run_amanzi_standard.run_amanzi(input_file, 1, ["calcite_dbs.bgd", input_file], path_to_amanzi) comp = 'mineral_volume_fractions.cell.Calcite vol frac' x_native, y_native, z_native = GetXYZ_Amanzi(path_to_amanzi, root, comp, nodesx=nodesx, nodesy=nodesy) except Exception: pass extent = [0.0, 0.60, 0.0, 0.50] # plot adjustments
for i, time in enumerate(times_CF): x_crunchflow, c_crunchflow = GetXY_CrunchFlow(path_to_crunchflow, root, time, comp, ignore) VF_crunchOS3D = VF_crunchOS3D + [c_crunchflow / 100.0] CWD = os.getcwd() local_path = "" # subplots fig, ax = plt.subplots(3, sharex=True, figsize=(8, 10)) try: # Amanzi native chemistry input_filename = os.path.join("amanzi-u-1d-calcite.xml") path_to_amanzi = "amanzi-native-output" run_amanzi_standard.run_amanzi(input_filename, 1, ["calcite.bgd"], path_to_amanzi) comp = 'total_component_concentration.cell.Ca++ conc' Ca_amanzi_native = [] for i, time in enumerate(times): x_amanzi_native, c_amanzi_native = GetXY_Amanzi( path_to_amanzi, root, comp) Ca_amanzi_native = Ca_amanzi_native + [c_amanzi_native] comp = 'free_ion_species.cell.H+' pH_amanzi_native = [] for i, time in enumerate(times): x_amanzi_native, c_amanzi_native = GetXY_Amanzi( path_to_amanzi, root, comp) pH_amanzi_native = pH_amanzi_native + [-np.log10(c_amanzi_native)]
# mineral volume fraction w_pflotran = [[] for x in range(len(vfpflo))] for j, vf in enumerate(vfpflo): x_pflotran, c_pflotran = GetXY_PFloTran_1D(path_to_pflotran, root_pflotran, time, vf) w_pflotran[j] = c_pflotran CWD = os.getcwd() local_path = "" # Amanzi + Native chemistry try: input_file = os.path.join("amanzi-u-1d-" + root + ".xml") path_to_amanzi = "output-u" run_amanzi_standard.run_amanzi(input_file, 1, [root + ".bgd", input_file], path_to_amanzi) time = timesama[0] # tot conc u_amanzi_native = [[] for x in range(len(totcama))] for j, comp in enumerate(totcama): x_amanzi_native, c_amanzi_native = GetXY_AmanziU_1D( path_to_amanzi, 'plot', comp, 1) u_amanzi_native[j] = c_amanzi_native # sorb conc v_amanzi_native = [[] for x in range(len(sorbama))] for j, sorb in enumerate(sorbama): x_amanzi_native, c_amanzi_native = GetXY_AmanziU_1D(
if os.path.exists("table_values.txt"): os.remove("table_values.txt") table_file = open("table_values.txt", "w+") table_file.write(x.get_string()) table_file.close() if __name__ == "__main__": import os import run_amanzi_standard input_filename = "amanzi_linear_materials_serial_1d-isv2.xml" try: run_amanzi_standard.run_amanzi(input_filename, 1) obs_xml = loadInputXML(input_filename) obs_data = loadDataFile(obs_xml) fig1 = plt.figure() axes1 = fig1.add_axes([.15, .15, .80, .80]) cmap = plotTestObservations(obs_xml, obs_data, axes1) plotTestModel(input_filename, cmap, axes1, obs_xml, obs_data) # plt.show() MakeTable(obs_data, obs_xml, input_filename) finally: pass
# crunchflow OS3D path_to_crunchflow = "crunchflow/os3d" x_crunchOS3D, c_crunchOS3D = GetXY_CrunchFlow(path_to_crunchflow, root, times_CF, comp, ignore) CWD = os.getcwd() local_path = "" # amanziU - native try: comp = 'total_component_concentration.cell.tracer conc' input_filename = os.path.join("amanzi-u-1d-" + root + ".xml") path_to_amanzi = "amanzi-u-native-output" run_amanzi_standard.run_amanzi(input_filename, 1, [], path_to_amanzi) x_amanzi_native, c_amanzi_native = GetXY_AmanziU( path_to_amanzi, root, comp) native = len(x_amanzi_native) except: native = 0 # amanziU - alquimia pflotran try: comp = 'total_component_concentration.cell.tracer conc' input_filename = os.path.join("amanzi-u-1d-" + root + "-alq-pflo.xml") path_to_amanzi = "amanzi-u-alq-pflo-output" run_amanzi_standard.run_amanzi(input_filename, 1, ["1d-" + root + ".in", root + ".dat"],
for i, time in enumerate(times_CF_pH): y_crunchflow, c_crunchflow = GetXY_CrunchFlow_1D(path_to_crunch,root,time,comp,ignore) pH_crunchflow[i] = c_crunchflow crunch = True except: crunch = False # AmanziU + Native chemistry ---> try: input_file = os.path.join("amanzi-u-1d-"+root+".xml") path_to_amanzi = "output-u" run_amanzi_standard.run_amanzi(input_file, 1, [root+".bgd",input_file], path_to_amanzi) u_amanzi_native = [[[] for x in range(len(amanzi_totc))] for x in range(len(times))] for i, time in enumerate(times): for j, comp in enumerate(amanzi_totc): x_amanzi_native, c_amanzi_native = GetXY_AmanziU_1D(path_to_amanzi,root,comp,1) u_amanzi_native[i][j] = c_amanzi_native v_amanzi_native = [[[] for x in range(len(amanzi_sorb))] for x in range(len(times))] for i, time in enumerate(times): for j, comp in enumerate(amanzi_sorb): x_amanzi_native, c_amanzi_native = GetXY_AmanziU_1D(path_to_amanzi,root,comp,1) v_amanzi_native[i][j] = c_amanzi_native pH_amanzi_native = [ [] for x in range(len(times)) ]
axes1.plot(numpy.log10(obstimes[1:ntime3,0]), obsdata[1:ntime3,0], 'ro', label='Amanzi: Obs1') axes1.plot(numpy.log10(ana_data[ntime1+1:ntime2,0]), ana_data[ntime1+1:ntime2,1], '-b', label='Butler Pod Solution: Obs2') axes1.plot(numpy.log10(obstimes[1:ntime4,1]), obsdata[1:ntime4,1], 'bo', label='Amanzi: Obs2') axes1.legend(loc='upper left') if __name__ == "__main__": import os import run_amanzi_standard input_filename =os.path.join("amanzi_butler_pod_2d.xml") cwd = os.getcwd() try: run_amanzi_standard.run_amanzi(input_filename, 10, {"mesh_cylinder.exo"}) obs_xml = loadInputXML(input_filename) obs_data = load_amanzi_obs() obsdata = [] obstimes = [] for obs in obs_data.observations.itervalues(): obsdata.append(obs.data) obstimes.append(obs.times) obsdata = numpy.transpose(numpy.array(obsdata)) obstimes = numpy.transpose(numpy.array(obstimes)) obstimes[:] = obstimes[:]/24./3600. ana_data=load_ana_solution() ana_data[:,0] = ana_data[:,0]/24./3600.
x_crunchflow, c_crunchflow = GetXY_CrunchFlow_1D( path_to_crunchflow, root, time, comp, ignore) VF_crunchOS3D = VF_crunchOS3D + [c_crunchflow] CWD = os.getcwd() local_path = "" # subplots fig, ax = plt.subplots(3, sharex=True, figsize=(8, 10)) try: # Amanzi native chemistry input_file = os.path.join("amanzi-u-1d-calcite.xml") path_to_amanzi = "output-u" run_amanzi_standard.run_amanzi(input_file, 1, ["calcite.bgd", input_file], path_to_amanzi) comp = 'total_component_concentration.cell.Ca++ conc' Ca_amanzi_native = [] for i, time in enumerate(times): x_amanzi_native, c_amanzi_native = GetXY_AmanziU_1D( path_to_amanzi, root, comp, 1) Ca_amanzi_native = Ca_amanzi_native + [c_amanzi_native] comp = 'free_ion_species.cell.H+' pH_amanzi_native = [] for i, time in enumerate(times): x_amanzi_native, c_amanzi_native = GetXY_AmanziU_1D( path_to_amanzi, root, comp, 1) pH_amanzi_native = pH_amanzi_native + [-np.log10(c_amanzi_native)]
table_file = open("table_values.txt", "w+") table_file.write('.. tabularcolumns:: ' + '|R|C|C|C|' + '\n\n') table_file.write(x.get_string(sortby="x [m]")) table_file.write('\n') table_file.close() if __name__ == "__main__": import os import run_amanzi_standard input_filename = "amanzi_linear_head_head_1d-isv2.xml" try: max_np = 1 run_amanzi_standard.run_amanzi(input_filename, max_np) obs_xml = loadInputXML(input_filename) obs_data = loadDataFile(obs_xml) fig1 = plt.figure() axes1 = fig1.add_axes([.15, .15, .80, .80]) MakeTable(obs_data, obs_xml, input_filename) cmap = plotTestObservations(obs_xml, obs_data, axes1) plotTestModel(input_filename, cmap, axes1, obs_xml, obs_data) # plt.show() finally: pass
obsdata[1:ntime3, 0], 'bo', label='Amanzi: r=100m') axes1.legend(loc='lower right') if __name__ == "__main__": import os import run_amanzi_standard input_file = os.path.join("amanzi_hantush_anisotropic_2d-u.xml") try: run_amanzi_standard.run_amanzi(input_file, 1, ["porflow4_6.exo", input_file]) obs_data = load_amanzi_obs() obsdata = [] obstimes = [] for obs in obs_data.observations.itervalues(): obsdata.append(obs.data) obstimes.append(obs.times) obsdata = numpy.transpose(numpy.array(obsdata)) obstimes = numpy.transpose(numpy.array(obstimes)) obstimes[:] = obstimes[:] / 24. / 3600. # analytic solution is not available yet ana_data = load_ana_solution()
table_file = open("table_values.txt", "w+") table_file.write('.. tabularcolumns:: ' + '|R|C|C|C|' + '\n\n') table_file.write(x.get_string(sortby="x [m]")) table_file.write('\n') table_file.close() if __name__ == "__main__": import os import run_amanzi_standard input_file = "amanzi_linear_head_head_1d-u.xml" try: max_np = 1 run_amanzi_standard.run_amanzi(input_file, max_np, [input_file]) obs_xml = loadInputXML(input_file) obs_data = loadDataFile(obs_xml) fig1 = plt.figure() axes1 = fig1.add_axes([.15, .15, .80, .80]) MakeTable(obs_data, obs_xml, input_file) cmap = plotTestObservations(obs_xml, obs_data, axes1) plotTestModel(input_file, cmap, axes1, obs_xml, obs_data) # plt.show() finally: pass
'bo', label='Amanzi: Obs2') axes1.legend(loc='upper left') if __name__ == "__main__": import os import run_amanzi_standard input_file = os.path.join("amanzi_butler_pod_2d.xml") cwd = os.getcwd() try: run_amanzi_standard.run_amanzi(input_file, 10, ["mesh_cylinder.exo", input_file]) obs_xml = loadInputXML(input_file) obs_data = load_amanzi_obs() obsdata = [] obstimes = [] for obs in obs_data.observations.itervalues(): obsdata.append(obs.data) obstimes.append(obs.times) obsdata = numpy.transpose(numpy.array(obsdata)) obstimes = numpy.transpose(numpy.array(obstimes)) obstimes[:] = obstimes[:] / 24. / 3600. ana_data = load_ana_solution() ana_data[:, 0] = ana_data[:, 0] / 24. / 3600.
os.remove("table_values.txt") table_file = open("table_values.txt", "w+") table_file.write('.. tabularcolumns:: ' + '|R|C|C|C|' + '\n\n') table_file.write(x.get_string(sortby="x [m]")) table_file.write('\n') table_file.close() if __name__ == "__main__": import os import run_amanzi_standard input_filename = "amanzi_unconfined_seepage_1d-isv2.xml" try: run_amanzi_standard.run_amanzi(input_filename, 1, ["porflow4_4.exo"]) obs_xml=loadInputXML(input_filename) obs_data=loadDataFile(obs_xml) fig1 = plt.figure() axes1=fig1.add_axes([.15,.15,.80,.80]) MakeTable(obs_data,obs_xml,input_filename) cmap = plotTestObservations(obs_xml,obs_data,axes1) plotTestModel(input_filename,cmap,axes1,obs_xml,obs_data) # plt.show() finally: pass
table_file = open("table_values.txt", "w+") table_file.write('.. tabularcolumns:: ' + '|R|C|C|C|' + '\n\n') table_file.write(x.get_string(sortby="x [m]")) table_file.write('\n') table_file.close() if __name__ == "__main__": import os import run_amanzi_standard input_file = "amanzi_linear_flux_head_1d-u.xml" run_dir = "amanzi-output" try: run_amanzi_standard.run_amanzi(input_file, 2, [input_file], run_dir) obs_xml = loadInputXML(input_file) obs_data = loadDataFile(obs_xml) fig1 = plt.figure() axes1 = fig1.add_axes([.15, .15, .80, .80]) MakeTable(obs_data, obs_xml, input_file) cmap = plotTestObservations(obs_xml, obs_data, axes1) plotTestModel(input_file, cmap, axes1, obs_xml, obs_data) # plt.show() finally: pass
if legend == "Amanzi" : axes1.scatter(obs.times, numpy.log10(obs.data), marker='o', s=25, c=color, label=legend) if __name__ == "__main__": import os import run_amanzi_standard input_file = os.path.join("amanzi_single_fracture.xml") path_to_amanzi = "amanzi-output" cwd = os.getcwd() try: max_np = 1 run_amanzi_standard.run_amanzi(input_file, max_np, ["single_fracture.exo", input_file], path_to_amanzi) obs_xml=loadInputXML(input_file) obs_data=loadDataFile(obs_xml) fig1 = plt.figure() axes1 = fig1.add_axes([0.12,0.1,0.86,0.84]) plotSingleFractureObservations(obs_xml,obs_data,axes1) # first benchmark (2 figures are planned for future) data = [] data = open("benchmark/UiB_RT0.txt").read().split(); for i in range(0, len(data)): data[i] = data[i].split(',') data = numpy.array(data, dtype=numpy.double)
import matplotlib from matplotlib import pyplot as plt import run_amanzi_standard from compare_field_results import GetXY_AmanziU_1D from compare_field_results import GetXY_AmanziS_1D if __name__ == "__main__": # Amanzi: unstructured try: input_file = "amanzi_infiltration_sand_loam_1d-u.xml" path_to_amanzi = "output_2b-u" root_amanzi = 'case_2b_plot' run_amanzi_standard.run_amanzi(input_file, 1, [input_file], path_to_amanzi) comp = 'pressure.cell.0' x_amanziU, c_amanziU = GetXY_AmanziU_1D(path_to_amanzi, root_amanzi, comp, 3) unstruct = len(x_amanziU) except: unstruct = 0 # Amanzi: structured try: input_file = "amanzi_infiltration_sand_loam_1d-s.xml" path_to_amanzi = "output_2b-s" root_amanzi = "plot" run_amanzi_standard.run_amanzi(input_file, 1, [input_file],
table_file.write('.. tabularcolumns:: ' + '|R|C|C|C|' + '\n\n') table_file.write(x.get_string(sortby="x [m]")) table_file.write('\n') table_file.close() if __name__ == "__main__": import os import run_amanzi_standard input_file = "amanzi_unconfined_seepage_1d-u.xml" run_dir = "amanzi-output" try: run_amanzi_standard.run_amanzi(input_file, 1, ["porflow4_4.exo", input_file], run_dir) obs_xml = loadInputXML(input_file) obs_data = loadDataFile(obs_xml) fig1 = plt.figure() axes1 = fig1.add_axes([.15, .15, .80, .80]) MakeTable(obs_data, obs_xml, input_file) cmap = plotTestObservations(obs_xml, obs_data, axes1) plotTestModel(input_file, cmap, axes1, obs_xml, obs_data) plt.savefig('unconfined_seepage_1d.png') # plt.show() finally:
x_crunchflow, c_crunchflow = GetXY_CrunchFlow(path_to_crunchflow, root, times_CF, comp, ignore) CWD = os.getcwd() local_path = "" # subplots fig, ax = plt.subplots() # AmanziS + Alqumia + PFlotran chemistry try: input_file = os.path.join("amanzi-s-1d-" + root + "-alq-pflo.xml") path_to_amanzi = "output-s-alq-pflo" run_amanzi_standard.run_amanzi( input_file, 1, ["1d-" + root + "-trim.in", root + ".dat", input_file], path_to_amanzi) root_amanzi = "plt00037" comp = "Tritium_water_Concentration" x_amanziS, c_amanziS = GetXY_AmanziS(path_to_amanzi, root_amanzi, comp) struct = len(x_amanziS) except: struct = 0 # AmanziS + Alqumia + CrunchFlow chemistry try: input_file = os.path.join("amanzi-s-1d-" + root + "-alq-crunch.xml") path_to_amanzi = "output-s-alq-crunch" run_amanzi_standard.run_amanzi(input_file, 1, [ "1d-" + root + "-crunch.in", root + ".dbs", "aqueous.dbs", input_file
'total_sorbed.cell.3'] amanzi_compS = ['Na+_Aqueous_Concentration', \ 'Ca++_Aqueous_Concentration', \ 'Mg++_Aqueous_Concentration', \ 'Cl-_Aqueous_Concentration'] amanzi_sorbS = ['Na+_Sorbed_Concentration', \ 'Ca++_Sorbed_Concentration', \ 'Mg++_Sorbed_Concentration', \ 'Cl-_Sorbed_Concentration'] try: # Amanzi native chemistry input_filename = os.path.join("amanzi-u-1d-"+root+".xml") path_to_amanzi = "amanzi-native-output" run_amanzi_standard.run_amanzi(input_filename, 1, [root+".bgd"], path_to_amanzi) u_amanzi_native = [[[] for x in range(len(amanzi_components))] for x in range(len(times))] for i, time in enumerate(times): for j, comp in enumerate(amanzi_components): x_amanzi_native, c_amanzi_native = GetXY_Amanzi(path_to_amanzi,root,comp) u_amanzi_native[i][j] = c_amanzi_native v_amanzi_native = [[[] for x in range(len(amanzi_sorbed))] for x in range(len(times))] for i, time in enumerate(times): for j, comp in enumerate(amanzi_sorbed): x_amanzi_native, c_amanzi_native = GetXY_Amanzi(path_to_amanzi,root,comp) v_amanzi_native[i][j] = c_amanzi_native native = True