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: #include <stdlib.h> 20: 21: #include "../../heccer/compartment.h" 22: #include "../../heccer/heccer.h" 23: #include "../../heccer/mathcomponent.h" 24: 25: 26: #define HECCER_TEST_REPORTING_GRANULARITY 100000 27: #define HECCER_TEST_STEPS 1000000 28: #define HECCER_TEST_TESTED_THINGS ( HECCER_DUMP_VM_COMPARTMENT_MATRIX \ 29: | HECCER_DUMP_VM_COMPARTMENT_DATA \ 30: | HECCER_DUMP_VM_COMPARTMENT_OPERATIONS \ 31: | HECCER_DUMP_VM_CHANNEL_POOL_FLUXES \ 32: | HECCER_DUMP_VM_MECHANISM_DATA \ 33: | HECCER_DUMP_VM_MECHANISM_OPERATIONS \ 34: | HECCER_DUMP_VM_SUMMARY \ 35: ) 36: #define HECCER_TEST_TIME_GRANULARITY (1e-14) 37: #define HECCER_TEST_TIME_STEP (1e-11) 38: 39: 40: struct Compartment comp = 41: { 42: //m administrative overhead 43: 44: { 45: //m type of structure 46: 47: MATH_TYPE_Compartment, 48: }, 49: 50: //m index of parent compartment, -1 for none 51: 52: -1, 53: 54: /* //m first mechanism */ 55: 56: /* NULL, */ 57: 58: /* //m number of mechanisms */ 59: 60: /* 0, */ 61: 62: //m descriptive values, alphabetical order 63: 64: /* double dCm; */ 65: 66: 5.755329373e-12, // unscaled 0.0164, 67: 68: /* double dEm; */ 69: 70: -0.08, 71: 72: /* double dInitVm; */ 73: 74: -0.068, 75: 76: /* double dInject; */ 77: 78: 1e-9, 79: 80: /* double dRa; */ 81: 82: 772813.4375, // unscaled 2.5, 83: 84: /* double dRm; */ 85: 86: 8.548598272e9, // unscaled 3 87: }; 88: 89: 90: //v a simple fast calcium channel 91: 92: struct ChannelActInact caiCaT = 93: { 94: //m administrative overhead 95: 96: { 97: //m type of structure 98: 99: MATH_TYPE_ChannelActInact, 100: }, 101: 102: //m first set of descriptive values, alphabetical order 103: 104: //m initial reversal potential 105: 106: 0.1470214874, 107: 108: //m get reversal potential from this intermediary, -1 for none 109: 110: 1, 111: 112: //m maximal conductance when all channels are permissive 113: 114: 1.754672296e-09, 115: 116: //m contributes to this concentration pool, -1 for none, boolean indicator only. 117: 118: 1, 119: 120: //m activation description 121: 122: { 123: //m power, for a standard heccer, something between 1 and 4 or so. 124: 125: 1, 126: 127: //m gate definition 128: 129: { 130: //m initial value, commonly forward over backward steady states 131: 132: 0.038918706451336625, 133: 134: //m corresponding index in tables, set to -1 for initialization. 135: 136: -1, 137: 138: { 139: //m forward kinetiks, commonly denoted with alpha or non-perm to perm rate 140: 141: { 142: //m multiplier 143: 144: 2.6e3, 145: 146: //m multiplier membrane dependence, 0.0 for no dependence 147: 148: 0.0, 149: 150: //m 2b: multiplier membrane dependence offset, 0.0 for no dependence 151: 152: 0.0, 153: 154: //m choose between nominator or denominator, 1 means nominator, -1 155: //m means denominator 156: 157: -1.0, 158: 159: //m nominator or denominator offset 160: 161: 1.0, 162: 163: //m membrane offset 164: 165: 0.021, 166: 167: //m denormalized time constant 168: 169: -8e-3, 170: }, 171: 172: //m backward kinetiks, commonly denoted with beta or perm to non-perm rate 173: 174: { 175: //m multiplier 176: 177: 0.18e3, 178: 179: //m multiplier membrane dependence, 0.0 for no dependence 180: 181: 0.0, 182: 183: //m 2b: multiplier membrane dependence offset, 0.0 for no dependence 184: 185: 0.0, 186: 187: //m choose between nominator or denominator, 1 means nominator, -1 188: //m means denominator 189: 190: -1.0, 191: 192: //m nominator or denominator offset 193: 194: 1.0, 195: 196: //m membrane offset 197: 198: 0.04, 199: 200: //m denormalized time constant 201: 202: 4e-3, 203: }, 204: }, 205: }, 206: }, 207: 208: //m inactivation description 209: 210: { 211: //m power, for a standard heccer, something between 1 and 4 or so. 212: 213: 1, 214: 215: //m gate definition 216: 217: { 218: //m initial value, commonly forward over backward steady states 219: 220: 0.082602128127539254, 221: 222: //m corresponding index in tables, set to -1 for initialization. 223: 224: -1, 225: 226: { 227: //m forward kinetiks, commonly denoted with alpha or non-perm to perm rate 228: 229: { 230: //m multiplier 231: 232: 0.0025e3, 233: 234: //m multiplier membrane dependence, 0.0 for no dependence 235: 236: 0.0, 237: 238: //m 2b: multiplier membrane dependence offset, 0.0 for no dependence 239: 240: 0.0, 241: 242: //m choose between nominator or denominator, 1 means nominator, -1 243: //m means denominator 244: 245: -1.0, 246: 247: //m nominator or denominator offset 248: 249: 1.0, 250: 251: //m membrane offset 252: 253: 0.04, 254: 255: //m denormalized time constant 256: 257: 8e-3, 258: }, 259: 260: //m backward kinetiks, commonly denoted with beta or perm to non-perm rate 261: 262: { 263: //m multiplier 264: 265: 0.19e3, 266: 267: //m multiplier membrane dependence, 0.0 for no dependence 268: 269: 0.0, 270: 271: //m 2b: multiplier membrane dependence offset, 0.0 for no dependence 272: 273: 0.0, 274: 275: //m choose between nominator or denominator, 1 means nominator, -1 276: //m means denominator 277: 278: -1.0, 279: 280: //m nominator or denominator offset 281: 282: 1.0, 283: 284: //m membrane offset 285: 286: 0.05, 287: 288: //m denormalized time constant 289: 290: -10.0e-3, 291: }, 292: }, 293: }, 294: }, 295: }; 296: 297: 298: struct InternalNernst inCa = 299: { 300: //m administrative overhead 301: 302: { 303: //m type of structure 304: 305: MATH_TYPE_InternalNernst, 306: }, 307: 308: //m nernst constant 309: 310: 0.013363, 311: 312: //m link to internal concentration 313: 314: 2, 315: 316: //m constant external concentration 317: 318: 2.4000, 319: 320: //m initial nernst potential 321: 322: 0.1470214874, 323: }; 324: 325: 326: struct ExponentialDecay exdecCa = 327: { 328: //m administrative overhead 329: 330: { 331: //m type of structure 332: 333: MATH_TYPE_ExponentialDecay, 334: }, 335: 336: //m initial value 337: 338: 4e-5, 339: 340: //m beta 341: 342: 7.579027046e+10, 343: 344: //m steady state 345: 346: 4e-05, 347: 348: //m tau 349: 350: 0.00010, 351: 352: //m external contribution delivered by these intermediaries 353: 354: { 355: 0, 356: -1, 357: -1, 358: -1, 359: }, 360: }; 361: 362: 363: int piC2m[] = 364: { 365: 3, 366: -1, 367: }; 368: 369: 370: struct MathComponentArray mca = 371: { 372: //m number of math components 373: 374: 3, 375: 376: //m math component data 377: 378: NULL, 379: 380: //m math component index, initialize to NULL 381: 382: NULL, 383: 384: }; 385: 386: 387: struct Intermediary inter = 388: { 389: //m compartment array 390: 391: 1, 392: 393: &comp, 394: 395: //m all other mathematical components 396: 397: &mca, 398: 399: //m compartment 2 first mechanism number 400: 401: piC2m, 402: }; 403: 404: 405: int main(int argc, char *argv[]) 406: { 407: //- determine intermediary size, and allocate 408: 409: struct MathComponentInfo *pmciCaT = MathComponentInfoLookup(caiCaT.mc.iType); 410: 411: struct MathComponentInfo *pmciCa = MathComponentInfoLookup(exdecCa.mc.iType); 412: 413: struct MathComponentInfo *pmciNernst = MathComponentInfoLookup(inCa.mc.iType); 414: 415: int iChars = pmciCaT->iChars + pmciCa->iChars + pmciNernst->iChars; 416: 417: void *pmc = calloc(sizeof(char), iChars); 418: 419: //- prepare the mechanism intermediary 420: 421: struct ChannelActInact *pcai = (struct ChannelActInact *)pmc; 422: 423: *pcai = caiCaT; 424: 425: struct InternalNernst *pin = (struct InternalNernst *)&((char *)pcai)[pmciCaT->iChars]; 426: 427: *pin = inCa; 428: 429: struct ExponentialDecay *pexdec = (struct ExponentialDecay *)&((char *)pin)[pmciNernst->iChars]; 430: 431: *pexdec = exdecCa; 432: 433: //! other order: 434: 435: /* struct ExponentialDecay *pexdec = (struct ExponentialDecay *)&((char *)pcai)[pmciCaT->iChars]; */ 436: 437: /* *pexdec = exdecCa; */ 438: 439: /* struct InternalNernst *pin = (struct InternalNernst *)&((char *)pexdec)[pmciCa->iChars]; */ 440: 441: /* *pin = inCa; */ 442: 443: //- link the intermediary 444: 445: mca.pmc = pmc; 446: 447: //- do the simulation 448: 449: simulate(argc,argv); 450: } 451: 452: 453: #define main(argc,argv) simulate(argc,argv) 454: 455: //t this prototype can give warning and perhaps errors. 456: 457: int main(int argc, char *argv[]); 458: 459: 460: #include "main.c" 461: 462: 463: