kssingle.h

Go to the documentation of this file.
00001 #ifndef kssingle_h
00002 #define kssingle_h
00003 
00004 #include <math.h>
00005 #include <OS/math.h>
00006 #include <kschan.h>
00007 #include <netcon.h>
00008 
00009 extern "C" {
00010 double mcell_ran4(unsigned int* idum, double* x, int n, double range);
00011 }
00012 
00013 class KSSingleTrans;
00014 class KSSingleState;
00015 class KSSingle;
00016 class KSChan;
00017 
00018 class KSSingleNodeData : public DiscreteEvent {
00019 public:
00020    KSSingleNodeData();
00021    virtual ~KSSingleNodeData();  
00022 
00023    // subclassed DiscreteEvent methods
00024    virtual void deliver(double t, NetCvode*, NrnThread*);
00025    virtual void pr(const char*, double t, NetCvode*);
00026 
00027    // specific to KSSingleNodeData
00028    int nsingle_;
00029    double* statepop_; // points to prop->param state array
00030    int filledstate_; // used when nsingle_ == 1, index of populated state
00031    double vlast_; // voltage at which the transition rates were calculated
00032    double t0_; // last transition time. <= t on entry to step calculations.
00033    double t1_; // next. > t + dt on exit from step calculations.
00034    int next_trans_; // if t1_ takes effect, this is the trans.
00035    Point_process** ppnt_;
00036    KSSingle* kss_;
00037    TQItem* qi_;
00038 };
00039 
00040 class KSSingle {
00041 public:
00042    KSSingle(KSChan*);
00043    virtual ~KSSingle();
00044 
00045    void alloc(Prop*, int sindex);
00046    void init(double v, double* s, KSSingleNodeData* snd, NrnThread*);
00047 
00048    void state(Node*, double*, Datum*, NrnThread*);
00049    void cv_update(Node*, double*, Datum*, NrnThread*);
00050    void one(double, KSSingleNodeData*, NrnThread*);
00051    void do1trans(KSSingleNodeData*);
00052    void next1trans(KSSingleNodeData*);
00053    void multi(double, KSSingleNodeData*, NrnThread*);
00054    void doNtrans(KSSingleNodeData*);
00055    void nextNtrans(KSSingleNodeData*);
00056 
00057    boolean vsame(double x, double y) {return Math::equal(x, y, vres_);}
00058    double exprand() { double x; return -log(mcell_ran4(&idum_, &x, 1, 1.)); }
00059    double unifrand(double range) { double x; return mcell_ran4(&idum_, &x, 1, range); }
00060    int rvalrand(int);
00061 
00062    int ntrans_, nstate_, sndindex_;
00063    KSSingleTrans* transitions_;
00064    KSSingleState* states_;
00065    double* rval_;
00066    boolean uses_ligands_;
00067    static double vres_;
00068    static unsigned int idum_;
00069 
00070    static unsigned long singleevent_deliver_;
00071    static unsigned long singleevent_move_;
00072 };
00073 
00074 class KSSingleTrans {
00075 public:
00076    KSSingleTrans();
00077    virtual ~KSSingleTrans();
00078    double rate(Point_process*);
00079    double rate(double v) { return fac_ * (f_ ? kst_->alpha(v) : kst_->beta(v)); }
00080    double rate(Datum* pd) { return fac_ * (f_ ? kst_->alpha(pd) : kst_->beta()); }
00081    int src_;
00082    int target_;
00083    KSTransition* kst_;
00084    boolean f_;
00085    double fac_;
00086 };
00087 
00088 class KSSingleState {
00089 public:
00090    KSSingleState();
00091    virtual ~KSSingleState();
00092    int ntrans_;
00093    int* transitions_;
00094 };
00095 
00096 #endif
Generated on Mon Jun 13 08:10:25 2011 for NEURON by  doxygen 1.6.3