Skip to content

Commit 550f7bf

Browse files
author
Nicolas Cornu
authored
Use non linear newton solver for sparse method (BlueBrain/nmodl#804)
* Use non linear newton solver for sparse method It is possible to give non linear system to sparse solver. The sparse method was mistaken using linear solver, now use deriv implicit. Fix BlueBrain/nmodl#801 NMODL Repo SHA: BlueBrain/nmodl@2833671
1 parent efc18a8 commit 550f7bf

File tree

3 files changed

+287
-104
lines changed

3 files changed

+287
-104
lines changed

src/nmodl/visitors/sympy_solver_visitor.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,8 @@ void SympySolverVisitor::visit_derivative_block(ast::DerivativeBlock& node) {
555555
}
556556
}
557557

558-
if (solve_method == codegen::naming::SPARSE_METHOD) {
559-
solve_linear_system(pre_solve_statements);
560-
} else if (solve_method == codegen::naming::DERIVIMPLICIT_METHOD) {
558+
if (solve_method == codegen::naming::SPARSE_METHOD ||
559+
solve_method == codegen::naming::DERIVIMPLICIT_METHOD) {
561560
solve_non_linear_system(pre_solve_statements);
562561
} else {
563562
logger->error("SympySolverVisitor :: Solve method {} not supported", solve_method);

src/nmodl/visitors/sympy_solver_visitor.hpp

+3-11
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,7 @@ namespace visitor {
4242
* For `DERIVATIVE` block, solver method `euler`:
4343
* - replace each ODE with forwards Euler timestep
4444
*
45-
* For `DERIVATIVE` block, solver method `sparse`:
46-
* - construct backwards Euler timestep linear system
47-
* - for small systems: solves resulting linear algebraic equation by
48-
* Gaussian elimination, replaces differential equations
49-
* with explicit solution of backwards Euler equations
50-
* - for large systems, returns matrix and vector of linear system
51-
* to be solved by e.g. LU factorization
52-
*
53-
* For `DERIVATIVE` block, solver method `derivimplicit`:
45+
* For `DERIVATIVE` block, solver method `sparse` and `derivimplicit`:
5446
* - construct backwards Euler timestep non-linear system
5547
* - return function F and its Jacobian J to be solved by newton solver
5648
*
@@ -86,10 +78,10 @@ class SympySolverVisitor: public AstVisitor {
8678
const std::vector<std::string>& solutions,
8779
bool linear);
8880

89-
/// solve linear system (for "sparse" and "LINEAR")
81+
/// solve linear system (for "LINEAR")
9082
void solve_linear_system(const std::vector<std::string>& pre_solve_statements = {});
9183

92-
/// solve non-linear system (for "derivimplicit" and "NONLINEAR")
84+
/// solve non-linear system (for "derivimplicit", "sparse" and "NONLINEAR")
9385
void solve_non_linear_system(const std::vector<std::string>& pre_solve_statements = {});
9486

9587
/// return NMODL string version of node, excluding any units

0 commit comments

Comments
 (0)