Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow derivimplicit to use finite differences. #1444

Merged
merged 5 commits into from
Sep 23, 2024
Merged

Conversation

1uc
Copy link
Collaborator

@1uc 1uc commented Sep 20, 2024

In NOCMODL derivimplicit uses finite differences to compute each
element of the Jacobian. In stead we try to use SymPy, however, if it
fails, e.g. because it encounters an opaque function, we allow it to use
a finite difference instead.

When SymPy can't compute a derivative analytically, it replaces it
with a Derivative({func}, ({variable}, {n})), which represents the
nth derivative of func w.r.t. variable.

In this PR we crawl SymPy's AST to find Derivative objects, and
replace them with a finite difference. The step-with is the same
as used in NEURON for computing the elements of the Jacobian.

Additionally, there's some code to enable computing the \Delta x.

1uc added 2 commits September 20, 2024 10:01
In NOCMODL `derivimplicit` uses finite differences to compute each
element of the Jacobian. In stead we try to use SymPy, however, if it
fails, e.g. because it encounters an opaque function, we allow it to use
a finite difference instead.
@1uc 1uc force-pushed the 1uc/finite-differences branch from 3f53252 to 7b9225c Compare September 20, 2024 08:01
bbpadministrator pushed a commit to BlueBrain/nmodl-references that referenced this pull request Sep 20, 2024
@1uc 1uc marked this pull request as ready for review September 20, 2024 09:13
python/nmodl/ode.py Outdated Show resolved Hide resolved
python/nmodl/ode.py Outdated Show resolved Hide resolved
python/nmodl/ode.py Outdated Show resolved Hide resolved
bbpadministrator pushed a commit to BlueBrain/nmodl-references that referenced this pull request Sep 20, 2024
@1uc 1uc force-pushed the 1uc/finite-differences branch from 5576cc9 to 3f22ed5 Compare September 23, 2024 06:20
bbpadministrator pushed a commit to BlueBrain/nmodl-references that referenced this pull request Sep 23, 2024
Copy link
Contributor

@JCGoran JCGoran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, some minor comments.

bbpadministrator pushed a commit to BlueBrain/nmodl-references that referenced this pull request Sep 23, 2024
@1uc 1uc merged commit 5798e94 into master Sep 23, 2024
21 checks passed
@1uc 1uc deleted the 1uc/finite-differences branch September 23, 2024 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants