#include "Cmprtmnt.h"#include "Current.h"#include <math.h>Compartment::Compartment( void ){	// set variables to default values	// LATER: get these from some preferences thing somewhere	Gm = Gi = 1;	EGm = Gm * -0.070;	negC = -1;	V[0] = V[1] = 0;}void Compartment::Step( const real dt ){	// This is the routine which actually calculates the new value of V.		//	Algorithm to update V in a compartment by Exponential Euler integration:	//	1. compute A = EG + i->comp2->V * i->G + j->E * j->G  for all currents i and all ion channels j	// 	2. compute B = G + i->G + j->G  for all currents i and all ion channels j	//	3. compute D = exp(B*dt/negC)	//	4. compute Vnew = V*D + A/B*(1-D)	real A = EGm, B = Gm;	for (CurrentNode *ln = itsCurrentList; ln; ln = ln->itsNext) {		// note: this is a lot of dereferencing... can this be streamlined more?		A += ln->itsCurrent->GetEG();		B += ln->itsCurrent->G;	}		real D = exp( B*dt / negC );		int curIdx = itsMaster->GetCurIdx();	V[!curIdx] = V[curIdx]*D + (A/B)*(1-D);}
