Commit 18efbd8d authored by Feliks Kuba Kiszkurno's avatar Feliks Kuba Kiszkurno
Browse files

Prepared the code to be submitted to ogstools repo.

Removed part that was using Dr. Buchwalds code and replaced it with a placeholder (get_analytic_solution). Replaced legend_without_duplicate_labels with new code.
parent 2132287f
[submodule "AHM"]
path = AHM
url = git@github.com:felikskiszkurno-ufz/AHM.git
Subproject commit aabc33b1eebe45ef5625907917c83f4e9a257f59
......@@ -52,9 +52,9 @@ def extract_params(folder_name):
param_a = {}
param_b = {}
param_a['name'] = folder_name.name.split("_")[0]
param_a['value'] = folder_name.name.split("_")[1]
param_b['name'] = folder_name.name.split("_")[-2]
param_b['value'] = folder_name.name.split("_")[-1]
param_a['name'] = folder_name.split("_")[0]
param_a['value'] = folder_name.split("_")[1]
param_b['name'] = folder_name.split("_")[-2]
param_b['value'] = folder_name.split("_")[-1]
return param_a, param_b
......@@ -2,75 +2,10 @@ import sys
import os
sys.path.append(os.path.join('AHM'))
from AHM.models import heatsource
import numpy as np
# TODO: This should be removed and AHM package should be called directly
# This is a placeholder.
# Originally here was a function that used code written by Dr. Jörg Buchwald.
# When his code will be submitted and merged to the ogstools repo,
# I will rewrite this part to call to it. For now it will remain a placeholder.
def get_analytica_model(parameter_name, x, y, z, t, ogs_model=None):
model = heatsource.ANASOL()
if ogs_model == None:
model.E = 8e9
model.nu = 0.35
model.aprime = 1.5e-5
model.a_s = 1.5e-5
model.a_w = 4.0e-4
model.Q = 152
model.n = 0.18
model.rho_w = 999.1
model.rho_s = 2689.65517241379
model.K_w = 0.6
model.K_s = 2.4
model.vis = 1.0e-3
model.c_w = 4181.3
model.c_s = 995
model.T0 = 288.15
model.k = 5e-20
model.reInit()
else:
model.E = float(
ogs_model.tree.find("./parameters/parameter[name='YoungsModuliClay']/values").text.split(" ")[0])
model.nu = float(
ogs_model.tree.find("./parameters/parameter[name='PoissonsRatiosClay']/values").text.split(" ")[0])
model.a_s = 3 * float(ogs_model.tree.find(
"./media/medium/phases/phase[type='Solid']/properties/property[name='thermal_expansivity']/value").text)
model.aprime = model.a_s
model.a_w = -float(ogs_model.tree.find(
"./media/medium/phases/phase[type='AqueousLiquid']/properties/property[name='density']/independent_variable/slope").text)
model.n = float(ogs_model.tree.find("./media/medium/properties/property[name='porosity']/value").text)
model.rho_w = float(ogs_model.tree.find(
"./media/medium/phases/phase[type='AqueousLiquid']/properties/property[name='density']/reference_value").text)
model.rho_s = float(ogs_model.tree.find(
"./media/medium/phases/phase[type='Solid']/properties/property[name='density']/value").text)
model.c_w = float(ogs_model.tree.find(
"./media/medium/phases/phase[type='AqueousLiquid']/properties/property[name='specific_heat_capacity']/value").text)
model.c_s = float(ogs_model.tree.find(
"./media/medium/phases/phase[type='Solid']/properties/property[name='specific_heat_capacity']/value").text)
# ana_model.K_w = float(ogs_model.tree.find(
# "./media/medium/phases/phase[type='AqueousLiquid']/properties/property[name='thermal_conductivity']/value").text)
model.K_w = 0.6
model.K_s = float(ogs_model.tree.find(
"./parameters/parameter[name='ThermalConductivityClay']/values").text.split(" ")[0])
# ana_model.vis = float(ogs_model.tree.find(
# "./media/medium/phases/phase[type='AqueousLiquid']/properties/property[name='viscosity']/value").text)
model.vis = 0.001137740703477269
model.k = float(
ogs_model.tree.find("./parameters/parameter[name='IntrinsicPermClay']/values").text.split(" ")[0])
model.Q = 2 * float(
ogs_model.tree.find("./parameters/parameter[name='heater']/values").text)
model.T0 = float(ogs_model.tree.find("./parameters/parameter[name='temperature_ic']/values").text)
model.reInit()
# t[0] = 0.01
R = np.sqrt(x ** 2 + y ** 2 + z ** 2)
if parameter_name == 'temperature' or parameter_name == 'temperature_interpolated':
output = model.temperature(R, t)
elif parameter_name == 'pressure' or parameter_name == 'pressure_interpolated':
output = model.porepressure(R, t)
else:
print('Unrecognized parameter name! Skipping analytical model...')
return output
pass
import matplotlib.pyplot as plt
def legend_without_duplicate_labels(figure): # modified Julien Jm @ https://stackoverflow.com/questions/19385639/duplicate-items-in-legend-in-matplotlib
handles, labels = plt.gca().get_legend_handles_labels()
by_label = dict(zip(labels, handles))
figure.legend(by_label.values(), by_label.keys(), loc='lower center', ncol=8)
def legend_without_duplicate_labels(figure, leg_loc='lower center', n_col=8):
# The default key values work for the example plots, but may require editing for other data.
handles, labels = figure.gca().get_legend_handles_labels()
figure.legend(handles, labels, loc=leg_loc, ncol=n_col)
return figure
\ No newline at end of file
......@@ -2,6 +2,7 @@ import os
import vtuIO
from .detect_experiments import getfilesbyextension
# TODO: add option to use different tools for
def read_data(experiments_to_include, field_to_read, points, results_folder):
SEC2A = 1 / (356 * 24 * 60 * 60) # time in seconds to time in years
......
......@@ -91,6 +91,8 @@ class OGSDataCompare:
k = 0
for i, j in itertools.product(range(ax.shape[0]), range(ax.shape[1])):
point_name = self.data.point_names[k]
# THIS FUNCTIONALITY IS NOT AVAILABLE NOW. SET analytical_ref TO FALSE.
# See Tools\get_analytical_model.py for explanation.
if analytical_ref is True:
exp_data_plot = get_analytica_model(self.config.parameter, self.points[point_name][0],
self.points[point_name][1], self.points[point_name][2],
......@@ -206,7 +208,7 @@ class OGSDataCompare:
output_file_name = "compare_separate_legend"
self.__save_figure(fig_legend, output_file_name)
def ogs_compare_time_point(self, time_step, analytical_ref=True, ogs_model=None):
def ogs_compare_time_point(self, time_step, analytical_ref=False, ogs_model=None):
# Prepare results
sub_params_n = self.data.experiments_results_param[self.config.reference_experiment][self.data.point_names[0]].shape
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment