User Guide
nmodl::parser::diffeq::DiffEqContext Class Reference

Helper class used by driver and parser while solving diff equation. More...

Detailed Description

Helper class used by driver and parser while solving diff equation.

Definition at line 71 of file diffeq_context.hpp.

#include <diffeq_context.hpp>

Public Member Functions

 DiffEqContext ()=default
 
 DiffEqContext (std::string state, int, std::string rhs, std::string method)
 
const std::string & state_variable () const
 return the state variable More...
 
std::string get_solution (bool &cnexp_possible)
 return solution of the differential equation More...
 
std::string get_expr_for_nonlinear () const
 return expression with Dstate added More...
 
void print () const
 print the context (for debugging) More...
 

Public Attributes

Term solution
 "final" solution of the equation More...
 
bool deriv_invalid = false
 if derivative of the equation is invalid More...
 
bool eqn_invalid = false
 if equation itself is invalid More...
 

Private Member Functions

std::string get_cnexp_solution () const
 return solution for cnexp method More...
 
std::string get_euler_derivate () const
 return only the derivate for euler method More...
 
std::string get_non_cnexp_solution () const
 return solution for non-cnexp method More...
 
std::string get_cvode_linear_diffeq () const
 for non-cnexp methods : return the solution based on if equation is linear or not More...
 
std::string get_cvode_nonlinear_diffeq () const
 Return solution for non-cnexp method and when equation is non-linear. More...
 
std::string cvode_deriv () const
 
std::string cvode_eqnrhs () const
 

Private Attributes

std::string method
 name of the solve method More...
 
std::string state
 name of the state variable More...
 
std::string rhs
 rhs of equation More...
 

Constructor & Destructor Documentation

◆ DiffEqContext() [1/2]

nmodl::parser::diffeq::DiffEqContext::DiffEqContext ( )
default

◆ DiffEqContext() [2/2]

nmodl::parser::diffeq::DiffEqContext::DiffEqContext ( std::string  state,
int  ,
std::string  rhs,
std::string  method 
)
inline

Definition at line 110 of file diffeq_context.hpp.

Member Function Documentation

◆ cvode_deriv()

std::string nmodl::parser::diffeq::DiffEqContext::cvode_deriv ( ) const
private
Todo:
Methods inherited neuron implementation

Definition at line 47 of file diffeq_context.cpp.

◆ cvode_eqnrhs()

std::string nmodl::parser::diffeq::DiffEqContext::cvode_eqnrhs ( ) const
private

Definition at line 56 of file diffeq_context.cpp.

◆ get_cnexp_solution()

std::string nmodl::parser::diffeq::DiffEqContext::get_cnexp_solution ( ) const
private

return solution for cnexp method

Return solution for cnexp method.

a is zero typically when rhs doesn't have state variable in this case we have to remove "last" term "/(0.0)" from b and then return : state = state - dt*(b)

Definition at line 119 of file diffeq_context.cpp.

◆ get_cvode_linear_diffeq()

std::string nmodl::parser::diffeq::DiffEqContext::get_cvode_linear_diffeq ( ) const
private

for non-cnexp methods : return the solution based on if equation is linear or not

Return solution for non-cnexp method and when equation is linear.

Definition at line 99 of file diffeq_context.cpp.

◆ get_cvode_nonlinear_diffeq()

std::string nmodl::parser::diffeq::DiffEqContext::get_cvode_nonlinear_diffeq ( ) const
private

Return solution for non-cnexp method and when equation is non-linear.

Definition at line 108 of file diffeq_context.cpp.

◆ get_euler_derivate()

std::string nmodl::parser::diffeq::DiffEqContext::get_euler_derivate ( ) const
private

return only the derivate for euler method

Return solution for euler method.

Definition at line 142 of file diffeq_context.cpp.

◆ get_expr_for_nonlinear()

std::string nmodl::parser::diffeq::DiffEqContext::get_expr_for_nonlinear ( ) const

return expression with Dstate added

When non-cnexp method is used, for solving non-linear equations we need original expression but with replacing every state variable with (state+0.001).

In order to do this we scan original expression and build new by replacing only state variable.

build lexer instance

scan entire expression

extract value of the token and check if it is a token

Definition at line 70 of file diffeq_context.cpp.

◆ get_non_cnexp_solution()

std::string nmodl::parser::diffeq::DiffEqContext::get_non_cnexp_solution ( ) const
private

return solution for non-cnexp method

Return solution for non-cnexp method.

Definition at line 150 of file diffeq_context.cpp.

◆ get_solution()

std::string nmodl::parser::diffeq::DiffEqContext::get_solution ( bool &  cnexp_possible)

return solution of the differential equation

Return the solution for differential equation based on method used.

Todo:
Currently we have tested cnexp, euler and derivimplicit methods with all equations from BBP models. Need to test this against various other mod files, especially kinetic schemes, reaction-diffusion etc.

Definition at line 170 of file diffeq_context.cpp.

◆ print()

void nmodl::parser::diffeq::DiffEqContext::print ( ) const

print the context (for debugging)

Definition at line 35 of file diffeq_context.cpp.

◆ state_variable()

const std::string& nmodl::parser::diffeq::DiffEqContext::state_variable ( ) const
inline

return the state variable

Definition at line 116 of file diffeq_context.hpp.

Member Data Documentation

◆ deriv_invalid

bool nmodl::parser::diffeq::DiffEqContext::deriv_invalid = false

if derivative of the equation is invalid

Definition at line 103 of file diffeq_context.hpp.

◆ eqn_invalid

bool nmodl::parser::diffeq::DiffEqContext::eqn_invalid = false

if equation itself is invalid

Definition at line 106 of file diffeq_context.hpp.

◆ method

std::string nmodl::parser::diffeq::DiffEqContext::method
private

name of the solve method

Definition at line 73 of file diffeq_context.hpp.

◆ rhs

std::string nmodl::parser::diffeq::DiffEqContext::rhs
private

rhs of equation

Definition at line 79 of file diffeq_context.hpp.

◆ solution

Term nmodl::parser::diffeq::DiffEqContext::solution

"final" solution of the equation

Definition at line 100 of file diffeq_context.hpp.

◆ state

std::string nmodl::parser::diffeq::DiffEqContext::state
private

name of the state variable

Definition at line 76 of file diffeq_context.hpp.


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