001: //
002: // Heccer : a compartmental solver that implements efficient Crank-Nicolson
003: // integration for neuronal models.
004: //
005: 
006: //////////////////////////////////////////////////////////////////////////////
007: //'
008: //' Heccer : testbed C implementation
009: //'
010: //' Copyright (C) 2006-2008 Hugo Cornelis
011: //'
012: //' functional ideas ..   Hugo Cornelis, hugo.cornelis@gmail.com
013: //'
014: //' coding ............   Hugo Cornelis, hugo.cornelis@gmail.com
015: //'
016: //////////////////////////////////////////////////////////////////////////////
017: 
018: 
019: #include <stdio.h>
020: 
021: #include "../../heccer/callout.h"
022: #include "../../heccer/compartment.h"
023: #include "../../heccer/heccer.h"
024: 
025: 
026: struct Compartment compSoma =
027: {
028:     //m administrative overhead
029: 
030:     {
031:         //m type of structure
032: 
033:         MATH_TYPE_Compartment,
034:     },
035: 
036:     //m index of parent compartment, -1 for none
037: 
038:     -1,
039: 
040: /*     //m first mechanism */
041: 
042: /*     NULL, */
043: 
044: /*     //m number of mechanisms */
045: 
046: /*     0, */
047: 
048:     //m descriptive values, alphabetical order
049: 
050: /*     double dCm; */
051: 
052:     4.57537e-11, // unscaled 0.0164,
053: 
054: /*     double dEm; */
055: 
056:     -0.08,
057: 
058: /*     double dInitVm; */
059: 
060:     -0.068,
061: 
062: /*     double dInject;		 */
063: 
064:     0,
065: 
066: /*     double dRa; */
067: 
068:     360502, // unscaled 2.5,
069: 
070: /*     double dRm; */
071: 
072:     3.58441e+08, // unscaled 1
073: };
074: 
075: 
076: struct InternalResults pirSoma =
077: {
078:     //m membrane potential for this compartment
079: 
080:     0.0,
081: };
082: 
083: 
084: struct ExternalResults perSoma =
085: {
086:     //m external conductance, this is just an example
087: 
088:     10.0,
089: 
090:     //m external current, another example
091: 
092:     10.0,
093: };
094: 
095: 
096: ExternalFunction pefSoma;
097: 
098: 
099: struct Callout callSoma =
100: {
101:     {
102:         //m type of structure
103: 
104:         MATH_TYPE_CallOut_conductance_current,
105:     },
106: 
107:     //m external alien data
108: 
109:     NULL,
110: 
111:     //m internal results
112: 
113:     &pirSoma,
114: 
115:     //m external results
116: 
117:     &perSoma,
118: 
119:     //m external function
120: 
121:     pefSoma,
122: };
123: 
124: 
125: int piC2m[] =
126: {
127:     1,
128:     -1,
129: };
130: 
131: 
132: struct MathComponentArray mca =
133: {
134:     //m number of math components
135: 
136:     1,
137: 
138:     //m math component data
139: 
140:     &callSoma.mc,
141: 
142:     //m math component index, initialize to NULL
143: 
144:     NULL,
145: 
146: };
147: 
148: 
149: struct Intermediary inter =
150: {
151:     //m compartment array
152: 
153:     1,
154: 
155:     &compSoma,
156: 
157:     //m all other mathematical components
158: 
159:     &mca,
160: 
161:     //m compartment 2 first mechanism number
162: 
163:     piC2m,
164: };
165: 
166: 
167: int pefSoma(struct Callout *pco, struct Heccer *pheccer, struct InternalResults *pir, struct ExternalResults *per)
168: {
169:     //- set default result
170: 
171:     int iResult = 0;
172: 
173:     //- initialize
174: 
175:     per->dConductance = 0.0;
176:     per->dCurrent = 0.0;
177: 
178:     //t do something to compute the current and conductance, using pco->pvAlien
179: 
180:     //t fill in the conductance and current in the external results
181: 
182:     //- give some feedback for testing purposes
183: 
184:     fprintf(stdout, "The pefSoma callout says that it is computing current and conductance externally\n");
185:     fprintf(stdout, "The pefSoma callout is advancing to time %g\n", pheccer->dTime);
186: 
187:     //- return result
188: 
189:     return(iResult);
190: }
191: 
192: 
193: #include "main.c"
194: 
195: