Skip to content

Commit ba782a9

Browse files
authoredSep 18, 2018
Pulled in changes on Sep 17, 2018 (#242)
* Squashed 'moose-core/' changes from d229eba6bb..ec06b242ae ec06b242ae HotFix: Fix regression in StreadyState solver caused by #293. (#304) 385a5cf0a1 Merge pull request #303 from upibhalla/master 080767c5aa Fixes to rdesigneur due to bad merge. Cleanup on rmoogli 62f8bc89e0 Tweak to Neuron.cpp so it can handle insertion of spines with uniform spacing. 342092829c Update moose_test.py (#301) f1230f1518 Merge branch 'master' of https://github.com/upibhalla/moose-core 23a2892cc8 Merge branch 'master' of https://github.com/BhallaLab/moose-core 8a835c1332 minor bugfix to rdesigneur 6ef1d567ec Merge branch 'master' into master a9a2e758ff Merge branch 'master' of https://github.com/BhallaLab/moose-core 5e1294d991 Further updates to rdesigneur for argument handling a702bded54 Put in kwargs based specification of plotList, stimList and moogList. Folded savePlots into plotList but not yet tested. git-subtree-dir: moose-core git-subtree-split: ec06b242ae650f413d50b9c22b76381a94efcba4 * Squashed 'moose-examples/' changes from 2d9849222d..e30d87a637 e30d87a637 Merge pull request #47 from BhallaLab/nml2 e350e8a801 Fixed path in script. 1602f54763 Added missing NML files and removed unneccessary files. 6d6c27e051 nml2 snippets. 3963e7969a Merge pull request #46 from upibhalla/master 4165c53e4a Merge branch 'master' of https://github.com/BhallaLab/moose-examples 2c0afa8fcc Clean up of ephys1 and ephys2 tutorials 9793e59f6c Merge branch 'master' of https://github.com/BhallaLab/moose-examples 2e91700547 Merge pull request #45 from upibhalla/master 7420933455 Added missing image file 70a3b3fc1c Test with python2.7, python3.6 and python3.7 . bf6c180ee1 Use pypi nightly version to test. 075d01c1af Merge pull request #44 from upibhalla/master 13da78cfc0 Merge branch 'master' of https://github.com/BhallaLab/moose-examples e3cd31b515 Added Ephys demo for Rall's Law 2e12a9b42a Added squid demo with pyqt5. 410103e36a Use moose.element to get the element. 8f71469d17 Merge pull request #42 from upibhalla/master 77f6694e0e cleanup of some rdesigneur tutorials 9a6f8e214e Merge branch 'master' of https://github.com/BhallaLab/moose-examples cc44a7e4fb Added demo for uniform spine placement, and putting them in a spiral 3a25620865 First commit for Electrophys tutorial directory 1502a55070 removed old script. 3b7a109b5e Merge branch 'master' of https://github.com/BhallaLab/moose-examples 4336dc3ae8 Fixed passiveDistrib argument list, got rid of unused '.' argument in a few examples c5e895f30e Updated ex7.5 and README 9f95a87909 Merge branch 'master' of https://github.com/BhallaLab/moose-examples 9ce8913fa5 Added 3 demos for dendritic transport git-subtree-dir: moose-examples git-subtree-split: e30d87a6374107d7f0494587dd3d868a22a58e20 * Squashed 'moose-gui/' changes from d226931e0b..c29cede420 c29cede420 hen vertical or horizontal layout is applied for group, compartment size is recalculated d76d66af1d Function moved to place other than parentpool location its pullback d03482329c color field is not editable for compartment, enzcplxpool and reaction 0a4b1cab43 compartment boundary is selected if its inside another compartment interior 02b9d3964f comparment size is calculated based on group sceneBoundingRect 8dae832c35 kkitViewcontrol both the groups size are updated if moved from-to is different 44b53bc56d default: addSolver->mooseAddChemSolver, kkitViewcontrol: while rubberbandselection if entire group is selected then delete if partly selected then delete all the items under the selection 80b599f85d mgui: is popup exist then close, objectedit: objectwindowTitle is updated with name when changed, kkit: in positionChange all the neutral is updated with size, kkitViewcontrol:when moose object is moved from Compt/group to group/compartment then mooseobject path is set and for qgraphicalItem and qlineitem objects the parentItem is set which will be grpItem or comptItem git-subtree-dir: moose-gui git-subtree-split: c29cede4201bd25dfe868aaaa9d227ea455410ae
1 parent 2d914db commit ba782a9

38 files changed

+2661
-587
lines changed
 

‎moose-core/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
130130

131131
if(WITH_BOOST)
132132
set(WITH_BOOST_ODE ON)
133+
set(WITH_GSL OFF)
133134
endif(WITH_BOOST)
134135

135136
# If using BOOST ODE2 library to solve ODE system, then don't use GSL.

‎moose-core/biophysics/Neuron.cpp

+21-9
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,17 @@ const Cinfo* Neuron::initCinfo()
315315
"The expression for the *spacing* field must evaluate to > 0 for "
316316
"the spine to be installed. For example, if the expresssion is\n"
317317
" H(1 - L) \n"
318-
"then the systemwill only put spines closer than "
318+
"then the system will only put spines closer than "
319319
"one length constant from the soma, and zero elsewhere. \n"
320320
"Available spine parameters are: \n"
321321
"spacing, minSpacing, size, sizeDistrib "
322-
"angle, angleDistrib \n",
322+
"angle, angleDistrib \n"
323+
"minSpacing sets the granularity of sampling (typically about 0.1*"
324+
"spacing) for the usual case where spines are spaced randomly. "
325+
"If minSpacing < 0 then the spines are spaced equally at "
326+
"'spacing', unless the dendritic segment length is smaller than "
327+
"'spacing'. In that case it falls back to the regular random "
328+
"placement method.",
323329
&Neuron::setSpineDistribution,
324330
&Neuron::getSpineDistribution
325331
);
@@ -1788,6 +1794,19 @@ static void addPos( unsigned int segIndex, unsigned int eIndex,
17881794
vector< unsigned int >& elistIndex,
17891795
vector< double >& pos )
17901796
{
1797+
if ( minSpacing < 0.0 ) {
1798+
// Use uniform spacing
1799+
for ( double position = spacing * 0.5;
1800+
position < dendLength; position += spacing ) {
1801+
seglistIndex.push_back( segIndex );
1802+
elistIndex.push_back( eIndex );
1803+
pos.push_back( position );
1804+
}
1805+
if ( dendLength > spacing * 0.5 )
1806+
return;
1807+
// If the dend length is too small for regular placement,
1808+
// fall back to using probability to decide if segment gets spine
1809+
}
17911810
if ( minSpacing < spacing * 0.1 && minSpacing < 1e-7 )
17921811
minSpacing = spacing * 0.1;
17931812
if ( minSpacing > spacing * 0.5 )
@@ -1860,13 +1879,6 @@ void Neuron::makeSpacingDistrib( const vector< ObjId >& elist,
18601879
{
18611880
double spacing = val[ j + nuParser::EXPR ];
18621881
double spacingDistrib = parser.eval( val.begin() + j );
1863-
if ( spacingDistrib > spacing || spacingDistrib < 0 )
1864-
{
1865-
cout << "Warning: Neuron::makeSpacingDistrib: " <<
1866-
"0 < " << spacingDistrib << " < " << spacing <<
1867-
" fails on " << elist[i].path() << ". Using 0.\n";
1868-
spacingDistrib = 0.0;
1869-
}
18701882
map< Id, unsigned int>::const_iterator
18711883
lookupDend = segIndex_.find( elist[i] );
18721884
if ( lookupDend != segIndex_.end() )

‎moose-core/ksolve/Ksolve.cpp

+6-10
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static const Cinfo* ksolveCinfo = Ksolve::initCinfo();
235235

236236
Ksolve::Ksolve()
237237
:
238-
#if USE_GSL
238+
#ifdef USE_GSL
239239
method_( "rk5" ),
240240
#elif USE_BOOST_ODE
241241
method_( "rk5a" ),
@@ -248,19 +248,12 @@ Ksolve::Ksolve()
248248
dsolve_(),
249249
dsolvePtr_( 0 )
250250
{
251+
;
251252
}
252253

253254
Ksolve::~Ksolve()
254255
{
255-
#if 0
256-
char* p = getenv( "MOOSE_SHOW_SOLVER_PERF" );
257-
if( p != NULL )
258-
{
259-
cout << "Info: Ksolve (+Dsolve) took " << totalTime_ << " seconds and took " << numSteps_
260-
<< " steps." << endl;
261-
262-
}
263-
#endif
256+
;
264257
}
265258

266259
//////////////////////////////////////////////////////////////
@@ -378,6 +371,7 @@ void Ksolve::setStoich( Id stoich )
378371
assert( stoich.element()->cinfo()->isA( "Stoich" ) );
379372
stoich_ = stoich;
380373
stoichPtr_ = reinterpret_cast< Stoich* >( stoich.eref().data() );
374+
381375
if ( !isBuilt_ )
382376
{
383377
OdeSystem ode;
@@ -386,6 +380,7 @@ void Ksolve::setStoich( Id stoich )
386380
// ode.initStepSize = getEstimatedDt();
387381
ode.initStepSize = 0.01; // This will be overridden at reinit.
388382
ode.method = method_;
383+
389384
#ifdef USE_GSL
390385
ode.gslSys.dimension = stoichPtr_->getNumAllPools();
391386
if ( ode.gslSys.dimension == 0 )
@@ -416,6 +411,7 @@ void Ksolve::setStoich( Id stoich )
416411
#endif
417412
isBuilt_ = true;
418413
}
414+
419415
}
420416

421417
Id Ksolve::getDsolve() const

‎moose-core/ksolve/OdeSystem.h

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ class OdeSystem {
2626
{;}
2727

2828
std::string method;
29-
// GSL stuff
29+
30+
double initStepSize;
31+
double epsAbs; // Absolute error
32+
double epsRel; // Relative error
3033

3134
#ifdef USE_GSL
35+
// GSL stuff
3236
gsl_odeiv2_system gslSys;
3337
const gsl_odeiv2_step_type* gslStep;
3438
#endif
35-
double initStepSize;
36-
double epsAbs; // Absolute error
37-
double epsRel; // Relative error
3839

3940
#if USE_BOOST_ODE
4041
size_t dimension;

‎moose-core/ksolve/SteadyStateBoost.cpp

+48-73
Original file line numberDiff line numberDiff line change
@@ -85,27 +85,6 @@ struct reac_info
8585

8686
const Cinfo* SteadyState::initCinfo()
8787
{
88-
/**
89-
* This picks up the entire Stoich data structure
90-
static Finfo* gslShared[] =
91-
{
92-
new SrcFinfo( "reinitSrc", Ftype0() ),
93-
new DestFinfo( "assignStoich",
94-
Ftype1< void* >(),
95-
RFCAST( &SteadyState::assignStoichFunc )
96-
),
97-
new DestFinfo( "setMolN",
98-
Ftype2< double, unsigned int >(),
99-
RFCAST( &SteadyState::setMolN )
100-
),
101-
new SrcFinfo( "requestYsrc", Ftype0() ),
102-
new DestFinfo( "assignY",
103-
Ftype1< double* >(),
104-
RFCAST( &SteadyState::assignY )
105-
),
106-
};
107-
*/
108-
10988
/**
11089
* These are the fields of the SteadyState class
11190
*/
@@ -207,59 +186,59 @@ const Cinfo* SteadyState::initCinfo()
207186
// MsgDest definitions
208187
///////////////////////////////////////////////////////
209188
static DestFinfo setupMatrix( "setupMatrix",
210-
"This function initializes and rebuilds the matrices used "
211-
"in the calculation.",
212-
new OpFunc0< SteadyState >(&SteadyState::setupMatrix)
213-
);
189+
"This function initializes and rebuilds the matrices used "
190+
"in the calculation.",
191+
new OpFunc0< SteadyState >(&SteadyState::setupMatrix)
192+
);
214193

215194
static DestFinfo settle( "settle",
216-
"Finds the nearest steady state to the current initial "
217-
"conditions. This function rebuilds the entire calculation "
218-
"only if the object has not yet been initialized.",
219-
new OpFunc0< SteadyState >( &SteadyState::settleFunc )
220-
);
195+
"Finds the nearest steady state to the current initial "
196+
"conditions. This function rebuilds the entire calculation "
197+
"only if the object has not yet been initialized.",
198+
new OpFunc0< SteadyState >( &SteadyState::settleFunc )
199+
);
221200
static DestFinfo resettle( "resettle",
222-
"Finds the nearest steady state to the current initial "
223-
"conditions. This function rebuilds the entire calculation ",
224-
new OpFunc0< SteadyState >( &SteadyState::resettleFunc )
225-
);
201+
"Finds the nearest steady state to the current initial "
202+
"conditions. This function rebuilds the entire calculation ",
203+
new OpFunc0< SteadyState >( &SteadyState::resettleFunc )
204+
);
226205
static DestFinfo showMatrices( "showMatrices",
227-
"Utility function to show the matrices derived for the calculations on the reaction system. Shows the Nr, gamma, and total matrices",
228-
new OpFunc0< SteadyState >( &SteadyState::showMatrices )
229-
);
206+
"Utility function to show the matrices derived for the calculations on the reaction system. Shows the Nr, gamma, and total matrices",
207+
new OpFunc0< SteadyState >( &SteadyState::showMatrices )
208+
);
230209
static DestFinfo randomInit( "randomInit",
231-
"Generate random initial conditions consistent with the mass"
232-
"conservation rules. Typically invoked in order to scan"
233-
"states",
234-
new EpFunc0< SteadyState >(
235-
&SteadyState::randomizeInitialCondition )
236-
);
210+
"Generate random initial conditions consistent with the mass"
211+
"conservation rules. Typically invoked in order to scan"
212+
"states",
213+
new EpFunc0< SteadyState >(
214+
&SteadyState::randomizeInitialCondition )
215+
);
237216
///////////////////////////////////////////////////////
238217
// Shared definitions
239218
///////////////////////////////////////////////////////
240219

241220
static Finfo * steadyStateFinfos[] =
242221
{
243-
&stoich, // Value
244-
&badStoichiometry, // ReadOnlyValue
245-
&isInitialized, // ReadOnlyValue
246-
&nIter, // ReadOnlyValue
247-
&status, // ReadOnlyValue
248-
&maxIter, // Value
249-
&convergenceCriterion, // ReadOnlyValue
250-
&numVarPools, // ReadOnlyValue
251-
&rank, // ReadOnlyValue
252-
&stateType, // ReadOnlyValue
253-
&nNegEigenvalues, // ReadOnlyValue
254-
&nPosEigenvalues, // ReadOnlyValue
255-
&solutionStatus, // ReadOnlyValue
256-
&total, // LookupValue
257-
&eigenvalues, // ReadOnlyLookupValue
258-
&setupMatrix, // DestFinfo
259-
&settle, // DestFinfo
260-
&resettle, // DestFinfo
261-
&showMatrices, // DestFinfo
262-
&randomInit, // DestFinfo
222+
&stoich, // Value
223+
&badStoichiometry, // ReadOnlyValue
224+
&isInitialized, // ReadOnlyValue
225+
&nIter, // ReadOnlyValue
226+
&status, // ReadOnlyValue
227+
&maxIter, // Value
228+
&convergenceCriterion, // ReadOnlyValue
229+
&numVarPools, // ReadOnlyValue
230+
&rank, // ReadOnlyValue
231+
&stateType, // ReadOnlyValue
232+
&nNegEigenvalues, // ReadOnlyValue
233+
&nPosEigenvalues, // ReadOnlyValue
234+
&solutionStatus, // ReadOnlyValue
235+
&total, // LookupValue
236+
&eigenvalues, // ReadOnlyLookupValue
237+
&setupMatrix, // DestFinfo
238+
&settle, // DestFinfo
239+
&resettle, // DestFinfo
240+
&showMatrices, // DestFinfo
241+
&randomInit, // DestFinfo
263242

264243

265244
};
@@ -278,7 +257,7 @@ const Cinfo* SteadyState::initCinfo()
278257
"Note that the method finds unstable as well as stable fixed "
279258
"points.\n "
280259
"The SteadyState class also provides a utility function "
281-
"*randomInit()* to "
260+
"*randomInit()* to "
282261
"randomly initialize the concentrations, within the constraints "
283262
"of stoichiometry. This is useful if you are trying to find "
284263
"the major fixed points of the system. Note that this is "
@@ -368,12 +347,10 @@ void SteadyState::setStoich( Id value )
368347
numVarPools_ = Field< unsigned int >::get( stoich_, "numVarPools" );
369348
nReacs_ = Field< unsigned int >::get( stoich_, "numRates" );
370349
setupSSmatrix();
371-
double vol = LookupField< unsigned int, double >::get(
372-
stoichPtr->getCompartment(), "oneVoxelVolume", 0 );
350+
double vol = LookupField< unsigned int, double >::get(stoichPtr->getCompartment(), "oneVoxelVolume", 0 );
373351
pool_.setVolume( vol );
374352
pool_.setStoich( stoichPtr, 0 );
375-
pool_.updateAllRateTerms( stoichPtr->getRateTerms(),
376-
stoichPtr->getNumCoreRates() );
353+
pool_.updateAllRateTerms( stoichPtr->getRateTerms(), stoichPtr->getNumCoreRates() );
377354
isInitialized_ = 1;
378355
}
379356

@@ -513,9 +490,9 @@ void SteadyState::showMatrices()
513490
return;
514491
}
515492
int numConsv = numVarPools_ - rank_;
516-
cout << "Totals: ";
493+
cout << "Totals: ";
517494
for ( int i = 0; i < numConsv; ++i )
518-
cout << total_[i] << " ";
495+
cout << total_[i] << " ";
519496
cout << endl;
520497
cout << "gamma " << gamma_ << endl;
521498
cout << "Nr " << Nr_ << endl;
@@ -549,9 +526,7 @@ void SteadyState::setupSSmatrix()
549526
{
550527
double x = 0;
551528
if ( j == colIndex[k] && k < rowStart[i+1] )
552-
{
553529
x = entry[k++];
554-
}
555530
N(i,j) = x;
556531
LU_(i,j) = x;
557532
}
@@ -714,7 +689,7 @@ static bool isSolutionValid( const vector< double >& x )
714689
for( size_t i = 0; i < x.size(); i++ )
715690
{
716691
double v = x[i];
717-
if ( std::isnan( v ) or std::isinf( v ) )
692+
if ( std::isnan( v ) || std::isinf( v ) )
718693
{
719694
cout << "Warning: SteadyState iteration gave nan/inf concs\n";
720695
return false;

0 commit comments

Comments
 (0)
Please sign in to comment.