Skip to content

Commit

Permalink
removed getFullStateSize from mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
sg-s committed Dec 12, 2020
1 parent 99dc6b5 commit 2594e50
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 131 deletions.
2 changes: 1 addition & 1 deletion +xolotl/version.m
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
function version()
disp('v20.12.11');
disp('v20.12.12');
4 changes: 2 additions & 2 deletions c++/compartment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ void compartment::addMechanism(mechanism *mech_) {
n_mech++;

// also store the mechanism's full state size
mechanism_sizes.push_back(mech_->getFullStateSize());
mechanism_sizes.push_back(mech_->fullStateSize);
}

/*
Expand Down Expand Up @@ -640,7 +640,7 @@ what their data dimension is, and adding up all those numbers.
int compartment::getFullMechanismSize(void) {
int full_size = 0;
for (int i=0; i<n_mech; i++) {
full_size += mech[i]->getFullStateSize();
full_size += mech[i]->fullStateSize;
}
return full_size;
}
Expand Down
11 changes: 2 additions & 9 deletions c++/mechanism.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class mechanism {

int verbosity = -1;

int fullStateSize = 0;

mechanism()
{
// null pointers to all
Expand All @@ -66,7 +68,6 @@ class mechanism {
virtual void integrate(void);
virtual void integrateMS(int, double, double);

virtual int getFullStateSize(void);
virtual int getFullState(double*, int);
virtual double getState(int);
virtual string getClass(void) = 0;
Expand Down Expand Up @@ -172,14 +173,6 @@ double mechanism::getState(int i) {
}


/* This virtual method does nothing, but should return the full state
size of your mechanism
*/

int mechanism::getFullStateSize() {
return 0;
}


/* This virtual method does nothing, but can return as many dynamic
variables as you want
Expand Down
5 changes: 1 addition & 4 deletions c++/mechanisms/ChannelProbe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class ChannelProbe: public mechanism {
// specify parameters + initial conditions for
ChannelProbe(double dummy_) {
dummy = dummy_;
fullStateSize = 2;
}

void connectConductance(conductance *);

int getFullStateSize(void);
int getFullState(double * cont_state, int idx);
string getClass(void);

Expand All @@ -40,9 +40,6 @@ string ChannelProbe::getClass() {



int ChannelProbe::getFullStateSize(){return 2; }


int ChannelProbe::getFullState(double *cont_state, int idx) {
// read out m and h
cont_state[idx] = channel->m;
Expand Down
9 changes: 2 additions & 7 deletions c++/mechanisms/gorur-shandilya/CalciumSensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ class CalciumSensor: public mechanism {

// specify parameters + initial conditions for
// mechanism that controls a conductance
CalciumSensor(double tau_, double Ca_average_)
{
CalciumSensor(double tau_, double Ca_average_) {
tau = tau_;
controlling_class = "unset";
Ca_average = Ca_average_;

fullStateSize = 1;
}


Expand All @@ -40,7 +40,6 @@ class CalciumSensor: public mechanism {
void connectCompartment(compartment*);


int getFullStateSize(void);
int getFullState(double * cont_state, int idx);
string getClass(void);

Expand All @@ -51,10 +50,6 @@ string CalciumSensor::getClass() {
}


int CalciumSensor::getFullStateSize() {
return 1;
}


int CalciumSensor::getFullState(double *cont_state, int idx) {
// return internal variable
Expand Down
7 changes: 2 additions & 5 deletions c++/mechanisms/liu/DCSensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ class DCSensor: public mechanism {
X = X_;
m = m_;

fullStateSize = 1;

// these defaults make it a "F" type sensor
// these defaults make it a "DC" type sensor
if (isnan(ZM)) {ZM = 3;}
if (isnan(tau_m)) {tau_m = 500; } // ms
if (isnan(G)) {G = 1;}
Expand All @@ -62,8 +63,6 @@ class DCSensor: public mechanism {

double boltzmann(double);


int getFullStateSize(void);
int getFullState(double * cont_state, int idx);
double getState(int);
string getClass(void);
Expand All @@ -78,8 +77,6 @@ string DCSensor::getClass() {
double DCSensor::getState(int idx){return X;}


int DCSensor::getFullStateSize(){return 1; }


int DCSensor::getFullState(double *cont_state, int idx) {
cont_state[idx] = X;
Expand Down
4 changes: 2 additions & 2 deletions c++/mechanisms/liu/FastSensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class FastSensor: public mechanism {
X = X_;


fullStateSize = 1;

// these defaults make it a "F" type sensor
if (isnan(ZM)) {ZM = 14.2;}
if (isnan(ZH)) {ZH = 9.8;}
Expand Down Expand Up @@ -84,8 +86,6 @@ string FastSensor::getClass() {
double FastSensor::getState(int idx){return X;}


int FastSensor::getFullStateSize(){return 1; }


int FastSensor::getFullState(double *cont_state, int idx) {
cont_state[idx] = X;
Expand Down
5 changes: 1 addition & 4 deletions c++/mechanisms/liu/LiuController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class LiuController: public mechanism {
// defaults
if (isnan(tau)) {tau = 5000; } // ms


fullStateSize = 1;

}

Expand All @@ -61,7 +61,6 @@ class LiuController: public mechanism {
double boltzmann(double);


int getFullStateSize(void);
int getFullState(double * cont_state, int idx);
string getClass(void);

Expand Down Expand Up @@ -121,8 +120,6 @@ string LiuController::getClass() {



int LiuController::getFullStateSize(){return 1; }


int LiuController::getFullState(double *cont_state, int idx) {
cont_state[idx] = channel->gbar;
Expand Down
6 changes: 2 additions & 4 deletions c++/mechanisms/liu/SlowSensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class SlowSensor: public mechanism {
G = G_;
X = X_;

fullStateSize = 1;

// these defaults make it a "S" type sensor
if (isnan(ZM)) {ZM = 7.2;}
if (isnan(ZH)) {ZH = 2.8;}
Expand All @@ -67,7 +69,6 @@ class SlowSensor: public mechanism {
double boltzmann(double);


int getFullStateSize(void);
int getFullState(double * cont_state, int idx);
double getState(int);
string getClass(void);
Expand All @@ -82,9 +83,6 @@ string SlowSensor::getClass() {
double SlowSensor::getState(int idx){return X;}


int SlowSensor::getFullStateSize(){return 1; }


int SlowSensor::getFullState(double *cont_state, int idx) {
cont_state[idx] = X;
idx++;
Expand Down
5 changes: 2 additions & 3 deletions c++/mechanisms/oleary/IntegralController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class IntegralController: public mechanism {
m = m_;


fullStateSize = 2;

// if (tau_m<=0) {mexErrMsgTxt("[IntegralController] tau_m must be > 0. Perhaps you meant to set it to Inf?\n");}
if (tau_g<=0) {mexErrMsgTxt("[IntegralController] tau_g must be > 0. Perhaps you meant to set it to Inf?\n");}
}
Expand All @@ -55,7 +57,6 @@ class IntegralController: public mechanism {
void connectConductance(conductance*);
void connectSynapse(synapse*);

int getFullStateSize(void);
int getFullState(double * cont_state, int idx);
double getState(int);
string getClass(void);
Expand Down Expand Up @@ -116,8 +117,6 @@ double IntegralController::getState(int idx) {
}


int IntegralController::getFullStateSize(){return 2; }


int IntegralController::getFullState(double *cont_state, int idx) {
// give it the current mRNA level
Expand Down
18 changes: 2 additions & 16 deletions c++/mechanisms/soto-trevino/ProportionalController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,17 @@ class ProportionalController: public mechanism {
m = m_;
tau_m = tau_m_;
if (isnan(tau_m)) {tau_m = 10e3;};

fullStateSize = 1;
}


void integrate(void);

void checkSolvers(int);

void connect(conductance *);
void connect(synapse*);
void connect(compartment*);

int getFullStateSize(void);
int getFullState(double * cont_state, int idx);
double getState(int);
string getClass(void);
Expand All @@ -76,8 +75,6 @@ double ProportionalController::getState(int idx) {
}


int ProportionalController::getFullStateSize(){return 1; }


int ProportionalController::getFullState(double *cont_state, int idx) {

Expand Down Expand Up @@ -115,9 +112,6 @@ void ProportionalController::connect(conductance * channel_) {

}

void ProportionalController::connect(compartment* comp_) {
mexErrMsgTxt("[ProportionalController] This mechanism cannot connect to a compartment object");
}

void ProportionalController::connect(synapse* syn_) {

Expand Down Expand Up @@ -211,14 +205,6 @@ void ProportionalController::integrate(void) {



void ProportionalController::checkSolvers(int k) {
if (k == 0){
return;
} else {
mexErrMsgTxt("[ProportionalController] unsupported solver order\n");
}
}




Expand Down
2 changes: 1 addition & 1 deletion c++/mexTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
int idx = 0;
for(int j = 0; j < n_comp; j++) {
for (int k = 0; k < xolotl_network.comp[j]->n_mech; k++) {
int mech_size = (xolotl_network.comp[j]->getMechanismPointer(k))->getFullStateSize();
int mech_size = (xolotl_network.comp[j]->getMechanismPointer(k))->fullStateSize;
mech_sizes_out[idx] = mech_size;
idx++;
}
Expand Down
42 changes: 2 additions & 40 deletions docs/how-to/make-own-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ public:

// defaults
if (isnan(gbar)) { gbar = 0; }


if (isnan (E)) { E = 30; }

// specify exponents of m and h
Expand Down Expand Up @@ -190,16 +188,12 @@ public:
double B = 1;
// constructor
NewMech(double A_, B_)
{
NewMech(double A_, B_) {
A = A_;
B = B_;
controlling_class = "unset";
}
// declare methods
void checkSolvers(int);
void integrate(void);
void integrateMS(int, double, double);
Expand All @@ -214,19 +208,12 @@ public:
// these methods allow reading out of the mechanism
// state
int getFullStateSize(void);
int getFullState(double * mech_state, int idx);
double getState(int);
};
double NewMech::getState(int idx){return std::numeric_limits<double>::quiet_NaN();}
// specify the dimensions of your mechanism
// this size must match the getState method
int NewMech::getFullStateSize(){return 0; }
// this does nothing since our state size is 0
// otherwise we should increment idx, and
// fill in values in the mech_state array
Expand All @@ -236,19 +223,12 @@ int NewMech::getFullState(double *mech_state, int idx) {
// connection methods
// we allow the mechanism to connect to a compartment
// all other connection attempts will lead to a runtime error
void NewMech::connect(compartment* comp_) {
comp = comp_;
comp->addMechanism(this);
}
// disallow other connections
void NewMech::connect(conductance* cond_) {
mexErrMsgTxt("[NewMech] This mechanism cannot connect to a conductance object");
}
void NewMech::connect(synapse* syn_) {
mexErrMsgTxt("[NewMech] This mechanism cannot connect to a synapse object");
}
// specify how we integrate it with the default
Expand All @@ -263,24 +243,6 @@ double NewMech::NewMechCustomMethod(double X_) {
// insert your code here
}
// Runge-Kutta 4 integrator
// you don't have to code this...see checkSolvers
void NewMech::integrateMS(int k, double V, double Ca_) {
if (k == 4){return;}
// insert RK4 code here
}
// throw an error to disallow solver_orders
// 0 must always work, though
void NewMech::checkSolvers(int k) {
if (k == 0){
return;
} else if (k == 4){
return;
} else {
mexErrMsgTxt("[CalciumMech] unsupported solver order\n");
}
}
#endif
Expand Down

0 comments on commit 2594e50

Please sign in to comment.