Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

KINETIC block with function call result into sympy exception: SympySolverVisitor :: solve_non_lin_system python exception: 'Symbol' object is not callable #927

Description

@pramodk

Consider a MOD file glia__dbbs_mod_collection__Na__granule_cell.mod which has:

FUNCTION alfa(v(mV))(/ms){ 
	alfa = Q10*Aalfa*exp(v/Valfa) 
}

FUNCTION beta(v(mV))(/ms){ 
	beta = Q10*Abeta*exp(-v/Vbeta) 
}

FUNCTION teta(v(mV))(/ms){ 
	teta = Q10*Ateta*exp(-v/Vteta) 
}
 

KINETIC kstates {
	: 1 riga
	~ C1 <-> C2 (n1*alfa(v),n4*beta(v))
	~ C2 <-> C3 (n2*alfa(v),n3*beta(v))
	~ C3 <-> C4 (n3*alfa(v),n2*beta(v))
	~ C4 <-> C5 (n4*alfa(v),n1*beta(v))
	~ C5 <-> O  (gamma,delta)
	~  O <-> OB (epsilon,teta(v))
	
	: 2 riga
	~ I1 <-> I2	(n1*alfa(v)*a,n4*beta(v)*b)
	~ I2 <-> I3	(n2*alfa(v)*a,n3*beta(v)*b)
	~ I3 <-> I4	(n3*alfa(v)*a,n2*beta(v)*b)
	~ I4 <-> I5 (n4*alfa(v)*a,n1*beta(v)*b)
	~ I5 <-> I6 (gamma,delta)
	
	: connette 1 riga con 2 riga
	~ C1 <-> I1 (Con,Coff)
	~ C2 <-> I2 (Con*a,Coff*b)
	~ C3 <-> I3 (Con*a^2,Coff*b^2)
	~ C4 <-> I4 (Con*a^3,Coff*b^3)
	~ C5 <-> I5 (Con*a^4,Coff*b^4)
	~  O <-> I6 (Oon,Ooff)
	
	CONSERVE C1+C2+C3+C4+C5+O+OB+I1+I2+I3+I4+I5+I6=1
}

when we run this via NMODl we get:

./bin/nmodl mod2c/glia__dbbs_mod_collection__Na__granule_cell.mod host --c passes --inline
[NMODL] [info] :: Processing ../../../build_nmodl/x86_64/corenrn/mod2c/glia__dbbs_mod_collection__Na__granule_cell.mod
[NMODL] [info] :: Running semantic analysis visitor
[NMODL] [info] :: Running symtab 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 nmodl inline visitor
[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] :: SympySolverVisitor :: solve_non_lin_system python exception: 'Symbol' object is not callable
[NMODL] [info] :: Running cnexp visitor
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [error] :: NeuronSolveVisitor :: solver method 'sparse' not supported
[NMODL] [info] :: Running C backend code generator
[NMODL] [warning] :: RenameVisitor :: Renaming variable v at 121.15 to arg_v
[NMODL] [warning] :: RenameVisitor :: Renaming variable v at 122.23 to arg_v
[NMODL] [warning] :: RenameVisitor :: Renaming variable v at 125.15 to arg_v
[NMODL] [warning] :: RenameVisitor :: Renaming variable v at 126.24 to arg_v
[NMODL] [warning] :: RenameVisitor :: Renaming variable v at 129.15 to arg_v
[NMODL] [warning] :: RenameVisitor :: Renaming variable v at 130.24 to arg_v
[NMODL] [warning] :: RenameVisitor :: Renaming variable alfa at 122.2-5 to ret_alfa
[NMODL] [warning] :: RenameVisitor :: Renaming variable beta at 126.2-5 to ret_beta
[NMODL] [warning] :: RenameVisitor :: Renaming variable teta at 130.2-5 to ret_teta
libc++abi: terminating with uncaught exception of type std::runtime_error: PRIME encountered during code generation, ODEs not solved?

Here some quick comments:

  • note the function calls alpha, beta and teta. I think they are not inlined in the above example and probably make sense
  • but, if we pass the statements with function calls to sympy, it won't be able to do right thing in the absence of function definition?

The above needs to be verified. Calling sympy / solver expert @cattabiani !

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcodegenCode generation backendsolverSolver and numerical methods

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions