Skip to content

Commit d5428be

Browse files
committed
Add binding model submodule tests to CI
Fix FD pattern sign tolerance in Fruendlich LDF test In the test settings, remove EXT_ prefix from constant binding parameters, fixing the configuration of external binding parameter handler
1 parent e054d22 commit d5428be

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ jobs:
165165
${INSTALL_PREFIX}/bin/cadet-cli LWE.h5 || true
166166
- name: Run tests
167167
run: |
168-
${BUILD_DIR}/test/testRunner [CI]
168+
${BUILD_DIR}/test/testRunner [CI],[BindingModel]
169169
MacOS:
170170
runs-on: macos-latest
171171
strategy:

test/BindingModelTests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ int ConfiguredBindingModel::requiredBufferSize() CADET_NOEXCEPT
187187
return 0;
188188
}
189189

190-
void testJacobianAD(const char* modelName, unsigned int nComp, unsigned int const* nBound, bool isKinetic, const char* config, double const* point, bool skipStructureTest, double absTol, double relTol)
190+
void testJacobianAD(const char* modelName, unsigned int nComp, unsigned int const* nBound, bool isKinetic, const char* config, double const* point, bool skipStructureTest, double FDsignAbsTol, double absTol, double relTol)
191191
{
192192
ConfiguredBindingModel cbm = ConfiguredBindingModel::create(modelName, nComp, nBound, isKinetic, config);
193193

@@ -229,12 +229,12 @@ void testJacobianAD(const char* modelName, unsigned int nComp, unsigned int cons
229229
cadet::test::checkJacobianPatternFD(
230230
[&](double const* lDir, double* res) -> void { cbm.model().flux(1.0, 0u, ColumnPosition{0.0, 0.0, 0.0}, lDir + cbm.nComp(), lDir, res, cbm.buffer()); },
231231
[&](double const* lDir, double* res) -> void { jacAna.submatrixMultiplyVector(lDir, cbm.nComp(), 0, numEq, numDofs, res); },
232-
yState.data(), dir.data(), colA.data(), colB.data(), numDofs, numEq);
232+
yState.data(), dir.data(), colA.data(), colB.data(), numDofs, numEq, FDsignAbsTol);
233233

234234
cadet::test::checkJacobianPatternFD(
235235
[&](double const* lDir, double* res) -> void { cbm.model().flux(1.0, 0u, ColumnPosition{0.0, 0.0, 0.0}, lDir + cbm.nComp(), lDir, res, cbm.buffer()); },
236236
[&](double const* lDir, double* res) -> void { jacAD.multiplyVector(lDir, res); },
237-
yState.data(), dir.data(), colA.data(), colB.data(), numDofs, numEq);
237+
yState.data(), dir.data(), colA.data(), colB.data(), numDofs, numEq, FDsignAbsTol);
238238
}
239239

240240
// Check Jacobians against each other

test/BindingModelTests.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,11 @@ namespace binding
130130
* @param [in] config JSON string with binding model parameters
131131
* @param [in] point Liquid phase and solid phase values to check Jacobian at
132132
* @param [in] skipStructureTest Determines whether the structural test using finite differences is skipped
133+
* @param [in] FDsignAbsTol Absolute tolerance in FD pattern sign check
133134
* @param [in] absTol Absolute error tolerance
134135
* @param [in] relTol Relative error tolerance
135136
*/
136-
void testJacobianAD(const char* modelName, unsigned int nComp, unsigned int const* nBound, bool isKinetic, const char* config, double const* point, bool skipStructureTest = false, double absTol = 0.0, double relTol = std::numeric_limits<float>::epsilon() * 100.0);
137+
void testJacobianAD(const char* modelName, unsigned int nComp, unsigned int const* nBound, bool isKinetic, const char* config, double const* point, bool skipStructureTest = false, double FDsignAbsTol = 0.0, double absTol = 0.0, double relTol = std::numeric_limits<float>::epsilon() * 100.0);
137138

138139
/**
139140
* @brief Checks residual and analytic Jacobian of normal model variant against externally dependent ones

test/BindingModels.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ CADET_BINDINGTEST("MOBILE_PHASE_MODULATOR", "EXT_MOBILE_PHASE_MODULATOR", (1,1,1
273273
"EXT_MPM_BETA_T": [0.0, 1.5, 2.0],
274274
"EXT_MPM_BETA_TT": [0.0, 0.0, 0.0],
275275
"EXT_MPM_BETA_TTT": [0.0, 0.0, 0.0],
276-
"EXT_MPM_LINEAR_THRESHOLD": 1e-10
276+
"MPM_LINEAR_THRESHOLD": 1e-10
277277
)json", \
278278
R"json( "EXT_MPM_KA": [0.0, 0.0, 0.0, 0.0],
279279
"EXT_MPM_KA_T": [0.0, 1.14, 1.0, 2.0],
@@ -295,7 +295,7 @@ CADET_BINDINGTEST("MOBILE_PHASE_MODULATOR", "EXT_MOBILE_PHASE_MODULATOR", (1,1,1
295295
"EXT_MPM_BETA_T": [0.0, 1.5, 0.0, 2.0],
296296
"EXT_MPM_BETA_TT": [0.0, 0.0, 0.0, 0.0],
297297
"EXT_MPM_BETA_TTT": [0.0, 0.0, 0.0, 0.0],
298-
"EXT_MPM_LINEAR_THRESHOLD": 1e-10
298+
"MPM_LINEAR_THRESHOLD": 1e-10
299299
)json", \
300300
1e-10, 1e-10, CADET_NONBINDING_LIQUIDPHASE_COMP_UNUSED, CADET_COMPARE_BINDING_VS_NONBINDING)
301301

@@ -334,7 +334,7 @@ CADET_BINDINGTEST("MOBILE_PHASE_MODULATOR", "EXT_MOBILE_PHASE_MODULATOR", (1,1,1
334334
"EXT_MPM_BETA_T": [0.0, 1.5, 2.0],
335335
"EXT_MPM_BETA_TT": [0.0, 0.0, 0.0],
336336
"EXT_MPM_BETA_TTT": [0.0, 0.0, 0.0],
337-
"EXT_MPM_LINEAR_THRESHOLD": 1e-10
337+
"MPM_LINEAR_THRESHOLD": 1e-10
338338
)json", \
339339
R"json( "EXT_MPM_KA": [0.0, 0.0, 0.0, 0.0],
340340
"EXT_MPM_KA_T": [0.0, 1.14, 1.0, 2.0],
@@ -356,7 +356,7 @@ CADET_BINDINGTEST("MOBILE_PHASE_MODULATOR", "EXT_MOBILE_PHASE_MODULATOR", (1,1,1
356356
"EXT_MPM_BETA_T": [0.0, 1.5, 0.0, 2.0],
357357
"EXT_MPM_BETA_TT": [0.0, 0.0, 0.0, 0.0],
358358
"EXT_MPM_BETA_TTT": [0.0, 0.0, 0.0, 0.0],
359-
"EXT_MPM_LINEAR_THRESHOLD": 1e-10
359+
"MPM_LINEAR_THRESHOLD": 1e-10
360360
)json", \
361361
1e-10, 1e-10, CADET_NONBINDING_LIQUIDPHASE_COMP_UNUSED, CADET_COMPARE_BINDING_VS_NONBINDING)
362362

@@ -1002,7 +1002,7 @@ CADET_BINDINGTEST("MULTI_COMPONENT_LDF_FREUNDLICH", "EXT_MULTI_COMPONENT_LDF_FRE
10021002
"EXT_MCLDFFRL_A_T": [3.0, 2.2, 1.5, 0.5],
10031003
"EXT_MCLDFFRL_A_TT": [0.0, 0.0, 0.0, 0.0],
10041004
"EXT_MCLDFFRL_A_TTT": [0.0, 0.0, 0.0, 0.0],
1005-
"EXT_MCLDFFRL_TAU": 0.1
1005+
"MCLDFFRL_TAU": 0.1
10061006
)json", \
10071007
R"json( "EXT_MCLDFFRL_KLDF": [0.0, 0.0, 0.0],
10081008
"EXT_MCLDFFRL_KLDF_T": [1.14, 1.0, 2.0],
@@ -1020,7 +1020,7 @@ CADET_BINDINGTEST("MULTI_COMPONENT_LDF_FREUNDLICH", "EXT_MULTI_COMPONENT_LDF_FRE
10201020
"EXT_MCLDFFRL_A_T": [2.2, 1.1, 0.4, 0.1, 0.94, 2.8, 0.5, 1.2, 2.4],
10211021
"EXT_MCLDFFRL_A_TT": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
10221022
"EXT_MCLDFFRL_A_TTT": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
1023-
"EXT_MCLDFFRL_TAU": 0.1
1023+
"MCLDFFRL_TAU": 0.1
10241024
)json", \
10251025
1e-10, 1e-10, CADET_NONBINDING_LIQUIDPHASE_COMP_USED, CADET_DONT_COMPARE_BINDING_VS_NONBINDING)
10261026

@@ -1059,7 +1059,7 @@ CADET_BINDINGTEST("MULTI_COMPONENT_SIPS", "EXT_MULTI_COMPONENT_SIPS", (1, 1, 1,
10591059
"EXT_SIPS_EXP_TTT": [0.0, 0.0, 0.0, 0.0],
10601060
"EXT_SIPS_REFC0": 2.0,
10611061
"EXT_SIPS_REFQ": 1.1,
1062-
"EXT_SIPS_LINEAR_THRESHOLD": 1e-10
1062+
"SIPS_LINEAR_THRESHOLD": 1e-10
10631063
)json", \
10641064
R"json( "EXT_SIPS_KA": [0.0, 0.0, 0.0, 0.0, 0.0],
10651065
"EXT_SIPS_KA_T": [1.14, 1.0, 2.0, 1.14, 2.0],
@@ -1079,7 +1079,7 @@ CADET_BINDINGTEST("MULTI_COMPONENT_SIPS", "EXT_MULTI_COMPONENT_SIPS", (1, 1, 1,
10791079
"EXT_SIPS_EXP_TTT": [0.0, 0.0, 0.0, 0.0, 0.0],
10801080
"EXT_SIPS_REFC0": 2.0,
10811081
"EXT_SIPS_REFQ": 1.1,
1082-
"EXT_SIPS_LINEAR_THRESHOLD": 1e-10
1082+
"SIPS_LINEAR_THRESHOLD": 1e-10
10831083
)json", \
10841084
1e-10, 1e-10, CADET_NONBINDING_LIQUIDPHASE_COMP_UNUSED, CADET_COMPARE_BINDING_VS_NONBINDING)
10851085

@@ -1461,6 +1461,7 @@ CADET_BINDINGTEST("GENERALIZED_ION_EXCHANGE", "EXT_GENERALIZED_ION_EXCHANGE", (1
14611461
{
14621462
const unsigned int nBound[] = { 0, 0, 1, 1, 1};
14631463
const double state[] = { 0.9, 1.1, 1.5e-2, 3.2e-3, 1.5e-5, 3.2e-5, 1.5e-5, 3.2e-5 };
1464+
double FDsignAbsTol = 1e-10; // specific tolerance for this test, non-default value
14641465
char const* const config = R"json({
14651466
"COL_PHI": 49232983.6522396,
14661467
"COL_KAPPA_EXP": 1.8,
@@ -1487,7 +1488,7 @@ CADET_BINDINGTEST("GENERALIZED_ION_EXCHANGE", "EXT_GENERALIZED_ION_EXCHANGE", (1
14871488
const bool isKinetic = bindMode;
14881489
SECTION(std::string("Binding mode ") + (isKinetic ? "dynamic" : "quasi-stationary"))
14891490
{
1490-
cadet::test::binding::testJacobianAD("MULTI_COMPONENT_COLLOIDAL", sizeof(nBound) / sizeof(unsigned int), nBound, isKinetic, config, state);
1491+
cadet::test::binding::testJacobianAD("MULTI_COMPONENT_COLLOIDAL", sizeof(nBound) / sizeof(unsigned int), nBound, isKinetic, config, state, FDsignAbsTol);
14911492
}
14921493
}
14931494
}

0 commit comments

Comments
 (0)