Commit 914822d1 authored by Lukas Riedel's avatar Lukas Riedel

Add test script for constant quantity in output

* Add evaluation script computing the stddev of a quantity integrated
  over the entire grid, and accepting values below a tolerance value.
* Enable transport system test for constant solute density
  - Expand cases: Vary diffusion coefficient and soil parameterization.
  - Reduce simulation time.
parent 5b8dd8f6
import numpy as np
from dorie.utilities.vtktools import pvd_reader
from dorie.testtools.utilities.decorators import evaluation_script
@evaluation_script
def evaluate(iniinfo,runtime):
"""Verify that a certain scalar quantity in the output has a standard
deviation below a given tolerance.
"""
model = iniinfo["_model"]
pvd = iniinfo["{}.output.fileName".format(model)] + ".pvd"
vtks = pvd_reader.read(pvd)
vtk_file = vtks[-1]
# read data from the vtk file
quantity_name = iniinfo["_quantity"]
grid = vtk_file.read([quantity_name])
cells = grid.cellCenters()
y = cells[...,1].flatten()
tri, connectivity = grid.triangulation()
data = grid.data()
iy = np.argsort(y)
y = y[iy]
# compute stddev
average = lambda v: grid.integrate(v) / grid.integrate(1)
stddev = lambda v: np.sqrt(grid.integrate((v - average(v))**2)
/ grid.integrate(1))
tol = float(iniinfo["_tol"])
quantity = data[quantity_name].flatten()[iy]
q_mean = average(quantity)
q_std = stddev(quantity)
print("{} – avrg: {}, stddev: {}".format(quantity_name, q_mean, q_std))
return bool(q_std < tol)
......@@ -2,8 +2,11 @@ include ${CMAKE_BINARY_DIR}/doc/default_files/config.ini
_test_command = run
_asset_path = "${CMAKE_CURRENT_LIST_DIR}"
# _evaluation = const
__name = transport_const
_evaluation = const
_model = transport
_quantity = solute
_tol = 1E-8
__name = const_transport
[simulation]
mode = richards+transport
......@@ -11,37 +14,40 @@ mode = richards+transport
[grid]
gridType = rectangular
initialLevel = 0
cells = 1 160
cells = 1 200
[grid.mapping]
volume = 0, 1 | expand param
[richards]
output.fileName = transport_const-water
output.outputPath = transport_const
output.policy = none
output.fileName = const_transport_water
output.outputPath = const_transport
output.policy = endOfRichardsStep
boundary.file = "{_asset_path}/bcs/infiltration_2d.dat"
parameters.file = "{_asset_path}/param/param.yml"
time.end = 1E8
time.maxTimestep = 1E7
time.end = 1E6
time.maxTimestep = 1E6
time.startTimestep = 1E4
numerics.FEorder = 1
[transport]
output.fileName = transport_const-solute
output.outputPath = transport_const
output.fileName = const_transport_solute
output.outputPath = const_transport
output.vertexData = false
output.policy = endOfRichardsStep
boundary.file = "{_asset_path}/bcs/solute_2d_const.dat"
parameters.molecularDiffusion = 2E-9
parameters.molecularDiffusion = 0, 2E-9 | expand diff
time.end = 1E8
time.maxTimestep = 1E7
time.end = 1E6
time.maxTimestep = 1E6
time.startTimestep = 1E4
numerics.timestepMethod = implicit_euler
\ No newline at end of file
numerics.timestepMethod = implicit_euler
Markdown is supported
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