User Guide
nmodl::visitor::SympySolverVisitor Class Reference

Visitor for systems of algebraic and differential equations More...

Detailed Description

Visitor for systems of algebraic and differential equations

For DERIVATIVE block, solver method cnexp:

  • replace each ODE with its analytic solution
  • optionally using the (1,1) order Pade approximant in dt

For DERIVATIVE block, solver method euler:

  • replace each ODE with forwards Euler timestep

For DERIVATIVE block, solver method sparse and derivimplicit:

  • construct backwards Euler timestep non-linear system
  • return function F and its Jacobian J to be solved by newton solver

For LINEAR blocks:

  • for small systems: solve linear system of algebraic equations by Gaussian elimination, replace equations with solutions
  • for large systems: return matrix and vector of linear system to be solved by e.g. LU factorization

For NON_LINEAR blocks:

  • return function F and its Jacobian J to be solved by newton solver

Definition at line 58 of file sympy_solver_visitor.hpp.

#include <sympy_solver_visitor.hpp>

Inheritance diagram for nmodl::visitor::SympySolverVisitor:
nmodl::visitor::AstVisitor nmodl::visitor::Visitor

Public Member Functions

 SympySolverVisitor (bool use_pade_approx=false, bool elimination=true, int SMALL_LINEAR_SYSTEM_MAX_STATES=3)
 
void visit_var_name (ast::VarName &node) override
 visit node of type ast::VarName More...
 
void visit_diff_eq_expression (ast::DiffEqExpression &node) override
 visit node of type ast::DiffEqExpression More...
 
void visit_conserve (ast::Conserve &node) override
 visit node of type ast::Conserve More...
 
void visit_derivative_block (ast::DerivativeBlock &node) override
 visit node of type ast::DerivativeBlock More...
 
void visit_lin_equation (ast::LinEquation &node) override
 visit node of type ast::LinEquation More...
 
void visit_linear_block (ast::LinearBlock &node) override
 visit node of type ast::LinearBlock More...
 
void visit_non_lin_equation (ast::NonLinEquation &node) override
 visit node of type ast::NonLinEquation More...
 
void visit_non_linear_block (ast::NonLinearBlock &node) override
 visit node of type ast::NonLinearBlock More...
 
void visit_expression_statement (ast::ExpressionStatement &node) override
 visit node of type ast::ExpressionStatement More...
 
void visit_statement_block (ast::StatementBlock &node) override
 visit node of type ast::StatementBlock More...
 
void visit_program (ast::Program &node) override
 visit node of type ast::Program More...
 
- Public Member Functions inherited from nmodl::visitor::AstVisitor
void visit_node (ast::Node &node) override
 visit node of type ast::Node More...
 
void visit_statement (ast::Statement &node) override
 visit node of type ast::Statement More...
 
void visit_expression (ast::Expression &node) override
 visit node of type ast::Expression More...
 
void visit_block (ast::Block &node) override
 visit node of type ast::Block More...
 
void visit_identifier (ast::Identifier &node) override
 visit node of type ast::Identifier More...
 
void visit_number (ast::Number &node) override
 visit node of type ast::Number More...
 
void visit_string (ast::String &node) override
 visit node of type ast::String More...
 
void visit_integer (ast::Integer &node) override
 visit node of type ast::Integer More...
 
void visit_float (ast::Float &node) override
 visit node of type ast::Float More...
 
void visit_double (ast::Double &node) override
 visit node of type ast::Double More...
 
void visit_boolean (ast::Boolean &node) override
 visit node of type ast::Boolean More...
 
void visit_name (ast::Name &node) override
 visit node of type ast::Name More...
 
void visit_prime_name (ast::PrimeName &node) override
 visit node of type ast::PrimeName More...
 
void visit_indexed_name (ast::IndexedName &node) override
 visit node of type ast::IndexedName More...
 
void visit_var_name (ast::VarName &node) override
 visit node of type ast::VarName More...
 
void visit_argument (ast::Argument &node) override
 visit node of type ast::Argument More...
 
