Skip to content

Commit

Permalink
Merge branch 'elder' into 'master'
Browse files Browse the repository at this point in the history
Conversion elder benchmark to notebook

See merge request ogs/ogs!5068
  • Loading branch information
felikskiszkurno-ufz committed Oct 28, 2024
2 parents 366528d + 176f112 commit 5ee8abc
Show file tree
Hide file tree
Showing 11 changed files with 217 additions and 79 deletions.
1 change: 1 addition & 0 deletions ProcessLib/ComponentTransport/Tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,7 @@ if(NOT OGS_USE_PETSC)
NotebookTest(NOTEBOOKFILE Parabolic/ComponentTransport/ReactiveTransport/CO2Injection/CO2Injection.md RUNTIME 5)
NotebookTest(NOTEBOOKFILE Parabolic/ComponentTransport/MultiLayerDiffusion/MultiLayerDiffusion.ipynb RUNTIME 25)
NotebookTest(NOTEBOOKFILE Parabolic/ComponentTransport/DiffusionSorptionDecay/DiffusionSorptionDecay.ipynb RUNTIME 16)
NotebookTest(NOTEBOOKFILE Parabolic/ComponentTransport/elder_jupyter/elder_jupyter.py RUNTIME 25)
NotebookTest(NOTEBOOKFILE Parabolic/ThermalTwoPhaseFlowPP/HeatPipe/heatpipe.ipynb RUNTIME 10)
endif()

Expand Down
4 changes: 2 additions & 2 deletions Tests/Data/Mechanics/Linear/SimpleMechanics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,13 @@
"source": [
"mesh_series = MeshSeries(f\"{out_dir}/{prj_name}.pvd\")\n",
"points = np.asarray([[0.3, 0.5, 0.0], [0.24, 0.21, 0.0]])\n",
"disp = ot.properties.displacement\n",
"disp = ot.variables.displacement\n",
"\n",
"labels = [\n",
" f\"{i}: {label}\" for i, label in enumerate(ot.plot.utils.justified_labels(points))\n",
"]\n",
"fig = mesh_series.plot_probe(\n",
" points=points[:4], mesh_property=disp, time_unit=\"a\", labels=labels[:4]\n",
" points=points[:4], variable=disp, time_unit=\"a\", labels=labels[:4]\n",
")"
]
},
Expand Down
2 changes: 2 additions & 0 deletions Tests/Data/Notebooks/nbconvert_templates/collapsed.md.j2
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@
{% endblock data_latex %}

{% block data_html scoped %}
{% raw %} {{< rawhtml >}} {% endraw %}
{{ output.data['text/html'] }}
{% raw %} {{< /rawhtml >}} {% endraw %}
{% endblock data_html %}

{% block data_markdown scoped %}
Expand Down
52 changes: 26 additions & 26 deletions Tests/Data/Parabolic/ComponentTransport/elder/elder_reference.pvd
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<?xml version="1.0"?>
<VTKFile type="Collection" version="0.1" byte_order="LittleEndian" compressor="vtkZLibDataCompressor">
<Collection>
<DataSet timestep="0" group="" part="0" file="elder_pcs_0_ts_0_t_0.000000_reference.vtu"/>
<DataSet timestep="5259600" group="" part="0" file="elder_pcs_0_ts_20_t_5259600.000000_reference.vtu"/>
<DataSet timestep="10519200" group="" part="0" file="elder_pcs_0_ts_40_t_10519200.000000_reference.vtu"/>
<DataSet timestep="15778800" group="" part="0" file="elder_pcs_0_ts_60_t_15778800.000000_reference.vtu"/>
<DataSet timestep="21038400" group="" part="0" file="elder_pcs_0_ts_80_t_21038400.000000_reference.vtu"/>
<DataSet timestep="26298000" group="" part="0" file="elder_pcs_0_ts_100_t_26298000.000000_reference.vtu"/>
<DataSet timestep="31557600" group="" part="0" file="elder_pcs_0_ts_120_t_31557600.000000_reference.vtu"/>
<DataSet timestep="36817200" group="" part="0" file="elder_pcs_0_ts_140_t_36817200.000000_reference.vtu"/>
<DataSet timestep="42076800" group="" part="0" file="elder_pcs_0_ts_160_t_42076800.000000_reference.vtu"/>
<DataSet timestep="47336400" group="" part="0" file="elder_pcs_0_ts_180_t_47336400.000000_reference.vtu"/>
<DataSet timestep="52596000" group="" part="0" file="elder_pcs_0_ts_200_t_52596000.000000_reference.vtu"/>
<DataSet timestep="57855600" group="" part="0" file="elder_pcs_0_ts_220_t_57855600.000000_reference.vtu"/>
<DataSet timestep="63115200" group="" part="0" file="elder_pcs_0_ts_240_t_63115200.000000_reference.vtu"/>
<DataSet timestep="68374800" group="" part="0" file="elder_pcs_0_ts_260_t_68374800.000000_reference.vtu"/>
<DataSet timestep="73634400" group="" part="0" file="elder_pcs_0_ts_280_t_73634400.000000_reference.vtu"/>
<DataSet timestep="78894000" group="" part="0" file="elder_pcs_0_ts_300_t_78894000.000000_reference.vtu"/>
<DataSet timestep="84153600" group="" part="0" file="elder_pcs_0_ts_320_t_84153600.000000_reference.vtu"/>
<DataSet timestep="89413200" group="" part="0" file="elder_pcs_0_ts_340_t_89413200.000000_reference.vtu"/>
<DataSet timestep="94672800" group="" part="0" file="elder_pcs_0_ts_360_t_94672800.000000_reference.vtu"/>
<DataSet timestep="99932400" group="" part="0" file="elder_pcs_0_ts_380_t_99932400.000000_reference.vtu"/>
<DataSet timestep="105192000" group="" part="0" file="elder_pcs_0_ts_400_t_105192000.000000_reference.vtu"/>
<DataSet timestep="110451600" group="" part="0" file="elder_pcs_0_ts_420_t_110451600.000000_reference.vtu"/>
<DataSet timestep="115711200" group="" part="0" file="elder_pcs_0_ts_440_t_115711200.000000_reference.vtu"/>
<DataSet timestep="120970800" group="" part="0" file="elder_pcs_0_ts_460_t_120970800.000000_reference.vtu"/>
<DataSet timestep="126230400" group="" part="0" file="elder_pcs_0_ts_480_t_126230400.000000_reference.vtu"/>
<DataSet timestep="131490000" group="" part="0" file="elder_pcs_0_ts_500_t_131490000.000000_reference.vtu"/>
<DataSet timestep="0" group="" part="0" file="elder_ts_0_t_0.000000_reference.vtu"/>
<DataSet timestep="5259600" group="" part="0" file="elder_ts_20_t_5259600.000000_reference.vtu"/>
<DataSet timestep="10519200" group="" part="0" file="elder_ts_40_t_10519200.000000_reference.vtu"/>
<DataSet timestep="15778800" group="" part="0" file="elder_ts_60_t_15778800.000000_reference.vtu"/>
<DataSet timestep="21038400" group="" part="0" file="elder_ts_80_t_21038400.000000_reference.vtu"/>
<DataSet timestep="26298000" group="" part="0" file="elder_ts_100_t_26298000.000000_reference.vtu"/>
<DataSet timestep="31557600" group="" part="0" file="elder_ts_120_t_31557600.000000_reference.vtu"/>
<DataSet timestep="36817200" group="" part="0" file="elder_ts_140_t_36817200.000000_reference.vtu"/>
<DataSet timestep="42076800" group="" part="0" file="elder_ts_160_t_42076800.000000_reference.vtu"/>
<DataSet timestep="47336400" group="" part="0" file="elder_ts_180_t_47336400.000000_reference.vtu"/>
<DataSet timestep="52596000" group="" part="0" file="elder_ts_200_t_52596000.000000_reference.vtu"/>
<DataSet timestep="57855600" group="" part="0" file="elder_ts_220_t_57855600.000000_reference.vtu"/>
<DataSet timestep="63115200" group="" part="0" file="elder_ts_240_t_63115200.000000_reference.vtu"/>
<DataSet timestep="68374800" group="" part="0" file="elder_ts_260_t_68374800.000000_reference.vtu"/>
<DataSet timestep="73634400" group="" part="0" file="elder_ts_280_t_73634400.000000_reference.vtu"/>
<DataSet timestep="78894000" group="" part="0" file="elder_ts_300_t_78894000.000000_reference.vtu"/>
<DataSet timestep="84153600" group="" part="0" file="elder_ts_320_t_84153600.000000_reference.vtu"/>
<DataSet timestep="89413200" group="" part="0" file="elder_ts_340_t_89413200.000000_reference.vtu"/>
<DataSet timestep="94672800" group="" part="0" file="elder_ts_360_t_94672800.000000_reference.vtu"/>
<DataSet timestep="99932400" group="" part="0" file="elder_ts_380_t_99932400.000000_reference.vtu"/>
<DataSet timestep="105192000" group="" part="0" file="elder_ts_400_t_105192000.000000_reference.vtu"/>
<DataSet timestep="110451600" group="" part="0" file="elder_ts_420_t_110451600.000000_reference.vtu"/>
<DataSet timestep="115711200" group="" part="0" file="elder_ts_440_t_115711200.000000_reference.vtu"/>
<DataSet timestep="120970800" group="" part="0" file="elder_ts_460_t_120970800.000000_reference.vtu"/>
<DataSet timestep="126230400" group="" part="0" file="elder_ts_480_t_126230400.000000_reference.vtu"/>
<DataSet timestep="131490000" group="" part="0" file="elder_ts_500_t_131490000.000000_reference.vtu"/>
</Collection>
</VTKFile>
182 changes: 182 additions & 0 deletions Tests/Data/Parabolic/ComponentTransport/elder_jupyter/elder_jupyter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# %% [markdown]
# +++
# title = "Saturated Varible-Densitty Flow and Mass Transport(Elder)"
# date = "2024-08-09"
# author = "Marc Walther, Lion Ahrendt"
# project = ["Parabolic/ComponentTransport/elder_jupyter/elder.prj"]
# web_subsection = "hydro-component"
# +++

# %% [markdown]
# ## Overview
#
# The elder benchmark is based on a experiment in a Hele-Shaw cells conducted by John W. Elder in 1965.
# Although unlike the original experiment the flow is caused by a difference in density then a difference in temperature, but by scaling the parameters a similar Rayleigh number can be achieved and therefore similar results observed.
# Due to being used to test early modeling software it has become a basic test case for such problem.
# Over the years studies about this benchmark where conducted, for example by if and when the results converge with the grid density and numerical stability.
#
# ### Problem description
#
# Unfortunately the is at the moment no analytical solution for the Elder benchmark.
# The simulation works by assuming a dense fluid in a mixable single phase environment.
# On with a hight-concentration fluid is placed on top (in our case on the top right) witch is dissolved and by the power of gravity and diffusion is able to penetrate in to the domain and builds concentration fingers.
#
# ### Setup
#
# For the simulation the following variables where chosen:
# | variable | value | unit |
# |---- |---- | ---- |
# | length (L) | 300 | $m$ |
# | height (d) | 150 | $m$ |
# | extent of intrusion (e) | 150 | $m$ |
# | pore diffusion ($D_d$) | $3.57\cdot 10^{-6}$ | $m^2/s$ |
# | retardation factor | 1 | - |
# | viscosity ($\mu$) | $10^{-3}$ | $kg/m\cdot s$ |
# | permeability | 4.8404 $\cdot 10^{-13}$ | $m^2$ |
# | longitudinal diversity ($\beta_L$) | 0 | $m$ |
# | transversal diversity ($\beta_T$) | 0 | $m$ |
# | gravitational acceleration(g) | 9,81 | $m/s^{2}$ |
# | expansion coefficient($\alpha$) | 0.2 | - |
# | porosity ($\epsilon$) | 0.1 | - |
# | density ($\rho$) | 1000 | $kg/m^{3}$ |
#
# ## Running the simulation
#
# The simulation of the Elder experiment takes too long to be executed as part of the webpage benchmark.
# Instead, in the next section pre-computed reference results will be loaded.
# To actually run the simulation, you can use following code:

# %%
# import ogstools as ogs
# path_to_prj = '../elder/elder.prj'
# model = ogs.Project(input_file = path_to_prj, output_file=path_to_prj)
# model.run_model(write_logs=True)

# %% [markdown]
# ## Post processing
#
# ### Defining the variables of interest

# %%
import matplotlib.pyplot as plt
import ogstools as ogs
from IPython.display import HTML, Image

# %%
ogs.plot.setup.dpi = 30 # resolution
ogs.plot.setup.fontsize = 30

si = ogs.variables.Scalar(data_name="Si", output_name="Concentration", output_unit="%")
pressure = ogs.variables.Scalar(
data_name="pressure", output_name="Pressure", output_unit=""
)

# %% [markdown]
# ### Read data
#
# First, we are going to load the dataset produces by the simulation:

# %%
mesh_series = ogs.meshlib.MeshSeries("../elder/elder_reference.pvd")

# %% [markdown]
# Next, the data at the 1st time step is read:

# %%
mesh_t0 = mesh_series.mesh(1).slice(normal="y")

# %% [markdown]
# and at the last one:

# %%
mesh_tend = mesh_series.mesh(-1).slice(normal="y")

# %% [markdown]
# ### Plotting results
#
# The concentration and pressure at the beginning of the simulation are shown in the figures below.

# %%
fig_t0_si = ogs.plot.contourf(mesh_t0, si, vmin=0)
plt.show()

# %%
fig_t0_p = ogs.plot.contourf(mesh_t0, pressure)
plt.show()

# %% [markdown]
# The concentration and pressure at the end of the simulation are shown in the figures below.

# %%
fig_tend_si = ogs.plot.contourf(mesh_tend, si, vmin=0)
plt.show()

# %%
fig_tend_p = ogs.plot.contourf(mesh_tend, pressure)
plt.show()


# %% [markdown]
# ### Animate results
#
# Down below the results are shown in an animated plot


# %%
def mesh_func(mesh: ogs.Mesh) -> ogs.Mesh:
"Slice 2D mesh out of 3D mesh"
return mesh.slice("y", [0, 0, 0])


def plot_func(ax: plt.Axes, timevalue: float) -> None:
"Add the time to the title."
ax.set_title(f"{timevalue/(365.25*86400):.1f} yrs", loc="center")


# %%
anim = mesh_series.animate(
si,
mesh_series.timevalues(),
mesh_func=mesh_func,
plot_func=plot_func,
)
HTML(anim.to_jshtml())

# %% [markdown]
# ### Compare simulation results OGS-5 vs. OGS-6
#
# Here, we compare numerical results of OGS-6 to those of OGS-5.
# Settings of both simulators were chosen to be as identical as possible.
# Simulation times were and for $3300 s$ OGS-6 and $7800 s$ OGS-5, respectively.

# %%
Image(url="../elder/elder.gif")

