Skip to content

Commit

Permalink
Merge pull request nest#75 from clinssen/inhomogeneous_bugfix
Browse files Browse the repository at this point in the history
Fix inhomogeneous equation in a system of equations
  • Loading branch information
clinssen authored Jul 16, 2024
2 parents 67e9ded + 62bd0d9 commit 865565f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 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.6rc1,!=1.6rc2,!=1.6,!=1.10,!=1.10.*"]
sympy_version: ["==1.4", "!=1.5,!=1.5.*,!=1.6rc1,!=1.6rc2,!=1.6,!=1.6.*,!=1.10,!=1.10.*,!=1.13,!=1.13.*"]

steps:
- name: Checkout ODE-toolbox code
Expand Down
2 changes: 1 addition & 1 deletion odetoolbox/system_of_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def generate_propagator_solver(self):
# this is an inhomogeneous ODE
if _is_zero(self.A_[row, row]):
# of the form x' = const
update_expr_terms.append(Config().output_timestep_symbol + " * " + str(self.b_[col]))
update_expr_terms.append(Config().output_timestep_symbol + " * " + str(self.b_[row]))
else:
particular_solution = -self.b_[row] / self.A_[row, row]
sym_str = "__P__{}__{}".format(str(self.x_[row]), str(self.x_[row]))
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.6rc1,!=1.6rc2,!=1.6,!=1.10,!=1.10.*
sympy!=1.5,!=1.5.*,!=1.6rc1,!=1.6rc2,!=1.6,!=1.6.*,!=1.10,!=1.10.*,!=1.13,!=1.13.*
scipy
numpy>=1.8.2
pytest
Expand Down
14 changes: 14 additions & 0 deletions tests/test_inhomogeneous.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,17 @@ def test_inhomogeneous_solver_second_order_combined_system_api(self):
result = odetoolbox.analysis(indict)
assert len(result) == 1 \
and result[0]["solver"] == "analytical"

def test_inhomogeneous_solver_combined_system(self):
r"""test propagators generation for combined homogeneous/inhomogeneous ODEs when called via analysis()"""
indict = {"dynamics": [{"expression": "x' = a * 0.001",
"initial_value": "0.3"},
{"expression": "y' = -y / b",
"initial_value": "0"}]}

result = odetoolbox.analysis(indict, log_level="DEBUG")

assert len(result) == 1
assert result[0]["solver"] == "analytical"
assert "__h" in result[0]["update_expressions"]["x"]
assert "__h" not in result[0]["update_expressions"]["y"]

0 comments on commit 865565f

Please sign in to comment.