1: // 2: // Heccer : a compartmental solver that implements efficient Crank-Nicolson 3: // integration for neuronal models. 4: // 5: 6: ////////////////////////////////////////////////////////////////////////////// 7: //' 8: //' Heccer : testbed C implementation 9: //' 10: //' Copyright (C) 2006-2008 Hugo Cornelis 11: //' 12: //' functional ideas .. Hugo Cornelis, hugo.cornelis@gmail.com 13: //' 14: //' coding ............ Hugo Cornelis, hugo.cornelis@gmail.com 15: //' 16: ////////////////////////////////////////////////////////////////////////////// 17: 18: 19: #ifndef HECCER_VCLAMP_H 20: #define HECCER_VCLAMP_H 21: 22: 23: #include <stdio.h> 24: 25: 26: struct VClamp 27: { 28: //m a string identifier, for what it is worth 29: 30: char *pcName; 31: 32: //m number of clamped variables 33: 34: int iClampsActive; 35: 36: //m input, solved variables 37: 38: double *pdVoltage; 39: 40: double *pdInjector; 41: 42: //m command current 43: 44: double dInjected; 45: 46: //m intial resistance and capacitance 47: 48: double dC; 49: double dR; 50: 51: //m resulting command voltage 52: 53: double dCommand; 54: 55: //m gain and time constants 56: 57: //! setfield ^ gain 0.50 tau_i 0.02 tau_d 0.005 saturation 999.0 58: 59: double dGain; 60: double dTau_i; 61: double dTau_d; 62: double dSaturation; 63: 64: //m solved state variables 65: 66: double dE; 67: double dEIntegral; 68: double dEDerivative; 69: double dEPrevious; 70: 71: //m previous time of calculations 72: 73: double dPreviousTime; 74: 75: //m final output 76: 77: double dOutput; 78: 79: }; 80: 81: 82: int 83: VClampAddVariable 84: (struct VClamp * pvc, void *pvVoltage, void *pvInjector); 85: 86: int VClampSingleStep(struct VClamp * pvc, double dTime); 87: 88: int VClampFinish(struct VClamp * pvc); 89: 90: int VClampInitiate(struct VClamp * pvc); 91: 92: struct VClamp * VClampNew(char *pcName); 93: 94: int 95: VClampSetFields 96: (struct VClamp * pvc, 97: double dInjected, 98: double dC, 99: double dR, 100: double dCommand_init, 101: double dGain, 102: double dTau_i, 103: double dTau_d, 104: double dSaturation); 105: 106: 107: #endif 108: 109: 110: