00001 /* VClamp.h --- 00002 * 00003 * Filename: VClamp.h 00004 * Description: 00005 * Author: 00006 * Maintainer: 00007 * Created: Fri Feb 1 19:22:19 2013 (+0530) 00008 * Version: 00009 * Last-Updated: Wed Feb 6 17:20:48 2013 (+0530) 00010 * By: subha 00011 * Update #: 55 00012 * URL: 00013 * Keywords: 00014 * Compatibility: 00015 * 00016 */ 00017 00018 /* Commentary: 00019 * 00020 * Class for implementing voltage clamp 00021 * 00022 */ 00023 00024 /* Change log: 00025 * 00026 * 00027 */ 00028 00029 /* This program is free software; you can redistribute it and/or 00030 * modify it under the terms of the GNU General Public License as 00031 * published by the Free Software Foundation; either version 3, or 00032 * (at your option) any later version. 00033 * 00034 * This program is distributed in the hope that it will be useful, 00035 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00036 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00037 * General Public License for more details. 00038 * 00039 * You should have received a copy of the GNU General Public License 00040 * along with this program; see the file COPYING. If not, write to 00041 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth 00042 * Floor, Boston, MA 02110-1301, USA. 00043 */ 00044 00045 /* Code: */ 00046 00047 #ifndef _VCLAMP_H 00048 #define _VCLAMP_H 00049 namespace moose 00050 { 00051 class VClamp 00052 { 00053 static const unsigned DERIVATIVE_ON_PV; 00054 static const unsigned PROPORTIONAL_ON_PV; 00055 public: 00056 VClamp(); 00057 ~VClamp(); 00058 void setCommand(double v); 00059 double getCommand() const; 00060 void setVin(double v); 00061 double getVin() const; 00062 double getCurrent() const; 00063 void setMode(unsigned int mode); 00064 unsigned int getMode() const; 00065 void setTi(double value); 00066 double getTi() const; 00067 void setTd(double value); 00068 double getTd() const; 00069 void setTau(double value); 00070 double getTau() const; 00071 void setGain(double value); 00072 double getGain() const; 00073 void process(const Eref& e, ProcPtr p); 00074 void reinit(const Eref& e, ProcPtr p); 00075 00076 static const Cinfo* initCinfo(); 00077 00078 // finfo used to send out injection current to compartment 00079 static SrcFinfo1< double >* currentOut(); 00080 00081 protected: 00082 double vIn_; // membrane potential read from the compartment 00083 double command_; // command potential 00084 double current_; // current generated by the clamp circuit 00085 unsigned int mode_; // 0 - use normal PID 00086 // 1 - base derivative on PV 00087 // 2 - base proportional & derivative on PV 00088 double ti_; // integral time 00089 double td_; // derivative time 00090 double Kp_; // proportional gain - set to Cm/dt 00091 double tau_; // time constant for low pass filter on command voltage 00092 double tdByDt_; // internal variable for performance 00093 double dtByTi_; // internal variable for performance 00094 double tauByDt_;// internal variable for performance 00095 double e_; // error[n] (current step) 00096 double e1_; // error[n-1] 00097 double e2_; // error[n-2] 00098 double v1_; // internal variable used only when error term is replaced by process variable 00099 double cmdIn_; // older value of command potential 00100 double oldCmdIn_; 00101 double expt_; 00102 00103 }; 00104 } 00105 00106 #endif // _VCLAMP_H 00107 /* VClamp.h ends here */