Skip to content
Snippets Groups Projects
Commit b493e659 authored by Christoph Lehmann's avatar Christoph Lehmann
Browse files

[T/CT] Added diffusive mass flux test

parent 26959401
No related branches found
No related tags found
No related merge requests found
...@@ -926,3 +926,5 @@ if(NOT OGS_USE_PETSC) ...@@ -926,3 +926,5 @@ if(NOT OGS_USE_PETSC)
NotebookTest(NOTEBOOKFILE Parabolic/ComponentTransport/DiffusionSorptionDecay/DiffusionSorptionDecay.ipynb RUNTIME 16) NotebookTest(NOTEBOOKFILE Parabolic/ComponentTransport/DiffusionSorptionDecay/DiffusionSorptionDecay.ipynb RUNTIME 16)
NotebookTest(NOTEBOOKFILE Parabolic/ThermalTwoPhaseFlowPP/HeatPipe/heatpipe.ipynb RUNTIME 10) NotebookTest(NOTEBOOKFILE Parabolic/ThermalTwoPhaseFlowPP/HeatPipe/heatpipe.ipynb RUNTIME 10)
endif() endif()
OgsTest(PROJECTFILE Parabolic/ComponentTransport/MassFlux/only_grad_c.prj RUNTIME 1)
<?xml version="1.0"?>
<VTKFile type="UnstructuredGrid" version="1.0" byte_order="LittleEndian" header_type="UInt64">
<UnstructuredGrid>
<Piece NumberOfPoints="2" NumberOfCells="1" >
<PointData>
<DataArray type="UInt64" Name="bulk_node_ids" format="appended" RangeMin="0" RangeMax="3" offset="0" />
</PointData>
<CellData>
<DataArray type="UInt64" Name="bulk_element_ids" format="appended" RangeMin="1.8446744074e+19" RangeMax="1.8446744074e+19" offset="32" />
</CellData>
<Points>
<DataArray type="Float64" Name="Points" NumberOfComponents="3" format="appended" RangeMin="0" RangeMax="0.01" offset="56" />
</Points>
<Cells>
<DataArray type="Int64" Name="connectivity" format="appended" RangeMin="" RangeMax="" offset="132" />
<DataArray type="Int64" Name="offsets" format="appended" RangeMin="" RangeMax="" offset="164" />
<DataArray type="UInt8" Name="types" format="appended" RangeMin="" RangeMax="" offset="188" />
</Cells>
</Piece>
</UnstructuredGrid>
<AppendedData encoding="base64">
_EAAAAAAAAAADAAAAAAAAAAAAAAAAAAAACAAAAAAAAAD//////////w==MAAAAAAAAAAAAAAAAAAAAHsUrkfheoQ/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=EAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACAAAAAAAAAACAAAAAAAAAA==AQAAAAAAAAAD
</AppendedData>
</VTKFile>
<?xml version="1.0"?>
<VTKFile type="UnstructuredGrid" version="1.0" byte_order="LittleEndian" header_type="UInt64">
<UnstructuredGrid>
<Piece NumberOfPoints="2" NumberOfCells="1" >
<PointData>
<DataArray type="UInt64" Name="bulk_node_ids" format="appended" RangeMin="1" RangeMax="2" offset="0" />
</PointData>
<CellData>
<DataArray type="UInt64" Name="bulk_element_ids" format="appended" RangeMin="13" RangeMax="13" offset="32" />
</CellData>
<Points>
<DataArray type="Float64" Name="Points" NumberOfComponents="3" format="appended" RangeMin="0.8" RangeMax="0.80006249756" offset="56" />
</Points>
<Cells>
<DataArray type="Int64" Name="connectivity" format="appended" RangeMin="" RangeMax="" offset="132" />
<DataArray type="Int64" Name="offsets" format="appended" RangeMin="" RangeMax="" offset="164" />
<DataArray type="UInt8" Name="types" format="appended" RangeMin="" RangeMax="" offset="188" />
</Cells>
</Piece>
</UnstructuredGrid>
<AppendedData encoding="base64">
_EAAAAAAAAAACAAAAAAAAAAEAAAAAAAAACAAAAAAAAAANAAAAAAAAAA==MAAAAAAAAACamZmZmZnpP3sUrkfheoQ/AAAAAAAAAACamZmZmZnpPwAAAAAAAAAAAAAAAAAAAAA=EAAAAAAAAAABAAAAAAAAAAAAAAAAAAAACAAAAAAAAAACAAAAAAAAAA==AQAAAAAAAAAD
</AppendedData>
</VTKFile>
File added
<?xml version='1.0' encoding='ISO-8859-1'?>
<OpenGeoSysProject>
<meshes>
<mesh>mesh_2D.vtu</mesh>
<mesh>geometry_right.vtu</mesh>
<mesh>geometry_left.vtu</mesh>
</meshes>
<processes>
<process>
<name>HC</name>
<type>ComponentTransport</type>
<integration_order>4</integration_order>
<process_variables>
<concentration>C</concentration>
<pressure>pressure</pressure>
</process_variables>
<secondary_variables>
<secondary_variable internal_name="darcy_velocity" output_name="darcy_velocity"/>
<secondary_variable internal_name="CFlux" output_name="CFlux"/>
</secondary_variables>
<specific_body_force>0 0</specific_body_force>
</process>
</processes>
<media>
<medium id="0">
<phases>
<phase>
<type>AqueousLiquid</type>
<components>
<component>
<name>C</name>
<properties>
<property>
<name>pore_diffusion</name>
<type>Constant</type>
<value>1.e-9</value>
</property>
<property>
<name>retardation_factor</name>
<type>Constant</type>
<value>1.0</value>
</property>
<property>
<name>decay_rate</name>
<type>Parameter</type>
<parameter_name>decay</parameter_name>
</property>
</properties>
</component>
</components>
<properties>
<property>
<name>density</name>
<type>Constant</type>
<value>1</value>
</property>
<property>
<name>viscosity</name>
<type>Constant</type>
<value>1.0</value>
</property>
</properties>
</phase>
</phases>
<properties>
<property>
<name>permeability</name>
<type>Constant</type>
<value>1.e-9</value>
</property>
<property>
<name>porosity</name>
<type>Constant</type>
<value>0.15</value>
</property>
<property>
<name>longitudinal_dispersivity</name>
<type>Constant</type>
<value>0</value>
</property>
<property>
<name>transversal_dispersivity</name>
<type>Constant</type>
<value>0.0</value>
</property>
</properties>
</medium>
<medium id="1">
<phases>
<phase>
<type>AqueousLiquid</type>
<components>
<component>
<name>C</name>
<properties>
<property>
<name>pore_diffusion</name>
<type>Constant</type>
<value>1.e-9</value>
</property>
<property>
<name>retardation_factor</name>
<type>Constant</type>
<value>1.0</value>
</property>
<property>
<name>decay_rate</name>
<type>Parameter</type>
<parameter_name>decay</parameter_name>
</property>
</properties>
</component>
</components>
<properties>
<property>
<name>density</name>
<type>Constant</type>
<value>1</value>
</property>
<property>
<name>viscosity</name>
<type>Constant</type>
<value>1.0</value>
</property>
</properties>
</phase>
</phases>
<properties>
<property>
<name>permeability</name>
<type>Constant</type>
<value>1.e-9</value>
</property>
<property>
<name>porosity</name>
<type>Constant</type>
<value>0.65</value>
</property>
<property>
<name>longitudinal_dispersivity</name>
<type>Constant</type>
<value>0</value>
</property>
<property>
<name>transversal_dispersivity</name>
<type>Constant</type>
<value>0.0</value>
</property>
</properties>
</medium>
</media>
<parameters>
<parameter>
<name>decay</name>
<type>Constant</type>
<value>0</value>
</parameter>
<parameter>
<name>C_right</name>
<type>Constant</type>
<value>1</value>
</parameter>
<parameter>
<name>C_left</name>
<type>Constant</type>
<value>0</value>
</parameter>
<parameter>
<name>C_ini</name>
<type>Function</type>
<expression>
var c1 := 1;
var c0 := 0;
var phi1 := 0.65;
var phi0 := 0.15;
var L := 0.8;
var a0 := (c1 - c0) / (1 + phi0/phi1) * 2 / L;
var a1 := (c1 - c0) / (1 + phi1/phi0) * 2 / L;
var b0 := c0;
var b1 := (2*c0 + c1 * (phi1/phi0 - 1)) / (1 + phi1/phi0);
x &lt; L/2 ? a0 * x + b0 : a1 * x + b1;
</expression>
</parameter>
<parameter>
<name>p0</name>
<type>Constant</type>
<value>0</value>
</parameter>
<parameter>
<name>p1</name>
<type>Constant</type>
<value>0</value>
</parameter>
</parameters>
<process_variables>
<process_variable>
<name>pressure</name>
<components>1</components>
<order>1</order>
<initial_condition>p0</initial_condition>
<boundary_conditions>
<boundary_condition>
<mesh>geometry_left</mesh>
<type>Dirichlet</type>
<parameter>p1</parameter>
</boundary_condition>
<boundary_condition>
<mesh>geometry_right</mesh>
<type>Dirichlet</type>
<parameter>p0</parameter>
</boundary_condition>
</boundary_conditions>
</process_variable>
<process_variable>
<name>C</name>
<components>1</components>
<order>1</order>
<initial_condition>C_ini</initial_condition>
<boundary_conditions>
<boundary_condition>
<mesh>geometry_right</mesh>
<type>Dirichlet</type>
<parameter>C_right</parameter>
</boundary_condition>
<boundary_condition>
<mesh>geometry_left</mesh>
<type>Dirichlet</type>
<parameter>C_left</parameter>
</boundary_condition>
</boundary_conditions>
</process_variable>
</process_variables>
<time_loop>
<processes>
<process ref="HC">
<nonlinear_solver>basic_picard</nonlinear_solver>
<convergence_criterion>
<type>PerComponentDeltaX</type>
<norm_type>INFINITY_N</norm_type>
<!--<reltols>1e-12 1e-10</reltols>-->
<abstols>1e-15 1e-15</abstols>
</convergence_criterion>
<time_discretization>
<type>BackwardEuler</type>
</time_discretization>
<time_stepping>
<type>FixedTimeStepping</type>
<t_initial> 0.0 </t_initial>
<t_end> 4e8 </t_end>
<timesteps>
<pair>
<repeat>4</repeat>
<delta_t>1e8</delta_t>
</pair>
</timesteps>
</time_stepping>
</process>
</processes>
<output>
<type>VTK</type>
<prefix>only_grad_c</prefix>
<timesteps>
<pair>
<repeat>1000</repeat>
<each_steps>1</each_steps>
</pair>
</timesteps>
<variables>
</variables>
<output_extrapolation_residuals>true</output_extrapolation_residuals>
</output>
</time_loop>
<nonlinear_solvers>
<nonlinear_solver>
<name>basic_picard</name>
<type>Picard</type>
<max_iter>50</max_iter>
<linear_solver>general_linear_solver</linear_solver>
</nonlinear_solver>
</nonlinear_solvers>
<linear_solvers>
<linear_solver>
<name>general_linear_solver</name>
<eigen>
<solver_type>SparseLU</solver_type>
<scaling>true</scaling>
</eigen>
<petsc>
<prefix>hc</prefix>
<parameters>-hc_ksp_type bcgs -hc_pc_type bjacobi -hc_ksp_rtol 1e-8 -hc_ksp_max_it 20000</parameters>
</petsc>
</linear_solver>
</linear_solvers>
<test_definition>
<vtkdiff>
<file>only_grad_c_ts_4_t_400000000.000000.vtu</file>
<field>pressure</field>
<absolute_tolerance>1e-15</absolute_tolerance>
<relative_tolerance>0</relative_tolerance>
</vtkdiff>
<vtkdiff>
<file>only_grad_c_ts_4_t_400000000.000000.vtu</file>
<field>C</field>
<absolute_tolerance>1.3e-12</absolute_tolerance>
<relative_tolerance>0</relative_tolerance>
</vtkdiff>
<vtkdiff>
<file>only_grad_c_ts_4_t_400000000.000000.vtu</file>
<field>CFlux</field>
<absolute_tolerance>4.1e-20</absolute_tolerance>
<relative_tolerance>0</relative_tolerance>
</vtkdiff>
<vtkdiff>
<file>only_grad_c_ts_4_t_400000000.000000.vtu</file>
<field>CFlux_residual</field>
<absolute_tolerance>4.0e-20</absolute_tolerance>
<relative_tolerance>0</relative_tolerance>
</vtkdiff>
<vtkdiff>
<file>only_grad_c_ts_4_t_400000000.000000.vtu</file>
<field>darcy_velocity</field>
<absolute_tolerance>1e-25</absolute_tolerance>
<relative_tolerance>0</relative_tolerance>
</vtkdiff>
<vtkdiff>
<file>only_grad_c_ts_4_t_400000000.000000.vtu</file>
<field>darcy_velocity_residual</field>
<absolute_tolerance>1e-25</absolute_tolerance>
<relative_tolerance>0</relative_tolerance>
</vtkdiff>
</test_definition>
</OpenGeoSysProject>
#!/usr/bin/env python
# This script computes the reference solution of the "only_grad_c" test case.
# Only a concentration gradient is applied over a quasi-one-dimensional domain.
# The pressure gradient is zero. The system is in its steady state.
# The left half of the domain and the right half of the domain have different
# porosities. However, the mass flux through the domain must be the same
# everywhere (due to the steady state).
# In this example only diffusive mass flux plays a role.
import numpy as np
import pyvista as pv
c1 = 1
c0 = 0
phi1 = 0.65
phi0 = 0.15
L = 0.8
D = 1e-9
a0 = (c1 - c0) / (1 + phi0 / phi1) * 2 / L
a1 = (c1 - c0) / (1 + phi1 / phi0) * 2 / L
b0 = c0
b1 = (2 * c0 + c1 * (phi1 / phi0 - 1)) / (1 + phi1 / phi0)
# @np.vectorize
def c_ana(x):
# return a0 * x + b0 if x < L/2 else a1 * x + b1
return np.where(x < L / 2, a0 * x + b0, a1 * x + b1)
# @np.vectorize
def flux_ana(x):
# grad_c = a0 if x < L/2 else a1
# phi = phi0 if x < L/2 else phi1
# return (-D * phi * grad_c, 0)
flux_x = -D * np.where(x < L / 2, a0 * phi0, a1 * phi1)
return np.c_[flux_x, np.zeros_like(x)]
mesh = pv.read("mesh_2D.vtu")
xs = mesh.points[:, 0]
cs = c_ana(xs)
fluxes = flux_ana(xs)
min_flux_x = np.min(fluxes[:, 0])
max_flux_x = np.max(fluxes[:, 0])
# mass flux must be constant on the entire mesh
assert (max_flux_x - min_flux_x) / abs(max_flux_x) < 1e-15
print(f"concentration range: [{np.min(cs)}, {np.max(cs)}]")
print(f"flux_x range: [{min_flux_x}, {max_flux_x}]")
mesh.point_data["pressure"] = np.zeros_like(xs)
mesh.point_data["C"] = cs
mesh.point_data["CFlux"] = fluxes
# spatially homogenous flux can be extrapolated exaclty
mesh.cell_data["CFlux_residual"] = np.zeros((mesh.n_cells, fluxes.shape[1]))
mesh.point_data["darcy_velocity"] = np.zeros((mesh.n_points, fluxes.shape[1]))
mesh.cell_data["darcy_velocity_residual"] = np.zeros((mesh.n_cells, fluxes.shape[1]))
mesh.save("only_grad_c_ts_4_t_400000000.000000.vtu")
<?xml version="1.0"?>
<VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian" header_type="UInt32" compressor="vtkZLibDataCompressor">
<UnstructuredGrid>
<Piece NumberOfPoints="30" NumberOfCells="14">
<PointData Scalars="pressure">
<DataArray type="Float64" Name="pressure" format="binary" RangeMin="0" RangeMax="0">
AQAAAACAAADwAAAADAAAAA==eJxjYBhZAAAA8AAB
</DataArray>
<DataArray type="Float64" Name="C" format="binary" RangeMin="0" RangeMax="1">
AQAAAACAAADwAAAAqQAAAA==eJxjYEAGH+xRaQaGeXO35d7ettc+dz6IPms/9a3HJBXPa/aMvSD+XXtTMSB30iP7mCcg8Wf2N7b8B4KX9vvibgMVvLIXOA9S99pezx6k7o2993ogN/etfYa8J1Dgnf3kfqCwynv7J1Mg9AlNiPjafRB1k4Ih+spfQMyJroWYKyQEct0re5UMT7C9Pxsg7og33Q521zmw+DX7PIvtYHc/sNkO9gcAvfttNQ==
</DataArray>
<DataArray type="Float64" Name="CFlux" NumberOfComponents="2" format="binary" RangeMin="3.046875e-10" RangeMax="3.0468750000000004e-10">
AQAAAACAAADgAQAAIQAAAA==eJxrC33fJPfhy14GKGglwG8bYD4h9w01Pq3DCwA66Jc8
<InformationKey name="L2_NORM_RANGE" location="vtkDataArray" length="2">
<Value index="0">
3.046875e-10
</Value>
<Value index="1">
3.046875e-10
</Value>
</InformationKey>
</DataArray>
<DataArray type="Float64" Name="darcy_velocity" NumberOfComponents="2" format="binary" RangeMin="0" RangeMax="0">
AQAAAACAAADgAQAADgAAAA==eJxjYBgFwxkAAAHgAAE=
<InformationKey name="L2_NORM_RANGE" location="vtkDataArray" length="2">
<Value index="0">
0
</Value>
<Value index="1">
0
</Value>
</InformationKey>
</DataArray>
</PointData>
<CellData Scalars="CFlux_residual">
<DataArray type="Int32" Name="MaterialIDs" format="binary" RangeMin="0" RangeMax="1">
AQAAAACAAAA4AAAADgAAAA==eJxjYMANGPFgAACoAAg=
</DataArray>
<DataArray type="Float64" Name="CFlux_residual" NumberOfComponents="2" format="binary" RangeMin="0" RangeMax="0">
AQAAAACAAADgAAAADAAAAA==eJxjYBjeAAAA4AAB
<InformationKey name="L2_NORM_RANGE" location="vtkDataArray" length="2">
<Value index="0">
0
</Value>
<Value index="1">
0
</Value>
</InformationKey>
</DataArray>
<DataArray type="Float64" Name="darcy_velocity_residual" NumberOfComponents="2" format="binary" RangeMin="0" RangeMax="0">
AQAAAACAAADgAAAADAAAAA==eJxjYBjeAAAA4AAB
<InformationKey name="L2_NORM_RANGE" location="vtkDataArray" length="2">
<Value index="0">
0
</Value>
<Value index="1">
0
</Value>
</InformationKey>
</DataArray>
</CellData>
<Points>
<DataArray type="Float64" Name="Points" NumberOfComponents="3" format="binary" RangeMin="0" RangeMax="0.8000624975587846">
AQAAAACAAADQAgAA4wAAAA==eJxjYMAOZs0EgZf2uMSrRda5P6xqwZBHF3ec7ih7xXEthjrOmSDxvRjiHzU+isZ/PIoh/rQNpP4shnj2J49JKp6XMMTvyoPMuYrpfn+Q+29iiNtPAZl/F0P8w5uSAPbSBxjiQfyeQHsfYYhvMgQaI/sEQ1w4BOSepxjiE8qOhtccfY4h/qIRIo4enmZZEHPQxVuCIPaii1+2grgTXVxRuRTsL3Txu2JO4HBAF9/2DBJu6OLzFkLCGV28O9oTHC/o4mt0nMDxiC7uuggS7+ji6/WdwOkEXVzAxAmcrtDFASQHob4=
<InformationKey name="L2_NORM_RANGE" location="vtkDataArray" length="2">
<Value index="0">
0
</Value>
<Value index="1">
0.80006249756
</Value>
</InformationKey>
</DataArray>
</Points>
<Cells>
<DataArray type="Int64" Name="connectivity" format="binary" RangeMin="0" RangeMax="29">
AQAAAACAAADAAQAAWwAAAA==eJxdyrUNwAAAA8EwM+P+a6bIu7Gbk6wPgn8Jvhjbn+Jjnf4Mb+v053hZp7/A0zr9JR7W6a9wt05/jZt1+htcrdPf4mKd/g5n6/T3OFmnf8DROv0hRtZ9+KYDYQ==
</DataArray>
<DataArray type="Int64" Name="offsets" format="binary" RangeMin="4" RangeMax="56">
AQAAAACAAABwAAAALQAAAA==eJxjYYAADijNA6UFoLQIlJaA0jJQWgFKq0BpDSitA6UNoLQJlLaA0gBGcAGl
</DataArray>
<DataArray type="UInt8" Name="types" format="binary" RangeMin="9" RangeMax="9">
AQAAAACAAAAOAAAACwAAAA==eJzj5EQGAAO/AH8=
</DataArray>
</Cells>
</Piece>
</UnstructuredGrid>
</VTKFile>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment