11 #include "../basecode/header.h"
12 #include "../basecode/global.h"
13 #include "../shell/Shell.h"
14 #include "../utility/testing_macros.hpp"
30 static const double thresh = 0.8;
31 static const double Vmax = 1.0;
32 static const double refractoryPeriod = 0.4;
33 static const double weightMax = 0.02;
34 static const double timestep = 0.2;
35 static const double delayMax = 4;
36 static const double delayMin = 0;
37 static const double connectionProbability = 0.1;
38 static const unsigned int NUM_TOT_SYN = 104831;
39 unsigned int size = 1024;
41 Eref sheller(
Id().eref() );
42 Shell* shell =
reinterpret_cast< Shell*
>( sheller.data() );
44 Id fire = shell->
doCreate(
"IntFire",
Id(),
"network", size );
47 Id i2 = shell->
doCreate(
"SimpleSynHandler", fire,
"syns", size );
48 assert( i2.element()->getName() ==
"syns" );
50 Id synId( i2.value() + 1 );
52 assert( syn->getName() ==
"synapse" );
58 ObjId( synId, 0 ),
"addSpike" );
61 connectionProbability, 5489UL );
63 mid = shell->
doAddMsg(
"OneToOne", i2,
"activationOut",
67 unsigned int nd = syn->totNumLocalField();
73 assert( nd == 52446 );
76 assert( nd == 35087 );
78 assert( nd == 26381 );
84 vector< string > funcs;
85 ObjId oi( fire, 123 );
87 get( oi,
"msgDests",
"spikeOut" );
89 get( oi,
"msgDestFunctions",
"spikeOut" );
90 assert( tgts.size() == funcs.size() );
100 for (
unsigned int i = 0; i < funcs.size(); ++i )
101 assert( funcs[i] ==
"addSpike" );
107 vector< double > origVm( size, 0.0 );
111 for (
unsigned int i = 0; i < size; ++i )
114 double origVm100 = origVm[100];
115 double origVm900 = origVm[900];
117 vector< double > temp;
119 temp.resize( size, thresh );
123 temp.resize( size, refractoryPeriod );
128 vector< unsigned int > numSynVec;
130 assert ( numSynVec.size() == size );
131 unsigned int numTotSyn = 0;
132 for (
unsigned int i = 0; i < size; ++i )
133 numTotSyn += numSynVec[i];
134 assert( numTotSyn == NUM_TOT_SYN );
136 vector< vector< double > > weight( size );
137 for (
unsigned int i = 0; i < size; ++i )
139 weight[i].resize( numSynVec[i], 0.0 );
140 vector< double > delay( numSynVec[i], 0.0 );
141 for (
unsigned int j = 0; j < numSynVec[i]; ++j )
144 delay[ j ] = delayMin +
moose::mtrand() * ( delayMax - delayMin );
152 for (
unsigned int i = 0; i < size; ++i )
154 vector< double > retVec(0);
156 assert( retVec.size() == numSynVec[i] );
157 for (
unsigned int j = 0; j < numSynVec[i]; ++j )
166 shell->
doUseClock(
"/network/syns",
"process", 0 );
177 assert( fabs( retVm100 - origVm100 ) < 1e-6 );
178 assert( fabs( retVm900 - origVm900 ) < 1e-6 );
180 shell->
doStart( static_cast< double >( timestep * runsteps) + 0.0 );
217 cout << std::setprecision(12) << retVm100 << endl;
218 cout << std::setprecision(12) << retVm101 << endl;
219 cout << std::setprecision(12) << retVm102 << endl;
220 cout << std::setprecision(11) << retVm99 << endl;
221 cout << std::setprecision(12) << retVm900 << endl;
222 cout << std::setprecision(12) << retVm901 << endl;
223 cout << std::setprecision(12) << retVm902 << endl;
242 cout <<
"." << flush;
247 static const double EREST = -0.07;
252 void testHHGateCreation()
255 vector< int > dims( 1, 1 );
257 Id comptId = shell->
doCreate(
"Compartment", nid,
"compt", dims );
258 Id chanId = shell->
doCreate(
"HHChannel", nid,
"Na", dims );
259 MsgId mid = shell->
doAddMsg(
"Single",
ObjId( comptId ),
"channel",
260 ObjId( chanId ),
"channel" );
261 assert( mid != Msg::bad );
266 assert( chan->
xGate_ == 0 );
267 assert( chan->
yGate_ == 0 );
268 assert( chan->
zGate_ == 0 );
270 assert( kids.size() == 3 );
271 assert( kids[0] ==
Id( chanId.
value() + 1 ) );
272 assert( kids[1] ==
Id( chanId.
value() + 2 ) );
273 assert( kids[2] ==
Id( chanId.
value() + 3 ) );
274 assert( kids[0]()->dataHandler()->localEntries() == 0 );
275 assert( kids[1]()->dataHandler()->localEntries() == 0 );
276 assert( kids[2]()->dataHandler()->localEntries() == 0 );
279 assert( chan->
xGate_ != 0 );
280 assert( chan->
yGate_ == 0 );
281 assert( chan->
zGate_ == 0 );
283 assert( kids.size() == 3 );
284 assert( kids[0]()->dataHandler()->localEntries() == 1 );
285 assert( kids[1]()->dataHandler()->localEntries() == 0 );
286 assert( kids[2]()->dataHandler()->localEntries() == 0 );
290 assert( chan->
xGate_ != 0 );
291 assert( chan->
yGate_ == 0 );
292 assert( chan->
zGate_ == 0 );
293 assert( kids[0]()->dataHandler()->localEntries() == 1 );
294 assert( kids[1]()->dataHandler()->localEntries() == 0 );
295 assert( kids[2]()->dataHandler()->localEntries() == 0 );
298 assert( chan->
xGate_ == 0 );
299 assert( chan->
yGate_ == 0 );
300 assert( chan->
zGate_ == 0 );
302 assert( kids.size() == 3 );
304 assert( kids[0] ==
Id( chanId.
value() + 1 ) );
305 assert( kids[0]()->dataHandler()->localEntries() == 0 );
306 assert( kids[1]()->dataHandler()->localEntries() == 0 );
307 assert( kids[2]()->dataHandler()->localEntries() == 0 );
310 assert( chan->
xGate_ != 0 );
311 assert( chan->
yGate_ == 0 );
312 assert( chan->
zGate_ == 0 );
314 assert( kids.size() == 3 );
316 assert( kids[0] ==
Id( chanId.
value() + 1 ) );
317 assert( kids[0]()->dataHandler()->localEntries() == 1 );
318 assert( kids[1]()->dataHandler()->localEntries() == 0 );
319 assert( kids[2]()->dataHandler()->localEntries() == 0 );
322 assert( chan->
xGate_ != 0 );
323 assert( chan->
yGate_ != 0 );
324 assert( chan->
zGate_ == 0 );
326 assert( kids.size() == 3 );
327 assert( kids[0]()->dataHandler()->localEntries() == 1 );
328 assert( kids[1]()->dataHandler()->localEntries() == 1 );
329 assert( kids[2]()->dataHandler()->localEntries() == 0 );
332 assert( chan->
xGate_ != 0 );
333 assert( chan->
yGate_ != 0 );
334 assert( chan->
zGate_ != 0 );
336 assert( kids.size() == 3 );
337 assert( kids[0] ==
Id( chanId.
value() + 1 ) );
338 assert( kids[1] ==
Id( chanId.
value() + 2 ) );
339 assert( kids[2] ==
Id( chanId.
value() + 3 ) );
340 assert( kids[0]()->dataHandler()->localEntries() == 1 );
341 assert( kids[1]()->dataHandler()->localEntries() == 1 );
342 assert( kids[2]()->dataHandler()->localEntries() == 1 );
345 cout <<
"." << flush;
351 static double actionPotl[] = { 0,
352 1.2315, 2.39872, 3.51917, 4.61015, 5.69088, 6.78432, 7.91934, 9.13413,
353 10.482, 12.0417, 13.9374, 16.3785, 19.7462, 24.7909, 33.0981, 47.967,
354 73.3833, 98.7377, 105.652, 104.663, 101.815, 97.9996, 93.5261, 88.6248,
355 83.4831, 78.2458, 73.0175, 67.8684, 62.8405, 57.9549, 53.217, 48.6206,
356 44.1488, 39.772, 35.4416, 31.0812, 26.5764, 21.7708, 16.4853, 10.6048,
357 4.30989, -1.60635, -5.965, -8.34834, -9.3682, -9.72711,
358 -9.81085, -9.78371, -9.71023, -9.61556, -9.50965, -9.39655,
359 -9.27795, -9.15458, -9.02674, -8.89458, -8.75814, -8.61746,
360 -8.47254, -8.32341, -8.17008, -8.01258, -7.85093, -7.68517,
361 -7.51537, -7.34157, -7.16384, -6.98227, -6.79695, -6.60796,
362 -6.41542, -6.21944, -6.02016, -5.81769, -5.61219, -5.40381,
363 -5.19269, -4.979, -4.76291, -4.54459, -4.32422, -4.10197,
364 -3.87804, -3.65259, -3.42582, -3.19791, -2.96904, -2.7394,
365 -2.50915, -2.27848, -2.04755, -1.81652, -1.58556, -1.3548,
366 -1.12439, -0.894457, -0.665128, -0.436511, -0.208708, 0.0181928,
373 double Na_m_A(
double v )
375 if ( fabs( EREST + 0.025 - v ) < 1e-6 )
377 return 0.1e6 * ( EREST + 0.025 - v ) / ( exp ( ( EREST + 0.025 - v )/ 0.01 ) - 1.0 );
381 double Na_m_B(
double v )
383 return 4.0e3 * exp ( ( EREST - v ) / 0.018 );
387 double Na_h_A(
double v )
389 return 70.0 * exp ( ( EREST - v ) / 0.020 );
393 double Na_h_B(
double v )
395 return 1.0e3 / ( exp ( ( 0.030 + EREST - v )/ 0.01 ) + 1.0 );
399 double K_n_A(
double v )
401 if ( fabs( EREST + 0.025 - v ) < 1e-6 )
404 return ( 1.0e4 * ( 0.01 + EREST - v ) ) / ( exp ( ( 0.01 + EREST - v ) / 0.01 ) - 1.0 );
408 double K_n_B(
double v )
410 return 0.125e3 * exp ( (EREST - v ) / 0.08 );
413 void testHHGateLookup()
419 gate.setMin( er, &q, -2.0 );
420 gate.setMax( er, &q, 2.0 );
421 gate.setDivs( er, &q, 1 );
422 assert( gate.A_.size() == 2 );
423 assert( gate.B_.size() == 2 );
424 assert( gate.getDivs( er, &q ) == 1 );
428 gate.lookupByInterpolation_ = 0;
438 gate.lookupByInterpolation_ = 1;
453 gate.lookupBoth( -3 , &x, &y );
456 gate.lookupBoth( -2 , &x, &y );
459 gate.lookupBoth( -0.5, &x, &y );
462 gate.lookupBoth( 0, &x, &y );
465 gate.lookupBoth( 1.5, &x, &y );
468 gate.lookupBoth( 100000, &x, &y );
472 cout <<
"." << flush;
475 void testHHGateSetup()
482 vector< double > parms;
488 unsigned int xdivs = 100;
491 parms.push_back( 0.1e6 * ( EREST + 0.025 ) );
492 parms.push_back( -0.1e6 );
493 parms.push_back( -1 );
494 parms.push_back( -(EREST + 0.025 ) );
495 parms.push_back( -0.01 );
497 parms.push_back( 4e3 );
498 parms.push_back( 0 );
499 parms.push_back( 0 );
500 parms.push_back( -EREST );
501 parms.push_back( 0.018 );
503 parms.push_back( xdivs );
504 parms.push_back( xmin );
505 parms.push_back( xmax );
507 gate.setupAlpha( er, &q, parms );
508 assert( gate.A_.size() == xdivs + 1 );
509 assert( gate.B_.size() == xdivs + 1 );
512 double dx = (xmax - xmin) / xdivs;
513 for (
unsigned int i = 0; i <= xdivs; ++i )
515 double ma = Na_m_A( x );
516 double mb = Na_m_B( x );
522 cout <<
"." << flush;
533 vector< int > dims( 1, 1 );
535 Id comptId = shell->
doCreate(
"Compartment", nid,
"compt", dims );
536 Id naId = shell->
doCreate(
"HHChannel", comptId,
"Na", dims );
537 MsgId mid = shell->
doAddMsg(
"Single",
ObjId( comptId ),
"channel",
538 ObjId( naId ),
"channel" );
539 assert( mid != Msg::bad );
540 Id kId = shell->
doCreate(
"HHChannel", comptId,
"K", dims );
541 mid = shell->
doAddMsg(
"Single",
ObjId( comptId ),
"channel",
542 ObjId( kId ),
"channel" );
543 assert( mid != Msg::bad );
576 assert( kids.size() == 3 );
577 vector< double > parms;
582 unsigned int xdivs = 150;
585 parms.push_back( 0.1e6 * ( EREST + 0.025 ) );
586 parms.push_back( -0.1e6 );
587 parms.push_back( -1 );
588 parms.push_back( -(EREST + 0.025 ) );
589 parms.push_back( -0.01 );
591 parms.push_back( 4e3 );
592 parms.push_back( 0 );
593 parms.push_back( 0 );
594 parms.push_back( -EREST );
595 parms.push_back( 0.018 );
597 parms.push_back( xdivs );
598 parms.push_back( xmin );
599 parms.push_back( xmax );
610 parms.push_back( 70 );
611 parms.push_back( 0 );
612 parms.push_back( 0 );
613 parms.push_back( -EREST );
614 parms.push_back( 0.02 );
616 parms.push_back( 1e3 );
617 parms.push_back( 0 );
618 parms.push_back( 1 );
619 parms.push_back( -( EREST + 0.03 ) );
620 parms.push_back( -0.01 );
622 parms.push_back( xdivs );
623 parms.push_back( xmin );
624 parms.push_back( xmax );
633 double dx = (xmax - xmin) / xdivs;
634 for (
unsigned int i = 0; i <= xdivs; ++i )
636 double ha = Na_h_A( x );
637 double hb = Na_h_B( x );
651 parms.push_back( 1e4 * (0.01 + EREST) );
652 parms.push_back( -1e4 );
653 parms.push_back( -1.0 );
654 parms.push_back( -( EREST + 0.01 ) );
655 parms.push_back( -0.01 );
657 parms.push_back( 0.125e3 );
658 parms.push_back( 0 );
659 parms.push_back( 0 );
660 parms.push_back( -EREST );
661 parms.push_back( 0.08 );
663 parms.push_back( xdivs );
664 parms.push_back( xmin );
665 parms.push_back( xmax );
674 for (
unsigned int i = 0; i <= xdivs; ++i )
676 double na = K_n_A( x );
677 double nb = K_n_B( x );
678 if ( i != 40 && i != 55 )
693 vector< int > dims( 1, 1 );
695 Id nid = makeSquid();
696 Id comptId(
"/n/compt" );
698 Id tabId = shell->
doCreate(
"Table", nid,
"tab", dims );
700 "requestOut",
ObjId( comptId, 0 ),
"get_Vm" );
701 assert( mid != Msg::bad );
712 shell->
doUseClock(
"/n/compt",
"process", 1 );
714 shell->
doUseClock(
"/n/compt/Na,/n/compt/K",
"process", 2 );
727 for (
unsigned int i = 0; i < 100; ++i )
729 double ref = EREST + actionPotl[i] * 0.001;
730 delta += (vec[i] - ref) * (vec[i] - ref);
732 assert( sqrt( delta/100 ) < 0.001 );
738 cout <<
"." << flush;
748 static double sampleCurrent[] = {0.0,
749 0.0000000e+00, 3.0005743e-26, 1.2004594e-25, 2.7015505e-25, 4.8036751e-25, 7.5071776e-25,
750 1.0812402e-24, 1.4719693e-24, 1.9229394e-24, 2.4341850e-24, 3.0057404e-24, 3.6376401e-24,
751 4.3299183e-24, 5.0826095e-24, 5.8957481e-24, 6.7693684e-24, 7.7035046e-24, 8.6981913e-24,
752 9.7534627e-24, 1.0869353e-23, 1.2045897e-23, 1.3283128e-23, 1.4581082e-23, 1.5939791e-23,
753 1.7359292e-23, 1.8839616e-23, 2.0380801e-23, 2.1982878e-23, 2.3645883e-23, 2.5369850e-23,
754 2.7154813e-23, 2.9000806e-23, 3.0907863e-23, 3.2876020e-23, 3.4905309e-23, 3.6995766e-23,
755 3.9147423e-23, 4.1360317e-23, 4.3634480e-23, 4.5969946e-23, 4.8366751e-23, 5.0824928e-23,
756 5.3344511e-23, 5.5925535e-23, 5.8568033e-23, 6.1272040e-23, 6.4037589e-23, 6.6864716e-23,
757 6.9753453e-23, 7.2703835e-23, 7.5715897e-23, 7.8789672e-23, 8.1925194e-23, 8.5122497e-23,
758 8.8381616e-23, 9.1702584e-23, 9.5085435e-23, 9.8530204e-23, 1.0203692e-22, 1.0560563e-22,
759 1.0923636e-22, 1.1292913e-22, 1.1668400e-22, 1.2050099e-22, 1.2438013e-22, 1.2832146e-22,
760 1.3232502e-22, 1.3639083e-22, 1.4051894e-22, 1.4470937e-22, 1.4896215e-22, 1.5327733e-22,
761 1.5765494e-22, 1.6209501e-22, 1.6659757e-22, 1.7116267e-22, 1.7579032e-22, 1.8048057e-22,
762 1.8523345e-22, 1.9004900e-22, 1.9492724e-22, 1.9986821e-22, 2.0487195e-22, 2.0993849e-22,
763 2.1506786e-22, 2.2026010e-22, 2.2551524e-22, 2.3083331e-22, 2.3621436e-22, 2.4165840e-22,
764 2.4716548e-22, 2.5273563e-22, 2.5836888e-22, 2.6406527e-22, 2.6982483e-22, 2.7564760e-22,
765 2.8153360e-22, 2.8748287e-22, 2.9349545e-22, 2.9957137e-22, 3.0571067e-22
768 void testMarkovGslSolver()
774 Id comptId = shell->
doCreate(
"Compartment", nid,
"compt", size );
775 Id rateTabId = shell->
doCreate(
"MarkovRateTable", comptId,
"rateTab", size );
776 Id mChanId = shell->
doCreate(
"MarkovChannel", comptId,
"mChan", size );
777 Id gslSolverId = shell->
doCreate(
"MarkovGslSolver", comptId,
"gslSolver", size );
779 Id tabId = shell->
doCreate(
"Table", nid,
"tab", size );
782 ObjId( mChanId ),
"channel" );
783 assert( !mid.
bad() );
785 mid = shell->
doAddMsg(
"Single",
ObjId( comptId ),
"channel",
786 ObjId( rateTabId ),
"channel" );
787 assert( !mid.bad() );
788 mid = shell->
doAddMsg(
"Single",
ObjId( gslSolverId ),
"stateOut",
789 ObjId( mChanId ),
"handleState" );
790 assert( !mid.bad() );
792 mid = shell->
doAddMsg(
"Single",
ObjId( rateTabId ),
"instratesOut",
793 ObjId( gslSolverId ),
"handleQ" );
795 mid = shell->
doAddMsg(
"Single",
ObjId( tabId, 0 ),
"requestOut",
796 ObjId( mChanId, 0 ),
"getIk" );
797 assert( !mid.bad() );
824 vector< double > initState;
826 initState.push_back( 0.0 );
827 initState.push_back( 0.0 );
828 initState.push_back( 0.0 );
829 initState.push_back( 0.0 );
830 initState.push_back( 1.0 );
834 vector< string > stateLabels;
836 stateLabels.push_back(
"O1" );
837 stateLabels.push_back(
"O2" );
838 stateLabels.push_back(
"C1" );
839 stateLabels.push_back(
"C2" );
840 stateLabels.push_back(
"C3" );
844 vector< double > gBars;
846 gBars.push_back( 40e-12 );
847 gBars.push_back( 50e-12 );
857 set( rateTabId,
"setconst", 1, 2, 0.05 );
859 set( rateTabId,
"setconst", 1, 4, 3 );
861 set( rateTabId,
"setconst", 2, 1, 0.00066667 );
863 set( rateTabId,
"setconst", 2, 3, 0.5 );
865 set( rateTabId,
"setconst", 3, 2, 15 );
867 set( rateTabId,
"setconst", 3, 4, 4 );
869 set( rateTabId,
"setconst", 4, 1, 0.015 );
871 set( rateTabId,
"setconst", 4, 3, 0.05 );
873 set( rateTabId,
"setconst", 4, 5, 2.0 );
875 set( rateTabId,
"setconst", 5, 4, 0.01 );
890 shell->
doUseClock(
"/n/compt",
"process", 1 );
891 shell->
doUseClock(
"/n/compt/rateTab",
"process", 1 );
892 shell->
doUseClock(
"/n/compt/gslSolver",
"process", 1 );
893 shell->
doUseClock(
"/n/compt/mChan,/n/tab",
"process", 2 );
901 for (
unsigned i = 0; i < 101; ++i )
903 if (!
doubleEq( sampleCurrent[i] * 1e25, vec[i] * 1e25 ))
905 cout <<
"testMarkovGslSolver: sample=" << sampleCurrent[i]*1e25 <<
" calculated=" << vec[i]*1e25 << endl;
913 cout <<
"." << flush;
931 void testMarkovChannel()
938 Id gslComptId = shell->
doCreate(
"Compartment", nid,
"gslCompt", size );
939 Id exptlComptId = shell->
doCreate(
"Compartment", nid,
940 "exptlCompt", size );
942 Id gslRateTableId = shell->
doCreate(
"MarkovRateTable", gslComptId,
943 "gslRateTable", size );
944 Id exptlRateTableId = shell->
doCreate(
"MarkovRateTable", exptlComptId,
945 "exptlRateTable", size );
947 Id mChanGslId = shell->
doCreate(
"MarkovChannel", gslComptId,
949 Id mChanExptlId = shell->
doCreate(
"MarkovChannel", exptlComptId,
950 "mChanExptl", size );
952 Id gslSolverId = shell->
doCreate(
"MarkovGslSolver", gslComptId,
954 Id exptlSolverId = shell->
doCreate(
"MarkovSolver", exptlComptId,
955 "exptlSolver", size );
957 Id gslTableId = shell->
doCreate(
"Table", nid,
"gslTable", size );
958 Id exptlTableId = shell->
doCreate(
"Table", nid,
"exptlTable", size );
960 Id int2dTableId = shell->
doCreate(
"Interpol2D", nid,
"int2dTable", size );
961 Id vecTableId = shell->
doCreate(
"VectorTable", nid,
"vecTable", size );
963 vector< double > table1d;
964 vector< vector< double > > table2d;
975 ObjId( mChanGslId ),
"channel" );
976 assert( !mid.
bad() );
978 mid = shell->
doAddMsg(
"Single",
ObjId( exptlComptId ),
"channel",
979 ObjId( mChanExptlId ),
"channel" );
980 assert( !mid.bad() );
995 mid = shell->
doAddMsg(
"Single",
ObjId( gslComptId ),
"channel",
996 ObjId( gslRateTableId ),
"channel" );
997 assert( !mid.bad() );
1003 mid = shell->
doAddMsg(
"Single",
ObjId( gslRateTableId ),
"instratesOut",
1004 ObjId( gslSolverId ),
"handleQ" );
1011 mid = shell->
doAddMsg(
"Single",
ObjId( gslSolverId ),
"stateOut",
1012 ObjId( mChanGslId ),
"handleState" );
1013 assert( !mid.bad() );
1024 mid = shell->
doAddMsg(
"Single",
ObjId( exptlComptId ),
"channel",
1025 ObjId( exptlSolverId ),
"channel" );
1026 assert( !mid.bad() );
1028 mid = shell->
doAddMsg(
"Single",
ObjId( exptlSolverId ),
"stateOut",
1029 ObjId( mChanExptlId ),
"handleState" );
1030 assert( !mid.bad() );
1037 mid = shell->
doAddMsg(
"Single",
ObjId( gslTableId ),
"requestOut",
1038 ObjId( mChanGslId ),
"getIk" );
1039 assert( !mid.bad() );
1042 mid = shell->
doAddMsg(
"Single",
ObjId( exptlTableId ),
"requestOut",
1043 ObjId( mChanExptlId ),
"getIk" );
1044 assert( !mid.bad() );
1078 vector< string > stateLabels;
1083 stateLabels.push_back(
"O" );
1084 stateLabels.push_back(
"B1" );
1085 stateLabels.push_back(
"B2" );
1086 stateLabels.push_back(
"C" );
1093 vector< double > gBar;
1095 gBar.push_back( 5.431553e-9 );
1101 vector< double > initState;
1103 initState.push_back( 0.00 );
1104 initState.push_back( 0.20 );
1105 initState.push_back( 0.80 );
1106 initState.push_back( 0.00 );
1130 for (
unsigned int i = 0; i < 201; ++i )
1132 table1d.push_back( 1e3 * exp( -16 * v - 2.91 ) );
1139 gslRateTableId,
"set1d", 1, 2, vecTableId, 0 );
1141 exptlRateTableId,
"set1d", 1, 2, vecTableId, 0 );
1143 table1d.erase( table1d.begin(), table1d.end() );
1147 for (
unsigned int i = 0; i < 201; ++i )
1149 table1d.push_back( 1e3 * exp( 9 * v + 1.22 ) );
1155 gslRateTableId,
"set1d", 2, 1, vecTableId, 0 );
1157 exptlRateTableId,
"set1d", 2, 1, vecTableId, 0 );
1159 table1d.erase( table1d.begin(), table1d.end() );
1176 table2d.resize( 201 );
1178 for (
unsigned int i = 0; i < 201; ++i )
1181 for (
unsigned int j = 0; j < 31; ++j )
1183 table2d[i].push_back( 1e3 * conc * exp( -45 * v - 6.97 ) );
1193 "set2d", 1, 3, int2dTableId );
1195 "set2d", 1, 3, int2dTableId );
1201 for (
unsigned int i = 0; i < 201; ++i )
1203 table1d.push_back( 1e3 * exp( 17 * v + 0.96 ) );
1209 gslRateTableId,
"set1d", 3, 1, vecTableId, 0 );
1211 exptlRateTableId,
"set1d", 3, 1, vecTableId, 0 );
1213 table1d.erase( table1d.begin(), table1d.end() );
1217 "setconst", 1, 4, 1e3 * exp( -2.847 ) );
1219 "setconst", 1, 4, 1e3 * exp( -2.847 ) );
1223 "setconst", 2, 4, 1e3 * exp( -0.693 ) );
1225 "setconst", 2, 4, 1e3 * exp( -0.693 ) );
1229 "setconst", 3, 4, 1e3* exp( -3.101 ) );
1231 "setconst", 3, 4, 1e3* exp( -3.101 ) );
1251 shell->
doUseClock(
"/n/gslCompt,/n/exptlCompt",
"init", 0 );
1252 shell->
doUseClock(
"/n/gslCompt,/n/exptlCompt",
"process", 1 );
1253 shell->
doUseClock(
"/n/gslCompt/gslRateTable,/n/exptlCompt/exptlRateTable",
1255 shell->
doUseClock(
"/n/gslCompt/gslSolver,/n/exptlCompt/exptlSolver",
1257 shell->
doUseClock(
"/n/gslCompt/mChanGsl,/n/gslTable",
"process", 4 );
1258 shell->
doUseClock(
"/n/exptlCompt/mChanExptl,/n/exptlTable",
"process", 5 );
1267 assert( gslVec.size() == 1001 );
1268 assert( exptlVec.size() == 1001 );
1270 for (
unsigned int i = 0; i < 1001; ++i )
1274 cout <<
"." << flush;
1297 Id synChanId = shell->
doCreate(
"SynChan", nid,
"synChan", 1 );
1298 Id synHandlerId = shell->
doCreate(
"SimpleSynHandler", synChanId,
"syns", 1 );
1299 Id synId( synHandlerId.
value() + 1 );
1300 Id sgId1 = shell->
doCreate(
"SpikeGen", nid,
"sg1", 1 );
1301 Id sgId2 = shell->
doCreate(
"SpikeGen", nid,
"sg2", 1 );
1306 assert( synId.element()->getName() ==
"synapse" );
1319 Element* syne = synId.element();
1323 ObjId( sgId1, 0 ),
"spikeOut",
ObjId( synId, 0, 0 ),
"addSpike" );
1324 assert( mid !=
Id() );
1326 ObjId( sgId2, 0 ),
"spikeOut",
ObjId( synId, 0, 1 ),
"addSpike" );
1327 assert( mid !=
Id() );
1329 synHandlerId,
"activationOut", synChanId,
"activation" );
1330 assert( mid !=
Id() );
1376 shell->
doUseClock(
"/n/sg1,/n/sg2",
"process", 0 );
1377 shell->
doUseClock(
"/n/synChan/syns",
"process", 1 );
1378 shell->
doUseClock(
"/n/synChan",
"process", 2 );
1409 cout <<
"." << flush;
1418 vector< int > dims( 1, 1 );
1419 Id nid = shell->
doCreate(
"Neutral",
Id(),
"n", dims );
1421 Id synChanId = shell->
doCreate(
"NMDAChan", nid,
"nmdaChan", dims );
1422 Id synId( synChanId.
value() + 1 );
1423 Id sgId1 = shell->
doCreate(
"SpikeGen", nid,
"sg1", dims );
1428 assert( synId()->getName() ==
"synapse" );
1442 assert( syne->dataHandler()->localEntries() == 1 );
1443 dynamic_cast< FieldDataHandlerBase*
>( syne->dataHandler() )->setNumField( synChanId.
eref().
data(), 1 );
1445 assert( syne->dataHandler()->totalEntries() == 1 );
1446 assert( syne->dataHandler()->numDimensions() == 1 );
1447 assert( syne->dataHandler()->sizeOfDim( 0 ) == 1 );
1449 MsgId mid = shell->
doAddMsg(
"single",
1452 assert( mid !=
Id() );
1479 shell->
doUseClock(
"/n/synChan,/n/sg1",
"process", 0 );
1490 cout <<
"Gk:" << dret << endl;
1491 assert(
doubleApprox( dret, 1.0614275017053588e-07 ) );
1514 cout <<
"." << flush;
1519 static Id addCompartment(
const string&
name,
1520 Id neuron,
Id parent,
1521 double dx,
double dy,
double dz,
double dia )
1527 Id compt = shell->
doCreate(
"Compartment", neuron, name, 1 );
1528 if ( parent !=
Id() )
1531 parent,
"axial", compt,
"raxial" );
1532 assert( mid !=
Id() );
1543 double length = sqrt( dx*dx + dy*dy + dz*dz );
1552 #include "../utility/Vec.h"
1556 #include "../shell/Wildcard.h"
1557 static void testNeuronBuildTree()
1562 double somaDia = 5e-6;
1563 double dendDia = 2e-6;
1564 double branchDia = 1e-6;
1565 static double len[] = { 10e-6, 100e-6, 200e-6, 500e-6 };
1566 static double dia[] = { somaDia, dendDia, branchDia, branchDia };
1567 Id soma = addCompartment (
"soma", nid,
Id(), 10e-6, 0, 0, somaDia );
1568 Id dend1 = addCompartment (
"dend1", nid, soma, 100e-6, 0, 0, dendDia);
1569 Id branch1 = addCompartment (
"branch1", nid, dend1, 0, 200e-6, 0, branchDia );
1570 Id branch2 = addCompartment (
"branch2", nid, dend1, 0, -500e-6, 0, branchDia );
1571 static double x[] = { 10e-6, 110e-6, 110e-6, 110e-6 };
1572 static double y[] = {0, 0, 200e-6, -500e-6};
1573 static double z[] = {0, 0, 0, 0};
1578 nid,
"electrotonicDistanceFromSoma" );
1580 nid,
"geometricalDistanceFromSoma" );
1582 nid,
"pathDistanceFromSoma" );
1583 assert( e.size() == 4 );
1585 double dL = 100e-6 / sqrt( dendDia /4.0 );
1587 double bL1 = dL + 200e-6 / sqrt( branchDia /4.0 );
1589 double bL2 = dL + 500e-6 / sqrt( branchDia/4.0 );
1606 unsigned int nuParserNumVal = 13;
1607 vector< ObjId > elist;
1610 vector< double > val;
1612 assert( val.size() == nuParserNumVal * elist.size() );
1616 for (
unsigned int i = 0; i < elist.size(); ++i )
1618 if ( maxP < p[i] ) maxP = p[i];
1619 if ( maxG < g[i] ) maxG = g[i];
1620 if ( maxL < e[i] ) maxL = e[i];
1623 for (
unsigned int i = 0; i < elist.size(); ++i )
1625 if ( !elist[i].element()->cinfo()->isA(
"CompartmentBase" ) )
1627 assert( val[i * nuParserNumVal] ==
1628 p[j] + g[j] + e[j] + len[j] + dia[j] + ( 1.0 - e[j] > 0 ) );
1632 assert(
doubleEq( val[i * nuParserNumVal + 4], len[j] ));
1647 vector< unsigned int > seglistIndex;
1648 vector< unsigned int > elistIndex;
1649 vector< double > pos;
1650 vector< string > line;
1656 assert( seglistIndex[0] == 2 );
1657 assert( seglistIndex.back() == 3 );
1658 assert( elistIndex[0] == 2 );
1659 assert( elistIndex.back() == 3 );
1670 testNeuronBuildTree();
1672 testMarkovSolverBase();
1674 testHHGateCreation();
1696 #else // ifdef DO_UNIT_TESTS
int wildcardFind(const string &path, vector< ObjId > &ret)
void testIntFireNetwork(unsigned int unsteps=5)
void mtseed(unsigned int x)
Set the global seed or all rngs.
void doStart(double runtime, bool notify=false)
HHGate * zGate_
HHGate data structure for the yGate.
Element * element() const
Synonym for Id::operator()()
void makeSpacingDistrib(const vector< ObjId > &elist, const vector< double > &val, vector< unsigned int > &seglistIndex, vector< unsigned int > &elistIndex, vector< double > &pos, const vector< string > &line) const
void doSetClock(unsigned int tickNum, double dt)
unsigned int value() const
void evalExprForElist(const vector< ObjId > &elist, const string &expn, vector< double > &val) const
static bool set(const ObjId &dest, const string &field, A arg)
void testCompartmentProcess()
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
void testMarkovRateTable()
bool doubleApprox(double x, double y)
bool doubleEq(double x, double y)
static bool set(const ObjId &dest, const string &field, A1 arg1, A2 arg2, A3 arg3, A4 arg4)
HHGate * yGate_
HHGate data structure for the yGate.
#define EXPECT_EQ(a, b, token)
static bool setVec(ObjId destId, const string &field, const vector< A > &arg)
static bool set(const ObjId &dest, const string &field)
virtual unsigned int totNumLocalField() const =0
void testBiophysicsProcess()
ObjId doAddMsg(const string &msgType, ObjId src, const string &srcField, ObjId dest, const string &destField)
static bool set(const ObjId &dest, const string &field, A arg)
static bool set(const ObjId &dest, const string &field, A1 arg1, A2 arg2, A3 arg3)
double mtrand(void)
Generate a random double between 0 and 1.
void doUseClock(string path, string field, unsigned int tick)
static A get(const ObjId &dest, const string &field)
static unsigned int numNodes()
static void getVec(ObjId dest, const string &field, vector< A > &vec)
#define ASSERT_DOUBLE_EQ(token, a, b)
const string & getName() const
static bool set(const ObjId &dest, const string &field, A1 arg1, A2 arg2)