From 089956b46859c63229501bdd5d563c9d2af1f5cd Mon Sep 17 00:00:00 2001 From: "C.A.P. Linssen" Date: Thu, 21 Nov 2024 03:11:24 -0800 Subject: [PATCH] compute propagator for each block of block-diagonal system matrix --- .github/workflows/ode-toolbox-build.yml | 2 +- odetoolbox/system_of_shapes.py | 1 - requirements.txt | 2 +- tests/test_system_matrix_construction.py | 10 +++++----- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ode-toolbox-build.yml b/.github/workflows/ode-toolbox-build.yml index b5126dfb..b95c07ee 100644 --- a/.github/workflows/ode-toolbox-build.yml +++ b/.github/workflows/ode-toolbox-build.yml @@ -43,7 +43,7 @@ jobs: fail-fast: false matrix: with_gsl: ["0", "1"] - sympy_version: ["==1.4", "!=1.5,!=1.5.*,!=1.6rc1,!=1.6rc2,!=1.6,!=1.6.*,!=1.10,!=1.10.*,!=1.13,!=1.13.*"] + sympy_version: ["==1.4", ""] # empty string for "latest" steps: - name: Checkout ODE-toolbox code diff --git a/odetoolbox/system_of_shapes.py b/odetoolbox/system_of_shapes.py index 27bfd8ff..6483229f 100644 --- a/odetoolbox/system_of_shapes.py +++ b/odetoolbox/system_of_shapes.py @@ -203,7 +203,6 @@ def _generate_propagator_matrix(self, A): XXX: the default custom simplification expression does not work well with sympy 1.4 here. Consider replacing sympy.simplify() with _custom_simplify_expr() if sympy 1.4 support is dropped. """ - # naive: calculate propagators in one step # P_naive = sympy.simplify(sympy.exp(A * sympy.Symbol(Config().output_timestep_symbol))) diff --git a/requirements.txt b/requirements.txt index 5b25f9ef..38337047 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -sympy!=1.5,!=1.5.*,!=1.6rc1,!=1.6rc2,!=1.6,!=1.6.*,!=1.10,!=1.10.*,!=1.13,!=1.13.* +sympy>=1.13 scipy numpy>=1.8.2 pytest diff --git a/tests/test_system_matrix_construction.py b/tests/test_system_matrix_construction.py index 5ec7661b..26ea224f 100644 --- a/tests/test_system_matrix_construction.py +++ b/tests/test_system_matrix_construction.py @@ -34,9 +34,9 @@ def test_system_matrix_construction(self): shapes, parameters = _from_json_to_shapes(indict) sigma, beta = sympy.symbols("sigma beta") shape_sys = SystemOfShapes.from_shapes(shapes, parameters=parameters) - assert shape_sys.A_ == sympy.Matrix([[-sigma, sigma, 0.0], - [0.0, 0.0, 0.0], - [0.0, 0.0, -beta]]) + assert shape_sys.A_ == sympy.Matrix([[-sigma, sigma, 0], + [0, 0, 0], + [0, 0, -beta]]) x, y, z = sympy.symbols("x y z") assert shape_sys.c_ == sympy.Matrix([[0], [3 * z * x**2 - x * y], @@ -63,10 +63,10 @@ def test_morris_lecar(self): shape_sys = SystemOfShapes.from_shapes(shapes, parameters=parameters) C_m, g_Ca, g_K, g_L, E_Ca, E_K, E_L, I_ext = sympy.symbols("C_m g_Ca g_K g_L E_Ca E_K E_L I_ext") assert shape_sys.A_ == sympy.Matrix([[sympy.parsing.sympy_parser.parse_expr("-500.0 * g_Ca / C_m - 1000.0 * g_L / C_m"), sympy.parsing.sympy_parser.parse_expr("1000.0 * E_K * g_K / C_m")], - [sympy.parsing.sympy_parser.parse_expr("0.0"), sympy.parsing.sympy_parser.parse_expr("0.0")]]) + [sympy.parsing.sympy_parser.parse_expr("0"), sympy.parsing.sympy_parser.parse_expr("0")]]) V, W = sympy.symbols("V W") assert shape_sys.b_ == sympy.Matrix([[sympy.parsing.sympy_parser.parse_expr("500.0 * E_Ca * g_Ca / C_m + 1000.0 * E_L * g_L / C_m + 1000.0 * I_ext / C_m")], - [sympy.parsing.sympy_parser.parse_expr("0.0")]]) + [sympy.parsing.sympy_parser.parse_expr("0")]]) assert shape_sys.c_ == sympy.Matrix([[sympy.parsing.sympy_parser.parse_expr("500.0 * E_Ca * g_Ca * tanh(V / 15 + 1 / 15) / C_m - 1000.0 * V * W * g_K / C_m - 500.0 * V * g_Ca * tanh(V / 15 + 1 / 15) / C_m")], [sympy.parsing.sympy_parser.parse_expr("-200.0 * W * cosh(V / 60) + 100.0 * cosh(V / 60) * tanh(V / 30) + 100.0 * cosh(V / 60)")]])