From 3385cbaf55b58319f4c6710838a8b5cf87ba1f7c Mon Sep 17 00:00:00 2001
From: Timo Koch <timo.koch@iws.uni-stuttgart.de>
Date: Sat, 21 Mar 2020 18:01:52 +0100
Subject: [PATCH] [test][2p][material] Improve BC and VG tests

---
 .../fluidmatrixinteractions/2p/CMakeLists.txt |   22 +-
 .../2p/test_material_2p_brookscorey.cc        |   63 ++
 .../2p/test_material_2p_vangenuchten.cc       |   64 ++
 .../2p/test_materiallaws.cc                   |  195 ----
 .../2p/testmateriallawfunctions.hh            |  104 ++
 test/references/pcswcurve.dat                 | 1001 -----------------
 test/references/test_pcsw_brookscorey.dat     |  100 ++
 test/references/test_pcsw_vangenuchten.dat    |  100 ++
 8 files changed, 446 insertions(+), 1203 deletions(-)
 create mode 100644 test/material/fluidmatrixinteractions/2p/test_material_2p_brookscorey.cc
 create mode 100644 test/material/fluidmatrixinteractions/2p/test_material_2p_vangenuchten.cc
 delete mode 100644 test/material/fluidmatrixinteractions/2p/test_materiallaws.cc
 create mode 100644 test/material/fluidmatrixinteractions/2p/testmateriallawfunctions.hh
 delete mode 100644 test/references/pcswcurve.dat
 create mode 100644 test/references/test_pcsw_brookscorey.dat
 create mode 100644 test/references/test_pcsw_vangenuchten.dat

diff --git a/test/material/fluidmatrixinteractions/2p/CMakeLists.txt b/test/material/fluidmatrixinteractions/2p/CMakeLists.txt
index 13813a52bc..ce1b775409 100644
--- a/test/material/fluidmatrixinteractions/2p/CMakeLists.txt
+++ b/test/material/fluidmatrixinteractions/2p/CMakeLists.txt
@@ -8,10 +8,18 @@ dumux_add_test(SOURCES test_thermalconductivity.cc
                               ${CMAKE_CURRENT_BINARY_DIR}/johansen_lambda_eff.dat
                       --command "${CMAKE_CURRENT_BINARY_DIR}/test_thermalconductivity")
 
-dumux_add_test(SOURCES test_materiallaws.cc
-              LABELS unit material
-              COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py
-              CMD_ARGS --script fuzzyData --delimiter " "
-                      --files  ${CMAKE_SOURCE_DIR}/test/references/pcswcurve.dat
-                              ${CMAKE_CURRENT_BINARY_DIR}/pcswcurve.dat
-                      --command "${CMAKE_CURRENT_BINARY_DIR}/test_materiallaws")
+dumux_add_test(SOURCES test_material_2p_vangenuchten.cc
+               LABELS unit material
+               COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py
+               CMD_ARGS --script fuzzyData --delimiter " "
+                        --files  ${CMAKE_SOURCE_DIR}/test/references/test_pcsw_vangenuchten.dat
+                                 ${CMAKE_CURRENT_BINARY_DIR}/test_pcsw_vangenuchten.dat
+                        --command "${CMAKE_CURRENT_BINARY_DIR}/test_material_2p_vangenuchten")
+
+dumux_add_test(SOURCES test_material_2p_brookscorey.cc
+               LABELS unit material
+               COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py
+               CMD_ARGS --script fuzzyData --delimiter " "
+                        --files  ${CMAKE_SOURCE_DIR}/test/references/test_pcsw_brookscorey.dat
+                                 ${CMAKE_CURRENT_BINARY_DIR}/test_pcsw_brookscorey.dat
+                        --command "${CMAKE_CURRENT_BINARY_DIR}/test_material_2p_brookscorey")
diff --git a/test/material/fluidmatrixinteractions/2p/test_material_2p_brookscorey.cc b/test/material/fluidmatrixinteractions/2p/test_material_2p_brookscorey.cc
new file mode 100644
index 0000000000..1ab7cb0a30
--- /dev/null
+++ b/test/material/fluidmatrixinteractions/2p/test_material_2p_brookscorey.cc
@@ -0,0 +1,63 @@
+#include <config.h>
+
+#include <dune/common/float_cmp.hh>
+
+#include <dumux/material/fluidmatrixinteractions/2p/efftoabslaw.hh>
+#include <dumux/material/fluidmatrixinteractions/2p/brookscorey.hh>
+#include <dumux/material/fluidmatrixinteractions/2p/brookscoreyparams.hh>
+#include <dumux/material/fluidmatrixinteractions/2p/regularizedbrookscorey.hh>
+#include <dumux/material/fluidmatrixinteractions/2p/regularizedbrookscoreyparams.hh>
+
+#include <dumux/io/container.hh>
+#include "testmateriallawfunctions.hh"
+
+namespace Dumux::Test {
+
+// test if endPointPc() is the same as evaluation at sw=1
+template<class Law>
+void checkEndPointPc(const typename Law::Params& params)
+{
+    const auto pcSat = Law::pc(params, Law::sweToSw_(params, 1.0));
+    const auto endPointPc = Law::endPointPc(params);
+    const auto entryPressure = params.pe();
+    static constexpr double eps = 1e-10;
+
+    if (Dune::FloatCmp::ne(pcSat, endPointPc, eps))
+        DUNE_THROW(Dune::Exception, "pc(sw=1) != endPointPc(): " << pcSat << " != " << endPointPc);
+    if (Dune::FloatCmp::ne(pcSat, entryPressure, eps))
+        DUNE_THROW(Dune::Exception, "pc(sw=1) != entryPressure: " << pcSat << " != " << entryPressure);
+}
+
+} // end namespace Dumux
+
+int main(int argc, char** argv) try
+{
+    using namespace Dumux;
+
+    using BCReg = EffToAbsLaw<RegularizedBrooksCorey<double>>;
+    using BC = EffToAbsLaw<BrooksCorey<double>, BCReg::Params>;
+
+    // set some parameters
+    BCReg::Params params;
+    params.setPe(1e4);
+    params.setLambda(2.0);
+    params.setSwr(0.1);
+    params.setSnr(0.1);
+    params.setThresholdSw(0.01);
+
+    Test::checkEndPointPc<BC>(params);
+    Test::checkEndPointPc<BCReg>(params);
+
+    const auto sw = Dumux::linspace(0.0, 1.0, 100);
+    const auto swNonReg = Dumux::linspace(BCReg::sweToSw_(params, params.thresholdSw()), BCReg::sweToSw_(params, 1.0), 100);
+
+    Test::runTest<BC, BCReg>("brookscorey", params, sw, swNonReg);
+
+    return 0;
+}
+// error handler
+catch (const Dune::Exception& e)
+{
+    std::cerr << "Test failed with exception: " << e << std::endl;
+    return 1;
+}
diff --git a/test/material/fluidmatrixinteractions/2p/test_material_2p_vangenuchten.cc b/test/material/fluidmatrixinteractions/2p/test_material_2p_vangenuchten.cc
new file mode 100644
index 0000000000..68f48216a6
--- /dev/null
+++ b/test/material/fluidmatrixinteractions/2p/test_material_2p_vangenuchten.cc
@@ -0,0 +1,64 @@
+#include <config.h>
+
+#include <dune/common/float_cmp.hh>
+
+#include <dumux/material/fluidmatrixinteractions/2p/efftoabslaw.hh>
+#include <dumux/material/fluidmatrixinteractions/2p/vangenuchten.hh>
+#include <dumux/material/fluidmatrixinteractions/2p/vangenuchtenparams.hh>
+#include <dumux/material/fluidmatrixinteractions/2p/regularizedvangenuchten.hh>
+#include <dumux/material/fluidmatrixinteractions/2p/regularizedvangenuchtenparams.hh>
+
+#include <dumux/io/container.hh>
+#include "testmateriallawfunctions.hh"
+
+namespace Dumux::Test {
+
+// test if endPointPc() is the same as evaluation at sw=1
+template<class Law>
+void checkEndPointPc(const typename Law::Params& params)
+{
+    const auto pcSat = Law::pc(params, Law::sweToSw_(params, 1.0));
+    const auto endPointPc = Law::endPointPc(params);
+    static constexpr double eps = 1e-10;
+
+    if (Dune::FloatCmp::ne(pcSat, endPointPc, eps))
+        DUNE_THROW(Dune::Exception, "pc(sw=1) != endPointPc(): " << pcSat << " != " << endPointPc);
+}
+
+} // end namespace Dumux
+
+int main(int argc, char** argv) try
+{
+    using namespace Dumux;
+
+    using VGReg = EffToAbsLaw<RegularizedVanGenuchten<double>>;
+    using VG = EffToAbsLaw<VanGenuchten<double>, VGReg::Params>;
+
+    // set some parameters
+    VGReg::Params params;
+    params.setVgAlpha(6.66e-5);
+    params.setVgn(3.652);
+    params.setVgl(0.5);
+    params.setSwr(0.1);
+    params.setSnr(0.1);
+    params.setPcLowSw(0.01);
+    params.setPcHighSw(0.99);
+    params.setKrnLowSw(0.1);
+    params.setKrwHighSw(0.9);
+
+    Test::checkEndPointPc<VG>(params);
+    Test::checkEndPointPc<VGReg>(params);
+
+    const auto sw = Dumux::linspace(0.0, 1.0, 100);
+    const auto swNonReg = Dumux::linspace(VGReg::sweToSw_(params, params.pcLowSw()), VGReg::sweToSw_(params, params.pcHighSw()), 100);
+
+    Test::runTest<VG, VGReg>("vangenuchten", params, sw, swNonReg);
+
+    return 0;
+}
+// error handler
+catch (const Dune::Exception& e)
+{
+    std::cerr << "Test failed with exception: " << e << std::endl;
+    return 1;
+}
diff --git a/test/material/fluidmatrixinteractions/2p/test_materiallaws.cc b/test/material/fluidmatrixinteractions/2p/test_materiallaws.cc
deleted file mode 100644
index 56e465f8d3..0000000000
--- a/test/material/fluidmatrixinteractions/2p/test_materiallaws.cc
+++ /dev/null
@@ -1,195 +0,0 @@
-// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
-// vi: set et ts=4 sw=4 sts=4:
-/*****************************************************************************
- *   See the file COPYING for full copying permissions.                      *
- *                                                                           *
- *   This program is free software: you can redistribute it and/or modify    *
- *   it under the terms of the GNU General Public License as published by    *
- *   the Free Software Foundation, either version 3 of the License, or       *
- *   (at your option) any later version.                                     *
- *                                                                           *
- *   This program is distributed in the hope that it will be useful,         *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            *
- *   GNU General Public License for more details.                            *
- *                                                                           *
- *   You should have received a copy of the GNU General Public License       *
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
- *****************************************************************************/
-/*!
- * \file
- * \ingroup MaterialTests
- * \brief Test for the material laws Brooks-Corey and van-Genuchten.
- */
-
- #include <config.h>
- #include <dumux/common/math.hh>
-
- #include <dumux/material/fluidmatrixinteractions/2p/brookscorey.hh>
- #include <dumux/material/fluidmatrixinteractions/2p/brookscoreyparams.hh>
- #include <dumux/material/fluidmatrixinteractions/2p/regularizedbrookscorey.hh>
- #include <dumux/material/fluidmatrixinteractions/2p/regularizedbrookscoreyparams.hh>
-
- #include <dumux/material/fluidmatrixinteractions/2p/vangenuchten.hh>
- #include <dumux/material/fluidmatrixinteractions/2p/vangenuchtenparams.hh>
- #include <dumux/material/fluidmatrixinteractions/2p/regularizedvangenuchten.hh>
- #include <dumux/material/fluidmatrixinteractions/2p/regularizedvangenuchtenparams.hh>
-
- #include <dumux/common/numericdifferentiation.hh>
- #include <dumux/material/fluidmatrixinteractions/2p/efftoabslaw.hh>
-
- #include <dumux/io/plotmateriallaw.hh>
- #include <dumux/io/gnuplotinterface.hh>
- #include <dumux/io/container.hh>
-
-template <class Scalar, class MaterialLaw, class MaterialLawRegularized, class MaterialLawParams, class MaterialLawParamsRegularized>
-void testMaterialLawCommon(MaterialLaw &materialLaw,
-                          MaterialLawRegularized &materialLawRegularized,
-                          MaterialLawParams &materialLawParams,
-                          MaterialLawParamsRegularized &materialLawParamsRegularized,
-                          Scalar sweValue,
-                          Scalar pcValue,
-                          Scalar eps)
-{
-    // test if derivatives match numerical derivatives for dpc_dsw
-    Scalar analyticDerivativePcSw = materialLaw.dpc_dswe(materialLawParams, sweValue);
-    Scalar numericDerivativePcSw = 0.0;
-
-    auto materialLawPcNumericPcSw = [&](Scalar sw)
-    {
-        return materialLaw.pc(materialLawParams, sw);
-    };
-
-    Dumux::NumericDifferentiation::partialDerivative(materialLawPcNumericPcSw, sweValue,
-                                                     numericDerivativePcSw,
-                                                     materialLaw.pc(materialLawParams, sweValue),
-                                                     eps, 0 /*central*/);
-
-    if (Dune::FloatCmp::eq(analyticDerivativePcSw, numericDerivativePcSw, eps*analyticDerivativePcSw))
-        DUNE_THROW(Dune::Exception, "analytic derivative dpc_dswe doesn't match numerical derivative dpc_dswe: "
-        << analyticDerivativePcSw << " != " << numericDerivativePcSw << "\n");
-
-    // test if derivatives match numerical derivatives for dsw_dpc
-    Scalar analyticDerivativeSwPc = materialLaw.dswe_dpc(materialLawParams, pcValue);
-    Scalar numericDerivativeSwPc = 0.0;
-
-    auto materialLawPcNumericSwPc = [&](Scalar pc)
-    {
-       return materialLaw.sw(materialLawParams, pc);
-    };
-
-    Dumux::NumericDifferentiation::partialDerivative(materialLawPcNumericSwPc, pcValue,
-                                                     numericDerivativeSwPc,
-                                                     materialLaw.sw(materialLawParams, pcValue),
-                                                     eps, 0 /*central*/);
-
-    if (Dune::FloatCmp::eq(analyticDerivativeSwPc, numericDerivativeSwPc, eps*analyticDerivativeSwPc))
-        DUNE_THROW(Dune::Exception, "analytic derivative dswe_dpc doesn't match numerical derivative dsw_dpc: "
-        << analyticDerivativeSwPc << " != " << numericDerivativeSwPc << "\n");
-
-    // test if the unregularized pc is the same as regularized pc in the non-regularized range
-    Scalar pC = materialLaw.pc(materialLawParams, sweValue);
-    Scalar pCReg = materialLawRegularized.pc(materialLawParamsRegularized, sweValue);
-
-    if (Dune::FloatCmp::ne(pC, pCReg, eps*pC))
-        DUNE_THROW(Dune::Exception, "regulized pc doesn't match unregularized pc: "
-        << pCReg << " != " << pC << "\n");
-
-    // test if endPointPc() is the same as evaluation at Sw=1 and entryPressure
-    // for the un-regularized material law
-    Scalar pCSat = materialLaw.pc(materialLawParams, 1.0);
-    Scalar endPointPc = materialLaw.endPointPc(materialLawParams);
-
-    if (Dune::FloatCmp::ne(pCSat, endPointPc, eps*pCSat))
-        DUNE_THROW(Dune::Exception, "pc(Sw=1) doesn't match endPointPc: " << pCSat << " != "
-        << endPointPc << "\n");
-
-    // for the regularized material law
-    Scalar pCSatReg = materialLawRegularized.pc(materialLawParamsRegularized, 1.0);
-    Scalar endPointPcReg = materialLawRegularized.endPointPc(materialLawParamsRegularized);
-
-    if (Dune::FloatCmp::ne(pCSatReg, endPointPcReg, eps*pCSatReg))
-        DUNE_THROW(Dune::Exception, "regularized pc(Sw=1) doesn't match regularized endPointPc: "
-        << pCSatReg << " != " << endPointPcReg << "\n");
-}
-
- int main(int argc, char** argv)
- {
-    using namespace Dumux;
-
-    using Scalar = double;
-
-    using BrooksCorey = BrooksCorey<Scalar>;
-    using BrooksCoreyParams = typename BrooksCorey::Params;
-    using BrooksCoreyRegularized = RegularizedBrooksCorey<Scalar>;
-    using BrooksCoreyParamsRegularized = typename BrooksCoreyRegularized::Params;
-
-    BrooksCorey brooksCorey;
-    BrooksCoreyParams brooksCoreyParams;
-    BrooksCoreyRegularized brooksCoreyRegularized;
-    BrooksCoreyParamsRegularized brooksCoreyParamsRegularized;
-
-    using VanGenuchten = VanGenuchten<Scalar>;
-    using VanGenuchtenParams = typename VanGenuchten::Params;
-    using VanGenuchtenRegularized = RegularizedVanGenuchten<Scalar>;
-    using VanGenuchtenParamsRegularized = typename VanGenuchtenRegularized::Params;
-
-    // set Params Brooks-Corey
-    brooksCoreyParams.setPe(1e4);
-    brooksCoreyParams.setLambda(2.0);
-    brooksCoreyParamsRegularized.setPe(1e4);
-    brooksCoreyParamsRegularized.setLambda(2.0);
-
-    VanGenuchten vanGenuchten;
-    VanGenuchtenParams vanGenuchtenParams;
-    VanGenuchtenRegularized vanGenuchtenRegularized;
-    VanGenuchtenParamsRegularized vanGenuchtenParamsRegularized;
-
-    // set Params van-Genuchten
-    vanGenuchtenParams.setVgAlpha(6.66e-5);
-    vanGenuchtenParams.setVgn(3.652);
-    vanGenuchtenParamsRegularized.setVgAlpha(6.66e-5);
-    vanGenuchtenParamsRegularized.setVgn(3.652);
-
-    // test common functions of both material laws
-    // define ranges for sw and pc for testing the material laws
-    const int n = 10; //size of the following vectors
-    const auto sweValues = Dumux::linspace(0.005, 1.0, n); // range of tested sw values
-    const auto pcValues = Dumux::linspace(1.0, 10000.0, n); // range of tested pc values
-    Scalar eps = 1.0e-6; // threshhold value
-
-    for( int i = 0; i < n; i++)
-    {
-    // test Brooks-Corey
-        testMaterialLawCommon<Scalar, BrooksCorey, BrooksCoreyRegularized, BrooksCoreyParams, BrooksCoreyParamsRegularized>
-        (brooksCorey, brooksCoreyRegularized, brooksCoreyParams, brooksCoreyParamsRegularized, sweValues[i], pcValues[i], eps);
-    // test van-Genuchten
-        testMaterialLawCommon<Scalar, VanGenuchten, VanGenuchtenRegularized, VanGenuchtenParams, VanGenuchtenParamsRegularized>
-        (vanGenuchten, vanGenuchtenRegularized, vanGenuchtenParams, vanGenuchtenParamsRegularized, sweValues[i], pcValues[i], eps);
-    }
-
-    // test Brooks-Corey specific functions
-    // test if endPointPc() is the same as entryPressure
-    Scalar pCSat = brooksCorey.pc(brooksCoreyParams, 1.0);
-    Scalar pCSatReg = brooksCoreyRegularized.pc(brooksCoreyParamsRegularized, 1.0);
-    if (Dune::FloatCmp::ne(pCSat, brooksCoreyParams.pe(), eps*pCSat))
-        DUNE_THROW(Dune::Exception, "pc(Sw=1) doesn't match entryPressure: " << pCSat << " != " << brooksCoreyParams.pe() << "\n");
-    if (Dune::FloatCmp::ne(pCSatReg, brooksCoreyParamsRegularized.pe(), eps*pCSatReg))
-        DUNE_THROW(Dune::Exception, "regularized pc(Sw=1) doesn't match regularized entryPressure: " << pCSatReg << " != " << brooksCoreyParamsRegularized.pe() << "\n");
-
-// 4) test against some precomputed reference values (a good regression test)
-    GnuplotInterface<double> gnuplot;
-    gnuplot.setOpenPlotWindow(false);
-    using PlotMaterialLaw = PlotMaterialLaw<Scalar, BrooksCorey>;
-    PlotMaterialLaw plotMaterialLaw;
-    const std::string fileName = "pcswcurve.dat";
-
-    plotMaterialLaw.addpcswcurve(gnuplot, brooksCoreyParams, 0.0 + eps, 1.0, fileName);
-
-// 5) //TODO test eff to abs law
-//     using MaterialLaw = EffToAbsLaw<BrooksCorey>;
-//     using MaterialLawRegularized = EffToAbsLaw<EffectiveLawRegularized>;
-
-
-    return 0;
- }
\ No newline at end of file
diff --git a/test/material/fluidmatrixinteractions/2p/testmateriallawfunctions.hh b/test/material/fluidmatrixinteractions/2p/testmateriallawfunctions.hh
new file mode 100644
index 0000000000..da71bebadc
--- /dev/null
+++ b/test/material/fluidmatrixinteractions/2p/testmateriallawfunctions.hh
@@ -0,0 +1,104 @@
+// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+// vi: set et ts=4 sw=4 sts=4:
+/*****************************************************************************
+ *   See the file COPYING for full copying permissions.                      *
+ *                                                                           *
+ *   This program is free software: you can redistribute it and/or modify    *
+ *   it under the terms of the GNU General Public License as published by    *
+ *   the Free Software Foundation, either version 3 of the License, or       *
+ *   (at your option) any later version.                                     *
+ *                                                                           *
+ *   This program is distributed in the hope that it will be useful,         *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            *
+ *   GNU General Public License for more details.                            *
+ *                                                                           *
+ *   You should have received a copy of the GNU General Public License       *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
+ *****************************************************************************/
+/*!
+ * \file
+ * \ingroup MaterialTests
+ * \brief Test for the 2p van Genuchten material law
+ */
+
+#ifndef DUMUX_TEST_MATERIALLAW_FUNCTIONS_HH
+#define DUMUX_TEST_MATERIALLAW_FUNCTIONS_HH
+
+#include <dune/common/float_cmp.hh>
+
+#include <dumux/common/math.hh>
+#include <dumux/common/numericdifferentiation.hh>
+
+namespace Dumux::Test {
+
+template<class F, class D>
+void testDerivatives(std::string_view derivName,
+                     const std::vector<double>& values,
+                     const F& f, const D& deriv)
+{
+    static constexpr double eps = 1e-7;
+    static constexpr double numEps = 1e-8;
+    for (auto val : values)
+    {
+        const double analyticDeriv = deriv(val);
+
+        double numericDeriv = 0.0;
+        Dumux::NumericDifferentiation::partialDerivative(f, val,
+            numericDeriv, f(val), numEps, 0 /*central differences*/);
+
+        if (Dune::FloatCmp::ne(analyticDeriv, numericDeriv, eps))
+             DUNE_THROW(Dune::Exception, "Analytic derivative for " << derivName
+                         << " doesn't match numerical derivative: "
+                         << std::setprecision(10) << analyticDeriv << " != " << numericDeriv
+                         << " evaluated at " << val);
+    }
+}
+
+template<class F, class G>
+void testValueEqualRange(std::string_view testName,
+                         const std::vector<double>& values,
+                         const F& f, const G& g)
+{
+    static constexpr double eps = 1e-7;
+    for (auto val : values)
+    {
+        const auto a = f(val);
+        const auto b = g(val);
+
+        if (Dune::FloatCmp::ne(a, b, eps))
+            DUNE_THROW(Dune::Exception, "Test: " << testName << ": Function values do not match: "
+                       << a << " != " << b << " evaluated at " << val << "\n");
+
+    }
+}
+
+
+template<class Law, class RegLaw>
+void runTest(const std::string& name, const typename RegLaw::Params& params,
+             const std::vector<typename Law::Scalar>& sw,
+             const std::vector<typename Law::Scalar>& swNonReg)
+{
+    const auto pc = [&](){ auto pc = sw;
+        for (int i = 0; i < sw.size(); ++i)
+            pc[i] = RegLaw::pc(params, sw[i]);
+        return pc;
+    }();
+
+    testDerivatives("dpc_dsw", sw, [&](auto sw){ return RegLaw::pc(params, sw); }, [&](auto sw){ return RegLaw::dpc_dsw(params, sw); });
+    //testDerivatives("dkrw_dsw", sw, [&](auto sw){ return RegLaw::krw(params, sw); }, [&](auto sw){ return RegLaw::dkrw_dsw(params, sw); });
+    //testDerivatives([&](auto sw){ return RegLaw::krn(params, sw); }, [&](auto sw){ return RegLaw::dkrn_dsw(params, sw); }, sw, "dkrn_dsw");
+    //testDerivatives("dsw_dpc", [&](auto sw){ return RegLaw::sw(params, sw); }, [&](auto sw){ return RegLaw::dsw_dpc(params, sw); }, pc);
+    testValueEqualRange("Checking sw == sw(pc(sw))", sw, [](auto sw){ return sw; }, [&](auto sw) { return RegLaw::sw(params, RegLaw::pc(params, sw)); });
+    testValueEqualRange("Checking 1.0 == dsw_dpc*dpc_dsw^-1", sw, [](auto sw){ return 1.0; }, [&](auto sw) { return RegLaw::dpc_dsw(params, sw)*RegLaw::dsw_dpc(params, RegLaw::pc(params, sw)); });
+
+    // check that regularized and unregularized are the same in the region without regularization
+    testValueEqualRange("Checking NoReg::pc == Reg::pc", swNonReg, [&](auto sw){ return RegLaw::pc(params, sw); }, [&](auto sw) { return Law::pc(params, sw); });
+
+    // test pc-sw curve against some precomputed values
+    writeContainerToFile(pc, "test_pcsw_" + name + ".dat", 100);
+}
+
+} // end namespace Dumux
+
+#endif
diff --git a/test/references/pcswcurve.dat b/test/references/pcswcurve.dat
deleted file mode 100644
index 72066bc8ed..0000000000
--- a/test/references/pcswcurve.dat
+++ /dev/null
@@ -1,1001 +0,0 @@
-1e-06 1e+07
-0.001001 316070
-0.002001 223551
-0.003001 182544
-0.004001 158094
-0.005001 141407
-0.00600099 129089
-0.00700099 119514
-0.00800099 111796
-0.00900099 105403
-0.010001 99995.1
-0.011001 95342
-0.012001 91283.3
-0.013001 87702.5
-0.014001 84512.4
-0.015001 81647
-0.016001 79054.5
-0.017001 76694.3
-0.018001 74533.6
-0.019001 72545.8
-0.020001 70708.9
-0.021001 69004.9
-0.022001 67418.5
-0.023001 65936.6
-0.024001 64548.4
-0.025001 63244.3
-0.026001 62016.2
-0.027001 60857
-0.028001 59760.4
-0.029001 58721
-0.030001 57734.1
-0.031001 56795.3
-0.032001 55900.9
-0.033001 55047.4
-0.034001 54231.8
-0.035001 53451.5
-0.036001 52703.9
-0.037001 51986.8
-0.038001 51298.3
-0.039001 50636.3
-0.040001 49999.4
-0.041001 49385.9
-0.042001 48794.4
-0.043001 48223.7
-0.044001 47672.6
-0.045001 47140
-0.046001 46624.8
-0.047001 46126.1
-0.048001 45643.1
-0.049001 45175
-0.050001 44720.9
-0.0510009 44280.3
-0.0520009 43852.5
-0.0530009 43436.8
-0.0540009 43032.8
-0.0550009 42639.8
-0.0560009 42257.4
-0.0570009 41885
-0.0580009 41522.4
-0.0590009 41169
-0.0600009 40824.5
-0.0610009 40488.5
-0.0620009 40160.7
-0.0630009 39840.7
-0.0640009 39528.2
-0.0650009 39222.9
-0.0660009 38924.7
-0.0670009 38633.1
-0.0680009 38348
-0.0690009 38069.1
-0.0700009 37796.2
-0.0710009 37529.1
-0.0720009 37267.6
-0.0730009 37011.4
-0.0740009 36760.5
-0.0750009 36514.6
-0.0760009 36273.6
-0.0770009 36037.3
-0.0780009 35805.5
-0.0790009 35578.2
-0.0800009 35355.1
-0.0810009 35136.2
-0.0820009 34921.3
-0.0830009 34710.3
-0.0840009 34503.1
-0.0850009 34299.5
-0.0860009 34099.5
-0.0870009 33903
-0.0880009 33709.8
-0.0890009 33519.9
-0.0900009 33333.2
-0.0910009 33149.5
-0.0920009 32968.9
-0.0930009 32791.1
-0.0940009 32616.2
-0.0950009 32444.1
-0.0960009 32274.7
-0.0970009 32107.9
-0.0980009 31943.7
-0.0990009 31781.9
-0.100001 31622.6
-0.101001 31465.7
-0.102001 31311.1
-0.103001 31158.7
-0.104001 31008.6
-0.105001 30860.5
-0.106001 30714.6
-0.107001 30570.8
-0.108001 30428.9
-0.109001 30289
-0.110001 30151
-0.111001 30014.9
-0.112001 29880.6
-0.113001 29748.1
-0.114001 29617.3
-0.115001 29488.3
-0.116001 29360.9
-0.117001 29235.2
-0.118001 29111
-0.119001 28988.4
-0.120001 28867.4
-0.121001 28747.9
-0.122001 28629.8
-0.123001 28513.2
-0.124001 28398
-0.125001 28284.2
-0.126001 28171.7
-0.127001 28060.6
-0.128001 27950.8
-0.129001 27842.2
-0.130001 27734.9
-0.131001 27628.9
-0.132001 27524
-0.133001 27420.3
-0.134001 27317.8
-0.135001 27216.5
-0.136001 27116.2
-0.137001 27017.1
-0.138001 26919
-0.139001 26822
-0.140001 26726
-0.141001 26631.1
-0.142001 26537.2
-0.143001 26444.2
-0.144001 26352.2
-0.145001 26261.2
-0.146001 26171.1
-0.147001 26082
-0.148001 25993.7
-0.149001 25906.3
-0.150001 25819.8
-0.151001 25734.2
-0.152001 25649.4
-0.153001 25565.4
-0.154001 25482.3
-0.155001 25400
-0.156001 25318.4
-0.157001 25237.7
-0.158001 25157.7
-0.159001 25078.4
-0.160001 24999.9
-0.161001 24922.2
-0.162001 24845.1
-0.163001 24768.8
-0.164001 24693.2
-0.165001 24618.2
-0.166001 24544
-0.167001 24470.4
-0.168001 24397.4
-0.169001 24325.2
-0.170001 24253.5
-0.171001 24182.5
-0.172001 24112.1
-0.173001 24042.3
-0.174001 23973.1
-0.175001 23904.5
-0.176001 23836.5
-0.177001 23769.1
-0.178001 23702.2
-0.179001 23635.9
-0.180001 23570.2
-0.181001 23505
-0.182001 23440.3
-0.183001 23376.2
-0.184001 23312.6
-0.185001 23249.5
-0.186001 23186.9
-0.187001 23124.8
-0.188001 23063.2
-0.189001 23002.1
-0.190001 22941.5
-0.191001 22881.4
-0.192001 22821.7
-0.193001 22762.5
-0.194001 22703.8
-0.195001 22645.5
-0.196001 22587.7
-0.197001 22530.2
-0.198001 22473.3
-0.199001 22416.7
-0.200001 22360.6
-0.201001 22304.9
-0.202001 22249.7
-0.203001 22194.8
-0.204001 22140.3
-0.205001 22086.3
-0.206001 22032.6
-0.207001 21979.3
-0.208001 21926.4
-0.209001 21873.9
-0.210001 21821.7
-0.211001 21770
-0.212001 21718.6
-0.213001 21667.5
-0.214001 21616.8
-0.215001 21566.5
-0.216001 21516.5
-0.217001 21466.9
-0.218001 21417.6
-0.219001 21368.7
-0.220001 21320
-0.221001 21271.7
-0.222001 21223.8
-0.223001 21176.1
-0.224001 21128.8
-0.225001 21081.8
-0.226001 21035.1
-0.227001 20988.7
-0.228001 20942.7
-0.229001 20896.9
-0.230001 20851.4
-0.231001 20806.2
-0.232001 20761.3
-0.233001 20716.7
-0.234001 20672.4
-0.235001 20628.4
-0.236001 20584.6
-0.237001 20541.2
-0.238001 20498
-0.239001 20455
-0.240001 20412.4
-0.241001 20370
-0.242001 20327.9
-0.243001 20286
-0.244001 20244.4
-0.245001 20203
-0.246001 20161.9
-0.247001 20121.1
-0.248001 20080.5
-0.249001 20040.1
-0.250001 20000
-0.251001 19960.1
-0.252001 19920.4
-0.253001 19881
-0.254001 19841.9
-0.255001 19802.9
-0.256001 19764.2
-0.257001 19725.7
-0.258001 19687.5
-0.259001 19649.4
-0.260001 19611.6
-0.261001 19574
-0.262001 19536.6
-0.263001 19499.4
-0.264001 19462.4
-0.265001 19425.7
-0.266001 19389.1
-0.267001 19352.8
-0.268001 19316.7
-0.269001 19280.7
-0.270001 19245
-0.271001 19209.4
-0.272001 19174.1
-0.273001 19138.9
-0.274001 19104
-0.275001 19069.2
-0.276001 19034.6
-0.277001 19000.3
-0.278001 18966.1
-0.279001 18932
-0.280001 18898.2
-0.281001 18864.5
-0.282001 18831.1
-0.283001 18797.8
-0.284001 18764.6
-0.285001 18731.7
-0.286001 18698.9
-0.287001 18666.3
-0.288001 18633.9
-0.289001 18601.6
-0.290001 18569.5
-0.291001 18537.6
-0.292001 18505.8
-0.293001 18474.2
-0.294001 18442.8
-0.295001 18411.5
-0.296001 18380.3
-0.297001 18349.4
-0.298001 18318.6
-0.299001 18287.9
-0.300001 18257.4
-0.301001 18227
-0.302001 18196.8
-0.303001 18166.8
-0.304001 18136.9
-0.305001 18107.1
-0.306001 18077.5
-0.307001 18048.1
-0.308001 18018.7
-0.309001 17989.5
-0.310001 17960.5
-0.311001 17931.6
-0.312001 17902.9
-0.313001 17874.2
-0.314001 17845.7
-0.315001 17817.4
-0.316001 17789.2
-0.317001 17761.1
-0.318001 17733.2
-0.319001 17705.3
-0.320001 17677.7
-0.321001 17650.1
-0.322001 17622.7
-0.323001 17595.4
-0.324001 17568.2
-0.325001 17541.1
-0.326001 17514.2
-0.327001 17487.4
-0.328001 17460.7
-0.329001 17434.2
-0.330001 17407.7
-0.331001 17381.4
-0.332001 17355.2
-0.333001 17329.2
-0.334001 17303.2
-0.335001 17277.4
-0.336001 17251.6
-0.337001 17226
-0.338001 17200.5
-0.339001 17175.1
-0.340001 17149.8
-0.341001 17124.7
-0.342001 17099.6
-0.343001 17074.7
-0.344001 17049.8
-0.345001 17025.1
-0.346001 17000.5
-0.347001 16976
-0.348001 16951.6
-0.349001 16927.3
-0.350001 16903.1
-0.351001 16879
-0.352001 16855
-0.353001 16831.1
-0.354001 16807.3
-0.355001 16783.6
-0.356001 16760
-0.357001 16736.5
-0.358001 16713.1
-0.359001 16689.8
-0.360001 16666.7
-0.361001 16643.6
-0.362001 16620.5
-0.363001 16597.6
-0.364001 16574.8
-0.365001 16552.1
-0.366001 16529.5
-0.367001 16506.9
-0.368001 16484.5
-0.369001 16462.1
-0.370001 16439.9
-0.371001 16417.7
-0.372001 16395.6
-0.373001 16373.6
-0.374001 16351.7
-0.375001 16329.9
-0.376001 16308.2
-0.377001 16286.5
-0.378001 16265
-0.379001 16243.5
-0.380001 16222.1
-0.381001 16200.8
-0.382001 16179.6
-0.383001 16158.5
-0.384001 16137.4
-0.385001 16116.4
-0.386001 16095.6
-0.387001 16074.7
-0.388001 16054
-0.389001 16033.4
-0.390001 16012.8
-0.391001 15992.3
-0.392001 15971.9
-0.393001 15951.6
-0.394001 15931.3
-0.395001 15911.1
-0.396001 15891
-0.397001 15871
-0.398001 15851.1
-0.399001 15831.2
-0.400001 15811.4
-0.401001 15791.6
-0.402001 15772
-0.403001 15752.4
-0.404001 15732.9
-0.405001 15713.5
-0.406001 15694.1
-0.407001 15674.8
-0.408001 15655.6
-0.409001 15636.4
-0.410001 15617.4
-0.411001 15598.4
-0.412001 15579.4
-0.413001 15560.5
-0.414001 15541.7
-0.415001 15523
-0.416001 15504.3
-0.417001 15485.7
-0.418001 15467.2
-0.419001 15448.7
-0.420001 15430.3
-0.421001 15412
-0.422001 15393.7
-0.423001 15375.5
-0.424001 15357.4
-0.425001 15339.3
-0.426001 15321.3
-0.427001 15303.3
-0.428001 15285.4
-0.429001 15267.6
-0.430001 15249.8
-0.431001 15232.1
-0.432001 15214.5
-0.433001 15196.9
-0.434001 15179.4
-0.435001 15162
-0.436001 15144.6
-0.437001 15127.2
-0.438001 15109.9
-0.439001 15092.7
-0.440001 15075.6
-0.441001 15058.5
-0.442001 15041.4
-0.443001 15024.4
-0.444001 15007.5
-0.445001 14990.6
-0.446001 14973.8
-0.447001 14957.1
-0.448001 14940.3
-0.449001 14923.7
-0.450001 14907.1
-0.451001 14890.6
-0.452001 14874.1
-0.453001 14857.7
-0.454001 14841.3
-0.455001 14825
-0.456001 14808.7
-0.457001 14792.5
-0.458001 14776.3
-0.459001 14760.2
-0.460001 14744.2
-0.461001 14728.2
-0.462001 14712.2
-0.463001 14696.3
-0.464001 14680.5
-0.465001 14664.7
-0.466001 14649
-0.467001 14633.3
-0.468001 14617.6
-0.469001 14602
-0.470001 14586.5
-0.471001 14571
-0.472001 14555.6
-0.473001 14540.2
-0.474001 14524.8
-0.475001 14509.5
-0.476001 14494.3
-0.477001 14479.1
-0.478001 14463.9
-0.479001 14448.8
-0.480001 14433.7
-0.481001 14418.7
-0.482001 14403.8
-0.483001 14388.9
-0.484001 14374
-0.485001 14359.2
-0.486001 14344.4
-0.487001 14329.6
-0.488001 14315
-0.489001 14300.3
-0.490001 14285.7
-0.491001 14271.2
-0.492001 14256.6
-0.493001 14242.2
-0.494001 14227.8
-0.495001 14213.4
-0.496001 14199
-0.497001 14184.7
-0.498001 14170.5
-0.499001 14156.3
-0.5 14142.1
-0.501 14128
-0.502 14113.9
-0.503 14099.9
-0.504 14085.9
-0.505 14071.9
-0.506 14058
-0.507 14044.2
-0.508 14030.3
-0.509 14016.5
-0.51 14002.8
-0.511 13989.1
-0.512 13975.4
-0.513 13961.8
-0.514 13948.2
-0.515 13934.7
-0.516 13921.1
-0.517 13907.7
-0.518 13894.2
-0.519 13880.9
-0.52 13867.5
-0.521 13854.2
-0.522 13840.9
-0.523 13827.7
-0.524 13814.5
-0.525 13801.3
-0.526 13788.2
-0.527 13775.1
-0.528 13762
-0.529 13749
-0.53 13736.1
-0.531 13723.1
-0.532 13710.2
-0.533 13697.3
-0.534 13684.5
-0.535 13671.7
-0.536 13659
-0.537 13646.2
-0.538 13633.5
-0.539 13620.9
-0.54 13608.3
-0.541 13595.7
-0.542 13583.1
-0.543 13570.6
-0.544 13558.1
-0.545 13545.7
-0.546 13533.3
-0.547 13520.9
-0.548 13508.6
-0.549 13496.3
-0.55 13484
-0.551 13471.8
-0.552 13459.5
-0.553 13447.4
-0.554 13435.2
-0.555 13423.1
-0.556 13411
-0.557 13399
-0.558 13387
-0.559 13375
-0.56 13363.1
-0.561 13351.1
-0.562 13339.3
-0.563 13327.4
-0.564 13315.6
-0.565 13303.8
-0.566 13292
-0.567 13280.3
-0.568 13268.6
-0.569 13257
-0.57 13245.3
-0.571 13233.7
-0.572 13222.1
-0.573 13210.6
-0.574 13199.1
-0.575 13187.6
-0.576 13176.2
-0.577 13164.7
-0.578 13153.3
-0.579 13142
-0.58 13130.6
-0.581 13119.3
-0.582 13108.1
-0.583 13096.8
-0.584 13085.6
-0.585 13074.4
-0.586 13063.2
-0.587 13052.1
-0.588 13041
-0.589 13029.9
-0.59 13018.9
-0.591 13007.9
-0.592 12996.9
-0.593 12985.9
-0.594 12975
-0.595 12964.1
-0.596 12953.2
-0.597 12942.3
-0.598 12931.5
-0.599 12920.7
-0.6 12909.9
-0.601 12899.2
-0.602 12888.5
-0.603 12877.8
-0.604 12867.1
-0.605 12856.5
-0.606 12845.9
-0.607 12835.3
-0.608 12824.7
-0.609 12814.2
-0.61 12803.7
-0.611 12793.2
-0.612 12782.7
-0.613 12772.3
-0.614 12761.9
-0.615 12751.5
-0.616 12741.2
-0.617 12730.8
-0.618 12720.5
-0.619 12710.3
-0.62 12700
-0.621 12689.8
-0.622 12679.6
-0.623 12669.4
-0.624 12659.2
-0.625 12649.1
-0.626 12639
-0.627 12628.9
-0.628 12618.9
-0.629 12608.8
-0.63 12598.8
-0.631 12588.8
-0.632 12578.9
-0.633 12568.9
-0.634 12559
-0.635 12549.1
-0.636 12539.2
-0.637 12529.4
-0.638 12519.6
-0.639 12509.8
-0.64 12500
-0.641 12490.2
-0.642 12480.5
-0.643 12470.8
-0.644 12461.1
-0.645 12451.5
-0.646 12441.8
-0.647 12432.2
-0.648 12422.6
-0.649 12413
-0.65 12403.5
-0.651 12393.9
-0.652 12384.4
-0.653 12374.9
-0.654 12365.5
-0.655 12356
-0.656 12346.6
-0.657 12337.2
-0.658 12327.8
-0.659 12318.5
-0.66 12309.1
-0.661 12299.8
-0.662 12290.5
-0.663 12281.3
-0.664 12272
-0.665 12262.8
-0.666 12253.6
-0.667 12244.4
-0.668 12235.2
-0.669 12226.1
-0.67 12216.9
-0.671 12207.8
-0.672 12198.7
-0.673 12189.7
-0.674 12180.6
-0.675 12171.6
-0.676 12162.6
-0.677 12153.6
-0.678 12144.7
-0.679 12135.7
-0.68 12126.8
-0.681 12117.9
-0.682 12109
-0.683 12100.1
-0.684 12091.3
-0.685 12082.4
-0.686 12073.6
-0.687 12064.8
-0.688 12056.1
-0.689 12047.3
-0.69 12038.6
-0.691 12029.9
-0.692 12021.2
-0.693 12012.5
-0.694 12003.8
-0.695 11995.2
-0.696 11986.6
-0.697 11978
-0.698 11969.4
-0.699 11960.8
-0.7 11952.3
-0.701 11943.8
-0.702 11935.2
-0.703 11926.8
-0.704 11918.3
-0.705 11909.8
-0.706 11901.4
-0.707 11893
-0.708 11884.6
-0.709 11876.2
-0.71 11867.8
-0.711 11859.5
-0.712 11851.1
-0.713 11842.8
-0.714 11834.5
-0.715 11826.2
-0.716 11818
-0.717 11809.7
-0.718 11801.5
-0.719 11793.3
-0.72 11785.1
-0.721 11776.9
-0.722 11768.8
-0.723 11760.6
-0.724 11752.5
-0.725 11744.4
-0.726 11736.3
-0.727 11728.2
-0.728 11720.2
-0.729 11712.1
-0.73 11704.1
-0.731 11696.1
-0.732 11688.1
-0.733 11680.1
-0.734 11672.2
-0.735 11664.2
-0.736 11656.3
-0.737 11648.4
-0.738 11640.5
-0.739 11632.6
-0.74 11624.8
-0.741 11616.9
-0.742 11609.1
-0.743 11601.3
-0.744 11593.5
-0.745 11585.7
-0.746 11577.9
-0.747 11570.2
-0.748 11562.4
-0.749 11554.7
-0.75 11547
-0.751 11539.3
-0.752 11531.6
-0.753 11524
-0.754 11516.3
-0.755 11508.7
-0.756 11501.1
-0.757 11493.5
-0.758 11485.9
-0.759 11478.3
-0.76 11470.8
-0.761 11463.2
-0.762 11455.7
-0.763 11448.2
-0.764 11440.7
-0.765 11433.2
-0.766 11425.8
-0.767 11418.3
-0.768 11410.9
-0.769 11403.5
-0.77 11396.1
-0.771 11388.7
-0.772 11381.3
-0.773 11373.9
-0.774 11366.6
-0.775 11359.2
-0.776 11351.9
-0.777 11344.6
-0.778 11337.3
-0.779 11330
-0.78 11322.8
-0.781 11315.5
-0.782 11308.3
-0.783 11301.1
-0.784 11293.8
-0.785 11286.7
-0.786 11279.5
-0.787 11272.3
-0.788 11265.1
-0.789 11258
-0.79 11250.9
-0.791 11243.8
-0.792 11236.7
-0.793 11229.6
-0.794 11222.5
-0.795 11215.4
-0.796 11208.4
-0.797 11201.4
-0.798 11194.3
-0.799 11187.3
-0.8 11180.3
-0.801 11173.4
-0.802 11166.4
-0.803 11159.4
-0.804 11152.5
-0.805 11145.6
-0.806 11138.6
-0.807 11131.7
-0.808 11124.9
-0.809 11118
-0.81 11111.1
-0.811 11104.3
-0.812 11097.4
-0.813 11090.6
-0.814 11083.8
-0.815 11077
-0.816 11070.2
-0.817 11063.4
-0.818 11056.6
-0.819 11049.9
-0.82 11043.2
-0.821 11036.4
-0.822 11029.7
-0.823 11023
-0.824 11016.3
-0.825 11009.6
-0.826 11003
-0.827 10996.3
-0.828 10989.7
-0.829 10983
-0.83 10976.4
-0.831 10969.8
-0.832 10963.2
-0.833 10956.6
-0.834 10950.1
-0.835 10943.5
-0.836 10937
-0.837 10930.4
-0.838 10923.9
-0.839 10917.4
-0.84 10910.9
-0.841 10904.4
-0.842 10897.9
-0.843 10891.5
-0.844 10885
-0.845 10878.6
-0.846 10872.1
-0.847 10865.7
-0.848 10859.3
-0.849 10852.9
-0.85 10846.5
-0.851 10840.1
-0.852 10833.8
-0.853 10827.4
-0.854 10821.1
-0.855 10814.8
-0.856 10808.4
-0.857 10802.1
-0.858 10795.8
-0.859 10789.6
-0.86 10783.3
-0.861 10777
-0.862 10770.8
-0.863 10764.5
-0.864 10758.3
-0.865 10752.1
-0.866 10745.9
-0.867 10739.7
-0.868 10733.5
-0.869 10727.3
-0.87 10721.1
-0.871 10715
-0.872 10708.8
-0.873 10702.7
-0.874 10696.6
-0.875 10690.4
-0.876 10684.3
-0.877 10678.3
-0.878 10672.2
-0.879 10666.1
-0.88 10660
-0.881 10654
-0.882 10647.9
-0.883 10641.9
-0.884 10635.9
-0.885 10629.9
-0.886 10623.9
-0.887 10617.9
-0.888 10611.9
-0.889 10605.9
-0.89 10600
-0.891 10594
-0.892 10588.1
-0.893 10582.2
-0.894 10576.2
-0.895 10570.3
-0.896 10564.4
-0.897 10558.5
-0.898 10552.7
-0.899 10546.8
-0.9 10540.9
-0.901 10535.1
-0.902 10529.2
-0.903 10523.4
-0.904 10517.6
-0.905 10511.8
-0.906 10506
-0.907 10500.2
-0.908 10494.4
-0.909 10488.6
-0.91 10482.8
-0.911 10477.1
-0.912 10471.3
-0.913 10465.6
-0.914 10459.9
-0.915 10454.2
-0.916 10448.5
-0.917 10442.8
-0.918 10437.1
-0.919 10431.4
-0.92 10425.7
-0.921 10420.1
-0.922 10414.4
-0.923 10408.8
-0.924 10403.1
-0.925 10397.5
-0.926 10391.9
-0.927 10386.3
-0.928 10380.7
-0.929 10375.1
-0.93 10369.5
-0.931 10363.9
-0.932 10358.4
-0.933 10352.8
-0.934 10347.3
-0.935 10341.8
-0.936 10336.2
-0.937 10330.7
-0.938 10325.2
-0.939 10319.7
-0.94 10314.2
-0.941 10308.7
-0.942 10303.3
-0.943 10297.8
-0.944 10292.3
-0.945 10286.9
-0.946 10281.5
-0.947 10276
-0.948 10270.6
-0.949 10265.2
-0.95 10259.8
-0.951 10254.4
-0.952 10249
-0.953 10243.6
-0.954 10238.3
-0.955 10232.9
-0.956 10227.5
-0.957 10222.2
-0.958 10216.9
-0.959 10211.5
-0.96 10206.2
-0.961 10200.9
-0.962 10195.6
-0.963 10190.3
-0.964 10185
-0.965 10179.7
-0.966 10174.5
-0.967 10169.2
-0.968 10163.9
-0.969 10158.7
-0.97 10153.5
-0.971 10148.2
-0.972 10143
-0.973 10137.8
-0.974 10132.6
-0.975 10127.4
-0.976 10122.2
-0.977 10117
-0.978 10111.8
-0.979 10106.7
-0.98 10101.5
-0.981 10096.4
-0.982 10091.2
-0.983 10086.1
-0.984 10081
-0.985 10075.9
-0.986 10070.7
-0.987 10065.6
-0.988 10060.5
-0.989 10055.5
-0.99 10050.4
-0.991 10045.3
-0.992 10040.2
-0.993 10035.2
-0.994 10030.1
-0.995 10025.1
-0.996 10020.1
-0.997 10015
-0.998 10010
-0.999 10005
-1 10000
diff --git a/test/references/test_pcsw_brookscorey.dat b/test/references/test_pcsw_brookscorey.dat
new file mode 100644
index 0000000000..d8e8d2872f
--- /dev/null
+++ b/test/references/test_pcsw_brookscorey.dat
@@ -0,0 +1,100 @@
+7.7500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+05
+7.1186868686868681106716394424438476562500000000000000000000000000000000000000000000000000000000000000e+05
+6.4873737373737362213432788848876953125000000000000000000000000000000000000000000000000000000000000000e+05
+5.8560606060606054961681365966796875000000000000000000000000000000000000000000000000000000000000000000e+05
+5.2247474747474741889163851737976074218750000000000000000000000000000000000000000000000000000000000000e+05
+4.5934343434343428816646337509155273437500000000000000000000000000000000000000000000000000000000000000e+05
+3.9621212121212127385661005973815917968750000000000000000000000000000000000000000000000000000000000000e+05
+3.3308080808080802671611309051513671875000000000000000000000000000000000000000000000000000000000000000e+05
+2.6994949494949495419859886169433593750000000000000000000000000000000000000000000000000000000000000000e+05
+2.0681818181818185257725417613983154296875000000000000000000000000000000000000000000000000000000000000e+05
+1.4368686868686863454058766365051269531250000000000000000000000000000000000000000000000000000000000000e+05
+8.4852813742385696968995034694671630859375000000000000000000000000000000000000000000000000000000000000e+04
+6.1411957886299074743874371051788330078125000000000000000000000000000000000000000000000000000000000000e+04
+5.0545412350453909311909228563308715820312500000000000000000000000000000000000000000000000000000000000e+04
+4.3951192441993764077778905630111694335937500000000000000000000000000000000000000000000000000000000000e+04
+3.9407374645751122443471103906631469726562500000000000000000000000000000000000000000000000000000000000e+04
+3.6032771968552529870066791772842407226562500000000000000000000000000000000000000000000000000000000000e+04
+3.3398996358370990492403507232666015625000000000000000000000000000000000000000000000000000000000000000e+04
+3.1269438398822865565307438373565673828125000000000000000000000000000000000000000000000000000000000000e+04
+2.9501350313666498550446704030036926269531250000000000000000000000000000000000000000000000000000000000e+04
+2.8002828711428137467009946703910827636718750000000000000000000000000000000000000000000000000000000000e+04
+2.6711673731039645645068958401679992675781250000000000000000000000000000000000000000000000000000000000e+04
+2.5584085962673252652166411280632019042968750000000000000000000000000000000000000000000000000000000000e+04
+2.4588211660707569535588845610618591308593750000000000000000000000000000000000000000000000000000000000e+04
+2.3700255856415864400332793593406677246093750000000000000000000000000000000000000000000000000000000000e+04
+2.2902037273095993441529572010040283203125000000000000000000000000000000000000000000000000000000000000e+04
+2.2179392819428339862497523427009582519531250000000000000000000000000000000000000000000000000000000000e+04
+2.1521103473958813992794603109359741210937500000000000000000000000000000000000000000000000000000000000e+04
+2.0918151466453255125088617205619812011718750000000000000000000000000000000000000000000000000000000000e+04
+2.0363194392429551953682675957679748535156250000000000000000000000000000000000000000000000000000000000e+04
+1.9850185156473191455006599426269531250000000000000000000000000000000000000000000000000000000000000000e+04
+1.9374092242914681264664977788925170898437500000000000000000000000000000000000000000000000000000000000e+04
+1.8930690444988580566132441163063049316406250000000000000000000000000000000000000000000000000000000000e+04
+1.8516401995451029506511986255645751953125000000000000000000000000000000000000000000000000000000000000e+04
+1.8128174353590900864219292998313903808593750000000000000000000000000000000000000000000000000000000000e+04
+1.7763385054813668830320239067077636718750000000000000000000000000000000000000000000000000000000000000e+04
+1.7419766814227707072859629988670349121093750000000000000000000000000000000000000000000000000000000000e+04
+1.7095347978594207233982160687446594238281250000000000000000000000000000000000000000000000000000000000e+04
+1.6788404742792841716436669230461120605468750000000000000000000000000000000000000000000000000000000000e+04
+1.6497422479090731940232217311859130859375000000000000000000000000000000000000000000000000000000000000e+04
+1.6221064194066915661096572875976562500000000000000000000000000000000000000000000000000000000000000000e+04
+1.5958144610863189882365986704826354980468750000000000000000000000000000000000000000000000000000000000e+04
+1.5707608728339806475560180842876434326171875000000000000000000000000000000000000000000000000000000000e+04
+1.5468513971008949738461524248123168945312500000000000000000000000000000000000000000000000000000000000e+04
+1.5240015240022861689794808626174926757812500000000000000000000000000000000000000000000000000000000000e+04
+1.5021352323976214393042027950286865234375000000000000000000000000000000000000000000000000000000000000e+04
+1.4811839241547673736931756138801574707031250000000000000000000000000000000000000000000000000000000000e+04
+1.4610855175135608078562654554843902587890625000000000000000000000000000000000000000000000000000000000e+04
+1.4417836722200438089203089475631713867187500000000000000000000000000000000000000000000000000000000000e+04
+1.4232271243797780698514543473720550537109375000000000000000000000000000000000000000000000000000000000e+04
+1.4053691131299459811998531222343444824218750000000000000000000000000000000000000000000000000000000000e+04
+1.3881668845171579960151575505733489990234375000000000000000000000000000000000000000000000000000000000e+04
+1.3715812605873190477723255753517150878906250000000000000000000000000000000000000000000000000000000000e+04
+1.3555762637935782549902796745300292968750000000000000000000000000000000000000000000000000000000000000e+04
+1.3401187885209797968855127692222595214843750000000000000000000000000000000000000000000000000000000000e+04
+1.3251783128981584013672545552253723144531250000000000000000000000000000000000000000000000000000000000e+04
+1.3107266451838055218104273080825805664062500000000000000000000000000000000000000000000000000000000000e+04
+1.2967376999302448894013650715351104736328125000000000000000000000000000000000000000000000000000000000e+04
+1.2831872998785667732590809464454650878906250000000000000000000000000000000000000000000000000000000000e+04
+1.2700530001609864484635181725025177001953125000000000000000000000000000000000000000000000000000000000e+04
+1.2573139319013742351671680808067321777343750000000000000000000000000000000000000000000000000000000000e+04
+1.2449506627340209888643585145473480224609375000000000000000000000000000000000000000000000000000000000e+04
+1.2329450721194856669171713292598724365234375000000000000000000000000000000000000000000000000000000000e+04
+1.2212802396374116142396815121173858642578125000000000000000000000000000000000000000000000000000000000e+04
+1.2099403446897487810929305851459503173828125000000000000000000000000000000000000000000000000000000000e+04
+1.1989105762620321911526843905448913574218750000000000000000000000000000000000000000000000000000000000e+04
+1.1881770515720090770628303289413452148437500000000000000000000000000000000000000000000000000000000000e+04
+1.1777267425893653125967830419540405273437500000000000000000000000000000000000000000000000000000000000e+04
+1.1675474095420704543357715010643005371093750000000000000000000000000000000000000000000000000000000000e+04
+1.1576275406375920283608138561248779296875000000000000000000000000000000000000000000000000000000000000e+04
+1.1479562973239544589887373149394989013671875000000000000000000000000000000000000000000000000000000000e+04
+1.1385234644988229774753563106060028076171875000000000000000000000000000000000000000000000000000000000e+04
+1.1293194051465598022332414984703063964843750000000000000000000000000000000000000000000000000000000000e+04
+1.1203350189452788981725461781024932861328125000000000000000000000000000000000000000000000000000000000e+04
+1.1115617044397089557605795562267303466796875000000000000000000000000000000000000000000000000000000000e+04
+1.1029913244224324444076046347618103027343750000000000000000000000000000000000000000000000000000000000e+04
+1.0946161742067848535953089594841003417968750000000000000000000000000000000000000000000000000000000000e+04
+1.0864289525102223706198856234550476074218750000000000000000000000000000000000000000000000000000000000e+04
+1.0784227346980664151487872004508972167968750000000000000000000000000000000000000000000000000000000000e+04
+1.0705909481647646316559985280036926269531250000000000000000000000000000000000000000000000000000000000e+04
+1.0629273496537474784418009221553802490234375000000000000000000000000000000000000000000000000000000000e+04
+1.0554260043380167189752683043479919433593750000000000000000000000000000000000000000000000000000000000e+04
+1.0480812665021674547460861504077911376953125000000000000000000000000000000000000000000000000000000000e+04
+1.0408877616829495309502817690372467041015625000000000000000000000000000000000000000000000000000000000e+04
+1.0338403701399816782213747501373291015625000000000000000000000000000000000000000000000000000000000000e+04
+1.0269342115411071063135750591754913330078125000000000000000000000000000000000000000000000000000000000e+04
+1.0201646307582894223742187023162841796875000000000000000000000000000000000000000000000000000000000000e+04
+1.0135271846801166248042136430740356445312500000000000000000000000000000000000000000000000000000000000e+04
+1.0070176299560269399080425500869750976562500000000000000000000000000000000000000000000000000000000000e+04
+1.0006319115954480366781353950500488281250000000000000000000000000000000000000000000000000000000000000e+04
+9.9431818181818180164555087685585021972656250000000000000000000000000000000000000000000000000000000000e+03
+9.8800505050505053077358752489089965820312500000000000000000000000000000000000000000000000000000000000e+03
+9.8169191919191907800268381834030151367187500000000000000000000000000000000000000000000000000000000000e+03
+9.7537878787878780713072046637535095214843750000000000000000000000000000000000000000000000000000000000e+03
+9.6906565656565653625875711441040039062500000000000000000000000000000000000000000000000000000000000000e+03
+9.6275252525252526538679376244544982910156250000000000000000000000000000000000000000000000000000000000e+03
+9.5643939393939399451483041048049926757812500000000000000000000000000000000000000000000000000000000000e+03
+9.5012626262626254174392670392990112304687500000000000000000000000000000000000000000000000000000000000e+03
+9.4381313131313127087196335196495056152343750000000000000000000000000000000000000000000000000000000000e+03
+9.3750000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e+03
diff --git a/test/references/test_pcsw_vangenuchten.dat b/test/references/test_pcsw_vangenuchten.dat
new file mode 100644
index 0000000000..7379b19c72
--- /dev/null
+++ b/test/references/test_pcsw_vangenuchten.dat
@@ -0,0 +1,100 @@
+5.1970481100562302162870764732360839843750000000000000000000000000000000000000000000000000000000000000e+05
+4.7906694760963413864374160766601562500000000000000000000000000000000000000000000000000000000000000000e+05
+4.3842908421364525565877556800842285156250000000000000000000000000000000000000000000000000000000000000e+05
+3.9779122081765643088147044181823730468750000000000000000000000000000000000000000000000000000000000000e+05
+3.5715335742166754789650440216064453125000000000000000000000000000000000000000000000000000000000000000e+05
+3.1651549402567866491153836250305175781250000000000000000000000000000000000000000000000000000000000000e+05
+2.7587763062968989834189414978027343750000000000000000000000000000000000000000000000000000000000000000e+05
+2.3523976723370098625309765338897705078125000000000000000000000000000000000000000000000000000000000000e+05
+1.9460190383771213237196207046508789062500000000000000000000000000000000000000000000000000000000000000e+05
+1.5396404044172330759465694427490234375000000000000000000000000000000000000000000000000000000000000000e+05
+1.1332617704573439550586044788360595703125000000000000000000000000000000000000000000000000000000000000e+05
+7.5257129827769254916347563266754150390625000000000000000000000000000000000000000000000000000000000000e+04
+5.8908786364871477417182177305221557617187500000000000000000000000000000000000000000000000000000000000e+04
+5.0795624440500541822984814643859863281250000000000000000000000000000000000000000000000000000000000000e+04
+4.5644426169926569855306297540664672851562500000000000000000000000000000000000000000000000000000000000e+04
+4.1968673286320561601314693689346313476562500000000000000000000000000000000000000000000000000000000000e+04
+3.9158178424276818986982107162475585937500000000000000000000000000000000000000000000000000000000000000e+04
+3.6908400797575231990776956081390380859375000000000000000000000000000000000000000000000000000000000000e+04
+3.5047494767885298642795532941818237304687500000000000000000000000000000000000000000000000000000000000e+04
+3.3469887425013963365927338600158691406250000000000000000000000000000000000000000000000000000000000000e+04
+3.2106528424065170838730409741401672363281250000000000000000000000000000000000000000000000000000000000e+04
+3.0910026291437847248744219541549682617187500000000000000000000000000000000000000000000000000000000000e+04
+2.9846586121847511094529181718826293945312500000000000000000000000000000000000000000000000000000000000e+04
+2.8891346063433509698370471596717834472656250000000000000000000000000000000000000000000000000000000000e+04
+2.8025536416530510905431583523750305175781250000000000000000000000000000000000000000000000000000000000e+04
+2.7234673598064568068366497755050659179687500000000000000000000000000000000000000000000000000000000000e+04
+2.6507370159869740746216848492622375488281250000000000000000000000000000000000000000000000000000000000e+04
+2.5834526454111262864898890256881713867187500000000000000000000000000000000000000000000000000000000000e+04
+2.5208766922134112974163144826889038085937500000000000000000000000000000000000000000000000000000000000e+04
+2.4624037867532919335644692182540893554687500000000000000000000000000000000000000000000000000000000000e+04
+2.4075314610940527927596122026443481445312500000000000000000000000000000000000000000000000000000000000e+04
+2.3558384435967967874603345990180969238281250000000000000000000000000000000000000000000000000000000000e+04
+2.3069683121136331465095281600952148437500000000000000000000000000000000000000000000000000000000000000e+04
+2.2606170047871190035948529839515686035156250000000000000000000000000000000000000000000000000000000000e+04
+2.2165231533376365405274555087089538574218750000000000000000000000000000000000000000000000000000000000e+04
+2.1744605120024498319253325462341308593750000000000000000000000000000000000000000000000000000000000000e+04
+2.1342319633395320124691352248191833496093750000000000000000000000000000000000000000000000000000000000e+04
+2.0956647250431266002124175429344177246093750000000000000000000000000000000000000000000000000000000000e+04
+2.0586064817272024811245501041412353515625000000000000000000000000000000000000000000000000000000000000e+04
+2.0229222363744222093373537063598632812500000000000000000000000000000000000000000000000000000000000000e+04
+1.9884917269779376510996371507644653320312500000000000000000000000000000000000000000000000000000000000e+04
+1.9552072908887799712829291820526123046875000000000000000000000000000000000000000000000000000000000000e+04
+1.9229720866080831910949200391769409179687500000000000000000000000000000000000000000000000000000000000e+04
+1.8916986030221694818465039134025573730468750000000000000000000000000000000000000000000000000000000000e+04
+1.8613074013028097397182136774063110351562500000000000000000000000000000000000000000000000000000000000e+04
+1.8317260462407473823986947536468505859375000000000000000000000000000000000000000000000000000000000000e+04
+1.8028881926099533302476629614830017089843750000000000000000000000000000000000000000000000000000000000e+04
+1.7747327989632354729110375046730041503906250000000000000000000000000000000000000000000000000000000000e+04
+1.7472034465367814846104010939598083496093750000000000000000000000000000000000000000000000000000000000e+04
+1.7202477450573256646748632192611694335937500000000000000000000000000000000000000000000000000000000000e+04
+1.6938168104702614073175936937332153320312500000000000000000000000000000000000000000000000000000000000e+04
+1.6678648021396453259512782096862792968750000000000000000000000000000000000000000000000000000000000000e+04
+1.6423485090604550350690260529518127441406250000000000000000000000000000000000000000000000000000000000e+04
+1.6172269761804804147686809301376342773437500000000000000000000000000000000000000000000000000000000000e+04
+1.5924611631362911793985404074192047119140625000000000000000000000000000000000000000000000000000000000e+04
+1.5680136286253708021831698715686798095703125000000000000000000000000000000000000000000000000000000000e+04
+1.5438482343079098427551798522472381591796875000000000000000000000000000000000000000000000000000000000e+04
+1.5199298625859302774188108742237091064453125000000000000000000000000000000000000000000000000000000000e+04
+1.4962241428608087517204694449901580810546875000000000000000000000000000000000000000000000000000000000e+04
+1.4726971809279457374941557645797729492187500000000000000000000000000000000000000000000000000000000000e+04
+1.4493152860222813615109771490097045898437500000000000000000000000000000000000000000000000000000000000e+04
+1.4260446896607058079098351299762725830078125000000000000000000000000000000000000000000000000000000000e+04
+1.4028512498013938966323621571063995361328125000000000000000000000000000000000000000000000000000000000e+04
+1.3797001328998401731951162219047546386718750000000000000000000000000000000000000000000000000000000000e+04
+1.3565554651041484248708002269268035888671875000000000000000000000000000000000000000000000000000000000e+04
+1.3333799419776218201150186359882354736328125000000000000000000000000000000000000000000000000000000000e+04
+1.3101343835913005023030564188957214355468750000000000000000000000000000000000000000000000000000000000e+04
+1.2867772183412798767676576972007751464843750000000000000000000000000000000000000000000000000000000000e+04
+1.2632638740481856075348332524299621582031250000000000000000000000000000000000000000000000000000000000e+04
+1.2395460482465867244172841310501098632812500000000000000000000000000000000000000000000000000000000000e+04
+1.2155708202575220639118924736976623535156250000000000000000000000000000000000000000000000000000000000e+04
+1.1912795544193222667672671377658843994140625000000000000000000000000000000000000000000000000000000000e+04
+1.1666065248086211795452982187271118164062500000000000000000000000000000000000000000000000000000000000e+04
+1.1414771638695478031877428293228149414062500000000000000000000000000000000000000000000000000000000000e+04
+1.1158057956463577284011989831924438476562500000000000000000000000000000000000000000000000000000000000e+04
+1.0894926505671035556588321924209594726562500000000000000000000000000000000000000000000000000000000000e+04
+1.0624198588844017649535089731216430664062500000000000000000000000000000000000000000000000000000000000e+04
+1.0344459590600821684347465634346008300781250000000000000000000000000000000000000000000000000000000000e+04
+1.0053981899268188499263487756252288818359375000000000000000000000000000000000000000000000000000000000e+04
+9.7506137401109826896572485566139221191406250000000000000000000000000000000000000000000000000000000000e+03
+9.4316136849494723719544708728790283203125000000000000000000000000000000000000000000000000000000000000e+03
+9.0933948692882713658036664128303527832031250000000000000000000000000000000000000000000000000000000000e+03
+8.7311113070180672366404905915260314941406250000000000000000000000000000000000000000000000000000000000e+03
+8.3379502078379900922300294041633605957031250000000000000000000000000000000000000000000000000000000000e+03
+7.9038316694309032754972577095031738281250000000000000000000000000000000000000000000000000000000000000e+03
+7.4127824018750598042970523238182067871093750000000000000000000000000000000000000000000000000000000000e+03
+6.8368814145648402700317092239856719970703125000000000000000000000000000000000000000000000000000000000e+03
+6.1191904218508307167212478816509246826171875000000000000000000000000000000000000000000000000000000000e+03
+5.1047390461028435311163775622844696044921875000000000000000000000000000000000000000000000000000000000e+03
+1.0844026630833759554661810398101806640625000000000000000000000000000000000000000000000000000000000000e+03
+-1.0590063526482001179829239845275878906250000000000000000000000000000000000000000000000000000000000000e+04
+-2.2356800778128486854257062077522277832031250000000000000000000000000000000000000000000000000000000000e+04
+-3.4123538029775176255498081445693969726562500000000000000000000000000000000000000000000000000000000000e+04
+-4.5890275281421658291947096586227416992187500000000000000000000000000000000000000000000000000000000000e+04
+-5.7657012533068351331166923046112060546875000000000000000000000000000000000000000000000000000000000000e+04
+-6.9423749784714833367615938186645507812500000000000000000000000000000000000000000000000000000000000000e+04
+-8.1190487036361315404064953327178955078125000000000000000000000000000000000000000000000000000000000000e+04
+-9.2957224288008015719242393970489501953125000000000000000000000000000000000000000000000000000000000000e+04
+-1.0472396153965449775569140911102294921875000000000000000000000000000000000000000000000000000000000000e+05
+-1.1649069879130097979214042425155639648437500000000000000000000000000000000000000000000000000000000000e+05
-- 
GitLab