void visit_react_var_name (ast::ReactVarName &node) override
 visit node of type ast::ReactVarName More...
 
void visit_read_ion_var (ast::ReadIonVar &node) override
 visit node of type ast::ReadIonVar More...
 
void visit_write_ion_var (ast::WriteIonVar &node) override
 visit node of type ast::WriteIonVar More...
 
void visit_nonspecific_cur_var (ast::NonspecificCurVar &node) override
 visit node of type ast::NonspecificCurVar More...
 
void visit_electrode_cur_var (ast::ElectrodeCurVar &node) override
 visit node of type ast::ElectrodeCurVar More...
 
void visit_range_var (ast::RangeVar &node) override
 visit node of type ast::RangeVar More...
 
void visit_global_var (ast::GlobalVar &node) override
 visit node of type ast::GlobalVar More...
 
void visit_pointer_var (ast::PointerVar &node) override
 visit node of type ast::PointerVar More...
 
void visit_random_var (ast::RandomVar &node) override
 visit node of type ast::RandomVar More...
 
void visit_bbcore_pointer_var (ast::BbcorePointerVar &node) override
 visit node of type ast::BbcorePointerVar More...
 
void visit_extern_var (ast::ExternVar &node) override
 visit node of type ast::ExternVar More...
 
void visit_param_block (ast::ParamBlock &node) override
 visit node of type ast::ParamBlock More...
 
void visit_independent_block (ast::IndependentBlock &node) override
 visit node of type ast::IndependentBlock More...
 
void visit_assigned_block (ast::AssignedBlock &node) override
 visit node of type ast::AssignedBlock More...
 
void visit_state_block (ast::StateBlock &node) override
 visit node of type ast::StateBlock More...
 
void visit_initial_block (ast::InitialBlock &node) override
 visit node of type ast::InitialBlock More...
 
void visit_constructor_block (ast::ConstructorBlock &node) override
 visit node of type ast::ConstructorBlock More...
 
void visit_destructor_block (ast::DestructorBlock &node) override
 visit node of type ast::DestructorBlock More...
 
void visit_statement_block (ast::StatementBlock &node) override
 visit node of type ast::StatementBlock More...
 
void visit_derivative_block (ast::DerivativeBlock &node) override
 visit node of type ast::DerivativeBlock More...
 
void visit_linear_block (ast::LinearBlock &node) override
 visit node of type ast::LinearBlock More...
 
void visit_non_linear_block (ast::NonLinearBlock &node) override
 visit node of type ast::NonLinearBlock More...
 
void visit_discrete_block (ast::DiscreteBlock &node) override
 visit node of type ast::DiscreteBlock More...
 
void visit_function_table_block (ast::FunctionTableBlock &node) override
 visit node of type ast::FunctionTableBlock More...
 
void visit_function_block (ast::FunctionBlock &node) override
 visit node of type ast::FunctionBlock More...
 
void visit_procedure_block (ast::ProcedureBlock &node) override
 visit node of type ast::ProcedureBlock More...
 
void visit_net_receive_block (ast::NetReceiveBlock &node) override
 visit node of type ast::NetReceiveBlock More...
 
void visit_solve_block (ast::SolveBlock &node) override
 visit node of type ast::SolveBlock More...
 
void visit_breakpoint_block (ast::BreakpointBlock &node) override
 visit node of type ast::BreakpointBlock More...
 
void visit_before_block (ast::BeforeBlock &node) override
 visit node of type ast::BeforeBlock More...
 
void visit_after_block (ast::AfterBlock &node) override
 visit node of type ast::AfterBlock More...
 
void visit_ba_block (ast::BABlock &node) override
 visit node of type ast::BABlock More...
 
void visit_for_netcon (ast::ForNetcon &node) override
 visit node of type ast::ForNetcon More...
 
void visit_kinetic_block (ast::KineticBlock &node) override
 visit node of type ast::KineticBlock More...
 
void visit_unit_block (ast::UnitBlock &node) override
 visit node of type ast::UnitBlock More...
 
void visit_constant_block (ast::ConstantBlock &node) override
 visit node of type ast::ConstantBlock More...
 
void visit_neuron_block (ast::NeuronBlock &node) override
 visit node of type ast::NeuronBlock More...
 
void visit_unit (ast::Unit &node) override
 visit node of type ast::Unit More...
 
void visit_double_unit (ast::DoubleUnit &node) override
 visit node of type ast::DoubleUnit More...
 
void visit_local_var (ast::LocalVar &node) override
 visit node of type ast::LocalVar More...
 
void visit_limits (ast::Limits &node) override
 visit node of type ast::Limits More...
 
void visit_number_range (ast::NumberRange &node) override
 visit node of type ast::NumberRange More...
 
void visit_constant_var (ast::ConstantVar &node) override
 visit node of type ast::ConstantVar More...
 
void visit_binary_operator (ast::BinaryOperator &node) override
 visit node of type ast::BinaryOperator More...
 
void visit_unary_operator (ast::UnaryOperator &node) override
 visit node of type ast::UnaryOperator More...
 
void visit_reaction_operator (ast::ReactionOperator &node) override
 visit node of type ast::ReactionOperator More...
 
void visit_paren_expression (ast::ParenExpression &node) override
 visit node of type ast::ParenExpression More...
 
void visit_binary_expression (ast::BinaryExpression &node) override
 visit node of type ast::BinaryExpression More...
 
void visit_diff_eq_expression (ast::DiffEqExpression &node) override
 visit node of type ast::DiffEqExpression More...
 
void visit_unary_expression (ast::UnaryExpression &node) override
 visit node of type ast::UnaryExpression More...
 
void visit_non_lin_equation (ast::NonLinEquation &node) override
 visit node of type ast::NonLinEquation More...
 
void visit_lin_equation (ast::LinEquation &node) override
 visit node of type ast::LinEquation More...
 
void visit_function_call (ast::FunctionCall &node) override
 visit node of type ast::FunctionCall More...
 
void visit_watch (ast::Watch &node) override
 visit node of type ast::Watch More...
 
void visit_ba_block_type (ast::BABlockType &node) override
 visit node of type ast::BABlockType More...
 
void visit_unit_def (ast::UnitDef &node) override
 visit node of type ast::UnitDef More...
 
void visit_factor_def (ast::FactorDef &node) override
 visit node of type ast::FactorDef More...
 
void visit_valence (ast::Valence &node) override
 visit node of type ast::Valence More...
 
void visit_unit_state (ast::UnitState &node) override
 visit node of type ast::UnitState More...
 
void visit_local_list_statement (ast::LocalListStatement &node) override
 visit node of type ast::LocalListStatement More...
 
void visit_model (ast::Model &node) override
 visit node of type ast::Model More...
 
void visit_define (ast::Define &node) override
 visit node of type ast::Define More...
 
void visit_include (ast::Include &node) override
 visit node of type ast::Include More...
 
void visit_param_assign (ast::ParamAssign &node) override
 visit node of type ast::ParamAssign More...
 
void visit_assigned_definition (ast::AssignedDefinition &node) override
 visit node of type ast::AssignedDefinition More...
 
void visit_conductance_hint (ast::ConductanceHint &node) override
 visit node of type ast::ConductanceHint More...
 
void visit_expression_statement (ast::ExpressionStatement &node) override
 visit node of type ast::ExpressionStatement More...
 
void visit_protect_statement (ast::ProtectStatement &node) override
 visit node of type ast::ProtectStatement More...
 
void visit_from_statement (ast::FromStatement &node) override
 visit node of type ast::FromStatement More...
 
void visit_while_statement (ast::WhileStatement &node) override
 visit node of type ast::WhileStatement More...
 
void visit_if_statement (ast::IfStatement &node) override
 visit node of type ast::IfStatement More...
 
void visit_else_if_statement (ast::ElseIfStatement &node) override
 visit node of type ast::ElseIfStatement More...
 
void visit_else_statement (ast::ElseStatement &node) override
 visit node of type ast::ElseStatement More...
 
void visit_watch_statement (ast::WatchStatement &node) override
 visit node of type ast::WatchStatement More...
 
void visit_mutex_lock (ast::MutexLock &node) override
 visit node of type ast::MutexLock More...
 
void visit_mutex_unlock (ast::MutexUnlock &node) override
 visit node of type ast::MutexUnlock More...
 
void visit_conserve (ast::Conserve &node) override
 visit node of type ast::Conserve More...
 
void visit_compartment (ast::Compartment &node) override
 visit node of type ast::Compartment More...
 
void visit_lon_difuse (ast::LonDifuse &node) override
 visit node of type ast::LonDifuse More...
 
void visit_reaction_statement (ast::ReactionStatement &node) override
 visit node of type ast::ReactionStatement More...
 
void visit_lag_statement (ast::LagStatement &node) override
 visit node of type ast::LagStatement More...
 
void visit_constant_statement (ast::ConstantStatement &node) override
 visit node of type ast::ConstantStatement More...
 
void visit_table_statement (ast::TableStatement &node) override
 visit node of type ast::TableStatement More...
 
void visit_suffix (ast::Suffix &node) override
 visit node of type ast::Suffix More...
 
void visit_useion (ast::Useion &node) override
 visit node of type ast::Useion More...
 
void visit_nonspecific (ast::Nonspecific &node) override
 visit node of type ast::Nonspecific More...
 
void visit_electrode_current (ast::ElectrodeCurrent &node) override
 visit node of type ast::ElectrodeCurrent More...
 
void visit_range (ast::Range &node) override
 visit node of type ast::Range More...
 
void visit_global (ast::Global &node) override
 visit node of type ast::Global More...
 
void visit_random_var_list (ast::RandomVarList &node) override
 visit node of type ast::RandomVarList More...
 
void visit_pointer (ast::Pointer &node) override
 visit node of type ast::Pointer More...
 
void visit_bbcore_pointer (ast::BbcorePointer &node) override
 visit node of type ast::BbcorePointer More...
 
void visit_external (ast::External &node) override
 visit node of type ast::External More...
 
void visit_thread_safe (ast::ThreadSafe &node) override
 visit node of type ast::ThreadSafe More...
 
void visit_verbatim (ast::Verbatim &node) override
 visit node of type ast::Verbatim More...
 
void visit_line_comment (ast::LineComment &node) override
 visit node of type ast::LineComment More...
 
void visit_block_comment (ast::BlockComment &node) override
 visit node of type ast::BlockComment More...
 
void visit_ontology_statement (ast::OntologyStatement &node) override
 visit node of type ast::OntologyStatement More...
 
void visit_program (ast::Program &node) override
 visit node of type ast::Program More...
 
void visit_nrn_state_block (ast::NrnStateBlock &node) override
 visit node of type ast::NrnStateBlock More...
 
void visit_eigen_newton_solver_block (ast::EigenNewtonSolverBlock &node) override
 visit node of type ast::EigenNewtonSolverBlock More...
 
void visit_eigen_linear_solver_block (ast::EigenLinearSolverBlock &node) override
 visit node of type ast::EigenLinearSolverBlock More...
 
void visit_wrapped_expression (ast::WrappedExpression &node) override
 visit node of type ast::WrappedExpression More...
 
void visit_derivimplicit_callback (ast::DerivimplicitCallback &node) override
 visit node of type ast::DerivimplicitCallback More...
 
void visit_solution_expression (ast::SolutionExpression &node) override
 visit node of type ast::SolutionExpression More...
 
void visit_update_dt (ast::UpdateDt &node) override
 visit node of type ast::UpdateDt More...
 
- Public Member Functions inherited from nmodl::visitor::Visitor
virtual ~Visitor ()=default
 

Private Member Functions

void init_block_data (ast::Node *node)
 clear any data from previous block & get set of block local vars + global vars More...
 
