NEURON
neuron_solve_visitor.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2023 Blue Brain Project, EPFL.
3  * See the top-level LICENSE file for details.
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #pragma once
9 
10 /**
11  * \file
12  * \brief \copybrief nmodl::visitor::NeuronSolveVisitor
13  */
14 
15 #include <map>
16 #include <string>
17 
18 #include "symtab/decl.hpp"
19 #include "visitors/ast_visitor.hpp"
20 
21 
22 namespace nmodl {
23 namespace visitor {
24 
25 /**
26  * \addtogroup solver
27  * \addtogroup visitor_classes
28  * \{
29  */
30 
31 /**
32  * \class NeuronSolveVisitor
33  * \brief %Visitor that solves ODEs using old solvers of NEURON
34  *
35  * This pass solves ODEs in derivative block using `cnexp`, `euler` and
36  * `derivimplicit`method. This solved mimics original implementation in
37  * nocmodl/mod2c. The original ODEs get replaced with the solution and
38  * transformations are performed at AST level.
39  *
40  * \sa nmodl::visitor::SympySolverVisitor
41  */
43  private:
44  /// true while visiting differential equation
45  bool differential_equation = false;
46 
47  /// global symbol table
49 
50  /// a map holding solve block names and methods
51  std::map<std::string, std::string> solve_blocks;
52 
53  /// method specified in solve block
54  std::string solve_method;
55 
56  /// visiting derivative block
57  bool derivative_block = false;
58 
59  /// the derivative name currently being visited
60  std::string derivative_block_name;
61 
62  std::vector<std::shared_ptr<ast::Statement>> euler_solution_expressions;
63 
64  public:
65  NeuronSolveVisitor() = default;
66 
67  void visit_solve_block(ast::SolveBlock& node) override;
71  void visit_program(ast::Program& node) override;
72 };
73 
74 /** \} */ // end of visitor_classes
75 
76 } // namespace visitor
77 } // namespace nmodl
Concrete visitor for all AST classes.
Represents binary expression in the NMODL.
Represents DERIVATIVE block in the NMODL.
Represents differential equation in DERIVATIVE block.
Represents top level AST node for whole NMODL input.
Definition: program.hpp:39
Represent symbol table for a NMODL block.
Concrete visitor for all AST classes.
Definition: ast_visitor.hpp:37
Visitor that solves ODEs using old solvers of NEURON
void visit_solve_block(ast::SolveBlock &node) override
visit node of type ast::SolveBlock
std::vector< std::shared_ptr< ast::Statement > > euler_solution_expressions
void visit_diff_eq_expression(ast::DiffEqExpression &node) override
visit node of type ast::DiffEqExpression
std::string derivative_block_name
the derivative name currently being visited
symtab::SymbolTable * program_symtab
global symbol table
void visit_derivative_block(ast::DerivativeBlock &node) override
visit node of type ast::DerivativeBlock
bool differential_equation
true while visiting differential equation
std::map< std::string, std::string > solve_blocks
a map holding solve block names and methods
void visit_program(ast::Program &node) override
visit node of type ast::Program
void visit_binary_expression(ast::BinaryExpression &node) override
visit node of type ast::BinaryExpression
std::string solve_method
method specified in solve block
bool derivative_block
visiting derivative block
encapsulates code generation backend implementations
Definition: ast_common.hpp:26
static Node * node(Object *)
Definition: netcvode.cpp:291
Forward declarations of symbols in namespace nmodl::symtab.