From 3d29c347ad6f886f9dc403c51d5f455a6a1df9aa Mon Sep 17 00:00:00 2001 From: Valentin Sulzer Date: Thu, 24 Oct 2019 21:32:19 -0400 Subject: [PATCH 01/13] #646 add installation instructions for Mac and comments from #673 --- INSTALL-LINUX.md => INSTALL-LINUX-MAC.md | 61 ++- PyBaMM-env/.Python | 1 + PyBaMM-env/include/python2.7 | 1 + PyBaMM-env/include/python3.7m | 1 + PyBaMM-env/man/man1/nosetests.1 | 581 +++++++++++++++++++++++ README.md | 6 +- scripts/install_scikits_odes.sh | 3 +- 7 files changed, 636 insertions(+), 18 deletions(-) rename INSTALL-LINUX.md => INSTALL-LINUX-MAC.md (68%) create mode 120000 PyBaMM-env/.Python create mode 120000 PyBaMM-env/include/python2.7 create mode 120000 PyBaMM-env/include/python3.7m create mode 100644 PyBaMM-env/man/man1/nosetests.1 diff --git a/INSTALL-LINUX.md b/INSTALL-LINUX-MAC.md similarity index 68% rename from INSTALL-LINUX.md rename to INSTALL-LINUX-MAC.md index bd5b227d61..aeab75eafb 100644 --- a/INSTALL-LINUX.md +++ b/INSTALL-LINUX-MAC.md @@ -5,11 +5,25 @@ You'll need the following requirements: - Python 3.6+ - Git (`git` package on Ubuntu distributions) - Python libraries: `venv` (`python3-venv` package on Ubuntu distributions) +- Python graphical user interface (python3-tk) +- Graph visualization software (graphviz) You can get these on a Debian based distribution using `apt-get` ```bash -sudo apt-get install python3 git-core python3-venv +sudo apt-get install python3 git-core python3-venv python3-tk graphviz +``` + +or on Mac OS based distributions by [installing `brew`](https://docs.python-guide.org/starting/install3/osx/): + +```bash +ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +``` + +following instructions in link on adding brew to path, and then running + +```bash +brew install python3 git graphviz ``` ## Install PyBaMM @@ -21,8 +35,8 @@ git clone https://github.com/pybamm-team/PyBaMM.git cd PyBaMM ``` -The safest way to install PyBaMM is to do so within a virtual environment ([introduction -to virtual environments](https://realpython.com/python-virtual-environments-a-primer/)). +The safest way to install PyBaMM is to do so within a virtual environment ([a good introduction +to virtual environments to understand how these work](https://realpython.com/python-virtual-environments-a-primer/)). To create a virtual environment `env` within your current directory type: ```bash @@ -43,8 +57,9 @@ original system, just type: deactivate ``` -PyBaMM has the following python libraries as dependencies: `numpy`, `scipy`, `pandas`, -`matplotlib`. These will be installed automatically when you install PyBaMM using `pip`, +Whenever you close the terminal, or shut down, the environment is deactivated automatically. To go back into it, just run `source env/bin/activate` - this re-opens the same environment and the installs do not need to be rerun. + +PyBaMM has some libraries, such as `numpy` and `scipy`, as dependencies (a full list is available [here](./setup.py), [here](./.requirements-docs.txt) or [here](https://github.com/pybamm-team/PyBaMM/network/dependencies)). These will be installed automatically when you install PyBaMM using `pip`, following the instructions below. First, make sure you have activated your virtual environment as above, and that you have the latest version of pip installed: @@ -54,18 +69,20 @@ pip install --upgrade pip Then navigate to the path where you downloaded PyBaMM to (you will already be in the correct location if you followed the instructions above), and install both PyBaMM and -its dependencies by typing: +its dependencies, either by typing: ```bash pip install . ``` -Or, if you want to install PyBaMM as a [developer](CONTRIBUTING.md), use +or if you want to install PyBaMM as a [developer](CONTRIBUTING.md) by typing ```bash pip install -e .[dev,docs] ``` +Note that it's fine to first run `pip install .` and then `pip install -e .[dev,docs]`; any packages that are already installed are skipped over. + To check whether PyBaMM has installed properly, you can run the tests: ```bash @@ -89,12 +106,12 @@ The Sundials DAE solver is required to solve the DFN battery model in PyBaMM. Before installing scikits.odes, you need to have installed: -- Python header files (`python-dev/python3-dev` on Debian/Ubuntu-based distributions) +- Python header files (`python-dev/python3-dev` on Debian/Ubuntu-based distributions, comes with python3 by default in brew) - C compiler -- Fortran compiler (e.g. gfortran) +- Fortran compiler (e.g. gfortran, comes with gcc in brew) - BLAS/LAPACK install (OpenBLAS is recommended by the scikits.odes developers) - CMake (for building Sundials) -- Sundials 3.1.1 +- Sundials 3.1.1 (see instructions below) You can install these on Ubuntu or Debian using apt-get: @@ -102,6 +119,12 @@ You can install these on Ubuntu or Debian using apt-get: sudo apt-get install python3-dev gfortran gcc cmake libopenblas-dev ``` +or on a Mac OS distribution using brew: + +```bash +brew install gcc cmake openblas +``` + To install Sundials 3.1.1, on the command-line type: ```bash @@ -121,15 +144,21 @@ Then install [scikits.odes](https://github.com/bmcage/odes), letting it know the SUNDIALS_INST=$INSTALL_DIR pip install scikits.odes ``` -After this, you will need to set your `LD_LIBRARY_PATH` to point to the sundials -library: +After this, you will need to set your `LD_LIBRARY_PATH` (for Linux) or `DYLD_LIBRARY_PATH` (for Mac) to point to the sundials +library - for Linux: ```bash export LD_LIBRARY_PATH=$INSTALL_DIR/lib:$LD_LIBRARY_PATH ``` -You may wish to put this last line in your `.bashrc` or virtualenv `activate` script, -which will save you needing to set your `LD_LIBRARY_PATH` every time you log in. For +or for Mac: + +```bash +export DYLD_LIBRARY_PATH=$INSTALL_DIR/lib:$DYLD_LIBRARY_PATH +``` + +You may wish to put one of these lines in your `.bashrc` or virtualenv `activate` script, +which will save you needing to set your `LD_LIBRARY_PATH` or `DYLD_LIBRARY_PATH` every time you log in. For example, to add this line to your `.bashrc` you can type: ```bash @@ -149,13 +178,13 @@ when I run my Python script. -e .`. This sets the installed location of the source files to your current directory. **Problem:** When running `python run-tests.py --quick`, gives error `FileNotFoundError: -[Errno 2] No such file or directory: 'flake8': 'flake8`. +[Errno 2] No such file or directory: 'flake8': 'flake8'. **Solution:** make sure you have included the `[dev,docs]` flags when you pip installed PyBaMM, i.e. `pip install -e .[dev,docs]` **Problem:** Errors when solving model `ValueError: Integrator name ida does not -exsist`, or `ValueError: Integrator name cvode does not exsist`. +exsist`, or `ValueError: Integrator name cvode does not exist`. **Solution:** This could mean that you have not installed `scikits.odes` correctly, check the instrutions given above and make sure each command was successful. diff --git a/PyBaMM-env/.Python b/PyBaMM-env/.Python new file mode 120000 index 0000000000..97d19b23c4 --- /dev/null +++ b/PyBaMM-env/.Python @@ -0,0 +1 @@ +/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/Python \ No newline at end of file diff --git a/PyBaMM-env/include/python2.7 b/PyBaMM-env/include/python2.7 new file mode 120000 index 0000000000..3fe034fccc --- /dev/null +++ b/PyBaMM-env/include/python2.7 @@ -0,0 +1 @@ +/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 \ No newline at end of file diff --git a/PyBaMM-env/include/python3.7m b/PyBaMM-env/include/python3.7m new file mode 120000 index 0000000000..1acc697a01 --- /dev/null +++ b/PyBaMM-env/include/python3.7m @@ -0,0 +1 @@ +/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m \ No newline at end of file diff --git a/PyBaMM-env/man/man1/nosetests.1 b/PyBaMM-env/man/man1/nosetests.1 new file mode 100644 index 0000000000..577284569c --- /dev/null +++ b/PyBaMM-env/man/man1/nosetests.1 @@ -0,0 +1,581 @@ +.\" Man page generated from reStructuredText. +. +.TH "NOSETESTS" "1" "April 04, 2015" "1.3" "nose" +.SH NAME +nosetests \- Nicer testing for Python +. +.nr rst2man-indent-level 0 +. +.de1 rstReportMargin +\\$1 \\n[an-margin] +level \\n[rst2man-indent-level] +level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] +- +\\n[rst2man-indent0] +\\n[rst2man-indent1] +\\n[rst2man-indent2] +.. +.de1 INDENT +.\" .rstReportMargin pre: +. RS \\$1 +. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] +. nr rst2man-indent-level +1 +.\" .rstReportMargin post: +.. +.de UNINDENT +. RE +.\" indent \\n[an-margin] +.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] +.nr rst2man-indent-level -1 +.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] +.in \\n[rst2man-indent\\n[rst2man-indent-level]]u +.. +.SH NICER TESTING FOR PYTHON +.SS SYNOPSIS +.INDENT 0.0 +.INDENT 3.5 +nosetests [options] [names] +.UNINDENT +.UNINDENT +.SS DESCRIPTION +.sp +nose collects tests automatically from python source files, +directories and packages found in its working directory (which +defaults to the current working directory). Any python source file, +directory or package that matches the testMatch regular expression +(by default: \fI(?:^|[b_.\-])[Tt]est)\fP will be collected as a test (or +source for collection of tests). In addition, all other packages +found in the working directory will be examined for python source files +or directories that match testMatch. Package discovery descends all +the way down the tree, so package.tests and package.sub.tests and +package.sub.sub2.tests will all be collected. +.sp +Within a test directory or package, any python source file matching +testMatch will be examined for test cases. Within a test module, +functions and classes whose names match testMatch and TestCase +subclasses with any name will be loaded and executed as tests. Tests +may use the assert keyword or raise AssertionErrors to indicate test +failure. TestCase subclasses may do the same or use the various +TestCase methods available. +.sp +\fBIt is important to note that the default behavior of nose is to +not include tests from files which are executable.\fP To include +tests from such files, remove their executable bit or use +the \-\-exe flag (see \(aqOptions\(aq section below). +.SS Selecting Tests +.sp +To specify which tests to run, pass test names on the command line: +.INDENT 0.0 +.INDENT 3.5 +.sp +.nf +.ft C +nosetests only_test_this.py +.ft P +.fi +.UNINDENT +.UNINDENT +.sp +Test names specified may be file or module names, and may optionally +indicate the test case to run by separating the module or file name +from the test case name with a colon. Filenames may be relative or +absolute. Examples: +.INDENT 0.0 +.INDENT 3.5 +.sp +.nf +.ft C +nosetests test.module +nosetests another.test:TestCase.test_method +nosetests a.test:TestCase +nosetests /path/to/test/file.py:test_function +.ft P +.fi +.UNINDENT +.UNINDENT +.sp +You may also change the working directory where nose looks for tests +by using the \-w switch: +.INDENT 0.0 +.INDENT 3.5 +.sp +.nf +.ft C +nosetests \-w /path/to/tests +.ft P +.fi +.UNINDENT +.UNINDENT +.sp +Note, however, that support for multiple \-w arguments is now deprecated +and will be removed in a future release. As of nose 0.10, you can get +the same behavior by specifying the target directories \fIwithout\fP +the \-w switch: +.INDENT 0.0 +.INDENT 3.5 +.sp +.nf +.ft C +nosetests /path/to/tests /another/path/to/tests +.ft P +.fi +.UNINDENT +.UNINDENT +.sp +Further customization of test selection and loading is possible +through the use of plugins. +.sp +Test result output is identical to that of unittest, except for +the additional features (error classes, and plugin\-supplied +features such as output capture and assert introspection) detailed +in the options below. +.SS Configuration +.sp +In addition to passing command\-line options, you may also put +configuration options in your project\(aqs \fIsetup.cfg\fP file, or a .noserc +or nose.cfg file in your home directory. In any of these standard +ini\-style config files, you put your nosetests configuration in a +\fB[nosetests]\fP section. Options are the same as on the command line, +with the \-\- prefix removed. For options that are simple switches, you +must supply a value: +.INDENT 0.0 +.INDENT 3.5 +.sp +.nf +.ft C +[nosetests] +verbosity=3 +with\-doctest=1 +.ft P +.fi +.UNINDENT +.UNINDENT +.sp +All configuration files that are found will be loaded and their +options combined. You can override the standard config file loading +with the \fB\-c\fP option. +.SS Using Plugins +.sp +There are numerous nose plugins available via easy_install and +elsewhere. To use a plugin, just install it. The plugin will add +command line options to nosetests. To verify that the plugin is installed, +run: +.INDENT 0.0 +.INDENT 3.5 +.sp +.nf +.ft C +nosetests \-\-plugins +.ft P +.fi +.UNINDENT +.UNINDENT +.sp +You can add \-v or \-vv to that command to show more information +about each plugin. +.sp +If you are running nose.main() or nose.run() from a script, you +can specify a list of plugins to use by passing a list of plugins +with the plugins keyword argument. +.SS 0.9 plugins +.sp +nose 1.0 can use SOME plugins that were written for nose 0.9. The +default plugin manager inserts a compatibility wrapper around 0.9 +plugins that adapts the changed plugin api calls. However, plugins +that access nose internals are likely to fail, especially if they +attempt to access test case or test suite classes. For example, +plugins that try to determine if a test passed to startTest is an +individual test or a suite will fail, partly because suites are no +longer passed to startTest and partly because it\(aqs likely that the +plugin is trying to find out if the test is an instance of a class +that no longer exists. +.SS 0.10 and 0.11 plugins +.sp +All plugins written for nose 0.10 and 0.11 should work with nose 1.0. +.SS Options +.INDENT 0.0 +.TP +.B \-V, \-\-version +Output nose version and exit +.UNINDENT +.INDENT 0.0 +.TP +.B \-p, \-\-plugins +Output list of available plugins and exit. Combine with higher verbosity for greater detail +.UNINDENT +.INDENT 0.0 +.TP +.B \-v=DEFAULT, \-\-verbose=DEFAULT +Be more verbose. [NOSE_VERBOSE] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-verbosity=VERBOSITY +Set verbosity; \-\-verbosity=2 is the same as \-v +.UNINDENT +.INDENT 0.0 +.TP +.B \-q=DEFAULT, \-\-quiet=DEFAULT +Be less verbose +.UNINDENT +.INDENT 0.0 +.TP +.B \-c=FILES, \-\-config=FILES +Load configuration from config file(s). May be specified multiple times; in that case, all config files will be loaded and combined +.UNINDENT +.INDENT 0.0 +.TP +.B \-w=WHERE, \-\-where=WHERE +Look for tests in this directory. May be specified multiple times. The first directory passed will be used as the working directory, in place of the current working directory, which is the default. Others will be added to the list of tests to execute. [NOSE_WHERE] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-py3where=PY3WHERE +Look for tests in this directory under Python 3.x. Functions the same as \(aqwhere\(aq, but only applies if running under Python 3.x or above. Note that, if present under 3.x, this option completely replaces any directories specified with \(aqwhere\(aq, so the \(aqwhere\(aq option becomes ineffective. [NOSE_PY3WHERE] +.UNINDENT +.INDENT 0.0 +.TP +.B \-m=REGEX, \-\-match=REGEX, \-\-testmatch=REGEX +Files, directories, function names, and class names that match this regular expression are considered tests. Default: (?:^|[b_./\-])[Tt]est [NOSE_TESTMATCH] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-tests=NAMES +Run these tests (comma\-separated list). This argument is useful mainly from configuration files; on the command line, just pass the tests to run as additional arguments with no switch. +.UNINDENT +.INDENT 0.0 +.TP +.B \-l=DEFAULT, \-\-debug=DEFAULT +Activate debug logging for one or more systems. Available debug loggers: nose, nose.importer, nose.inspector, nose.plugins, nose.result and nose.selector. Separate multiple names with a comma. +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-debug\-log=FILE +Log debug messages to this file (default: sys.stderr) +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-logging\-config=FILE, \-\-log\-config=FILE +Load logging config from this file \-\- bypasses all other logging config settings. +.UNINDENT +.INDENT 0.0 +.TP +.B \-I=REGEX, \-\-ignore\-files=REGEX +Completely ignore any file that matches this regular expression. Takes precedence over any other settings or plugins. Specifying this option will replace the default setting. Specify this option multiple times to add more regular expressions [NOSE_IGNORE_FILES] +.UNINDENT +.INDENT 0.0 +.TP +.B \-e=REGEX, \-\-exclude=REGEX +Don\(aqt run tests that match regular expression [NOSE_EXCLUDE] +.UNINDENT +.INDENT 0.0 +.TP +.B \-i=REGEX, \-\-include=REGEX +This regular expression will be applied to files, directories, function names, and class names for a chance to include additional tests that do not match TESTMATCH. Specify this option multiple times to add more regular expressions [NOSE_INCLUDE] +.UNINDENT +.INDENT 0.0 +.TP +.B \-x, \-\-stop +Stop running tests after the first error or failure +.UNINDENT +.INDENT 0.0 +.TP +.B \-P, \-\-no\-path\-adjustment +Don\(aqt make any changes to sys.path when loading tests [NOSE_NOPATH] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-exe +Look for tests in python modules that are executable. Normal behavior is to exclude executable modules, since they may not be import\-safe [NOSE_INCLUDE_EXE] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-noexe +DO NOT look for tests in python modules that are executable. (The default on the windows platform is to do so.) +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-traverse\-namespace +Traverse through all path entries of a namespace package +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-first\-package\-wins, \-\-first\-pkg\-wins, \-\-1st\-pkg\-wins +nose\(aqs importer will normally evict a package from sys.modules if it sees a package with the same name in a different location. Set this option to disable that behavior. +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-no\-byte\-compile +Prevent nose from byte\-compiling the source into .pyc files while nose is scanning for and running tests. +.UNINDENT +.INDENT 0.0 +.TP +.B \-a=ATTR, \-\-attr=ATTR +Run only tests that have attributes specified by ATTR [NOSE_ATTR] +.UNINDENT +.INDENT 0.0 +.TP +.B \-A=EXPR, \-\-eval\-attr=EXPR +Run only tests for whose attributes the Python expression EXPR evaluates to True [NOSE_EVAL_ATTR] +.UNINDENT +.INDENT 0.0 +.TP +.B \-s, \-\-nocapture +Don\(aqt capture stdout (any stdout output will be printed immediately) [NOSE_NOCAPTURE] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-nologcapture +Disable logging capture plugin. Logging configuration will be left intact. [NOSE_NOLOGCAPTURE] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-logging\-format=FORMAT +Specify custom format to print statements. Uses the same format as used by standard logging handlers. [NOSE_LOGFORMAT] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-logging\-datefmt=FORMAT +Specify custom date/time format to print statements. Uses the same format as used by standard logging handlers. [NOSE_LOGDATEFMT] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-logging\-filter=FILTER +Specify which statements to filter in/out. By default, everything is captured. If the output is too verbose, +use this option to filter out needless output. +Example: filter=foo will capture statements issued ONLY to + foo or foo.what.ever.sub but not foobar or other logger. +Specify multiple loggers with comma: filter=foo,bar,baz. +If any logger name is prefixed with a minus, eg filter=\-foo, +it will be excluded rather than included. Default: exclude logging messages from nose itself (\-nose). [NOSE_LOGFILTER] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-logging\-clear\-handlers +Clear all other logging handlers +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-logging\-level=DEFAULT +Set the log level to capture +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-with\-coverage +Enable plugin Coverage: +Activate a coverage report using Ned Batchelder\(aqs coverage module. + [NOSE_WITH_COVERAGE] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-cover\-package=PACKAGE +Restrict coverage output to selected packages [NOSE_COVER_PACKAGE] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-cover\-erase +Erase previously collected coverage statistics before run +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-cover\-tests +Include test modules in coverage report [NOSE_COVER_TESTS] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-cover\-min\-percentage=DEFAULT +Minimum percentage of coverage for tests to pass [NOSE_COVER_MIN_PERCENTAGE] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-cover\-inclusive +Include all python files under working directory in coverage report. Useful for discovering holes in test coverage if not all files are imported by the test suite. [NOSE_COVER_INCLUSIVE] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-cover\-html +Produce HTML coverage information +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-cover\-html\-dir=DIR +Produce HTML coverage information in dir +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-cover\-branches +Include branch coverage in coverage report [NOSE_COVER_BRANCHES] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-cover\-xml +Produce XML coverage information +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-cover\-xml\-file=FILE +Produce XML coverage information in file +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-pdb +Drop into debugger on failures or errors +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-pdb\-failures +Drop into debugger on failures +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-pdb\-errors +Drop into debugger on errors +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-no\-deprecated +Disable special handling of DeprecatedTest exceptions. +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-with\-doctest +Enable plugin Doctest: +Activate doctest plugin to find and run doctests in non\-test modules. + [NOSE_WITH_DOCTEST] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-doctest\-tests +Also look for doctests in test modules. Note that classes, methods and functions should have either doctests or non\-doctest tests, not both. [NOSE_DOCTEST_TESTS] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-doctest\-extension=EXT +Also look for doctests in files with this extension [NOSE_DOCTEST_EXTENSION] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-doctest\-result\-variable=VAR +Change the variable name set to the result of the last interpreter command from the default \(aq_\(aq. Can be used to avoid conflicts with the _() function used for text translation. [NOSE_DOCTEST_RESULT_VAR] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-doctest\-fixtures=SUFFIX +Find fixtures for a doctest file in module with this name appended to the base name of the doctest file +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-doctest\-options=OPTIONS +Specify options to pass to doctest. Eg. \(aq+ELLIPSIS,+NORMALIZE_WHITESPACE\(aq +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-with\-isolation +Enable plugin IsolationPlugin: +Activate the isolation plugin to isolate changes to external +modules to a single test module or package. The isolation plugin +resets the contents of sys.modules after each test module or +package runs to its state before the test. PLEASE NOTE that this +plugin should not be used with the coverage plugin, or in any other case +where module reloading may produce undesirable side\-effects. + [NOSE_WITH_ISOLATION] +.UNINDENT +.INDENT 0.0 +.TP +.B \-d, \-\-detailed\-errors, \-\-failure\-detail +Add detail to error output by attempting to evaluate failed asserts [NOSE_DETAILED_ERRORS] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-with\-profile +Enable plugin Profile: +Use this plugin to run tests using the hotshot profiler. + [NOSE_WITH_PROFILE] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-profile\-sort=SORT +Set sort order for profiler output +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-profile\-stats\-file=FILE +Profiler stats file; default is a new temp file on each run +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-profile\-restrict=RESTRICT +Restrict profiler output. See help for pstats.Stats for details +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-no\-skip +Disable special handling of SkipTest exceptions. +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-with\-id +Enable plugin TestId: +Activate to add a test id (like #1) to each test name output. Activate +with \-\-failed to rerun failing tests only. + [NOSE_WITH_ID] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-id\-file=FILE +Store test ids found in test runs in this file. Default is the file .noseids in the working directory. +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-failed +Run the tests that failed in the last test run. +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-processes=NUM +Spread test run among this many processes. Set a number equal to the number of processors or cores in your machine for best results. Pass a negative number to have the number of processes automatically set to the number of cores. Passing 0 means to disable parallel testing. Default is 0 unless NOSE_PROCESSES is set. [NOSE_PROCESSES] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-process\-timeout=SECONDS +Set timeout for return of results from each test runner process. Default is 10. [NOSE_PROCESS_TIMEOUT] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-process\-restartworker +If set, will restart each worker process once their tests are done, this helps control memory leaks from killing the system. [NOSE_PROCESS_RESTARTWORKER] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-with\-xunit +Enable plugin Xunit: This plugin provides test results in the standard XUnit XML format. [NOSE_WITH_XUNIT] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-xunit\-file=FILE +Path to xml file to store the xunit report in. Default is nosetests.xml in the working directory [NOSE_XUNIT_FILE] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-xunit\-testsuite\-name=PACKAGE +Name of the testsuite in the xunit xml, generated by plugin. Default test suite name is nosetests. +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-all\-modules +Enable plugin AllModules: Collect tests from all python modules. + [NOSE_ALL_MODULES] +.UNINDENT +.INDENT 0.0 +.TP +.B \-\-collect\-only +Enable collect\-only: +Collect and output test names only, don\(aqt run any tests. + [COLLECT_ONLY] +.UNINDENT +.SH AUTHOR +Nose developers +.SH COPYRIGHT +2009, Jason Pellerin +.\" Generated by docutils manpage writer. +. diff --git a/README.md b/README.md index 2946fc01dc..2bb648c9a6 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,11 @@ can be found ### Linux -For instructions on installing PyBaMM on Debian-based distributions, please see [here](INSTALL-LINUX.md) +For instructions on installing PyBaMM on Debian-based distributions, please see [here](INSTALL-LINUX-MAC.md) + +### Mac OS + +For instructions on installing PyBaMM on Mac OS distributions, please see [here](INSTALL-LINUX-MAC.md) ### Windows diff --git a/scripts/install_scikits_odes.sh b/scripts/install_scikits_odes.sh index 8d91aef507..fa2d125cf7 100755 --- a/scripts/install_scikits_odes.sh +++ b/scripts/install_scikits_odes.sh @@ -16,7 +16,8 @@ cmake -DLAPACK_ENABLE=ON -DSUNDIALS_INDEX_TYPE=int32_t -DBUILD_ARKODE:BOOL=OFF - make install cd $CURRENT_DIR rm -rf $TMP_DIR -export LD_LIBRARY_PATH=$INSTALL_DIR/lib:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=$INSTALL_DIR/lib:$LD_LIBRARY_PATH # For Linux +export DYLD_LIBRARY_PATH=$INSTALL_DIR/lib:$DYLD_LIBRARY_PATH # For Mac export SUNDIALS_INST=$INSTALL_DIR pip install scikits.odes From e77cb1584e3e969dba39a5c1ff04e3b6f848b21c Mon Sep 17 00:00:00 2001 From: Valentin Sulzer Date: Thu, 24 Oct 2019 21:34:19 -0400 Subject: [PATCH 02/13] #646 git stuff --- PyBaMM-env/.Python | 1 - PyBaMM-env/include/python2.7 | 1 - PyBaMM-env/include/python3.7m | 1 - PyBaMM-env/man/man1/nosetests.1 | 581 -------------------------------- 4 files changed, 584 deletions(-) delete mode 120000 PyBaMM-env/.Python delete mode 120000 PyBaMM-env/include/python2.7 delete mode 120000 PyBaMM-env/include/python3.7m delete mode 100644 PyBaMM-env/man/man1/nosetests.1 diff --git a/PyBaMM-env/.Python b/PyBaMM-env/.Python deleted file mode 120000 index 97d19b23c4..0000000000 --- a/PyBaMM-env/.Python +++ /dev/null @@ -1 +0,0 @@ -/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/Python \ No newline at end of file diff --git a/PyBaMM-env/include/python2.7 b/PyBaMM-env/include/python2.7 deleted file mode 120000 index 3fe034fccc..0000000000 --- a/PyBaMM-env/include/python2.7 +++ /dev/null @@ -1 +0,0 @@ -/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 \ No newline at end of file diff --git a/PyBaMM-env/include/python3.7m b/PyBaMM-env/include/python3.7m deleted file mode 120000 index 1acc697a01..0000000000 --- a/PyBaMM-env/include/python3.7m +++ /dev/null @@ -1 +0,0 @@ -/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m \ No newline at end of file diff --git a/PyBaMM-env/man/man1/nosetests.1 b/PyBaMM-env/man/man1/nosetests.1 deleted file mode 100644 index 577284569c..0000000000 --- a/PyBaMM-env/man/man1/nosetests.1 +++ /dev/null @@ -1,581 +0,0 @@ -.\" Man page generated from reStructuredText. -. -.TH "NOSETESTS" "1" "April 04, 2015" "1.3" "nose" -.SH NAME -nosetests \- Nicer testing for Python -. -.nr rst2man-indent-level 0 -. -.de1 rstReportMargin -\\$1 \\n[an-margin] -level \\n[rst2man-indent-level] -level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] -- -\\n[rst2man-indent0] -\\n[rst2man-indent1] -\\n[rst2man-indent2] -.. -.de1 INDENT -.\" .rstReportMargin pre: -. RS \\$1 -. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] -. nr rst2man-indent-level +1 -.\" .rstReportMargin post: -.. -.de UNINDENT -. RE -.\" indent \\n[an-margin] -.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] -.nr rst2man-indent-level -1 -.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] -.in \\n[rst2man-indent\\n[rst2man-indent-level]]u -.. -.SH NICER TESTING FOR PYTHON -.SS SYNOPSIS -.INDENT 0.0 -.INDENT 3.5 -nosetests [options] [names] -.UNINDENT -.UNINDENT -.SS DESCRIPTION -.sp -nose collects tests automatically from python source files, -directories and packages found in its working directory (which -defaults to the current working directory). Any python source file, -directory or package that matches the testMatch regular expression -(by default: \fI(?:^|[b_.\-])[Tt]est)\fP will be collected as a test (or -source for collection of tests). In addition, all other packages -found in the working directory will be examined for python source files -or directories that match testMatch. Package discovery descends all -the way down the tree, so package.tests and package.sub.tests and -package.sub.sub2.tests will all be collected. -.sp -Within a test directory or package, any python source file matching -testMatch will be examined for test cases. Within a test module, -functions and classes whose names match testMatch and TestCase -subclasses with any name will be loaded and executed as tests. Tests -may use the assert keyword or raise AssertionErrors to indicate test -failure. TestCase subclasses may do the same or use the various -TestCase methods available. -.sp -\fBIt is important to note that the default behavior of nose is to -not include tests from files which are executable.\fP To include -tests from such files, remove their executable bit or use -the \-\-exe flag (see \(aqOptions\(aq section below). -.SS Selecting Tests -.sp -To specify which tests to run, pass test names on the command line: -.INDENT 0.0 -.INDENT 3.5 -.sp -.nf -.ft C -nosetests only_test_this.py -.ft P -.fi -.UNINDENT -.UNINDENT -.sp -Test names specified may be file or module names, and may optionally -indicate the test case to run by separating the module or file name -from the test case name with a colon. Filenames may be relative or -absolute. Examples: -.INDENT 0.0 -.INDENT 3.5 -.sp -.nf -.ft C -nosetests test.module -nosetests another.test:TestCase.test_method -nosetests a.test:TestCase -nosetests /path/to/test/file.py:test_function -.ft P -.fi -.UNINDENT -.UNINDENT -.sp -You may also change the working directory where nose looks for tests -by using the \-w switch: -.INDENT 0.0 -.INDENT 3.5 -.sp -.nf -.ft C -nosetests \-w /path/to/tests -.ft P -.fi -.UNINDENT -.UNINDENT -.sp -Note, however, that support for multiple \-w arguments is now deprecated -and will be removed in a future release. As of nose 0.10, you can get -the same behavior by specifying the target directories \fIwithout\fP -the \-w switch: -.INDENT 0.0 -.INDENT 3.5 -.sp -.nf -.ft C -nosetests /path/to/tests /another/path/to/tests -.ft P -.fi -.UNINDENT -.UNINDENT -.sp -Further customization of test selection and loading is possible -through the use of plugins. -.sp -Test result output is identical to that of unittest, except for -the additional features (error classes, and plugin\-supplied -features such as output capture and assert introspection) detailed -in the options below. -.SS Configuration -.sp -In addition to passing command\-line options, you may also put -configuration options in your project\(aqs \fIsetup.cfg\fP file, or a .noserc -or nose.cfg file in your home directory. In any of these standard -ini\-style config files, you put your nosetests configuration in a -\fB[nosetests]\fP section. Options are the same as on the command line, -with the \-\- prefix removed. For options that are simple switches, you -must supply a value: -.INDENT 0.0 -.INDENT 3.5 -.sp -.nf -.ft C -[nosetests] -verbosity=3 -with\-doctest=1 -.ft P -.fi -.UNINDENT -.UNINDENT -.sp -All configuration files that are found will be loaded and their -options combined. You can override the standard config file loading -with the \fB\-c\fP option. -.SS Using Plugins -.sp -There are numerous nose plugins available via easy_install and -elsewhere. To use a plugin, just install it. The plugin will add -command line options to nosetests. To verify that the plugin is installed, -run: -.INDENT 0.0 -.INDENT 3.5 -.sp -.nf -.ft C -nosetests \-\-plugins -.ft P -.fi -.UNINDENT -.UNINDENT -.sp -You can add \-v or \-vv to that command to show more information -about each plugin. -.sp -If you are running nose.main() or nose.run() from a script, you -can specify a list of plugins to use by passing a list of plugins -with the plugins keyword argument. -.SS 0.9 plugins -.sp -nose 1.0 can use SOME plugins that were written for nose 0.9. The -default plugin manager inserts a compatibility wrapper around 0.9 -plugins that adapts the changed plugin api calls. However, plugins -that access nose internals are likely to fail, especially if they -attempt to access test case or test suite classes. For example, -plugins that try to determine if a test passed to startTest is an -individual test or a suite will fail, partly because suites are no -longer passed to startTest and partly because it\(aqs likely that the -plugin is trying to find out if the test is an instance of a class -that no longer exists. -.SS 0.10 and 0.11 plugins -.sp -All plugins written for nose 0.10 and 0.11 should work with nose 1.0. -.SS Options -.INDENT 0.0 -.TP -.B \-V, \-\-version -Output nose version and exit -.UNINDENT -.INDENT 0.0 -.TP -.B \-p, \-\-plugins -Output list of available plugins and exit. Combine with higher verbosity for greater detail -.UNINDENT -.INDENT 0.0 -.TP -.B \-v=DEFAULT, \-\-verbose=DEFAULT -Be more verbose. [NOSE_VERBOSE] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-verbosity=VERBOSITY -Set verbosity; \-\-verbosity=2 is the same as \-v -.UNINDENT -.INDENT 0.0 -.TP -.B \-q=DEFAULT, \-\-quiet=DEFAULT -Be less verbose -.UNINDENT -.INDENT 0.0 -.TP -.B \-c=FILES, \-\-config=FILES -Load configuration from config file(s). May be specified multiple times; in that case, all config files will be loaded and combined -.UNINDENT -.INDENT 0.0 -.TP -.B \-w=WHERE, \-\-where=WHERE -Look for tests in this directory. May be specified multiple times. The first directory passed will be used as the working directory, in place of the current working directory, which is the default. Others will be added to the list of tests to execute. [NOSE_WHERE] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-py3where=PY3WHERE -Look for tests in this directory under Python 3.x. Functions the same as \(aqwhere\(aq, but only applies if running under Python 3.x or above. Note that, if present under 3.x, this option completely replaces any directories specified with \(aqwhere\(aq, so the \(aqwhere\(aq option becomes ineffective. [NOSE_PY3WHERE] -.UNINDENT -.INDENT 0.0 -.TP -.B \-m=REGEX, \-\-match=REGEX, \-\-testmatch=REGEX -Files, directories, function names, and class names that match this regular expression are considered tests. Default: (?:^|[b_./\-])[Tt]est [NOSE_TESTMATCH] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-tests=NAMES -Run these tests (comma\-separated list). This argument is useful mainly from configuration files; on the command line, just pass the tests to run as additional arguments with no switch. -.UNINDENT -.INDENT 0.0 -.TP -.B \-l=DEFAULT, \-\-debug=DEFAULT -Activate debug logging for one or more systems. Available debug loggers: nose, nose.importer, nose.inspector, nose.plugins, nose.result and nose.selector. Separate multiple names with a comma. -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-debug\-log=FILE -Log debug messages to this file (default: sys.stderr) -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-logging\-config=FILE, \-\-log\-config=FILE -Load logging config from this file \-\- bypasses all other logging config settings. -.UNINDENT -.INDENT 0.0 -.TP -.B \-I=REGEX, \-\-ignore\-files=REGEX -Completely ignore any file that matches this regular expression. Takes precedence over any other settings or plugins. Specifying this option will replace the default setting. Specify this option multiple times to add more regular expressions [NOSE_IGNORE_FILES] -.UNINDENT -.INDENT 0.0 -.TP -.B \-e=REGEX, \-\-exclude=REGEX -Don\(aqt run tests that match regular expression [NOSE_EXCLUDE] -.UNINDENT -.INDENT 0.0 -.TP -.B \-i=REGEX, \-\-include=REGEX -This regular expression will be applied to files, directories, function names, and class names for a chance to include additional tests that do not match TESTMATCH. Specify this option multiple times to add more regular expressions [NOSE_INCLUDE] -.UNINDENT -.INDENT 0.0 -.TP -.B \-x, \-\-stop -Stop running tests after the first error or failure -.UNINDENT -.INDENT 0.0 -.TP -.B \-P, \-\-no\-path\-adjustment -Don\(aqt make any changes to sys.path when loading tests [NOSE_NOPATH] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-exe -Look for tests in python modules that are executable. Normal behavior is to exclude executable modules, since they may not be import\-safe [NOSE_INCLUDE_EXE] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-noexe -DO NOT look for tests in python modules that are executable. (The default on the windows platform is to do so.) -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-traverse\-namespace -Traverse through all path entries of a namespace package -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-first\-package\-wins, \-\-first\-pkg\-wins, \-\-1st\-pkg\-wins -nose\(aqs importer will normally evict a package from sys.modules if it sees a package with the same name in a different location. Set this option to disable that behavior. -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-no\-byte\-compile -Prevent nose from byte\-compiling the source into .pyc files while nose is scanning for and running tests. -.UNINDENT -.INDENT 0.0 -.TP -.B \-a=ATTR, \-\-attr=ATTR -Run only tests that have attributes specified by ATTR [NOSE_ATTR] -.UNINDENT -.INDENT 0.0 -.TP -.B \-A=EXPR, \-\-eval\-attr=EXPR -Run only tests for whose attributes the Python expression EXPR evaluates to True [NOSE_EVAL_ATTR] -.UNINDENT -.INDENT 0.0 -.TP -.B \-s, \-\-nocapture -Don\(aqt capture stdout (any stdout output will be printed immediately) [NOSE_NOCAPTURE] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-nologcapture -Disable logging capture plugin. Logging configuration will be left intact. [NOSE_NOLOGCAPTURE] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-logging\-format=FORMAT -Specify custom format to print statements. Uses the same format as used by standard logging handlers. [NOSE_LOGFORMAT] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-logging\-datefmt=FORMAT -Specify custom date/time format to print statements. Uses the same format as used by standard logging handlers. [NOSE_LOGDATEFMT] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-logging\-filter=FILTER -Specify which statements to filter in/out. By default, everything is captured. If the output is too verbose, -use this option to filter out needless output. -Example: filter=foo will capture statements issued ONLY to - foo or foo.what.ever.sub but not foobar or other logger. -Specify multiple loggers with comma: filter=foo,bar,baz. -If any logger name is prefixed with a minus, eg filter=\-foo, -it will be excluded rather than included. Default: exclude logging messages from nose itself (\-nose). [NOSE_LOGFILTER] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-logging\-clear\-handlers -Clear all other logging handlers -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-logging\-level=DEFAULT -Set the log level to capture -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-with\-coverage -Enable plugin Coverage: -Activate a coverage report using Ned Batchelder\(aqs coverage module. - [NOSE_WITH_COVERAGE] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-cover\-package=PACKAGE -Restrict coverage output to selected packages [NOSE_COVER_PACKAGE] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-cover\-erase -Erase previously collected coverage statistics before run -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-cover\-tests -Include test modules in coverage report [NOSE_COVER_TESTS] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-cover\-min\-percentage=DEFAULT -Minimum percentage of coverage for tests to pass [NOSE_COVER_MIN_PERCENTAGE] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-cover\-inclusive -Include all python files under working directory in coverage report. Useful for discovering holes in test coverage if not all files are imported by the test suite. [NOSE_COVER_INCLUSIVE] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-cover\-html -Produce HTML coverage information -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-cover\-html\-dir=DIR -Produce HTML coverage information in dir -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-cover\-branches -Include branch coverage in coverage report [NOSE_COVER_BRANCHES] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-cover\-xml -Produce XML coverage information -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-cover\-xml\-file=FILE -Produce XML coverage information in file -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-pdb -Drop into debugger on failures or errors -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-pdb\-failures -Drop into debugger on failures -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-pdb\-errors -Drop into debugger on errors -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-no\-deprecated -Disable special handling of DeprecatedTest exceptions. -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-with\-doctest -Enable plugin Doctest: -Activate doctest plugin to find and run doctests in non\-test modules. - [NOSE_WITH_DOCTEST] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-doctest\-tests -Also look for doctests in test modules. Note that classes, methods and functions should have either doctests or non\-doctest tests, not both. [NOSE_DOCTEST_TESTS] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-doctest\-extension=EXT -Also look for doctests in files with this extension [NOSE_DOCTEST_EXTENSION] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-doctest\-result\-variable=VAR -Change the variable name set to the result of the last interpreter command from the default \(aq_\(aq. Can be used to avoid conflicts with the _() function used for text translation. [NOSE_DOCTEST_RESULT_VAR] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-doctest\-fixtures=SUFFIX -Find fixtures for a doctest file in module with this name appended to the base name of the doctest file -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-doctest\-options=OPTIONS -Specify options to pass to doctest. Eg. \(aq+ELLIPSIS,+NORMALIZE_WHITESPACE\(aq -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-with\-isolation -Enable plugin IsolationPlugin: -Activate the isolation plugin to isolate changes to external -modules to a single test module or package. The isolation plugin -resets the contents of sys.modules after each test module or -package runs to its state before the test. PLEASE NOTE that this -plugin should not be used with the coverage plugin, or in any other case -where module reloading may produce undesirable side\-effects. - [NOSE_WITH_ISOLATION] -.UNINDENT -.INDENT 0.0 -.TP -.B \-d, \-\-detailed\-errors, \-\-failure\-detail -Add detail to error output by attempting to evaluate failed asserts [NOSE_DETAILED_ERRORS] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-with\-profile -Enable plugin Profile: -Use this plugin to run tests using the hotshot profiler. - [NOSE_WITH_PROFILE] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-profile\-sort=SORT -Set sort order for profiler output -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-profile\-stats\-file=FILE -Profiler stats file; default is a new temp file on each run -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-profile\-restrict=RESTRICT -Restrict profiler output. See help for pstats.Stats for details -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-no\-skip -Disable special handling of SkipTest exceptions. -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-with\-id -Enable plugin TestId: -Activate to add a test id (like #1) to each test name output. Activate -with \-\-failed to rerun failing tests only. - [NOSE_WITH_ID] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-id\-file=FILE -Store test ids found in test runs in this file. Default is the file .noseids in the working directory. -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-failed -Run the tests that failed in the last test run. -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-processes=NUM -Spread test run among this many processes. Set a number equal to the number of processors or cores in your machine for best results. Pass a negative number to have the number of processes automatically set to the number of cores. Passing 0 means to disable parallel testing. Default is 0 unless NOSE_PROCESSES is set. [NOSE_PROCESSES] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-process\-timeout=SECONDS -Set timeout for return of results from each test runner process. Default is 10. [NOSE_PROCESS_TIMEOUT] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-process\-restartworker -If set, will restart each worker process once their tests are done, this helps control memory leaks from killing the system. [NOSE_PROCESS_RESTARTWORKER] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-with\-xunit -Enable plugin Xunit: This plugin provides test results in the standard XUnit XML format. [NOSE_WITH_XUNIT] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-xunit\-file=FILE -Path to xml file to store the xunit report in. Default is nosetests.xml in the working directory [NOSE_XUNIT_FILE] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-xunit\-testsuite\-name=PACKAGE -Name of the testsuite in the xunit xml, generated by plugin. Default test suite name is nosetests. -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-all\-modules -Enable plugin AllModules: Collect tests from all python modules. - [NOSE_ALL_MODULES] -.UNINDENT -.INDENT 0.0 -.TP -.B \-\-collect\-only -Enable collect\-only: -Collect and output test names only, don\(aqt run any tests. - [COLLECT_ONLY] -.UNINDENT -.SH AUTHOR -Nose developers -.SH COPYRIGHT -2009, Jason Pellerin -.\" Generated by docutils manpage writer. -. From ec9fd95d4db299d93235665be02ec676c3d0b2f4 Mon Sep 17 00:00:00 2001 From: Valentin Sulzer Date: Thu, 24 Oct 2019 21:35:16 -0400 Subject: [PATCH 03/13] #646 .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2c47eb938c..59aaf84253 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,7 @@ pyproject.toml # virtual enviroment venv/ venv3.5/ +PyBaMM-env/ bin/ etc/ lib/ From d0e9297e4b497cb00292e1cbb95f2778b7818c21 Mon Sep 17 00:00:00 2001 From: Valentin Sulzer Date: Fri, 25 Oct 2019 11:19:55 -0400 Subject: [PATCH 04/13] #646 codacy --- INSTALL-LINUX-MAC.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL-LINUX-MAC.md b/INSTALL-LINUX-MAC.md index aeab75eafb..6fd3662392 100644 --- a/INSTALL-LINUX-MAC.md +++ b/INSTALL-LINUX-MAC.md @@ -178,7 +178,7 @@ when I run my Python script. -e .`. This sets the installed location of the source files to your current directory. **Problem:** When running `python run-tests.py --quick`, gives error `FileNotFoundError: -[Errno 2] No such file or directory: 'flake8': 'flake8'. +[Errno 2] No such file or directory: `flake8`: `flake8`. **Solution:** make sure you have included the `[dev,docs]` flags when you pip installed PyBaMM, i.e. `pip install -e .[dev,docs]` From 433b92e848768370ddf06b03ed418faf1579375e Mon Sep 17 00:00:00 2001 From: Travis CI Date: Fri, 25 Oct 2019 21:34:51 -0400 Subject: [PATCH 05/13] #646 install some more brew stuff --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index c960e0b4f2..56742a1d14 100644 --- a/.travis.yml +++ b/.travis.yml @@ -177,6 +177,8 @@ before_install: | brew update; # Per the `pyenv homebrew recommendations `_. brew install graphviz openssl readline; + # Other brew packages + brew install gcc cmake openblas suitesparse; # See https://docs.travis-ci.com/user/osx-ci-environment/#A-note-on-upgrading-packages. brew outdated pyenv || brew upgrade pyenv # virtualenv doesn't work without pyenv knowledge. venv in Python 3.3 From 566d7d527389546fc2f2cb53d413b9378535c488 Mon Sep 17 00:00:00 2001 From: tinosulzer Date: Fri, 25 Oct 2019 22:37:03 -0400 Subject: [PATCH 06/13] #646 also run scikits tests on mac --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 56742a1d14..00483d3d91 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,6 +62,7 @@ matrix: env: - PYTHON=3.7.4 - PYBAMM_UNIT=true + - PYBAMM_SCIKITS_ODES=true - PYBAMM_KLU=true if: type != cron - python: "3.7" From 102436d0c4b1e82edd02fa8d25093206f1b6f191 Mon Sep 17 00:00:00 2001 From: tinosulzer Date: Sat, 26 Oct 2019 21:31:41 -0400 Subject: [PATCH 07/13] #646 making scikits install faster --- scripts/install_scikits_odes.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/install_scikits_odes.sh b/scripts/install_scikits_odes.sh index fa2d125cf7..01bf56b4cb 100755 --- a/scripts/install_scikits_odes.sh +++ b/scripts/install_scikits_odes.sh @@ -13,7 +13,15 @@ tar -xvf $SUNDIALS_NAME mkdir build-sundials-3.1.1 cd build-sundials-3.1.1/ cmake -DLAPACK_ENABLE=ON -DSUNDIALS_INDEX_TYPE=int32_t -DBUILD_ARKODE:BOOL=OFF -DEXAMPLES_ENABLE:BOOL=OFF -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR ../sundials-3.1.1/ -make install +if [ "$(uname)" == "Darwin" ]; then + # Mac OS X platform + NUM_OF_CORES=$(sysctl -n hw.cpu) +elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then + # GNU/Linux platform + NUM_OF_CORES=$(cat /proc/cpuinfo | grep processor | wc -l) +fi +make clean +make -j$NUM_OF_CORES install cd $CURRENT_DIR rm -rf $TMP_DIR export LD_LIBRARY_PATH=$INSTALL_DIR/lib:$LD_LIBRARY_PATH # For Linux From 6f00fc8cec9da4129bff621e9ff7280642be862f Mon Sep 17 00:00:00 2001 From: tinosulzer Date: Sun, 27 Oct 2019 23:47:09 -0400 Subject: [PATCH 08/13] #646 split up instructions and make clearer what is optional --- INSTALL-LINUX-MAC.md | 186 +----------------- INSTALL-SCIKITS.md | 106 ++++++++++ INSTALL-WINDOWS.md | 6 +- INSTALL_KLU.md | 161 +++++++++++++++ .../full_battery_models/lead_acid/full.py | 5 +- .../lead_acid/higher_order.py | 5 +- .../full_battery_models/lithium_ion/dfn.py | 6 +- pybamm/solvers/scikits_ode_solver.py | 2 +- .../test_asymptotics_convergence.py | 2 +- .../test_lead_acid/test_compare_outputs.py | 2 +- .../test_lead_acid/test_composite.py | 2 +- .../test_lead_acid/test_foqs.py | 2 +- .../test_lead_acid/test_full.py | 10 +- .../test_composite_side_reactions.py | 2 +- .../test_full_side_reactions.py | 4 +- .../test_loqs_side_reactions.py | 2 +- .../test_lithium_ion/test_dfn.py | 6 +- .../test_lithium_ion/test_spm.py | 4 +- .../test_lithium_ion/test_spme.py | 4 +- tests/integration/test_quick_plot.py | 4 +- .../test_lead_acid/test_composite.py | 4 +- .../test_lead_acid/test_full.py | 4 +- .../test_lead_acid/test_loqs.py | 2 +- .../test_lithium_ion/test_dfn.py | 12 +- .../test_lithium_ion/test_spm.py | 12 +- .../test_lithium_ion/test_spme.py | 12 +- .../unit/test_solvers/test_scikits_solvers.py | 2 +- 27 files changed, 333 insertions(+), 236 deletions(-) create mode 100644 INSTALL-SCIKITS.md create mode 100644 INSTALL_KLU.md diff --git a/INSTALL-LINUX-MAC.md b/INSTALL-LINUX-MAC.md index 65d4c86d87..c391c2ffce 100644 --- a/INSTALL-LINUX-MAC.md +++ b/INSTALL-LINUX-MAC.md @@ -97,195 +97,17 @@ pip uninstall pybamm ## Optional dependencies -### [scikits.odes](https://github.com/bmcage/odes) - -Users can install [scikits.odes](https://github.com/bmcage/odes) in order to use the -wrapped SUNDIALS ODE and DAE -[solvers](https://pybamm.readthedocs.io/en/latest/source/solvers/scikits_solvers.html). -The Sundials DAE solver is required to solve the DFN battery model in PyBaMM. - -Before installing scikits.odes, you need to have installed: - -- Python header files (`python-dev/python3-dev` on Debian/Ubuntu-based distributions, comes with python3 by default in brew) -- C compiler -- Fortran compiler (e.g. gfortran, comes with gcc in brew) -- BLAS/LAPACK install (OpenBLAS is recommended by the scikits.odes developers) -- CMake (for building Sundials) -- Sundials 3.1.1 (see instructions below) - -You can install these on Ubuntu or Debian using apt-get: - -```bash -sudo apt-get install python3-dev gfortran gcc cmake libopenblas-dev -``` - -or on a Mac OS distribution using brew: - -```bash -brew install gcc cmake openblas -``` - -To install Sundials 3.1.1, on the command-line type: - -```bash -INSTALL_DIR=`pwd`/sundials -wget https://computation.llnl.gov/projects/sundials/download/sundials-3.1.1.tar.gz -tar -xvf sundials-3.1.1.tar.gz -mkdir build-sundials-3.1.1 -cd build-sundials-3.1.1/ -cmake -DLAPACK_ENABLE=ON -DSUNDIALS_INDEX_TYPE=int32_t -DBUILD_ARKODE:BOOL=OFF -DEXAMPLES_ENABLE:BOOL=OFF -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR ../sundials-3.1.1/ -make install -rm -r ../sundials-3.1.1 -``` - -Then install [scikits.odes](https://github.com/bmcage/odes), letting it know the sundials install location: - -```bash -SUNDIALS_INST=$INSTALL_DIR pip install scikits.odes -``` - -After this, you will need to set your `LD_LIBRARY_PATH` (for Linux) or `DYLD_LIBRARY_PATH` (for Mac) to point to the sundials -library - for Linux: - -```bash -export LD_LIBRARY_PATH=$INSTALL_DIR/lib:$LD_LIBRARY_PATH -``` - -or for Mac: - -```bash -export DYLD_LIBRARY_PATH=$INSTALL_DIR/lib:$DYLD_LIBRARY_PATH -``` +Two DAE solvers (`scikits.odes` and `KLU`) can be optionally installed in PyBaMM. At least one of these is required to solve DAE models, such as the DFN, but you can install both if you like. -You may wish to put one of these lines in your `.bashrc` or virtualenv `activate` script, -which will save you needing to set your `LD_LIBRARY_PATH` or `DYLD_LIBRARY_PATH` every time you log in. For -example, to add this line to your `.bashrc` you can type: - -```bash -echo "export LD_LIBRARY_PATH=$INSTALL_DIR/lib:\$LD_LIBRARY_PATH" >> ~/.bashrc -``` +### [scikits.odes](https://github.com/bmcage/odes) -Please see the [scikits.odes -documentation](https://scikits-odes.readthedocs.io/en/latest/installation.html) for more -detailed installation instructions. +A python wrapper for the SUNDIALS ODE and DAE integrators. [Installation instructions](INSTALL-SCIKITS.md). ### Sundials with KLU sparse solver If you wish so simulate large systems such as the 2+1D models, we recommend employing a sparse solver. PyBaMM currently offers a direct interface to the sparse KLU solver within Sundials. -If you are on a linux based distribution, a bash script has been provided which should -install everything for you correctly. Please note you will require the python header files, openblas, -a c compiler (e.g. gcc), cmake, and suitesparse all of which you should be able to install, either on ubuntu using - -```bash -apt install python3-dev libopenblas-dev cmake gcc libsuitesparse-dev -``` - -or on a Mac OS distribution using brew (`python3-dev` is installed by `python3`): - -```bash -brew install gcc cmake openblas suitesparse -``` - -You will likely need to prepend `sudo` to the above command. - -To install sundials with KLU, from within the main PyBaMM directory type - -```bash -./scripts/install_sundials_4.1.0.sh -``` - -Note that this script has only been tested on Ubuntu 18.04.3 LTS. If this script does not work for you, you can try following the step-by-step instructions below: - -#### Download and build Sundials 4.1.0 - -The KLU solver is interfaced using an updated version of Sundials so even if you have installed Sundials for use with Scikits.odes, you still need to install sundials here. If you want more information on the sundials installation please refer to the the ida_guide.pdf available at on the [sundials site](https://computing.llnl.gov/projects/sundials/sundials-software) - -First, download Sundials 4.1.0 using - -```bash -wget https://computing.llnl.gov/projects/sundials/download/sundials-4.1.0.tar.gz -O sundials-4.1.0.tar.gz -tar -xvf sundials-4.1.0.tar.gz -rm sundials-4.1.0.tar.gz -``` - -The cmake instructions provided with Sundials have trouble linking the required libraries related to the KLU solver, therefore we have provided a modified `CMakeLists.txt` file which fixes this. Copy this across into the sundials-4.1.0 folder, overwriting the old file, using - -```bash -cp scripts/replace-cmake/CMakeLists.txt sundials-4.1.0/CMakeLists.txt -``` - -Now create a directory to build sundials in and set the install directory for sundials: - -```bash -mkdir build-sundials-4.1.0 -INSTALL_DIR=`pwd`/sundials4 -``` - -Now enter the build directory, use cmake to generate the appropriate make files, and then build sundials and install sundials into the install directory using make: - -```bash -cd build-sundials-4.1.0 -cmake -DBLAS_ENABLE=ON\ - -DLAPACK_ENABLE=ON\ - -DSUNDIALS_INDEX_SIZE=32\ - -DBUILD_ARKODE=OFF\ - -DBUILD_CVODE=OFF\ - -DBUILD_CVODES=OFF\ - -DBUILD_IDAS=OFF\ - -DBUILD_KINSOL=OFF\ - -DEXAMPLES_ENABLE:BOOL=OFF\ - -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR\ - -DKLU_ENABLE=ON\ - ../sundials-4.1.0 -make install -``` - -Now return to your PyBaMM home directory and remove the build-sundials-4.1.0 folder and the download folder: - -```bash -cd .. -rm -rf build-sundials-4.1.0 -rm -rf sundials-4.1.0 -``` - -#### Install pybind11 -To interface with Sundials which is written in C, we require pybind11. Clone the pybind11 repository whilst within a folder the third-party folder: - -```bash -mkdir third-party -cd third-party -git clone https://github.com/pybind/pybind11.git -cd .. -``` - -You will also require pybind11 to be pip installed so from within your virtual enviroment (if you are using one) type: - -```bash -pip install pybind11 -``` - -#### Build the KLU wrapper -We now have all the tools to build a shared library to interface to the KLU solver. Within your PyBaMM home directory build the required Makefile using - -```bash -cmake . -``` - -This will automatically find the headers for the latest version of python installed on your machine. If you are using an older version (e.g python3.6) within your virtual environment, then you instead can use `cmake -DPYBIND11_PYTHON_VERSION=3.6 .`. - -You can now simply run make to build the library (you can just run this command if you make some changes to klu.cpp) - -```bash -make -``` - -To clean up you directory you can now remove the automatically generated cmake files: -``` -rm -rf CMakeFiles -rm CMakeCache.txt -rm cmake_install.cmake -``` +[Installation instructions](INSTALL-KLU.md). ## Troubleshooting diff --git a/INSTALL-SCIKITS.md b/INSTALL-SCIKITS.md new file mode 100644 index 0000000000..b0b800e219 --- /dev/null +++ b/INSTALL-SCIKITS.md @@ -0,0 +1,106 @@ +# Install scikits.odes + +--- +**Note** + +This file provides installation instructions for either Ubuntu-based distributions or Mac OS distributions. Please read carefully which lines to run in each case. + +--- + + +Users can install [scikits.odes](https://github.com/bmcage/odes) in order to use the +wrapped SUNDIALS ODE and DAE +[solvers](https://pybamm.readthedocs.io/en/latest/source/solvers/scikits_solvers.html). +The Sundials DAE solver is required to solve the DFN battery model in PyBaMM. + +Before installing scikits.odes, you need to have installed: + +- Python header files (`python-dev/python3-dev` on Debian/Ubuntu-based distributions, comes with python3 by default in brew) +- C compiler +- Fortran compiler (e.g. gfortran, comes with gcc in brew) +- BLAS/LAPACK install (OpenBLAS is recommended by the scikits.odes developers) +- CMake (for building Sundials) +- Sundials 3.1.1 (see instructions below) + +You can install these on Ubuntu or Debian using apt-get: + +```bash +sudo apt-get install python3-dev gfortran gcc cmake libopenblas-dev +``` + +or on a Mac OS distribution using brew: + +```bash +brew install wget gcc cmake openblas +``` + +## Installing SUNDIALS and scikits.odes + +### Option 1: install with script + +We recommend that you first try to install SUNDIALS and scikits together by running the script + +```bash +source scripts/install_scikits_odes.sh +``` + +If this works, skip to [the final section](#setting-library-path). Otherwise, try Option 2 below. + +## Option 2: install manually + + +To install SUNDIALS 3.1.1 manually, on the command-line type: + +```bash +INSTALL_DIR=`pwd`/sundials +wget https://computation.llnl.gov/projects/sundials/download/sundials-3.1.1.tar.gz +tar -xvf sundials-3.1.1.tar.gz +mkdir build-sundials-3.1.1 +cd build-sundials-3.1.1/ +cmake -DLAPACK_ENABLE=ON -DSUNDIALS_INDEX_TYPE=int32_t -DBUILD_ARKODE:BOOL=OFF -DEXAMPLES_ENABLE:BOOL=OFF -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR ../sundials-3.1.1/ +make install +rm -r ../sundials-3.1.1 +``` + +Then install [scikits.odes](https://github.com/bmcage/odes), letting it know the sundials install location: + +```bash +SUNDIALS_INST=$INSTALL_DIR pip install scikits.odes +``` + +## Setting library path + +After this, you will need to set your `LD_LIBRARY_PATH` (for Linux) or `DYLD_LIBRARY_PATH` (for Mac) to point to the sundials +library - for Linux: + +```bash +export LD_LIBRARY_PATH=$INSTALL_DIR/lib:$LD_LIBRARY_PATH +``` + +or for Mac: + +```bash +export DYLD_LIBRARY_PATH=$INSTALL_DIR/lib:$DYLD_LIBRARY_PATH +``` + +You may wish to put one of these lines in your `.bashrc` or virtualenv `activate` script, +which will save you needing to set your `LD_LIBRARY_PATH` or `DYLD_LIBRARY_PATH` every time you log in. For +example, to add this line to your virtual environment `env` you can type: + +```bash +echo "export LD_LIBRARY_PATH=$INSTALL_DIR/lib:\$LD_LIBRARY_PATH" >> env/bin/activate +``` + +for Linux or + +```bash +echo "export DYLD_LIBRARY_PATH=$INSTALL_DIR/lib:\$DYLD_LIBRARY_PATH" >> env/bin/activate +``` + +for Mac. + +Please see the [scikits.odes +documentation](https://scikits-odes.readthedocs.io/en/latest/installation.html) for more +detailed installation instructions. + +You can also try installing the [KLU solver](INSTALL-KLU.md) if you haven't already done so, but you only need one DAE solver. \ No newline at end of file diff --git a/INSTALL-WINDOWS.md b/INSTALL-WINDOWS.md index abd2c3968d..47c425bd8c 100644 --- a/INSTALL-WINDOWS.md +++ b/INSTALL-WINDOWS.md @@ -18,20 +18,20 @@ To download the PyBaMM source code, you first need to install git, which you can typing ```bash -$ sudo apt install git-core +sudo apt install git-core ``` Now use git to clone the PyBaMM repository: ```bash -$ git clone https://github.com/pybamm-team/PyBaMM.git +git clone https://github.com/pybamm-team/PyBaMM.git ``` This will create a new directly called `PyBaMM`, you can move to this directory in bash using the `cd` command: ```bash -$ cd PyBaMM +cd PyBaMM ``` If you are unfamiliar with the linux command line, you might find it useful to work through this diff --git a/INSTALL_KLU.md b/INSTALL_KLU.md new file mode 100644 index 0000000000..fb7e37fc91 --- /dev/null +++ b/INSTALL_KLU.md @@ -0,0 +1,161 @@ +# Install IDA-KLU Solver + +--- +**Note** + +This file provides installation instructions for either Ubuntu-based distributions or Mac OS distributions. Please read carefully which lines to run in each case. + +--- + +If you are on a linux based distribution, a bash script has been provided which should +install everything for you correctly. Please note you will require the python header files, openblas, +a c compiler (e.g. gcc), cmake, and suitesparse all of which you should be able to install, either on ubuntu using + +```bash +apt install python3-dev libopenblas-dev cmake gcc libsuitesparse-dev +``` + +or on a Mac OS distribution using brew (`python3-dev` is installed by `python3`): + +```bash +brew install wget gcc cmake openblas suitesparse +``` + +You will likely need to prepend `sudo` to the above command. + +## Installing KLU + +### Option 1: install with script + +We recommend that you first try to install KLU by running the script. From within the main PyBaMM directory type + +```bash +source scripts/install_sundials_4.1.0.sh +``` + +Note that this script has only been tested on Ubuntu 18.04.3 LTS. If this works, skip to [the final section](#setting-library-path). Otherwise, try Option 2 below. If this script does not work for you, you can try following the step-by-step instructions below in Option 2. + +## Option 2: install manually + +#### Download and build Sundials 4.1.0 + +The KLU solver is interfaced using an updated version of Sundials so even if you have installed Sundials for use with Scikits.odes, you still need to install sundials here. If you want more information on the sundials installation please refer to the the ida_guide.pdf available at on the [sundials site](https://computing.llnl.gov/projects/sundials/sundials-software) + +First, download Sundials 4.1.0 using + +```bash +wget https://computing.llnl.gov/projects/sundials/download/sundials-4.1.0.tar.gz -O sundials-4.1.0.tar.gz +tar -xvf sundials-4.1.0.tar.gz +rm sundials-4.1.0.tar.gz +``` + +The cmake instructions provided with Sundials have trouble linking the required libraries related to the KLU solver, therefore we have provided a modified `CMakeLists.txt` file which fixes this. Copy this across into the sundials-4.1.0 folder, overwriting the old file, using + +```bash +cp scripts/replace-cmake/CMakeLists.txt sundials-4.1.0/CMakeLists.txt +``` + +Now create a directory to build sundials in and set the install directory for sundials: + +```bash +mkdir build-sundials-4.1.0 +INSTALL_DIR=`pwd`/sundials4 +``` + +Now enter the build directory, use cmake to generate the appropriate make files, and then build sundials and install sundials into the install directory using make: + +```bash +cd build-sundials-4.1.0 +cmake -DBLAS_ENABLE=ON\ + -DLAPACK_ENABLE=ON\ + -DSUNDIALS_INDEX_SIZE=32\ + -DBUILD_ARKODE=OFF\ + -DBUILD_CVODE=OFF\ + -DBUILD_CVODES=OFF\ + -DBUILD_IDAS=OFF\ + -DBUILD_KINSOL=OFF\ + -DEXAMPLES_ENABLE:BOOL=OFF\ + -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR\ + -DKLU_ENABLE=ON\ + ../sundials-4.1.0 +make install +``` + +Now return to your PyBaMM home directory and remove the build-sundials-4.1.0 folder and the download folder: + +```bash +cd .. +rm -rf build-sundials-4.1.0 +rm -rf sundials-4.1.0 +``` + +#### Install pybind11 +To interface with Sundials which is written in C, we require pybind11. Clone the pybind11 repository whilst within a folder the third-party folder: + +```bash +mkdir third-party +cd third-party +git clone https://github.com/pybind/pybind11.git +cd .. +``` + +You will also require pybind11 to be pip installed so from within your virtual enviroment (if you are using one) type: + +```bash +pip install pybind11 +``` + +#### Build the KLU wrapper +We now have all the tools to build a shared library to interface to the KLU solver. Within your PyBaMM home directory build the required Makefile using + +```bash +cmake . +``` + +This will automatically find the headers for the latest version of python installed on your machine. If you are using an older version (e.g python3.6) within your virtual environment, then you instead can use `cmake -DPYBIND11_PYTHON_VERSION=3.6 .`. + +You can now simply run make to build the library (you can just run this command if you make some changes to klu.cpp) + +```bash +make +``` + +To clean up you directory you can now remove the automatically generated cmake files: +``` +rm -rf CMakeFiles +rm CMakeCache.txt +rm cmake_install.cmake +``` + +## Setting library path + +After this, you will need to set your `LD_LIBRARY_PATH` (for Linux) or `DYLD_LIBRARY_PATH` (for Mac) to point to the sundials +library - for Linux: + +```bash +export LD_LIBRARY_PATH=$INSTALL_DIR/lib:$LD_LIBRARY_PATH +``` + +or for Mac: + +```bash +export DYLD_LIBRARY_PATH=$INSTALL_DIR/lib:$DYLD_LIBRARY_PATH +``` + +You may wish to put one of these lines in your `.bashrc` or virtualenv `activate` script, +which will save you needing to set your `LD_LIBRARY_PATH` or `DYLD_LIBRARY_PATH` every time you log in. For +example, to add this line to your virtual environment `env` you can type: + +```bash +echo "export LD_LIBRARY_PATH=$INSTALL_DIR/lib:\$LD_LIBRARY_PATH" >> env/bin/activate +``` + +for Linux or + +```bash +echo "export DYLD_LIBRARY_PATH=$INSTALL_DIR/lib:\$DYLD_LIBRARY_PATH" >> env/bin/activate +``` + +for Mac. + +You can also try installing the [scikits.odes solver](INSTALL_SCIKITS.md) if you haven't already done so, but you only need one DAE solver. \ No newline at end of file diff --git a/pybamm/models/full_battery_models/lead_acid/full.py b/pybamm/models/full_battery_models/lead_acid/full.py index 5e13d911bf..70f70a29d4 100644 --- a/pybamm/models/full_battery_models/lead_acid/full.py +++ b/pybamm/models/full_battery_models/lead_acid/full.py @@ -135,4 +135,7 @@ def default_solver(self): ): return pybamm.ScipySolver() else: - return pybamm.ScikitsDaeSolver() + if pybamm.have_scikit_odes(): + return pybamm.ScikitsDaeSolver() + elif pybamm.have_idaklu(): # pragma: no cover + return pybamm.IDAKLU() diff --git a/pybamm/models/full_battery_models/lead_acid/higher_order.py b/pybamm/models/full_battery_models/lead_acid/higher_order.py index 4f3e424d97..600789cbb0 100644 --- a/pybamm/models/full_battery_models/lead_acid/higher_order.py +++ b/pybamm/models/full_battery_models/lead_acid/higher_order.py @@ -176,7 +176,10 @@ def default_solver(self): self.options["current collector"] != "uniform" or self.options["surface form"] == "algebraic" ): - return pybamm.ScikitsDaeSolver() + if pybamm.have_scikit_odes(): + return pybamm.ScikitsDaeSolver() + elif pybamm.have_idaklu(): # pragma: no cover + return pybamm.IDAKLU() else: return pybamm.ScipySolver() diff --git a/pybamm/models/full_battery_models/lithium_ion/dfn.py b/pybamm/models/full_battery_models/lithium_ion/dfn.py index c448c048b6..67a46814a9 100644 --- a/pybamm/models/full_battery_models/lithium_ion/dfn.py +++ b/pybamm/models/full_battery_models/lithium_ion/dfn.py @@ -116,5 +116,7 @@ def default_solver(self): Create and return the default solver for this model """ - # Default solver to DAE - return pybamm.ScikitsDaeSolver() + if pybamm.have_scikit_odes(): + return pybamm.ScikitsDaeSolver() + elif pybamm.have_idaklu(): # pragma: no cover + return pybamm.IDAKLU() diff --git a/pybamm/solvers/scikits_ode_solver.py b/pybamm/solvers/scikits_ode_solver.py index 542b15d19a..1a409ae92f 100644 --- a/pybamm/solvers/scikits_ode_solver.py +++ b/pybamm/solvers/scikits_ode_solver.py @@ -16,7 +16,7 @@ def have_scikits_odes(): - return scikits_odes_spec is None + return scikits_odes_spec is not None class ScikitsOdeSolver(pybamm.OdeSolver): diff --git a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_asymptotics_convergence.py b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_asymptotics_convergence.py index 62cf64f8f1..4928475f8b 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_asymptotics_convergence.py +++ b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_asymptotics_convergence.py @@ -8,7 +8,7 @@ class TestAsymptoticConvergence(unittest.TestCase): - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_leading_order_convergence(self): """ Check that the leading-order model solution converges linearly in C_e to the diff --git a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_compare_outputs.py b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_compare_outputs.py index 5dbd216562..699a920425 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_compare_outputs.py +++ b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_compare_outputs.py @@ -7,7 +7,7 @@ from tests import StandardOutputComparison -@unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") +@unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") class TestCompareOutputs(unittest.TestCase): def test_compare_averages_asymptotics(self): """ diff --git a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_composite.py b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_composite.py index 97feb0c297..fae4ffd57f 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_composite.py +++ b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_composite.py @@ -55,7 +55,7 @@ def test_basic_processing_differential(self): modeltest = tests.StandardModelTest(model, parameter_values=param) modeltest.test_all() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_basic_processing_algebraic(self): options = {"surface form": "algebraic"} model = pybamm.lead_acid.Composite(options) diff --git a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_foqs.py b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_foqs.py index 737a408dc6..473f855b58 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_foqs.py +++ b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_foqs.py @@ -64,7 +64,7 @@ def test_basic_processing_differential(self): modeltest = tests.StandardModelTest(model, parameter_values=param) modeltest.test_all() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_basic_processing_algebraic(self): options = { "surface form": "algebraic", diff --git a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_full.py b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_full.py index e09ec47eaa..7c829cea5a 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_full.py +++ b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_full.py @@ -9,14 +9,14 @@ class TestLeadAcidFull(unittest.TestCase): - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_basic_processing(self): options = {"thermal": "isothermal"} model = pybamm.lead_acid.Full(options) modeltest = tests.StandardModelTest(model) modeltest.test_all(t_eval=np.linspace(0, 0.6)) - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_basic_processing_with_convection(self): options = {"thermal": "isothermal", "convection": True} model = pybamm.lead_acid.Full(options) @@ -40,7 +40,7 @@ def test_optimisations(self): np.testing.assert_array_almost_equal(original, simp_and_known) np.testing.assert_array_almost_equal(original, simp_and_python) - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_set_up(self): options = {"thermal": "isothermal"} model = pybamm.lead_acid.Full(options) @@ -58,7 +58,7 @@ def test_basic_processing_differential(self): modeltest = tests.StandardModelTest(model) modeltest.test_all() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_basic_processing_algebraic(self): options = {"surface form": "algebraic"} model = pybamm.lead_acid.Full(options) @@ -78,7 +78,7 @@ def test_optimisations(self): np.testing.assert_array_almost_equal(original, using_known_evals) np.testing.assert_array_almost_equal(original, simp_and_known, decimal=5) - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_set_up(self): options = {"surface form": "differential"} model = pybamm.lead_acid.Full(options) diff --git a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_composite_side_reactions.py b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_composite_side_reactions.py index af855e849d..2d25498234 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_composite_side_reactions.py +++ b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_composite_side_reactions.py @@ -15,7 +15,7 @@ def test_basic_processing_differential(self): modeltest = tests.StandardModelTest(model) modeltest.test_all(skip_output_tests=True) - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_basic_processing_algebraic(self): options = {"side reactions": ["oxygen"], "surface form": "algebraic"} model = pybamm.lead_acid.Composite(options) diff --git a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_full_side_reactions.py b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_full_side_reactions.py index eb4823a1d7..409998f96f 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_full_side_reactions.py +++ b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_full_side_reactions.py @@ -9,7 +9,7 @@ class TestLeadAcidFullSideReactions(unittest.TestCase): - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_basic_processing(self): options = {"side reactions": ["oxygen"]} model = pybamm.lead_acid.Full(options) @@ -22,7 +22,7 @@ def test_basic_processing_differential(self): modeltest = tests.StandardModelTest(model) modeltest.test_all(skip_output_tests=True) - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_basic_processing_algebraic(self): options = {"side reactions": ["oxygen"], "surface form": "algebraic"} model = pybamm.lead_acid.Full(options) diff --git a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_loqs_side_reactions.py b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_loqs_side_reactions.py index 1139a7d129..b62535bb69 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_loqs_side_reactions.py +++ b/tests/integration/test_models/test_full_battery_models/test_lead_acid/test_side_reactions/test_loqs_side_reactions.py @@ -23,7 +23,7 @@ def test_discharge_differential_varying_surface_area(self): modeltest = tests.StandardModelTest(model) modeltest.test_all() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_discharge_algebraic(self): options = {"surface form": "algebraic", "side reactions": ["oxygen"]} model = pybamm.lead_acid.LOQS(options) diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_dfn.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_dfn.py index 9dd672ebec..d16639af24 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_dfn.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_dfn.py @@ -8,7 +8,7 @@ import unittest -@unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") +@unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") class TestDFN(unittest.TestCase): def test_basic_processing(self): options = {"thermal": "isothermal"} @@ -18,7 +18,7 @@ def test_basic_processing(self): modeltest = tests.StandardModelTest(model, var_pts=var_pts) modeltest.test_all() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_basic_processing_1plus1D(self): options = {"current collector": "potential pair", "dimensionality": 1} model = pybamm.lithium_ion.DFN(options) @@ -35,7 +35,7 @@ def test_basic_processing_1plus1D(self): modeltest = tests.StandardModelTest(model, var_pts=var_pts) modeltest.test_all(skip_output_tests=True) - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_basic_processing_2plus1D(self): options = {"current collector": "potential pair", "dimensionality": 2} model = pybamm.lithium_ion.DFN(options) diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spm.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spm.py index 0aed23ae2e..1d8810a29a 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spm.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spm.py @@ -14,7 +14,7 @@ def test_basic_processing(self): modeltest = tests.StandardModelTest(model) modeltest.test_all() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_basic_processing_1plus1D(self): options = {"current collector": "potential pair", "dimensionality": 1} model = pybamm.lithium_ion.SPM(options) @@ -31,7 +31,7 @@ def test_basic_processing_1plus1D(self): modeltest = tests.StandardModelTest(model, var_pts=var_pts) modeltest.test_all(skip_output_tests=True) - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_basic_processing_2plus1D(self): options = {"current collector": "potential pair", "dimensionality": 2} model = pybamm.lithium_ion.SPM(options) diff --git a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py index 46199f70d8..c411fb69f6 100644 --- a/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py +++ b/tests/integration/test_models/test_full_battery_models/test_lithium_ion/test_spme.py @@ -15,7 +15,7 @@ def test_basic_processing(self): modeltest = tests.StandardModelTest(model) modeltest.test_all() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_basic_processing_1plus1D(self): options = {"current collector": "potential pair", "dimensionality": 1} model = pybamm.lithium_ion.SPMe(options) @@ -32,7 +32,7 @@ def test_basic_processing_1plus1D(self): modeltest = tests.StandardModelTest(model, var_pts=var_pts) modeltest.test_all(skip_output_tests=True) - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_basic_processing_2plus1D(self): options = {"current collector": "potential pair", "dimensionality": 2} model = pybamm.lithium_ion.SPMe(options) diff --git a/tests/integration/test_quick_plot.py b/tests/integration/test_quick_plot.py index d197b94a6b..6924486c54 100644 --- a/tests/integration/test_quick_plot.py +++ b/tests/integration/test_quick_plot.py @@ -8,7 +8,7 @@ class TestQuickPlot(unittest.TestCase): Tests that QuickPlot is created correctly """ - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_plot_lithium_ion(self): spm = pybamm.lithium_ion.SPM() spme = pybamm.lithium_ion.SPMe() @@ -73,7 +73,7 @@ def test_plot_lithium_ion(self): quick_plot.update(0.01) - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_plot_lead_acid(self): loqs = pybamm.lead_acid.LOQS() geometry = loqs.default_geometry diff --git a/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_composite.py b/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_composite.py index 33a86fc467..2a9e16edba 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_composite.py +++ b/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_composite.py @@ -22,7 +22,7 @@ def test_well_posed_differential(self): class TestLeadAcidCompositeMultiDimensional(unittest.TestCase): - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_well_posed(self): model = pybamm.lead_acid.Composite( {"dimensionality": 1, "current collector": "potential pair"} @@ -58,7 +58,7 @@ def test_well_posed_differential(self): model = pybamm.lead_acid.Composite(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_well_posed_algebraic(self): options = {"surface form": "algebraic", "side reactions": ["oxygen"]} model = pybamm.lead_acid.Composite(options) diff --git a/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_full.py b/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_full.py index 8683ec464c..44737342cf 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_full.py +++ b/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_full.py @@ -15,7 +15,7 @@ def test_well_posed_with_convection(self): model = pybamm.lead_acid.Full(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_default_solver(self): model = pybamm.lead_acid.Full() self.assertIsInstance(model.default_solver, pybamm.ScikitsDaeSolver) @@ -37,7 +37,7 @@ def test_well_posed_algebraic(self): model = pybamm.lead_acid.Full(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_default_solver(self): options = {"surface form": "differential"} model = pybamm.lead_acid.Full(options) diff --git a/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_loqs.py b/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_loqs.py index c4bbfd75a5..681b362f1b 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_loqs.py +++ b/tests/unit/test_models/test_full_battery_models/test_lead_acid/test_loqs.py @@ -146,7 +146,7 @@ def test_well_posed_1plus1D(self): model = pybamm.lead_acid.LOQS(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_default_solver(self): options = {"surface form": "differential"} model = pybamm.lead_acid.LOQS(options) diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_dfn.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_dfn.py index 7d72a0b19a..eb22429f2b 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_dfn.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_dfn.py @@ -48,7 +48,7 @@ def test_x_full_thermal_model_no_current_collector(self): with self.assertRaises(NotImplementedError): model = pybamm.lithium_ion.DFN(options) - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_x_full_Nplus1D_not_implemented(self): # 1plus1D options = { @@ -91,7 +91,7 @@ def test_x_lumped_thermal_model_0D_current_collector(self): model = pybamm.lithium_ion.DFN(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_xyz_lumped_thermal_1D_current_collector(self): options = { "current collector": "potential pair", @@ -109,7 +109,7 @@ def test_xyz_lumped_thermal_1D_current_collector(self): model = pybamm.lithium_ion.DFN(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_xyz_lumped_thermal_2D_current_collector(self): options = { "current collector": "potential pair", @@ -127,7 +127,7 @@ def test_xyz_lumped_thermal_2D_current_collector(self): model = pybamm.lithium_ion.DFN(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_x_lumped_thermal_1D_current_collector(self): options = { "current collector": "potential pair", @@ -137,7 +137,7 @@ def test_x_lumped_thermal_1D_current_collector(self): model = pybamm.lithium_ion.DFN(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_x_lumped_thermal_2D_current_collector(self): options = { "current collector": "potential pair", @@ -147,7 +147,7 @@ def test_x_lumped_thermal_2D_current_collector(self): model = pybamm.lithium_ion.DFN(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_default_solver(self): options = {"thermal": "isothermal"} model = pybamm.lithium_ion.DFN(options) diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spm.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spm.py index 98723a5726..42336ac4c5 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spm.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spm.py @@ -56,7 +56,7 @@ def test_x_full_thermal_model_no_current_collector(self): with self.assertRaises(NotImplementedError): model = pybamm.lithium_ion.SPM(options) - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_x_full_Nplus1D_not_implemented(self): # 1plus1D options = { @@ -99,7 +99,7 @@ def test_x_lumped_thermal_model_0D_current_collector(self): model = pybamm.lithium_ion.SPM(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_xyz_lumped_thermal_1D_current_collector(self): options = { "current collector": "potential pair", @@ -117,7 +117,7 @@ def test_xyz_lumped_thermal_1D_current_collector(self): model = pybamm.lithium_ion.SPM(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_xyz_lumped_thermal_2D_current_collector(self): options = { "current collector": "potential pair", @@ -135,7 +135,7 @@ def test_xyz_lumped_thermal_2D_current_collector(self): model = pybamm.lithium_ion.SPM(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_x_lumped_thermal_1D_current_collector(self): options = { "current collector": "potential pair", @@ -145,7 +145,7 @@ def test_x_lumped_thermal_1D_current_collector(self): model = pybamm.lithium_ion.SPM(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_x_lumped_thermal_2D_current_collector(self): options = { "current collector": "potential pair", @@ -155,7 +155,7 @@ def test_x_lumped_thermal_2D_current_collector(self): model = pybamm.lithium_ion.SPM(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_default_solver(self): options = {"thermal": "isothermal"} model = pybamm.lithium_ion.SPM(options) diff --git a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spme.py b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spme.py index 0f2403db51..8f3b101cb7 100644 --- a/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spme.py +++ b/tests/unit/test_models/test_full_battery_models/test_lithium_ion/test_spme.py @@ -55,7 +55,7 @@ def test_x_full_thermal_model_no_current_collector(self): with self.assertRaises(NotImplementedError): model = pybamm.lithium_ion.SPMe(options) - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_x_full_Nplus1D_not_implemented(self): # 1plus1D options = { @@ -98,7 +98,7 @@ def test_x_lumped_thermal_model_0D_current_collector(self): model = pybamm.lithium_ion.SPMe(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_xyz_lumped_thermal_1D_current_collector(self): options = { "current collector": "potential pair", @@ -116,7 +116,7 @@ def test_xyz_lumped_thermal_1D_current_collector(self): model = pybamm.lithium_ion.SPMe(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_xyz_lumped_thermal_2D_current_collector(self): options = { "current collector": "potential pair", @@ -126,7 +126,7 @@ def test_xyz_lumped_thermal_2D_current_collector(self): model = pybamm.lithium_ion.SPMe(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_x_lumped_thermal_1D_current_collector(self): options = { "current collector": "potential pair", @@ -144,7 +144,7 @@ def test_x_lumped_thermal_1D_current_collector(self): model = pybamm.lithium_ion.SPMe(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_x_lumped_thermal_2D_current_collector(self): options = { "current collector": "potential pair", @@ -154,7 +154,7 @@ def test_x_lumped_thermal_2D_current_collector(self): model = pybamm.lithium_ion.SPMe(options) model.check_well_posedness() - @unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") + @unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") def test_default_solver(self): options = {"thermal": "isothermal"} model = pybamm.lithium_ion.SPMe(options) diff --git a/tests/unit/test_solvers/test_scikits_solvers.py b/tests/unit/test_solvers/test_scikits_solvers.py index e8b503f2fe..436043cf20 100644 --- a/tests/unit/test_solvers/test_scikits_solvers.py +++ b/tests/unit/test_solvers/test_scikits_solvers.py @@ -9,7 +9,7 @@ from tests import get_mesh_for_testing, get_discretisation_for_testing -@unittest.skipIf(pybamm.have_scikits_odes(), "scikits.odes not installed") +@unittest.skipIf(~pybamm.have_scikits_odes(), "scikits.odes not installed") class TestScikitsSolvers(unittest.TestCase): def test_ode_integrate(self): # Constant From e0290a7e8838564fec0426ea95b39a9231e6a0e0 Mon Sep 17 00:00:00 2001 From: tinosulzer Date: Sun, 27 Oct 2019 23:54:01 -0400 Subject: [PATCH 09/13] #646 revert version changes, causing problems --- pybamm/__init__.py | 14 ++------------ pybamm/version | 1 - setup.py | 16 +++------------- 3 files changed, 5 insertions(+), 26 deletions(-) delete mode 100644 pybamm/version diff --git a/pybamm/__init__.py b/pybamm/__init__.py index 482d6c9476..ce9fc755b7 100644 --- a/pybamm/__init__.py +++ b/pybamm/__init__.py @@ -10,19 +10,9 @@ # # Version info +# Keep up to date with setup.py! # -def _load_version_int(): - try: - root = os.path.abspath(os.path.dirname(__file__)) - with open(os.path.join(root, "version"), "r") as f: - version = f.read().strip().split(",") - major, minor, revision = [int(x) for x in version] - return major, minor, revision - except Exception as e: - raise RuntimeError("Unable to read version number (" + str(e) + ").") - - -__version_int__ = _load_version_int() +__version_int__ = (0, 1, 0) __version__ = ".".join([str(x) for x in __version_int__]) if sys.version_info[0] < 3: del x # Before Python3, list comprehension iterators leaked diff --git a/pybamm/version b/pybamm/version deleted file mode 100644 index c7cff60e58..0000000000 --- a/pybamm/version +++ /dev/null @@ -1 +0,0 @@ -0, 1, 0 diff --git a/setup.py b/setup.py index 14227d4205..c8cb541f5d 100644 --- a/setup.py +++ b/setup.py @@ -8,22 +8,12 @@ readme = f.read() -# Read version number from file -def load_version(): - try: - import os - - root = os.path.abspath(os.path.dirname(__file__)) - with open(os.path.join(root, "pybamm", "version"), "r") as f: - version = f.read().strip().split(",") - return ".".join([str(int(x)) for x in version]) - except Exception as e: - raise RuntimeError("Unable to read version number (" + str(e) + ").") - +# Keep up to date with __init__! +version = "0.1.0" setup( name="pybamm", - version=load_version(), + version=version, description="Python Battery Mathematical Modelling.", long_description=readme, url="https://github.com/pybamm-team/PyBaMM", From af39ac217e6370638f53f0642a9468c2d63ce923 Mon Sep 17 00:00:00 2001 From: Valentin Sulzer Date: Fri, 8 Nov 2019 11:26:00 -0500 Subject: [PATCH 10/13] #646 try a fix for mac --- scripts/install_sundials_4.1.0.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/install_sundials_4.1.0.sh b/scripts/install_sundials_4.1.0.sh index 58a3085fc6..6da6751e70 100755 --- a/scripts/install_sundials_4.1.0.sh +++ b/scripts/install_sundials_4.1.0.sh @@ -44,7 +44,8 @@ make -j$NUM_OF_CORES install cd $CURRENT_DIR rm -rf build-sundials-4.1.0 rm -rf sundials-4.1.0 -export LD_LIBRARY_PATH=$INSTALL_DIR/lib:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH=$INSTALL_DIR/lib:$LD_LIBRARY_PATH # For Linux +export DYLD_LIBRARY_PATH=$INSTALL_DIR/lib:$DYLD_LIBRARY_PATH # For Mac export SUNDIALS_INST=$INSTALL_DIR # get pybind11 From bd290f8545923e442291bf3312933c02c27aacca Mon Sep 17 00:00:00 2001 From: Valentin Sulzer Date: Fri, 8 Nov 2019 11:30:16 -0500 Subject: [PATCH 11/13] #646 revert version changes --- pybamm/__init__.py | 14 ++++++++++++-- pybamm/version | 1 + setup.py | 16 +++++++++++++--- 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 pybamm/version diff --git a/pybamm/__init__.py b/pybamm/__init__.py index 07bf57749f..55ad930ce5 100644 --- a/pybamm/__init__.py +++ b/pybamm/__init__.py @@ -10,9 +10,19 @@ # # Version info -# Keep up to date with setup.py! # -__version_int__ = (0, 1, 0) +def _load_version_int(): + try: + root = os.path.abspath(os.path.dirname(__file__)) + with open(os.path.join(root, "version"), "r") as f: + version = f.read().strip().split(",") + major, minor, revision = [int(x) for x in version] + return major, minor, revision + except Exception as e: + raise RuntimeError("Unable to read version number (" + str(e) + ").") + + +__version_int__ = _load_version_int() __version__ = ".".join([str(x) for x in __version_int__]) if sys.version_info[0] < 3: del x # Before Python3, list comprehension iterators leaked diff --git a/pybamm/version b/pybamm/version new file mode 100644 index 0000000000..c7cff60e58 --- /dev/null +++ b/pybamm/version @@ -0,0 +1 @@ +0, 1, 0 diff --git a/setup.py b/setup.py index c3d29d450a..fbaebb09cb 100644 --- a/setup.py +++ b/setup.py @@ -8,12 +8,22 @@ readme = f.read() -# Keep up to date with __init__! -version = "0.1.0" +# Read version number from file +def load_version(): + try: + import os + + root = os.path.abspath(os.path.dirname(__file__)) + with open(os.path.join(root, "pybamm", "version"), "r") as f: + version = f.read().strip().split(",") + return ".".join([str(int(x)) for x in version]) + except Exception as e: + raise RuntimeError("Unable to read version number (" + str(e) + ").") + setup( name="pybamm", - version=version, + version=load_version(), description="Python Battery Mathematical Modelling.", long_description=readme, url="https://github.com/pybamm-team/PyBaMM", From da61cedbe523e534027fbe8e3224867f1cb36f16 Mon Sep 17 00:00:00 2001 From: Valentin Sulzer Date: Fri, 8 Nov 2019 11:33:38 -0500 Subject: [PATCH 12/13] #646 changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 066d81d63e..b4e9ee07d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - Added missing temperature dependence in electrolyte and interface submodels ([#698](https://github.com/pybamm-team/PyBaMM/pull/698)) - Fixed differentiation of functions that have more than one argument ([#687](https://github.com/pybamm-team/PyBaMM/pull/687)) - Added warning if `ProcessedVariable` is called outside its interpolation range ([#681](https://github.com/pybamm-team/PyBaMM/pull/681)) +- Updated installation instructions for Mac OS ([#680](https://github.com/pybamm-team/PyBaMM/pull/680)) - Improved the way `ProcessedVariable` objects are created in higher dimensions ([#581](https://github.com/pybamm-team/PyBaMM/pull/581)) # [v0.1.0](https://github.com/pybamm-team/PyBaMM/tree/v0.1.0) - 2019-10-08 From e3d21711012bfb0f841f134259a20b251f2ad3db Mon Sep 17 00:00:00 2001 From: vsulzer Date: Wed, 11 Dec 2019 17:23:32 -0500 Subject: [PATCH 13/13] #644 fix typo in name --- INSTALL_KLU.md => INSTALL-KLU.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename INSTALL_KLU.md => INSTALL-KLU.md (100%) diff --git a/INSTALL_KLU.md b/INSTALL-KLU.md similarity index 100% rename from INSTALL_KLU.md rename to INSTALL-KLU.md