void init_state_vars_vector ()
 construct vector from set of state vars in correct order More...
 
void check_expr_statements_in_same_block ()
 raise error if kinetic/ode/(non)linear statements are spread over multiple blocks More...
 
ast::StatementVector::const_iterator get_solution_location_iterator (const ast::StatementVector &statements)
 return iterator pointing to where solution should be inserted in statement block More...
 
void construct_eigen_solver_block (const std::vector< std::string > &pre_solve_statements, const std::vector< std::string > &solutions, bool linear)
 construct solver block More...
 
void solve_linear_system (const std::vector< std::string > &pre_solve_statements={})
 solve linear system (for "LINEAR") More...
 
void solve_non_linear_system (const std::vector< std::string > &pre_solve_statements={})
 solve non-linear system (for "derivimplicit", "sparse" and "NONLINEAR") More...
 

Static Private Member Functions

static void replace_diffeq_expression (ast::DiffEqExpression &expr, const std::string &new_expr)
 replace binary expression with new expression provided as string More...
 
static std::string to_nmodl_for_sympy (ast::Ast &node)
 return NMODL string version of node, excluding any units More...
 
static std::string & replaceAll (std::string &context, const std::string &from, const std::string &to)
 Function used by SympySolverVisitor::filter_X to replace the name X in a std::string to X_operator. More...
 
static std::vector< std::string > filter_string_vector (const std::vector< std::string > &original_vector, const std::string &original_string, const std::string &substitution_string)
 Check original_vector for elements that contain a variable named original_string and rename it to substitution_string. More...
 

Private Attributes

std::set< std::string > global_vars
 global variables More...
 
std::set< std::string > vars
 local variables in current block + globals More...
 
std::set< std::string > function_calls
 custom function calls used in ODE block More...
 
std::unordered_map< std::string, std::string > derivative_block_solve_method {}
 map between derivative block names and associated solver method More...
 
std::unordered_set< ast::Statement * > expression_statements
 expression statements appearing in the block (these can be of type DiffEqExpression, LinEquation or NonLinEquation) More...
 
ast::ExpressionStatementcurrent_expression_statement
 current expression statement being visited (to track ODEs / (non)lineqs) More...
 
ast::ExpressionStatementlast_expression_statement = nullptr
 last expression statement visited (to know where to insert solutions in statement block) More...
 
ast::StatementBlockcurrent_statement_block = nullptr
 current statement block being visited More...
 
ast::StatementBlockblock_with_expression_statements = nullptr
 block where expression statements appear (to check there is only one) More...
 
std::string solve_method
 method specified in solve block More...
 
std::vector< std::string > eq_system
 vector of {ODE, linear eq, non-linear eq} system to solve More...
 
bool eq_system_is_valid = true
 only solve eq_system system of equations if this is true: More...
 
bool collect_state_vars = false
 true for (non)linear eqs, to identify all state vars used in equations More...
 
std::vector< std::string > all_state_vars
 vector of all state variables (in order specified in STATE block in mod file) More...
 
std::set< std::string > state_vars_in_block
 set of state variables used in block More...
 
std::vector< std::string > state_vars
 vector of state vars used in block (in same order as all_state_vars) More...
 
std::unordered_map< std::string, std::string > conserve_equation
 map from state vars to the algebraic equation from CONSERVE statement that should replace their ODE, if any More...
 
bool use_pade_approx
 optionally replace cnexp solution with (1,1) pade approx More...
 
bool elimination
 optionally do CSE (common subexpression elimination) for sparse solver More...
 
int SMALL_LINEAR_SYSTEM_MAX_STATES
 max number of state vars allowed for small system linear solver More...
 

Constructor & Destructor Documentation

◆ SympySolverVisitor()

nmodl::visitor::SympySolverVisitor::SympySolverVisitor ( bool  use_pade_approx = false,
bool  elimination = true,
int  SMALL_LINEAR_SYSTEM_MAX_STATES = 3 
)
inlineexplicit

