Skip to content

Commit

Permalink
compute propagator for each block of block-diagonal system matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
C.A.P. Linssen committed Nov 21, 2024
1 parent c176e6c commit 089956b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ode-toolbox-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion odetoolbox/system_of_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions tests/test_system_matrix_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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)")]])

0 comments on commit 089956b

Please sign in to comment.