NEURON
NrnDAE Class Referenceabstract

NEURON Differential Algebraic Equations. More...

#include <nrndae.h>

Inheritance diagram for NrnDAE:
LinearModelAddition

Public Member Functions

int extra_eqn_count ()
 Find the number of state variables introduced by this object. More...
 
void alloc (int start_index)
 Allocate space for these dynamics in the overall system. More...
 
void lhs ()
 Compute the left side portion of. More...
 
void rhs ()
 Compute the right side portion of. More...
 
void dkres (double *y, double *yprime, double *delta)
 Compute the residual: More...
 
void init ()
 Initialize the dynamics. More...
 
void update ()
 Update states to reflect the changes over a time-step. More...
 
void dkmap (std::vector< double * > &pv, std::vector< double * > &pvdot)
 Setup the map between voltages and states in y_. More...
 
virtual ~NrnDAE ()
 Destructor. More...
 

Protected Member Functions

 NrnDAE (Matrix *cmat, Vect *const yvec, Vect *const y0, int nnode, Node **const nodes, Vect *const elayer, void(*f_init)(void *data)=NULL, void *const data=NULL)
 Constructor. More...
 

Private Member Functions

virtual void f_ (Vect &y, Vect &yprime, int size)=0
 The right-hand-side function. More...
 
virtual MatrixMapjacobian_ (Vect &y)=0
 Compute the Jacobian. More...
 
virtual double jacobian_multiplier_ ()
 
virtual void alloc_ (int size, int start, int nnode, Node **nodes, int *elayer)
 Additional allocation for subclasses. More...
 
void v2y ()
 Transfer any voltage states to y_. More...
 

Private Attributes

void(* f_init_ )(void *data)
 Function used for initializing the state variables. More...
 
void * data_
 Data to pass to f_init_. More...
 
MatrixMapc_
 the matrix More...
 
Matrixassumed_identity_
 identity matrix if constructed with More...
 
Vecty0_
 vector of initial conditions More...
 
Vecty_
 vector to store the state variables in More...
 
int size_
 total number of states declared or modified in this object More...
 
int * bmap_
 mapping between the states in y and the states in the whole system More...
 
int nnode_
 Number of voltage nodes used by the dynamics. More...
 
Node ** nodes_
 Pointers to voltage nodes used by the dynamics. More...
 
int start_
 the position of the first added equation (if any) in the global system More...
 
Vect cyp_
 temporary vector used for residual calculation. More...
 
Vect yptmp_
 temporary vector used for residual calculation. More...
 
int * elayer_
 Which voltage layers to read from. More...
 

Detailed Description

NEURON Differential Algebraic Equations.

Remarks
This is an abstract class; subclass this (or use a subclass) to add dynamics. LinearModelAddition is an example. See linmod.h.

Definition at line 27 of file nrndae.h.

Constructor & Destructor Documentation

◆ ~NrnDAE()

NrnDAE::~NrnDAE ( )
virtual

Destructor.

Definition at line 192 of file nrndae.cpp.

◆ NrnDAE()

NrnDAE::NrnDAE ( Matrix cmat,
Vect *const  yvec,
Vect *const  y0,
int  nnode,
Node **const  nodes,
Vect *const  elayer,
void(*)(void *data f_init = NULL,
void *const  data = NULL 
)
protected

Constructor.

Parameters
cmatthe matrix

\[$C$\]

in

\[$Cy'=f(y)$\]

.
yvecvector to store the state variables in
y0initial conditions
nnodenumber of voltage equations to modify
nodespointers to voltage nodes
elayerwhich potential layer to use for each voltage node
f_initfunction to call during an finitialize
datadata to pass to f_init
Remarks
If cmat is NULL, then assumes

\[$C$\]

is the identity matrix.
If f_init is non-NULL, that takes priority. Otherwise, if y0 is non-NULL, then initializes to those values. Otherwise initializes by setting all states to 0.

Definition at line 141 of file nrndae.cpp.

Member Function Documentation

◆ alloc()

void NrnDAE::alloc ( int  start_index)

Allocate space for these dynamics in the overall system.

Parameters
start_indexstarting index for new states

Definition at line 108 of file nrndae.cpp.

◆ alloc_()

void NrnDAE::alloc_ ( int  size,
int  start,
int  nnode,
Node **  nodes,
int *  elayer 
)
inlineprivatevirtual

Additional allocation for subclasses.

Remarks
Called during alloc(). Unless overriden, this function is empty.

Reimplemented in LinearModelAddition.

Definition at line 106 of file nrndae.cpp.

◆ dkmap()

void NrnDAE::dkmap ( std::vector< double * > &  pv,
std::vector< double * > &  pvdot 
)

Setup the map between voltages and states in y_.

Parameters
pvpointers to voltage nodes (set by this function)
pvdotpointers to voltage derivatives (set by this function)

Definition at line 214 of file nrndae.cpp.

◆ dkres()

void NrnDAE::dkres ( double *  y,
double *  yprime,
double *  delta 
)

Compute the residual:

\[$f(y) - C \frac{dy}{dt}$\]

Parameters
yarray of state variables
yprimearray of derivatives of state variables
deltaarray to store the difference $f(y)-Cy'$

Definition at line 277 of file nrndae.cpp.

◆ extra_eqn_count()

int NrnDAE::extra_eqn_count ( )

Find the number of state variables introduced by this object.

Returns
The number of states added (not modified) by this instance.

Definition at line 207 of file nrndae.cpp.

◆ f_()

virtual void NrnDAE::f_ ( Vect y,
Vect yprime,
int  size 
)
privatepure virtual

The right-hand-side function.

Parameters
ythe state variables
yprimea vector to store the derivatives
sizethe number of state variables

Implemented in LinearModelAddition.

◆ init()

void NrnDAE::init ( )

Initialize the dynamics.

Remarks
Does this by calling f_init_. If f_init_ is NULL, initializes to values in y0_. If y0_ is NULL, initializes all states to 0.

Definition at line 236 of file nrndae.cpp.

◆ jacobian_()

virtual MatrixMap* NrnDAE::jacobian_ ( Vect y)
privatepure virtual

Compute the Jacobian.

Parameters
ythe state variables
Returns
Pointer to a MatrixMap containing the jacobian.
Remarks
The calling function will not delete this pointer.
It is occasionally easier to return the Jacobian divided by a constant factor. If so, have jacobian_multiplier_ return a number that should be multiplied by the matrix returned by this function to get the true Jacobian.

Implemented in LinearModelAddition.

◆ jacobian_multiplier_()

virtual double NrnDAE::jacobian_multiplier_ ( )
inlineprivatevirtual

Reimplemented in LinearModelAddition.

Definition at line 150 of file nrndae.h.

◆ lhs()

void NrnDAE::lhs ( )

Compute the left side portion of.

\[$(C - J) \frac{dy}{dt} = f(y)$\]

.

Definition at line 314 of file nrndae.cpp.

◆ rhs()

void NrnDAE::rhs ( )

Compute the right side portion of.

\[$(C - J) \frac{dy}{dt} = f(y)$\]

.

Definition at line 305 of file nrndae.cpp.

◆ update()

void NrnDAE::update ( )

Update states to reflect the changes over a time-step.

Remarks
When this function is called, the changes have already been computed by the solver. This just updates the local variables.

Definition at line 224 of file nrndae.cpp.

◆ v2y()

void NrnDAE::v2y ( )
private

Transfer any voltage states to y_.

Definition at line 258 of file nrndae.cpp.

Member Data Documentation

◆ assumed_identity_

Matrix* NrnDAE::assumed_identity_
private

identity matrix if constructed with

\[$C$\]

NULL; else NULL.

Definition at line 165 of file nrndae.h.

◆ bmap_

int* NrnDAE::bmap_
private

mapping between the states in y and the states in the whole system

Definition at line 177 of file nrndae.h.

◆ c_

MatrixMap* NrnDAE::c_
private

the matrix

\[$C$ in $C y' = f(y)$\]

Definition at line 162 of file nrndae.h.

◆ cyp_

Vect NrnDAE::cyp_
private

temporary vector used for residual calculation.

Definition at line 189 of file nrndae.h.

◆ data_

void* NrnDAE::data_
private

Data to pass to f_init_.

Definition at line 147 of file nrndae.h.

◆ elayer_

int* NrnDAE::elayer_
private

Which voltage layers to read from.

Remarks
Normally elements are 0 and refer to internal potential. Otherwise range from 1 to nlayer and refer to vext[elayer-1]. vm+vext and vext must be placed in y for calculation of rhs

Definition at line 201 of file nrndae.h.

◆ f_init_

void(* NrnDAE::f_init_) (void *data)
private

Function used for initializing the state variables.

Definition at line 144 of file nrndae.h.

◆ nnode_

int NrnDAE::nnode_
private

Number of voltage nodes used by the dynamics.

Definition at line 180 of file nrndae.h.

◆ nodes_

Node** NrnDAE::nodes_
private

Pointers to voltage nodes used by the dynamics.

Definition at line 183 of file nrndae.h.

◆ size_

int NrnDAE::size_
private

total number of states declared or modified in this object

Definition at line 174 of file nrndae.h.

◆ start_

int NrnDAE::start_
private

the position of the first added equation (if any) in the global system

Definition at line 186 of file nrndae.h.

◆ y0_

Vect* NrnDAE::y0_
private

vector of initial conditions

Definition at line 168 of file nrndae.h.

◆ y_

Vect& NrnDAE::y_
private

vector to store the state variables in

Definition at line 171 of file nrndae.h.

◆ yptmp_

Vect NrnDAE::yptmp_
private

temporary vector used for residual calculation.

Definition at line 192 of file nrndae.h.


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