Definition at line 168 of file sympy_solver_visitor.hpp.

Member Function Documentation

◆ check_expr_statements_in_same_block()

void nmodl::visitor::SympySolverVisitor::check_expr_statements_in_same_block ( )
private

raise error if kinetic/ode/(non)linear statements are spread over multiple blocks

all ode/kinetic/(non)linear statements (typically) appear in the same statement block if this is not the case, for now return an error (and should instead use fallback solver)

Definition at line 73 of file sympy_solver_visitor.cpp.

◆ construct_eigen_solver_block()

void nmodl::visitor::SympySolverVisitor::construct_eigen_solver_block ( const std::vector< std::string > &  pre_solve_statements,
const std::vector< std::string > &  solutions,
bool  linear 
)
private

construct solver block

functor and initialize block converge in the same block

replace statement block with solver block as it contains all statements

create eigen newton solver block

replace statement block with solver block as it contains all statements

Definition at line 158 of file sympy_solver_visitor.cpp.

◆ filter_string_vector()

std::vector< std::string > nmodl::visitor::SympySolverVisitor::filter_string_vector ( const std::vector< std::string > &  original_vector,
const std::string &  original_string,
const std::string &  substitution_string 
)
staticprivate

Check original_vector for elements that contain a variable named original_string and rename it to substitution_string.

Definition at line 146 of file sympy_solver_visitor.cpp.

◆ get_solution_location_iterator()

ast::StatementVector::const_iterator nmodl::visitor::SympySolverVisitor::get_solution_location_iterator ( const ast::StatementVector statements)
private

return iterator pointing to where solution should be inserted in statement block

Definition at line 86 of file sympy_solver_visitor.cpp.

◆ init_block_data()

void nmodl::visitor::SympySolverVisitor::init_block_data ( ast::Node node)
private

clear any data from previous block & get set of block local vars + global vars

Definition at line 27 of file sympy_solver_visitor.cpp.

◆ init_state_vars_vector()

void nmodl::visitor::SympySolverVisitor::init_state_vars_vector ( )
private

construct vector from set of state vars in correct order

Definition at line 55 of file sympy_solver_visitor.cpp.

◆ replace_diffeq_expression()

void nmodl::visitor::SympySolverVisitor::replace_diffeq_expression ( ast::DiffEqExpression expr,
const std::string &  new_expr 
)
staticprivate

replace binary expression with new expression provided as string

Definition at line 64 of file sympy_solver_visitor.cpp.

◆ replaceAll()

std::string & nmodl::visitor::SympySolverVisitor::replaceAll ( std::string &  context,
const std::string &  from,
const std::string &  to 
)
staticprivate

Function used by SympySolverVisitor::filter_X to replace the name X in a std::string to X_operator.

Definition at line 134 of file sympy_solver_visitor.cpp.

◆ solve_linear_system()

void nmodl::visitor::SympySolverVisitor::solve_linear_system ( const std::vector< std::string > &  pre_solve_statements = {})
private

solve linear system (for "LINEAR")

Definition at line 286 of file sympy_solver_visitor.cpp.

◆ solve_non_linear_system()

void nmodl::visitor::SympySolverVisitor::solve_non_linear_system ( const std::vector< std::string > &  pre_solve_statements = {})
private

solve non-linear system (for "derivimplicit", "sparse" and "NONLINEAR")

Definition at line 343 of file sympy_solver_visitor.cpp.

◆ to_nmodl_for_sympy()

static std::string nmodl::visitor::SympySolverVisitor::to_nmodl_for_sympy ( ast::Ast node)
inlinestaticprivate

return NMODL string version of node, excluding any units

Definition at line 88 of file sympy_solver_visitor.hpp.

◆ visit_conserve()

void nmodl::visitor::SympySolverVisitor::visit_conserve ( ast::Conserve node)
overridevirtual

visit node of type ast::Conserve

Implements nmodl::visitor::Visitor.

Definition at line 468 of file sympy_solver_visitor.cpp.