# %% [markdown]
# ## Literature
#
# <!-- vale off -->
#
# Diersch, H.-J.G., Kolditz, O., 1998. Coupled groundwater flow and transport: 2. Thermohaline and 3D convection systems. Adv. Water Resour. 21, 401–425. doi:10.1016/S0309-1708(97)00003-1.
#
# Elder, J.W., 1965. Numerical experiments with free convection in a vertical slot. J. Fluid Mech. 24, 823. doi:10.1017/S0022112066001022.
#
# Elder, J., Simmons, C., Diersch, H.-J., Frolkovič, P., Holzbecher, E., Johannsen, K., 2017. The Elder Problem. Fluids 2, 11. doi:10.3390/fluids2010011.
#
# Graf, T., Degener, L., 2011. Grid convergence of variable-density flow simulations in discretely-fractured porous media. Adv. Water Resour. 34, 760–769. doi:10.1016/j.advwatres.2011.04.002.
#
# Guo, W., Langevin, C.D., 2002. User`s Guide to SEAWAT: A computer program for simulation of three-dimensional variable-density ground-water flow, USGS Techniques of Water Resources Investigations. ISBN: 0607992573.
#
# Johannsen, K., 2003. On the Validity of the Boussinesq Approximation for the Elder Problem. Comput. Geosci. 7, 169–182. doi:10.1023/A:1025515229807.
#
# Kolditz, O., Görke, U.-J., Shao, H., Wang, W., 2012. Thermo-Hydro-Mechanical-Chemical Processes in Porous Media: Benchmarks and Examples, Lecture notes in computational science and engineering. Springer. ISBN: 3642271766.
#
# Musuuza, J.L., Attinger, S., Radu, F.A., 2009. An extended stability criterion for density-driven flows in homogeneous porous media. Adv. Water Resour. 32, 796–808. doi:10.1016/j.advwatres.2009.01.012.
#
# H.-J.G. Diersch, O. Kolditz, 2002,Variable-density flow and transport in porous media: approaches and challenges,Advances in Water Resources.25, 899-944,do:10.1016/S0309-1708(02)00063-5.
#
# Elder, John W., Craig T. Simmons, Hans-Jörg Diersch, Peter Frolkovič, Ekkehard Holzbecher, and Klaus Johannsen. 2017. "The Elder Problem" Fluids 2, no. 1: 11. https://doi.org/10.3390/fluids2010011
#
# <!--vale on -->

# %%
2 changes: 1 addition & 1 deletion Tests/Data/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--extra-index-url https://gitlab.kitware.com/api/v4/projects/13/packages/pypi/simple
git+https://gitlab.opengeosys.org/ogs/tools/ogstools@b4f3780274c464260ff43a248fac7379e49c8975#egg=ogstools
git+https://gitlab.opengeosys.org/ogs/tools/ogstools@ee5c4cb237d348258633ead22e92f595c412966a#egg=ogstools
git+https://github.com/bilke/ogs6py@66410a2acc6db77f33c78949e0601670895b0af6#egg=ogs6py
gmsh>=4.11
h5py>=3.8
Expand Down
Binary file not shown.
48 changes: 0 additions & 48 deletions web/content/docs/benchmarks/hydro-component/elder/index.md

This file was deleted.

2 changes: 1 addition & 1 deletion web/content/docs/benchmarks/python-bc/elder/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ The aim of this test is:

## Details

This test is a copy of [this test case]({{< ref "docs/benchmarks/hydro-component/elder" >}}).
This test is a copy of [this test case]({{< ref "docs/benchmarks/hydro-component/elder_jupyter" >}}).
Please check the original test case for any details.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Under the keyword `<component>`, the properties of the transported chemical comp

* [Heterogeneous Saturated Mass Transport]({{< relref "hc_ogs6-vs-ogs5" >}})
* [Saturated Mass Transport]({{< relref "saturated-mass-transport" >}})
* [Saturated Variable-Density Flow and Mass Transport (Elder)]({{< relref "docs/benchmarks/hydro-component/elder" >}})
* [Saturated Variable-Density Flow and Mass Transport (Elder)]({{< relref "docs/benchmarks/hydro-component/elder_jupyter" >}})
* [Saturated Variable-Density Flow and Mass Transport (Goswami)]({{< relref "goswami" >}})
* [Theis solution for well pumping]({{< relref "hc_theis" >}})
* [Variable Dependent Boundary Condition]({{< relref "vdbc" >}})
Expand Down
1 change: 1 addition & 0 deletions web/layouts/shortcodes/rawhtml.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ .Inner }}

0 comments on commit 5ee8abc

Please sign in to comment.