-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow taking derivatives of
Xd
(#2221)
# Introduction The core problem is that `Xd` is not a `STATE` and only those can appear in derivatives/ODEs. This requires rewriting the idiomatic ``` NEURON { SUFFIX decay USEION x WRITE xd RANGE tau } PARAMETER { tau = 5 } BREAKPOINT { SOLVE dX METHOD cnexp } DERIVATIVE dX { xd' = -tau*xd } ``` as this ``` NEURON { SUFFIX decay USEION x WRITE xd RANGE tau } STATE { F } INITIAL { F = xd } PARAMETER { tau = 5 } BREAKPOINT { SOLVE dX METHOD cnexp xd = F } DERIVATIVE dX { F = xd F' = -tau*F } ``` _However_, `BREAKPOINT` is translated into _two_ C++ calls, not one: 1. compute $F(t)$ from $F'(t)$ 2. update `xd` based on `F` and other things -- like the **solver** -- happen in between. This has proven not only ugly, but also unsound, see #2129 and possibly more. # Fixing the Problem Simply allow `Xd` to be differentiated. As this is not an ionic _current_ nothing bad will happen., right? Right? This could still be awkward when making mechanisms like this ``` BREAKPOINT { SOLVE dX METHOD cnexp xd = xd + 42 } DERIVATIVE dX { xd' = -tau*xd } ```
- Loading branch information
1 parent
3998b01
commit 2f4c325
Showing
6 changed files
with
34 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
NEURON { | ||
SUFFIX decay | ||
USEION x WRITE xd | ||
RANGE F, tau | ||
RANGE tau | ||
} | ||
|
||
PARAMETER { tau = 5 } | ||
|
||
INITIAL { F = xd } | ||
|
||
STATE { F } | ||
|
||
BREAKPOINT { | ||
SOLVE dF METHOD cnexp | ||
xd = F | ||
SOLVE dX METHOD cnexp | ||
} | ||
|
||
DERIVATIVE dF { | ||
F = xd | ||
F' = -tau*F | ||
DERIVATIVE dX { | ||
xd' = -tau*xd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters