Skip to content

Commit

Permalink
Added diagnostics for filtered tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ssun30 authored and ischoegl committed Jul 29, 2023
1 parent 4dc301b commit 6b44f1e
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 121 deletions.
62 changes: 31 additions & 31 deletions test/matlab_experimental/ctTestKinetics.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,22 @@ function deleteSolution(self)
methods (Test)

function testCounts(self)
self.assumeEqual(self.phase.nReactions, 29);
self.assumeEqual(self.phase.nTotalSpecies, 10);
self.assumeEqual(self.phase.nPhases, 1);
self.verifyEqual(self.phase.nReactions, 29);
self.verifyEqual(self.phase.nTotalSpecies, 10);
self.verifyEqual(self.phase.nPhases, 1);

% Missing method
% self.assumeEqual(self.phase.reactionPhaseIndex, 0);
self.assumeFail('Fails because Kinetics.reactionPhaseIndex is missing')
self.verifyEqual(self.phase.reactionPhaseIndex, 0);
end

function testIsReversible(self)
% Fails because of incorrect indexing.
self.assumeFail();
self.assumeFail('Fails because of incorrect reaction indexing');

for i = 1:self.phase.nReactions
self.assumeTrue(self.phase.isReversible(i));
self.verifyTrue(self.phase.isReversible(i));
end
% To do: test on a mechanism where not all reactions are
% reversible

end

Expand All @@ -76,16 +77,16 @@ function testMultipler(self)
f1 = self.phase.forwardRatesOfProgress;
r1 = self.phase.reverseRatesOfProgress;

self.assumeEqual(2 .* f0(1), f1(1), 'AbsTol', self.atol);
self.assumeEqual(0.1 .* f0(7), f1(7), 'AbsTol', self.atol);
self.assumeEqual(2 .* r0(1), r1(1), 'AbsTol', self.atol);
self.assumeEqual(0.1 .* r0(7), r1(7), 'AbsTol', self.atol);
self.verifyEqual(2 .* f0(1), f1(1), 'AbsTol', self.atol);
self.verifyEqual(0.1 .* f0(7), f1(7), 'AbsTol', self.atol);
self.verifyEqual(2 .* r0(1), r1(1), 'AbsTol', self.atol);
self.verifyEqual(0.1 .* r0(7), r1(7), 'AbsTol', self.atol);

for i = 1:self.phase.nReactions

if i ~= 1 && i ~= 7
self.assumeEqual(f0(i), f1(i), 'AbsTol', self.atol);
self.assumeEqual(r0(i), r1(i), 'AbsTol', self.atol);
self.verifyEqual(f0(i), f1(i), 'AbsTol', self.atol);
self.verifyEqual(r0(i), r1(i), 'AbsTol', self.atol);
end

end
Expand All @@ -94,48 +95,47 @@ function testMultipler(self)
f2 = self.phase.forwardRatesOfProgress;
r2 = self.phase.reverseRatesOfProgress;
tol = ones(1, self.phase.nReactions) .* self.atol;
self.assumeEqual(0.5 .* f0, f2, 'AbsTol', tol);
self.assumeEqual(0.5 .* r0, r2, 'AbsTol', tol);
self.verifyEqual(0.5 .* f0, f2, 'AbsTol', tol);
self.verifyEqual(0.5 .* r0, r2, 'AbsTol', tol);

end

function testReactionEquations(self)
self.assumeEqual(self.phase.nReactions, ...
self.verifyEqual(self.phase.nReactions, ...
length(self.phase.reactionEquations));
s = strsplit(self.phase.reactionEquation(19), '<=>');
r = s{1};
p = s{2};
self.assumeSubstring(r, 'H');
self.assumeSubstring(r, 'H2O2');
self.assumeSubstring(p, 'HO2');
self.assumeSubstring(p, 'H2');
self.verifySubstring(r, 'H');
self.verifySubstring(r, 'H2O2');
self.verifySubstring(p, 'HO2');
self.verifySubstring(p, 'H2');

end

function testStoichCoeffs(self)
% Fails because StoichCoeffs methods does not convert species name to
% species index.
self.assumeFail();
self.assumeFail(['Fails because StoichCoeffs methods do not', ...
' convert species names to species indices']);

nu_r = self.phase.reactantStoichCoeffs;
nu_p = self.phase.productStoichCoeffs;

function checkReactnat(s, i, val)
function checkReactant(s, i, val)
k = self.phase.kineticsSpeciesIndex(s);
self.assumeEqual(self.phase.reactantStoichCoeffs(s, i), ...
self.verifyEqual(self.phase.reactantStoichCoeffs(s, i), ...
val);
self.assumeEqual(self.phase.reactantStoichCoeffs(k, i), ...
self.verifyEqual(self.phase.reactantStoichCoeffs(k, i), ...
val);
self.assumeEqual(nu_r(k, i), val);
self.verifyEqual(nu_r(k, i), val);
end

function checkProduct(s, i, val)
k = self.phase.kineticsSpeciesIndex(s);
self.assumeEqual(self.phase.productStoichCoeffs(s, i), ...
self.verifyEqual(self.phase.productStoichCoeffs(s, i), ...
val);
self.assumeEqual(self.phase.productStoichCoeffs(k, i), ...
self.verifyEqual(self.phase.productStoichCoeffs(k, i), ...
val);
self.assumeEqual(nu_p(k, i), val);
self.verifyEqual(nu_p(k, i), val);
end

% H + H2O2 <=> HO2 + H2
Expand Down
Loading

0 comments on commit 6b44f1e

Please sign in to comment.