-
Notifications
You must be signed in to change notification settings - Fork 16
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
KINETIC block with function call result into sympy exception: SympySolverVisitor :: solve_non_lin_system python exception: 'Symbol' object is not callable #927
Comments
ehehe, I need to remember. I will be back to you trying this. |
probably you can just add the functions like in this example: nmodl/test/unit/visitor/kinetic_block.cpp Lines 487 to 493 in af7c772
or use the |
After discussion with @cattabiani, I will put a simple example showing what we want to do here: NEURON {
SUFFIX glia
RANGE alfa, beta
RANGE Aalfa, Valfa, Abeta, Vbeta
}
PARAMETER {
Aalfa = 353.91 ( /ms)
Valfa = 13.99 ( /mV)
Abeta = 1.272 ( /ms)
Vbeta = 13.99 ( /mV)
n1 = 5.422
n4 = 0.738
}
STATE {
C1
C2
}
BREAKPOINT {
SOLVE kstates METHOD sparse
}
FUNCTION alfa(v(mV)) {
alfa = Q10*Aalfa*exp(v/Valfa)
}
FUNCTION beta(v(mV)) {
beta = Q10*Abeta*exp(-v/Vbeta)
}
KINETIC kstates {
~ C1 <-> C2 (n1*alfa(v),n4*beta(v))
} If we run above example via nmodl today then we get: ./bin/nmodl test.mod
[NMODL] [info] :: Processing test.mod
[NMODL] [info] :: Running symtab visitor
[NMODL] [info] :: Running semantic analysis visitor
[NMODL] [info] :: Running CVode to cnexp visitor
[NMODL] [info] :: Running code compatibility checker
[NMODL] [info] :: Running verbatim rename visitor
[NMODL] [info] :: Running KINETIC block visitor
[NMODL] [info] :: Running STEADYSTATE visitor
[NMODL] [info] :: Parsing Units
[NMODL] [info] :: Running local variable rename visitor
[NMODL] [info] :: Automatically enable sympy_analytic because it exists solver of type sparse
[NMODL] [info] :: Running sympy solve visitor
[NMODL] [warning] :: Python bindings are not available
[NMODL] [warning] :: SympySolverVisitor :: solve_non_lin_system python exception: 'Symbol' object is not callable
.... Note that the problematic part is that the ~ C1 <-> C2 (n1*alfa(v),n4*beta(v)) then sympy is not aware of function definition and hence error. So what we want to do in this case is avoid function calls by transforming KINETIC block like below: KINETIC kstates {
LOCAL x, y
x = alfa(v)
y = beta(v)
~ C1 <-> C2 (n1*x,n4*y)
} i.e. we avoid function calls from all With this, I was wondering why we can't just use regular Inlining pass here i.e. using So I tried: diff --git a/src/main.cpp b/src/main.cpp
index 1e2a4387..9a388eb9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -434,6 +434,12 @@ int main(int argc, const char* argv[]) {
SymtabVisitor(update_symtab).visit_program(*ast);
}
+ if (nmodl_inline) {
+ logger->info("Running nmodl inline visitor");
+ InlineVisitor().visit_program(*ast);
+ ast_to_nmodl(*ast, filepath("inline"));
+ }
+
/// note that we can not symtab visitor in update mode as we
/// replace kinetic block with derivative block of same name
/// in global scope
@@ -470,12 +476,6 @@ int main(int argc, const char* argv[]) {
/// that old symbols (e.g. prime variables) are not lost
update_symtab = true;
- if (nmodl_inline) {
- logger->info("Running nmodl inline visitor");
- InlineVisitor().visit_program(*ast);
- ast_to_nmodl(*ast, filepath("inline"));
- } With this, I was hoping So action items could be:
@alkino : I have assigned this to you in case you want to tackle this. I or @iomaganaris can also help to clarify details. |
@cattabiani : I think we were a bit wrong i.e. we forgot that that in sympy we already pass the list of user-defined functions here Line 199 in ea1acbd
nmodl/test/unit/visitor/sympy_solver.cpp Line 389 in ea1acbd
|
So here is a lot of problems:
|
There is three tickets on this. See my last comment |
Consider a MOD file glia__dbbs_mod_collection__Na__granule_cell.mod which has:
when we run this via NMODl we get:
Here some quick comments:
alpha
,beta
andteta
. I think they are not inlined in the above example and probably make senseThe above needs to be verified. Calling sympy / solver expert @cattabiani !
The text was updated successfully, but these errors were encountered: