Skip to content

Commit

Permalink
#1420 fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brosaplanella committed Mar 10, 2021
1 parent 020f6e4 commit b28604f
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions tests/integration/test_models/standard_output_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,23 +285,37 @@ def test_concentration_increase_decrease(self):
# For the assumed polynomial concentration profiles the values
# can increase/decrease within the particle as the polynomial shifts,
# so we just check the average instead
neg_end_vs_start = self.c_s_n_rav(t[1:], x_n) - self.c_s_n_rav(t[:-1], x_n)
pos_end_vs_start = self.c_s_p_rav(t[1:], x_p) - self.c_s_p_rav(t[:-1], x_p)
neg_diff = self.c_s_n_rav(t[1:], x_n) - self.c_s_n_rav(t[:-1], x_n)
pos_diff = self.c_s_p_rav(t[1:], x_p) - self.c_s_p_rav(t[:-1], x_p)
neg_end_vs_start = self.c_s_n_rav(t[-1], x_n) - self.c_s_n_rav(t[0], x_n)
pos_end_vs_start = self.c_s_p_rav(t[-1], x_p) - self.c_s_p_rav(t[0], x_p)
else:
neg_end_vs_start = self.c_s_n(t[1:], x_n, r_n) - self.c_s_n(
neg_diff = self.c_s_n(t[1:], x_n, r_n) - self.c_s_n(
t[:-1], x_n, r_n
)
pos_end_vs_start = self.c_s_p(t[1:], x_p, r_p) - self.c_s_p(
pos_diff = self.c_s_p(t[1:], x_p, r_p) - self.c_s_p(
t[:-1], x_p, r_p
)
neg_end_vs_start = self.c_s_n(t[-1], x_n, r_n) - self.c_s_n(
t[0], x_n, r_n
)
pos_end_vs_start = self.c_s_p(t[-1], x_p, r_p) - self.c_s_p(
t[0], x_p, r_p
)

if self.operating_condition == "discharge":
np.testing.assert_array_less(neg_end_vs_start, 1e-16)
np.testing.assert_array_less(-1e-16, pos_end_vs_start)
np.testing.assert_array_less(neg_diff, 1e-16)
np.testing.assert_array_less(-1e-16, pos_diff)
np.testing.assert_array_less(neg_end_vs_start, 0)
np.testing.assert_array_less(0, pos_end_vs_start)
elif self.operating_condition == "charge":
np.testing.assert_array_less(-1e-16, neg_end_vs_start)
np.testing.assert_array_less(pos_end_vs_start, 1e-16)
np.testing.assert_array_less(-1e-16, neg_diff)
np.testing.assert_array_less(pos_diff, 1e-16)
np.testing.assert_array_less(0, neg_end_vs_start)
np.testing.assert_array_less(pos_end_vs_start, 0)
elif self.operating_condition == "off":
np.testing.assert_array_almost_equal(neg_diff, 0)
np.testing.assert_array_almost_equal(pos_diff, 0)
np.testing.assert_array_almost_equal(neg_end_vs_start, 0)
np.testing.assert_array_almost_equal(pos_end_vs_start, 0)

Expand Down Expand Up @@ -374,8 +388,8 @@ def test_fluxes(self):
)
np.testing.assert_array_less(self.N_s_p(t[1:], x_p, r_p[1:]), 1e-16)
if self.operating_condition == "charge":
np.testing.assert_equal(self.N_s_n(t[1:], x_n, r_n[1:]), 1e-16)
np.testing.assert_equal(-1e-16, self.N_s_p(t[1:], x_p, r_p[1:]))
np.testing.assert_array_less(self.N_s_n(t[1:], x_n, r_n[1:]), 1e-16)
np.testing.assert_array less(-1e-16, self.N_s_p(t[1:], x_p, r_p[1:]))
if self.operating_condition == "off":
np.testing.assert_array_almost_equal(self.N_s_n(t, x_n, r_n), 0)
np.testing.assert_array_almost_equal(self.N_s_p(t, x_p, r_p), 0)
Expand Down

0 comments on commit b28604f

Please sign in to comment.