diff --git a/moose-core/.travis.yml b/moose-core/.travis.yml index a88c1f75306724a1614f40053e866de64a8e330c..7a134ba7fc4a69d462617c4e22315e601ab2edfb 100644 --- a/moose-core/.travis.yml +++ b/moose-core/.travis.yml @@ -10,6 +10,8 @@ os: notifications: email: recipients: + - bhalla@ncbs.res.in + - hrani@ncbs.res.in - dilawar.s.rajput@gmail.com on_success: change on_failure: always @@ -30,6 +32,6 @@ before_script : script: - # checking if any python3 incompatible file is in the source tree. - python2 -m compileall -q . - - if type python3 -c 'import sys' > /dev/null; then python3 -m compileall -q . ; fi + - if type python3 > /dev/null; then python3 -m compileall -q . ; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis/travis_build_osx.sh; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./.travis/travis_build_linux.sh; fi diff --git a/moose-core/.travis/travis_build_linux.sh b/moose-core/.travis/travis_build_linux.sh index cf3399695355795695fe42b8d668b8baa80e2d21..b993e109f7ec82154791414896c6b02e5b7c645c 100755 --- a/moose-core/.travis/travis_build_linux.sh +++ b/moose-core/.travis/travis_build_linux.sh @@ -30,8 +30,8 @@ PYTHON3="/usr/bin/python3" ( # Old makefile based flow. - python2 -m compileall -q . - if type $PYTHON3 > /dev/null; then python3 -m compileall -q . ; fi + $PYTHON2 -m compileall -q . + if type $PYTHON3 > /dev/null; then $PYTHON3 -m compileall -q . ; fi # Traditional make. make ## CMAKE based flow diff --git a/moose-core/biophysics/Neuron.cpp b/moose-core/biophysics/Neuron.cpp index 002952ac7780ea7d270dce08f1b07fb61c403965..cf30533641f7a385d5f10351cf1c3fd419853809 100644 --- a/moose-core/biophysics/Neuron.cpp +++ b/moose-core/biophysics/Neuron.cpp @@ -14,11 +14,10 @@ #include "shell/Wildcard.h" #include "ReadCell.h" #include "utility/Vec.h" -#include "randnum/Normal.h" -#include "randnum/randnum.h" #include "SwcSegment.h" #include "Spine.h" #include "Neuron.h" +#include "basecode/global.h" #include "muParser.h" @@ -1737,7 +1736,7 @@ static void addPos( unsigned int segIndex, unsigned int eIndex, unsigned int n = 1 + dendLength / minSpacing; double dx = dendLength / n; for( unsigned int i = 0; i < n; ++i ) { - if ( mtrand() < dx / spacing ) { + if ( moose::mtrand() < dx / spacing ) { seglistIndex.push_back( segIndex ); elistIndex.push_back( eIndex ); pos.push_back( i * dx + dx*0.5 ); @@ -1758,12 +1757,12 @@ static void addPos( unsigned int segIndex, unsigned int eIndex, { if ( spacingDistrib > 0.0 ) { double position = spacing * 0.5 + - ( mtrand() - 0.5 ) * spacingDistrib; + ( moose::mtrand() - 0.5 ) * spacingDistrib; while ( position < dendLength ) { seglistIndex.push_back( segIndex ); elistIndex.push_back( eIndex ); pos.push_back( position ); - position += spacing + ( mtrand() - 0.5 ) * spacingDistrib; + position += spacing + ( moose::mtrand() - 0.5 ) * spacingDistrib; } } else { for ( double position = spacing * 0.5; @@ -1846,7 +1845,7 @@ static void makeAngleDistrib ( const vector< ObjId >& elist, angleDistrib = distribParser.eval( val.begin() + j); } if ( angleDistrib > 0 ) - theta[k] = angle + ( mtrand() - 0.5 ) * angleDistrib; + theta[k] = angle + ( moose::mtrand() - 0.5 ) * angleDistrib; else theta[k] = angle; } @@ -1883,7 +1882,7 @@ static void makeSizeDistrib ( const vector< ObjId >& elist, sizeDistrib = distribParser.eval( val.begin() + j); } if ( sizeDistrib > 0 ) - size[k] = sz + ( mtrand() - 0.5 ) * sizeDistrib; + size[k] = sz + ( moose::mtrand() - 0.5 ) * sizeDistrib; else size[k] = sz; } diff --git a/moose-core/kinetics/Pool.cpp b/moose-core/kinetics/Pool.cpp index 691daf295c3b0242c87743d18ffd54b0883def95..8b8b656148f78c6a0390f22471e05eb29fea80a4 100644 --- a/moose-core/kinetics/Pool.cpp +++ b/moose-core/kinetics/Pool.cpp @@ -8,6 +8,7 @@ **********************************************************************/ #include "header.h" +#include "ElementValueFinfo.h" #include "lookupVolumeFromMesh.h" #include "PoolBase.h" #include "Pool.h" @@ -19,6 +20,16 @@ const Cinfo* Pool::initCinfo() ////////////////////////////////////////////////////////////// // Field Definitions: All inherited from PoolBase. ////////////////////////////////////////////////////////////// + static ElementValueFinfo< Pool, bool > isBuffered( + "isBuffered", + "Flag: True if Pool is buffered. This field changes the " + "type of the Pool object to BufPool, or vice versa. " + "None of the messages are affected. " + "This object class flip can only be done in the non-zombified " + "form of the Pool.", + &Pool::setIsBuffered, + &Pool::getIsBuffered + ); ////////////////////////////////////////////////////////////// // MsgDest Definitions: All but increment and decrement inherited @@ -45,9 +56,10 @@ const Cinfo* Pool::initCinfo() // SharedMsg Definitions: All inherited. ////////////////////////////////////////////////////////////// static Finfo* poolFinfos[] = { + &isBuffered, // ElementValueFinfo &increment, // DestFinfo &decrement, // DestFinfo - &nIn, + &nIn, // DestFinfo }; static Dinfo< Pool > dinfo; @@ -78,6 +90,33 @@ Pool::Pool() Pool::~Pool() {;} +////////////////////////////////////////////////////////////// +// Field Definitions +/** + * setIsBuffered is a really nasty operation, made possible only because + * BufPool is derived from Pool and has no other fields. + * It uses a low-level replaceCinfo call to just change the + * identity of the Cinfo used, leaving everything else as is. + */ +void Pool::setIsBuffered( const Eref& e, bool v ) +{ + static const Cinfo* bufPoolCinfo = Cinfo::find( "BufPool" ); + if (getIsBuffered( e ) == v) + return; + if (v) { + e.element()->replaceCinfo( bufPoolCinfo ); + } else { + e.element()->replaceCinfo( poolCinfo ); + } +} + +bool Pool::getIsBuffered( const Eref& e ) const +{ + return e.element()->cinfo()->name() == "BufPool"; +} + +////////////////////////////////////////////////////////////// +// ////////////////////////////////////////////////////////////// // MsgDest Definitions ////////////////////////////////////////////////////////////// diff --git a/moose-core/kinetics/Pool.h b/moose-core/kinetics/Pool.h index dc45e189b21b7adfd328c21833e7fb03db48ff2f..dec4dfa4f136057f79545254448ff89fa2d53227 100644 --- a/moose-core/kinetics/Pool.h +++ b/moose-core/kinetics/Pool.h @@ -53,6 +53,13 @@ class Pool: public PoolBase void vSetSpecies( const Eref& e, SpeciesId v ); SpeciesId vGetSpecies( const Eref& e ) const; + + /** + * Functions to examine and change class between Pool and BufPool. + */ + void setIsBuffered( const Eref& e, bool v ); + bool getIsBuffered( const Eref& e ) const; + ////////////////////////////////////////////////////////////////// // Dest funcs. These too override virtual funcs in the Pool base // class. diff --git a/moose-core/pymoose/moosemodule.cpp b/moose-core/pymoose/moosemodule.cpp index 62a9ea2eb85cc6c16ab8bd9dd145e39eeebc8421..1ac1d91f6c8737b1bca5fc6b3d99b5332a4b0668 100644 --- a/moose-core/pymoose/moosemodule.cpp +++ b/moose-core/pymoose/moosemodule.cpp @@ -125,7 +125,7 @@ extern void mooseBenchmarks( unsigned int option ); * themselves. If seed is not set by user, it uses std::random_device to * initialize itself. *-----------------------------------------------------------------------------*/ -void pymoose_mtseed_( unsigned int seed ) +void pymoose_mtseed_( long int seed ) { moose::mtseed( seed ); } diff --git a/moose-core/python/moose/__init__.py b/moose-core/python/moose/__init__.py index a1a77c0ea7e188ed7e3ef16b5cf2e246e7861c1c..2e2f6772607e82d4ad79b68e78782f4c109e5d30 100644 --- a/moose-core/python/moose/__init__.py +++ b/moose-core/python/moose/__init__.py @@ -26,8 +26,7 @@ from .moose import * # Wrapper to get moose version information. __version__ = moose._moose.__version__ + VERSION = moose._moose.VERSION -import chemUtil.add_Delete_ChemicalSolver -import chemUtil.chemConnectUtil -import chemUtil.graphUtils \ No newline at end of file +# NOTE: No module should be imported here. Use moose.py to write imports. diff --git a/moose-core/python/moose/chemUtil/add_Delete_ChemicalSolver.py b/moose-core/python/moose/chemUtil/add_Delete_ChemicalSolver.py index 6d5886f19bd5a003a5a1fa4a960ad5a5b4774809..af9437b92dd886e39e4644a60f15579f3f76d525 100644 --- a/moose-core/python/moose/chemUtil/add_Delete_ChemicalSolver.py +++ b/moose-core/python/moose/chemUtil/add_Delete_ChemicalSolver.py @@ -24,11 +24,11 @@ def mooseaddChemSolver(modelRoot, solver): comptinfo = moose.Annotator(moose.element(compt[0]).path + '/info') previousSolver = comptinfo.solver currentSolver = previousSolver - if solver == "Gillespie": + if solver == "Gillespie" or solver == "gssa": currentSolver = "gssa" - elif solver == "Runge Kutta": + elif solver == "Runge Kutta" or solver == "gsl": currentSolver = "gsl" - elif solver == "Exponential Euler": + elif solver == "Exponential Euler" or solver == "ee": currentSolver = "ee" if previousSolver != currentSolver: diff --git a/moose-core/randnum/RNG.h b/moose-core/randnum/RNG.h index 09dbdf05a691d74a36cded4f7012bb33388da654..8fe38b64c1a19168271e8ae627f6d8bddb9a8828 100644 --- a/moose-core/randnum/RNG.h +++ b/moose-core/randnum/RNG.h @@ -57,6 +57,14 @@ class RNG RNG () /* constructor */ { // Setup a random seed if possible. + setRandomSeed( ); + } + + ~RNG () /* destructor */ + { ; } + + void setRandomSeed( ) + { #if defined(USE_BOOST) #if defined(BOOST_RANDOM_DEVICE_EXISTS) boost::random::random_device rd; @@ -68,12 +76,6 @@ class RNG #else mtseed( time(NULL) ); #endif /* ----- not ENABLE_CPP11 ----- */ - - } - - ~RNG () /* destructor */ - { - } /* ==================== ACCESSORS ======================================= */ @@ -83,9 +85,21 @@ class RNG } /* ==================== MUTATORS ======================================= */ + /** + * @brief If seed if 0 then set seed to a random number else set seed to + * the given number. + * + * @param seed + */ void setSeed( const unsigned long int seed ) { seed_ = seed; + if( seed == 0 ) + { + setRandomSeed( ); + return; + } + #if defined(USE_BOOST) || defined(ENABLE_CPP11) rng_.seed( seed_ ); #else