![]() |
User Guide
|
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
#include <pybind11/embed.h>
#include <pybind11/stl.h>
#include "ast/program.hpp"
#include "codegen/codegen_coreneuron_cpp_visitor.hpp"
#include "parser/nmodl_driver.hpp"
#include "test/unit/utils/test_utils.hpp"
#include "visitors/checkparent_visitor.hpp"
#include "visitors/constant_folder_visitor.hpp"
#include "visitors/inline_visitor.hpp"
#include "visitors/kinetic_block_visitor.hpp"
#include "visitors/loop_unroll_visitor.hpp"
#include "visitors/neuron_solve_visitor.hpp"
#include "visitors/nmodl_visitor.hpp"
#include "visitors/solve_block_visitor.hpp"
#include "visitors/sympy_solver_visitor.hpp"
#include "visitors/symtab_visitor.hpp"
Go to the source code of this file.
Functions | |
std::vector< std::string > | run_sympy_solver_visitor (const std::string &text, bool pade=false, bool cse=false, AstNodeType ret_nodetype=AstNodeType::DIFF_EQ_EXPRESSION, bool kinetic=false) |
bool | is_unique_vars (std::string result) |
void | compare_blocks (const std::string &result, const std::string &expected, const bool require_fail=false) |
Compare nmodl blocks that contain systems of equations (i.e. More... | |
void | run_sympy_visitor_passes (ast::Program &node) |
std::string | ast_to_string (ast::Program &node) |
SCENARIO ("Check compare_blocks in sympy unit tests", "[visitor][sympy]") | |
SCENARIO ("Check local vars name-clash prevention", "[visitor][sympy]") | |
SCENARIO ("Solve ODEs with cnexp or euler method using SympySolverVisitor", "[visitor][sympy][cnexp][euler]") | |
SCENARIO ("Solve ODEs with derivimplicit method using SympySolverVisitor", "[visitor][sympy][derivimplicit]") | |
SCENARIO ("LINEAR solve block (SympySolver Visitor)", "[sympy][linear]") | |
SCENARIO ("Solve NONLINEAR block using SympySolver Visitor", "[visitor][solver][sympy][nonlinear]") | |
SCENARIO ("Solve KINETIC block using SympySolver Visitor", "[visitor][solver][sympy][kinetic]") | |
std::string ast_to_string | ( | ast::Program & | node | ) |
Definition at line 252 of file sympy_solver.cpp.
void compare_blocks | ( | const std::string & | result, |
const std::string & | expected, | ||
const bool | require_fail = false |
||
) |
Compare nmodl blocks that contain systems of equations (i.e.
derivative, linear, etc.)
This is basically and advanced string == string comparison where we detect the (various) systems of equations and check if they are equivalent. Implemented mostly in python since we need a call to sympy to simplify the equations.
compare_systems_of_eq The core of the code. result_dict
and expected_dict
are dictionaries that represent the systems of equations in this way:
a = b*x + c -> result_dict['a'] = 'b*x + c'
where the variable a
become a key k
of the dictionary.
In there we go over all the equations in result_dict
and expected_dict
and check that result_dict[k] - expected_dict[k] simplifies to 0.
require_fail
requires that the equations are different. Used only for unit-test this function
Definition at line 129 of file sympy_solver.cpp.
bool is_unique_vars | ( | std::string | result | ) |
Definition at line 88 of file sympy_solver.cpp.
std::vector<std::string> run_sympy_solver_visitor | ( | const std::string & | text, |
bool | pade = false , |
||
bool | cse = false , |
||
AstNodeType | ret_nodetype = AstNodeType::DIFF_EQ_EXPRESSION , |
||
bool | kinetic = false |
||
) |
Definition at line 48 of file sympy_solver.cpp.
void run_sympy_visitor_passes | ( | ast::Program & | node | ) |
Definition at line 234 of file sympy_solver.cpp.
SCENARIO | ( | "Check compare_blocks in sympy unit tests" | , |
"" | [visitor][sympy] | ||
) |
Definition at line 258 of file sympy_solver.cpp.
SCENARIO | ( | "Check local vars name-clash prevention" | , |
"" | [visitor][sympy] | ||
) |
Definition at line 331 of file sympy_solver.cpp.
SCENARIO | ( | "LINEAR solve block (SympySolver Visitor)" | , |
"" | [sympy][linear] | ||
) |
Definition at line 1530 of file sympy_solver.cpp.
SCENARIO | ( | "Solve KINETIC block using SympySolver Visitor" | , |
"" | [visitor][solver][sympy][kinetic] | ||
) |
Definition at line 1839 of file sympy_solver.cpp.
SCENARIO | ( | "Solve NONLINEAR block using SympySolver Visitor" | , |
"" | [visitor][solver][sympy][nonlinear] | ||
) |
Definition at line 1764 of file sympy_solver.cpp.
SCENARIO | ( | "Solve ODEs with cnexp or euler method using SympySolverVisitor" | , |
"" | [visitor][sympy][cnexp][euler] | ||
) |
sympy 1.9 able to solve ode but not older versions
sympy 1.4 able to solve ode but not older versions
Definition at line 374 of file sympy_solver.cpp.
SCENARIO | ( | "Solve ODEs with derivimplicit method using SympySolverVisitor" | , |
"" | [visitor][sympy][derivimplicit] | ||
) |
new derivative block with EigenNewtonSolverBlock node
EigenNewtonSolverBlock in each derivative block
Definition at line 624 of file sympy_solver.cpp.