Skip to content

Commit 6458833

Browse files
author
C.A.P. Linssen
committed
merge inhomogeneous and propagator singularity handling
1 parent fb162fc commit 6458833

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

odetoolbox/system_of_shapes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,8 @@ def generate_propagator_solver(self, disable_singularity_detection: bool = False
295295
if isinstance(eq, sympy.Eq):
296296
# replace equalities (not inequalities)
297297
conditional_A = conditional_A.subs(eq.lhs, eq.rhs)
298+
conditional_b = conditional_b.subs(eq.lhs, eq.rhs)
299+
conditional_c = conditional_c.subs(eq.lhs, eq.rhs)
298300

299301
conditional_dynamics = SystemOfShapes(self.x_, conditional_A, conditional_b, conditional_c, self.shapes_)
300302
solver_dict_conditional = conditional_dynamics.generate_propagator_solver(disable_singularity_detection=True)

tests/test_inhomogeneous_numerically_zero.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,18 @@ def _test_inhomogeneous_numerically_zero(self, late_ltd_check, late_ltp_check):
5656
solver_dict["parameters"]["late_ltd_check"] = late_ltd_check
5757
solver_dict["parameters"]["late_ltp_check"] = late_ltp_check
5858

59+
z0 = 0.0 # set the initial condition
5960
dt = .1
6061
T = 100.
61-
timevec = np.arange(0., T, dt)
62+
6263

6364
#
6465
# integration using the ODE-toolbox analytic integrator
6566
#
6667

68+
timevec = np.arange(0., T, dt)
6769
analytic_integrator = AnalyticIntegrator(solver_dict)
68-
analytic_integrator.set_initial_values({"z": 0.})
70+
analytic_integrator.set_initial_values({"z": z0})
6971
analytic_integrator.reset()
7072
actual = [analytic_integrator.get_value(t)["z"] for t in timevec]
7173

@@ -83,7 +85,6 @@ def ode_model(z, t, p, late_ltp_check, late_ltd_check, tau_z):
8385
dzdt = (((p * (1.0 - z) * late_ltp_check) - (p * (z + 0.5) * late_ltd_check))) / tau_z
8486
return dzdt
8587

86-
z0 = 0.0 # set the initial condition
8788
params = solver_dict["parameters"]
8889
ode_args = (
8990
params["p"],
@@ -122,11 +123,9 @@ def ode_model(z, t, p, late_ltp_check, late_ltd_check, tau_z):
122123

123124
np.testing.assert_allclose(correct, actual)
124125

125-
@pytest.mark.xfail(strict=True, raises=AssertionError)
126126
def test_inhomogeneous_numerically_zero(self):
127127
self._test_inhomogeneous_numerically_zero(late_ltd_check=1., late_ltp_check=-1.)
128128

129-
@pytest.mark.xfail(strict=True, raises=AssertionError)
130129
def test_inhomogeneous_numerically_zero_alt(self):
131130
self._test_inhomogeneous_numerically_zero(late_ltd_check=0., late_ltp_check=0.)
132131

0 commit comments

Comments
 (0)