Skip to content

Commit

Permalink
Add test for kinetic bloc
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Cornu authored and Nicolas Cornu committed Sep 27, 2022
1 parent e884563 commit 4e98736
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion test/unit/visitor/sympy_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "test/unit/utils/test_utils.hpp"
#include "visitors/checkparent_visitor.hpp"
#include "visitors/constant_folder_visitor.hpp"
#include "visitors/kinetic_block_visitor.hpp"
#include "visitors/loop_unroll_visitor.hpp"
#include "visitors/nmodl_visitor.hpp"
#include "visitors/sympy_solver_visitor.hpp"
Expand All @@ -35,7 +36,8 @@ 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) {
AstNodeType ret_nodetype = AstNodeType::DIFF_EQ_EXPRESSION,
bool kinetic = false) {
std::vector<std::string> results;

// construct AST from text
Expand All @@ -51,6 +53,10 @@ std::vector<std::string> run_sympy_solver_visitor(
ConstantFolderVisitor().visit_program(*ast);
SymtabVisitor().visit_program(*ast);

if (kinetic) {
KineticBlockVisitor().visit_program(*ast);
}

// run SympySolver on AST
SympySolverVisitor(pade, cse).visit_program(*ast);

Expand Down Expand Up @@ -2123,3 +2129,24 @@ SCENARIO("Solve NONLINEAR block using SympySolver Visitor", "[visitor][solver][s
}
}
}
SCENARIO("Solve KINETIC block using SympySolver Visitor", "[visitor][solver][sympy][kinetic]") {
GIVEN("NONLINEAR block with not inlined function should work") {
std::string nmodl_text = R"(
BREAKPOINT {
SOLVE kstates METHOD sparse
}
STATE {
C1
C2
}
FUNCTION alfa(v(mV)) {
alfa = v
}
KINETIC kstates {
~ C1 <-> C2 (alfa(v), alfa(v))
})";
THEN("Run Kinetic and Sympy Visitor") {
REQUIRE_NOTHROW(run_sympy_solver_visitor(nmodl_text, false, false, {}, true));
}
}
}

0 comments on commit 4e98736

Please sign in to comment.