◆ visit_derivative_block()

void nmodl::visitor::SympySolverVisitor::visit_derivative_block ( ast::DerivativeBlock node)
overridevirtual

visit node of type ast::DerivativeBlock

clear information from previous block, get global vars + block local vars

Implements nmodl::visitor::Visitor.

Definition at line 492 of file sympy_solver_visitor.cpp.

◆ visit_diff_eq_expression()

void nmodl::visitor::SympySolverVisitor::visit_diff_eq_expression ( ast::DiffEqExpression node)
overridevirtual

visit node of type ast::DiffEqExpression

Implements nmodl::visitor::Visitor.

Definition at line 389 of file sympy_solver_visitor.cpp.

◆ visit_expression_statement()

void nmodl::visitor::SympySolverVisitor::visit_expression_statement ( ast::ExpressionStatement node)
overridevirtual

visit node of type ast::ExpressionStatement

Implements nmodl::visitor::Visitor.

Definition at line 629 of file sympy_solver_visitor.cpp.

◆ visit_lin_equation()

void nmodl::visitor::SympySolverVisitor::visit_lin_equation ( ast::LinEquation node)
overridevirtual

visit node of type ast::LinEquation

Implements nmodl::visitor::Visitor.

Definition at line 573 of file sympy_solver_visitor.cpp.

◆ visit_linear_block()

void nmodl::visitor::SympySolverVisitor::visit_linear_block ( ast::LinearBlock node)
overridevirtual

visit node of type ast::LinearBlock

clear information from previous block, get global vars + block local vars

Implements nmodl::visitor::Visitor.

Definition at line 587 of file sympy_solver_visitor.cpp.

◆ visit_non_lin_equation()

void nmodl::visitor::SympySolverVisitor::visit_non_lin_equation ( ast::NonLinEquation node)
overridevirtual

visit node of type ast::NonLinEquation

Implements nmodl::visitor::Visitor.

Definition at line 601 of file sympy_solver_visitor.cpp.

◆ visit_non_linear_block()

void nmodl::visitor::SympySolverVisitor::visit_non_linear_block ( ast::NonLinearBlock node)
overridevirtual

visit node of type ast::NonLinearBlock

clear information from previous block, get global vars + block local vars

Implements nmodl::visitor::Visitor.

Definition at line 615 of file sympy_solver_visitor.cpp.

◆ visit_program()

void nmodl::visitor::SympySolverVisitor::visit_program ( ast::Program node)
overridevirtual

visit node of type ast::Program

Implements nmodl::visitor::Visitor.

Definition at line 643 of file sympy_solver_visitor.cpp.

◆ visit_statement_block()

void nmodl::visitor::SympySolverVisitor::visit_statement_block ( ast::StatementBlock node)
overridevirtual

visit node of type ast::StatementBlock

Implements nmodl::visitor::Visitor.

Definition at line 636 of file sympy_solver_visitor.cpp.

◆ visit_var_name()

void nmodl::visitor::SympySolverVisitor::visit_var_name ( ast::VarName node)
overridevirtual

visit node of type ast::VarName

Implements nmodl::visitor::Visitor.

Definition at line 369 of file sympy_solver_visitor.cpp.

Member Data Documentation

◆ all_state_vars

std::vector<std::string> nmodl::visitor::SympySolverVisitor::all_state_vars
private

vector of all state variables (in order specified in STATE block in mod file)

Definition at line 146 of file sympy_solver_visitor.hpp.

◆ block_with_expression_statements

ast::StatementBlock* nmodl::visitor::SympySolverVisitor::block_with_expression_statements = nullptr
private

block where expression statements appear (to check there is only one)

Definition at line 131 of file sympy_solver_visitor.hpp.

◆ collect_state_vars

bool nmodl::visitor::SympySolverVisitor::collect_state_vars = false
private

true for (non)linear eqs, to identify all state vars used in equations

Definition at line 143 of file sympy_solver_visitor.hpp.

◆ conserve_equation

std::unordered_map<std::string, std::string> nmodl::visitor::SympySolverVisitor::conserve_equation
private

map from state vars to the algebraic equation from CONSERVE statement that should replace their ODE, if any

Definition at line 156 of file sympy_solver_visitor.hpp.

◆ current_expression_statement

ast::ExpressionStatement* nmodl::visitor::SympySolverVisitor::current_expression_statement
private

current expression statement being visited (to track ODEs / (non)lineqs)

Definition at line 122 of file sympy_solver_visitor.hpp.

◆ current_statement_block

ast::StatementBlock* nmodl::visitor::SympySolverVisitor::current_statement_block = nullptr
private

current statement block being visited

Definition at line 128 of file sympy_solver_visitor.hpp.

◆ derivative_block_solve_method

std::unordered_map<std::string, std::string> nmodl::visitor::SympySolverVisitor::derivative_block_solve_method {}
private

map between derivative block names and associated solver method

Definition at line 115 of file sympy_solver_visitor.hpp.

◆ elimination

bool nmodl::visitor::SympySolverVisitor::elimination
private

optionally do CSE (common subexpression elimination) for sparse solver

Definition at line 162 of file sympy_solver_visitor.hpp.

◆ eq_system

std::vector<std::string> nmodl::visitor::SympySolverVisitor::eq_system
private

vector of {ODE, linear eq, non-linear eq} system to solve

Definition at line 137 of file sympy_solver_visitor.hpp.

◆ eq_system_is_valid

bool nmodl::visitor::SympySolverVisitor::eq_system_is_valid = true
private

only solve eq_system system of equations if this is true:

Definition at line 140 of file sympy_solver_visitor.hpp.

◆ expression_statements

std::unordered_set<ast::Statement*> nmodl::visitor::SympySolverVisitor::expression_statements
private

expression statements appearing in the block (these can be of type DiffEqExpression, LinEquation or NonLinEquation)

Definition at line 119 of file sympy_solver_visitor.hpp.

◆ function_calls

std::set<std::string> nmodl::visitor::SympySolverVisitor::function_calls
private

custom function calls used in ODE block

Definition at line 112 of file sympy_solver_visitor.hpp.

◆ global_vars

std::set<std::string> nmodl::visitor::SympySolverVisitor::global_vars
private

global variables

Definition at line 106 of file sympy_solver_visitor.hpp.

◆ last_expression_statement

ast::ExpressionStatement* nmodl::visitor::SympySolverVisitor::last_expression_statement = nullptr
private

last expression statement visited (to know where to insert solutions in statement block)

Definition at line 125 of file sympy_solver_visitor.hpp.

◆ SMALL_LINEAR_SYSTEM_MAX_STATES

int nmodl::visitor::SympySolverVisitor::SMALL_LINEAR_SYSTEM_MAX_STATES
private

max number of state vars allowed for small system linear solver

Definition at line 165 of file sympy_solver_visitor.hpp.

◆ solve_method

std::string nmodl::visitor::SympySolverVisitor::solve_method
private

method specified in solve block

Definition at line 134 of file sympy_solver_visitor.hpp.

◆ state_vars

std::vector<std::string> nmodl::visitor::SympySolverVisitor::state_vars
private

vector of state vars used in block (in same order as all_state_vars)

Definition at line 152 of file sympy_solver_visitor.hpp.

◆ state_vars_in_block

std::set<std::string> nmodl::visitor::SympySolverVisitor::state_vars_in_block
private

set of state variables used in block

Definition at line 149 of file sympy_solver_visitor.hpp.

◆ use_pade_approx

bool nmodl::visitor::SympySolverVisitor::use_pade_approx
private

optionally replace cnexp solution with (1,1) pade approx

Definition at line 159 of file sympy_solver_visitor.hpp.

◆ vars

std::set<std::string> nmodl::visitor::SympySolverVisitor::vars
private

local variables in current block + globals

Definition at line 109 of file sympy_solver_visitor.hpp.


The documentation for this class was generated from the following files: