Skip to content

Commit 4de9cc7

Browse files
authored
Combined 391+386+337+281 (#392)
* Hotfix | some old scripts in moose-examples failed because of regression caused by #390. * Added graph utility. Renamed to network_utils. Imported by default when moose.utils is imported. Renamed functions. * Added Boost ODE based solvers of MarkovChannel. Now GSL is optional. Renamed MarkovGslSolver class to MarkovOdeSolver. It compiles with both boost and gsl. * This is squashed version of #281 - Added new solver based on 'LSODA' method. This is a CPP version of the LSODA library for integration into MOOSE simulator. These source code are released under MIT license which is compatible with MOOSE. See Credit below. Adds three tests (1 python). Results are equivalent to scipy's lsoda solver. Following changes are made to this version: Used <array> and <vector> instead of raw array where-ever possible. Craeted a class LSODA and added a function to integrate it smoothly with moose. Various tweaks in various functions especially initialization. Core computing functions starts with index 1 rather than 0; this is hidden away from MOOSE api. The performance of this solver is really good. In debug mode, on a small model, I got 6.7x speedup without any multi-threading. The solver is not recommended for stiff systems. Once it is integrated we do more profiling vis-a-vis standard RK5 solver. - Licensing Work by Heng Li was released under MIT Incense which is less restrictive than GNU-GPLv3. See here. The LSODA class is released under the same license. - Logs https://docs.google.com/document/d/e/2PACX-1vQ3wU9xiMSMVcluDrNSzuSGHsttOqAqc8xN4a9qo7wFfYjwl-0KhKyY1LlM5XkQ_5CqJd3eFnUCYiAb/pub - Credit The original was aquired from http://www.ccl.net/cca/software/SOURCES/C/kinetics2/index.shtml and modified by Heng Li lh3lh3@gmail.com. Heng merged several C files into one and added a simpler interface. His version can be found http://lh3lh3.users.sourceforge.net/download/lsoda.c .
1 parent 9489bbd commit 4de9cc7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+5166
-1919
lines changed

.travis.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,3 @@ before_script:
3232
script:
3333
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.ci/travis_build_osx.sh; fi
3434
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./.ci/travis_build_linux.sh; fi
35-
36-
after_success:
37-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then\
38-
mkdir _sdist && cd _sdist && cmake .. && make sdist && make upload_test;\
39-
fi

CMakeLists.txt

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ if(WITH_ASAN AND "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
102102
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=address")
103103
endif()
104104

105+
if(WITH_GSL)
106+
set(WITH_BOOST OFF)
107+
set(WITH_BOOST_ODE OFF)
108+
elseif(WITH_BOOST)
109+
set(WITH_BOOST_ODE ON)
110+
set(WITH_GSL OFF)
111+
endif()
112+
105113
################################### TARGETS ####################################
106114

107115
link_directories(${CMAKE_BINARY_DIR})
@@ -112,17 +120,6 @@ add_executable(moose.bin basecode/main.cpp)
112120
################################### SETUP BUILD ################################
113121
# default include paths.
114122
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
115-
116-
if(WITH_BOOST)
117-
set(WITH_BOOST_ODE ON)
118-
set(WITH_GSL OFF)
119-
endif(WITH_BOOST)
120-
121-
# If using BOOST ODE2 library to solve ODE system, then don't use GSL.
122-
if(WITH_BOOST_ODE)
123-
set(WITH_GSL OFF)
124-
endif(WITH_BOOST_ODE)
125-
126123
set_target_properties(libmoose PROPERTIES COMPILE_DEFINITIONS "MOOSE_LIB")
127124
set_target_properties(libmoose PROPERTIES PREFIX "")
128125

@@ -235,6 +232,7 @@ add_subdirectory(benchmarks)
235232
add_subdirectory(kinetics)
236233
add_subdirectory(synapse)
237234
add_subdirectory(intfire)
235+
add_subdirectory(external/libsoda)
238236

239237
###################################### LINKING #################################
240238
list(APPEND MOOSE_LIBRARIES
@@ -255,6 +253,7 @@ list(APPEND MOOSE_LIBRARIES
255253
signeur
256254
diffusion
257255
ksolve
256+
lsoda
258257
device
259258
basecode
260259
)

basecode/global.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,22 @@ namespace moose {
144144
if( p.size() == 0 )
145145
return true;
146146

147+
#ifdef USE_BOOST_FILESYSTEM
148+
try
149+
{
150+
boost::filesystem::path pdirs( p );
151+
boost::filesystem::create_directories( pdirs );
152+
LOG( moose::info, "Created directory " << p );
153+
return true;
154+
}
155+
catch(const boost::filesystem::filesystem_error& e)
156+
{
157+
LOG( moose::warning, "create_directories(" << p << ") failed with "
158+
<< e.code().message()
159+
);
160+
return false;
161+
}
162+
#else /* ----- not USE_BOOST_FILESYSTEM ----- */
147163
string command( "mkdir -p ");
148164
command += p;
149165
int ret = system( command.c_str() );
@@ -163,6 +179,7 @@ namespace moose {
163179
LOG( moose::warning, p << " is no directory" );
164180
return false;
165181
}
182+
#endif /* ----- not USE_BOOST_FILESYSTEM ----- */
166183
return true;
167184
}
168185

basecode/global.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
#include <sstream>
1818
#include <valarray>
1919

20-
#include "../randnum/RNG.h" /* Use inbuilt rng */
20+
21+
#ifdef USE_BOOST_FILESYSTEM
22+
#include <boost/filesystem.hpp>
23+
#endif
24+
25+
#include "randnum/RNG.h" /* Use inbuilt rng */
2126
#include "../utility/print_function.hpp"
2227

2328
using namespace std;

basecode/main.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ int testIndex = 0;
3535
f; \
3636
cout << std::right << " [DONE]" << endl; \
3737

38-
extern void testSync();
3938
extern void testAsync();
4039
extern void testSyncArray( unsigned int size, unsigned int method );
4140
extern void testShell();
@@ -67,9 +66,9 @@ extern void testSigNeurProcess();
6766
extern unsigned int initMsgManagers();
6867
extern void destroyMsgManagers();
6968
// void regressionTests();
70-
#endif
71-
extern void speedTestMultiNodeIntFireNetwork(
72-
unsigned int size, unsigned int runsteps );
69+
#endif // DO_UNIT_TESTS
70+
71+
extern void speedTestMultiNodeIntFireNetwork(unsigned int size, unsigned int runsteps);
7372

7473
#ifdef USE_SMOLDYN
7574
extern void testSmoldyn();

biophysics/CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ cmake_minimum_required(VERSION 2.8)
22
include(${CMAKE_CURRENT_SOURCE_DIR}/../CheckCXXCompiler.cmake)
33

44
if(WITH_GSL)
5+
find_package(GSL 1.16)
56
include_directories(${GSL_INCLUDE_DIRS})
7+
elseif(WITH_BOOST_ODE)
8+
find_package(Boost)
9+
include_directories(${Boost_INCLUDE_DIRS})
610
endif(WITH_GSL)
711

812
set(BIOPHYSICS_SRCS
@@ -32,7 +36,6 @@ set(BIOPHYSICS_SRCS
3236
ReadSwc.cpp
3337
SynChan.cpp
3438
NMDAChan.cpp
35-
testBiophysics.cpp
3639
IzhikevichNrn.cpp
3740
DifShellBase.cpp
3841
DifShell.cpp
@@ -48,10 +51,9 @@ set(BIOPHYSICS_SRCS
4851
MarkovSolver.cpp
4952
VClamp.cpp
5053
Spine.cpp
54+
MarkovOdeSolver.cpp
55+
testBiophysics.cpp
5156
)
5257

53-
if(WITH_GSL)
54-
list(APPEND BIOPHYSICS_SRCS MarkovGslSolver.cpp)
55-
endif(WITH_GSL)
58+
add_library(biophysics ${BIOPHYSICS_SRCS})
5659

57-
add_library( biophysics ${BIOPHYSICS_SRCS} )

0 commit comments

Comments
 (0)