From 1e292ef99c50bf8f9a86c9942ca461d2145cff26 Mon Sep 17 00:00:00 2001 From: Josh Allen <joshua.w.allen@gmail.com> Date: Sat, 14 Feb 2015 13:36:53 -0500 Subject: [PATCH 01/15] Moved files into new pydas package. Now that we're wrapping multiple DAE solvers, it makes sense to collect them into a package. At the same time, we can improve the naming convention by calling the moved modules pydas.dassl and pydas.daspk instead of pydas and pydaspk. This will force everyone to update their import statements. --- pydas/__init__.py | 29 +++++++++++++++++++++++++++++ daspk.h => pydas/daspk.h | 0 pydaspk.pxd => pydas/daspk.pxd | 0 pydaspk.pyx => pydas/daspk.pyx | 0 das.h => pydas/dassl.h | 0 pydas.pxd => pydas/dassl.pxd | 0 pydas.pyx => pydas/dassl.pyx | 0 7 files changed, 29 insertions(+) create mode 100644 pydas/__init__.py rename daspk.h => pydas/daspk.h (100%) rename pydaspk.pxd => pydas/daspk.pxd (100%) rename pydaspk.pyx => pydas/daspk.pyx (100%) rename das.h => pydas/dassl.h (100%) rename pydas.pxd => pydas/dassl.pxd (100%) rename pydas.pyx => pydas/dassl.pyx (100%) diff --git a/pydas/__init__.py b/pydas/__init__.py new file mode 100644 index 0000000..0be6831 --- /dev/null +++ b/pydas/__init__.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +################################################################################ +# +# PyDAS - A Python wrapper to several differential algebraic system solvers +# +# Copyright (c) 2010-2014 by Joshua W. Allen (joshua.w.allen@gmail.com) +# extended by Connie W. Gao (connieg@mit.edu) +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the 'Software'), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +################################################################################ diff --git a/daspk.h b/pydas/daspk.h similarity index 100% rename from daspk.h rename to pydas/daspk.h diff --git a/pydaspk.pxd b/pydas/daspk.pxd similarity index 100% rename from pydaspk.pxd rename to pydas/daspk.pxd diff --git a/pydaspk.pyx b/pydas/daspk.pyx similarity index 100% rename from pydaspk.pyx rename to pydas/daspk.pyx diff --git a/das.h b/pydas/dassl.h similarity index 100% rename from das.h rename to pydas/dassl.h diff --git a/pydas.pxd b/pydas/dassl.pxd similarity index 100% rename from pydas.pxd rename to pydas/dassl.pxd diff --git a/pydas.pyx b/pydas/dassl.pyx similarity index 100% rename from pydas.pyx rename to pydas/dassl.pyx From 363703360907e62de7647cfda05d7d76b209db1c Mon Sep 17 00:00:00 2001 From: Josh Allen <joshua.w.allen@gmail.com> Date: Sat, 14 Feb 2015 13:48:04 -0500 Subject: [PATCH 02/15] Update build scripts to reflect new pydas package. Also fix a reference to header file das.h (now named pydas/dassl.h) in the pydas.dassl module. --- Makefile | 2 +- pydas/dassl.pyx | 2 +- setup.py | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index cc3a8db..7107eb6 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ daspk: DASPK31 cython-daspk cython-daspk: python setup.py build_ext daspk $(CYTHON_FLAGS) -cython: DASSL DASPK DASKR pydas.pyx +cython: DASSL DASPK DASKR pydas/dassl.pyx python setup.py build_ext $(CYTHON_FLAGS) install: DASSL DASPK DASKR cython diff --git a/pydas/dassl.pyx b/pydas/dassl.pyx index 92d2312..a1134c0 100644 --- a/pydas/dassl.pyx +++ b/pydas/dassl.pyx @@ -55,7 +55,7 @@ cimport cython ################################################################################ # Expose the (double-precision) DASSL function -cdef extern from "das.h": +cdef extern from "dassl.h": int ddassl_( void* res, # The residual function that defines the ODE/DAE system int* neq, # The number of equations to be solved diff --git a/setup.py b/setup.py index 172080e..c0e1682 100644 --- a/setup.py +++ b/setup.py @@ -50,28 +50,28 @@ # The Cython extension modules to compile pydas_ext = Extension( - 'pydas', - ['pydas.pyx'], - include_dirs=['.', numpy.get_include()], + 'pydas.dassl', + ['pydas/dassl.pyx'], + include_dirs=['pydas', numpy.get_include()], libraries=['gfortran'], extra_objects=['dassl/daux.o','dassl/ddassl.o','dassl/dlinpk.o'], ) pydaspk_ext = Extension( - 'pydaspk', - ['pydaspk.pyx'], - include_dirs=['.', numpy.get_include()], + 'pydas.daspk', + ['pydas/daspk.pyx'], + include_dirs=['pydas', numpy.get_include()], libraries=['gfortran'], extra_objects=['daspk31/adf_dummy.o','daspk31/daux.o','daspk31/ddaspk.o','daspk31/dlinpk.o','daspk31/dsensd.o','daspk31/mpi_dummy.o'], ) - modules = ['pydas'] + modules = ['pydas.dassl'] extensions = [pydas_ext] if 'daspk' in sys.argv: # Optionally compile and make pydaspk if the user requests it sys.argv.remove('daspk') - modules.append('pydaspk') + modules.append('pydas.daspk') extensions.append(pydaspk_ext) # Run the setup command From 5ca401b7a7d4040c27b66dc4003616b6db1ecc58 Mon Sep 17 00:00:00 2001 From: Josh Allen <joshua.w.allen@gmail.com> Date: Sat, 14 Feb 2015 14:05:38 -0500 Subject: [PATCH 03/15] Move test files into new tests folder. To further tidy up the top project folder. --- tests/__init__.py | 29 ++++++++++++++++++++++++++++ pydaspkTest.py => tests/daspkTest.py | 0 pydasTest.py => tests/dasslTest.py | 0 3 files changed, 29 insertions(+) create mode 100644 tests/__init__.py rename pydaspkTest.py => tests/daspkTest.py (100%) rename pydasTest.py => tests/dasslTest.py (100%) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..0be6831 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +################################################################################ +# +# PyDAS - A Python wrapper to several differential algebraic system solvers +# +# Copyright (c) 2010-2014 by Joshua W. Allen (joshua.w.allen@gmail.com) +# extended by Connie W. Gao (connieg@mit.edu) +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the 'Software'), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +################################################################################ diff --git a/pydaspkTest.py b/tests/daspkTest.py similarity index 100% rename from pydaspkTest.py rename to tests/daspkTest.py diff --git a/pydasTest.py b/tests/dasslTest.py similarity index 100% rename from pydasTest.py rename to tests/dasslTest.py From 4270d3050927532a4358406f234d2604f3193616 Mon Sep 17 00:00:00 2001 From: Josh Allen <joshua.w.allen@gmail.com> Date: Sat, 14 Feb 2015 14:17:55 -0500 Subject: [PATCH 04/15] Fix imports in test modules to reflect new pydas package. Similar changes will be required by all end users. --- tests/daspkTest.py | 2 +- tests/dasslTest.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/daspkTest.py b/tests/daspkTest.py index fc7e61f..3547a65 100644 --- a/tests/daspkTest.py +++ b/tests/daspkTest.py @@ -7,7 +7,7 @@ import unittest -from pydaspk import DASPK +from pydas.daspk import DASPK import math import numpy import matplotlib.pyplot as plt diff --git a/tests/dasslTest.py b/tests/dasslTest.py index d80fc1f..ea61207 100644 --- a/tests/dasslTest.py +++ b/tests/dasslTest.py @@ -7,7 +7,7 @@ import unittest -from pydas import DASSL +from pydas.dassl import DASSL import math import numpy From 1cb2cb2d0d63d9a7a797a9130ef9a674b45bfd9b Mon Sep 17 00:00:00 2001 From: Josh Allen <joshua.w.allen@gmail.com> Date: Sat, 14 Feb 2015 15:14:38 -0500 Subject: [PATCH 05/15] Update setup.py to include .pxd and .pyx files in distribution. The .pxd files are needed to allow others to link against the compiled pydas.dassl and pydas.daspk modules. The .pyx files are nice to have so that folks have another means of viewing the code behind the compiled modules. Closes #11. --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index c0e1682..23fd14f 100644 --- a/setup.py +++ b/setup.py @@ -82,6 +82,8 @@ author_email='joshua.w.allen@gmail.com', url='http://github.com/jwallen/PyDAS', py_modules= modules, + packages = ['pydas'], + package_data = {'pydas': ['*.pxd']}, cmdclass = {'build_ext': build_ext}, ext_modules = extensions ) From 564a64c828e2ce5dcfcc471c38ef1715ecb6ed5b Mon Sep 17 00:00:00 2001 From: Josh Allen <joshua.w.allen@gmail.com> Date: Sat, 14 Feb 2015 15:52:33 -0500 Subject: [PATCH 06/15] Add pydas.get_include() for finding PyDAS include directory. Usage should mirror numpy.get_include(), and thereby make it easier to link against the compiled PyDAS modules. --- pydas/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pydas/__init__.py b/pydas/__init__.py index 0be6831..42b1b24 100644 --- a/pydas/__init__.py +++ b/pydas/__init__.py @@ -27,3 +27,11 @@ # DEALINGS IN THE SOFTWARE. # ################################################################################ + +import os + +def get_include(): + """ + Return the PyDAS include directory. + """ + return os.path.dirname(os.path.abspath(__file__)) From 938b94ff17723505bae3981793bfe30f258d9262 Mon Sep 17 00:00:00 2001 From: Connie Gao <connieg@mit.edu> Date: Tue, 17 Feb 2015 13:06:04 -0500 Subject: [PATCH 07/15] Add automatic download and unpacking script for DASPK 3.1 fortran source code. --- daspk31/Makefile | 2 +- daspk31/README | 8 +++++--- daspk31/download_daspk31.sh | 5 +++++ 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 daspk31/download_daspk31.sh diff --git a/daspk31/Makefile b/daspk31/Makefile index aaacd3a..4a33cac 100644 --- a/daspk31/Makefile +++ b/daspk31/Makefile @@ -8,7 +8,7 @@ F77=gfortran CFLAGS=-fPIC -O3 -DOBJ=adf_dummy.o daux.o ddaskr.o ddaspk.o dlinpk.o dsensd.o mpi_dummy.o +DOBJ=solver/adf_dummy.o solver/daux.o solver/ddaskr.o solver/ddaspk.o solver/dlinpk.o solver/dsensd.o solver/mpi_dummy.o DLIB=libddaspk31.a diff --git a/daspk31/README b/daspk31/README index 845dfcc..1390a6a 100644 --- a/daspk31/README +++ b/daspk31/README @@ -1,9 +1,11 @@ DASPK 3.1 Large Scale Differential Algebraic Equation Solver with Sensitivity Analysis -Before using, dump the source files of the DASPK 3.1 solver folder into this folder. -The fortran solver can be downloaded here: http://www.engineering.ucsb.edu/~cse/software.html -The files present should be as follows: +Before using, dump the files from the DASPK 3.1 source code into this folder. +You can use the script download_daspk31.sh to automatically download and unpack the source files +or download it manually from the web here: http://www.engineering.ucsb.edu/~cse/software.html + +The following files should be present in the 'solver' folder: adf_dummy.f daux.f ddaskr.f diff --git a/daspk31/download_daspk31.sh b/daspk31/download_daspk31.sh new file mode 100644 index 0000000..3077603 --- /dev/null +++ b/daspk31/download_daspk31.sh @@ -0,0 +1,5 @@ +echo 'Downloading and unpacking DASPK 3.1 fortran source files...' +wget http://www.cs.ucsb.edu/~cse/Software/daspk31.tgz +tar zxvf daspk31.tgz -C ../ +rm daspk31.tgz + From c788670709f6b1119fbe9f51e987d70c0577f76f Mon Sep 17 00:00:00 2001 From: Connie Gao <connieg@mit.edu> Date: Tue, 17 Feb 2015 13:06:40 -0500 Subject: [PATCH 08/15] Make clean-cython delete the appropriate files inside the pydas/ folder --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 7107eb6..048b584 100644 --- a/Makefile +++ b/Makefile @@ -54,7 +54,7 @@ clean-DASKR: clean-cython: python setup.py clean $(CLEAN_FLAGS) - rm -f *.so *.pyc *.c + rm -f pydas/*.so pydas/*.pyc pydas/*.c help: @echo "" From 7d5757946e1205c01daaa828f110c0f5e67e6d68 Mon Sep 17 00:00:00 2001 From: Connie Gao <connieg@mit.edu> Date: Tue, 17 Feb 2015 13:07:53 -0500 Subject: [PATCH 09/15] Remove unecessary argument in `make cython` command. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 048b584..a856651 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ daspk: DASPK31 cython-daspk cython-daspk: python setup.py build_ext daspk $(CYTHON_FLAGS) -cython: DASSL DASPK DASKR pydas/dassl.pyx +cython: DASSL DASPK DASKR python setup.py build_ext $(CYTHON_FLAGS) install: DASSL DASPK DASKR cython From 0e1c4397d2ae4b56bacdbc11031a615a4cbbd44b Mon Sep 17 00:00:00 2001 From: Connie Gao <connieg@mit.edu> Date: Tue, 17 Feb 2015 13:08:52 -0500 Subject: [PATCH 10/15] Change .gitignore to ignore daspk31 source files. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 72b0ae9..51549b6 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ make.inc /.project /.pydevproject /.settings + +# DASPK3.1 source files +daspk31/* \ No newline at end of file From c43068649d57b9ff07dbf473b0e0156e0909e00b Mon Sep 17 00:00:00 2001 From: Connie Gao <connieg@mit.edu> Date: Tue, 17 Feb 2015 13:12:37 -0500 Subject: [PATCH 11/15] Fix cython setup.py file to use correct compiled daspk31 files --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 23fd14f..73c4ca4 100644 --- a/setup.py +++ b/setup.py @@ -61,7 +61,7 @@ ['pydas/daspk.pyx'], include_dirs=['pydas', numpy.get_include()], libraries=['gfortran'], - extra_objects=['daspk31/adf_dummy.o','daspk31/daux.o','daspk31/ddaspk.o','daspk31/dlinpk.o','daspk31/dsensd.o','daspk31/mpi_dummy.o'], + extra_objects=['daspk31/solver/adf_dummy.o','daspk31/solver/daux.o','daspk31/solver/ddaspk.o','daspk31/solver/dlinpk.o','daspk31/solver/dsensd.o','daspk31/solver/mpi_dummy.o'], ) From e1547bbb2d87b84a460034ae46117ed522fc82c8 Mon Sep 17 00:00:00 2001 From: Connie Gao <connieg@mit.edu> Date: Tue, 17 Feb 2015 13:35:49 -0500 Subject: [PATCH 12/15] Add some details about DASPK wrapper and compiling instructions to README.rst --- README.rst | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index b564c64..fec3915 100644 --- a/README.rst +++ b/README.rst @@ -13,6 +13,12 @@ provides a Python extension type for each solver, which in turn provides a Pythonic means of setting the solver options, providing residual and jacobian functions, and running the solver. +In addition, PyDAS also provides a wrapper to the DASPK3.1 solver, which +has native sensitivity analysis. The source code for DASPK3.1 is subject to +copyright restrictions but is available for research purposes. Due to these +restrictions, it is up to the user to download these source files manually. +Please see the README file inside the daspk31/ folder for more details. + The DASSL, DASPK, and DASKR solvers are all substantially more robust than VODE, the solver used within the ODE solver functionality provided by `SciPy <http://www.scipy.org/>`_. @@ -71,13 +77,14 @@ Installation .. note:: - Currently only the DASSL solver has been wrapped. The installation - scripts therefore only build and install the DASSL wrapper by default. + Currently only the DASSL and DASPK3.1 solvers have been wrapped. + The installation scripts only build and install the DASSL wrapper + by default. The DASPK wrapper must be installed with additional arguments. Windows ------- -The provided batch scripts will compile all of the solvers and the PyDAS +The provided batch scripts will compile the DASSL solver and the PyDAS wrapper code. These scripts presume that you have the 32-bit version of the MinGW C and Fortran compilers installed. Once you have run the batch script, you can install PyDAS into your Python packages if you desire by running the @@ -85,17 +92,26 @@ following command from the base package directory: > python setup.py install + Linux ----- -A Makefile has been provided that can be used to compile all of the solvers -and the PyDAS wrapper code. To use, invoke the following command from the +A Makefile has been provided that can be used to compile the DASSL solver and +DASSL wrapper code. To use, invoke the following command from the base package directory:: $ make This command will build PyDAS in-place, rather than installing it to your -Python package directory. If you wish to formall install PyDAS, run the +Python package directory. + +If you wish to compile the DASPK3.1 solver and wrapper, use the command +(Make sure you have already downloaded the fortran source files. See the +daspk/README file for more details):: + + $ make daspk + + If you wish to formall install PyDAS, run the following command from the base package directory after the ``make`` command (you may need root privileges for this):: @@ -106,6 +122,7 @@ the Makefiles (e.g. the Fortran compiler). An example of such a file, `make.inc.example`, has been provided. + Mac OS X -------- From 77709877515f5156fb3ea648b95d94347e60a174 Mon Sep 17 00:00:00 2001 From: Connie Gao <connieg@mit.edu> Date: Tue, 17 Feb 2015 13:54:39 -0500 Subject: [PATCH 13/15] Provide a windows batch script for making the DASPK3.1 solver and wrapper. --- README.rst | 7 +++++-- make_daspk.bat | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 make_daspk.bat diff --git a/README.rst b/README.rst index fec3915..ea4f848 100644 --- a/README.rst +++ b/README.rst @@ -84,8 +84,11 @@ Installation Windows ------- -The provided batch scripts will compile the DASSL solver and the PyDAS -wrapper code. These scripts presume that you have the 32-bit version of the +The provided make.bat batch script will compile the DASSL solver and the PyDAS +wrapper code. Use the make_daspk.bat script to compile the DASPK3.1 solver and the +DASPK wrapper code. Make sure you have manually downloaded the DASPK3.1 source +files into the daspk31 folder. See the daspk31/README file for more details. +These scripts presume that you have the 32-bit version of the MinGW C and Fortran compilers installed. Once you have run the batch script, you can install PyDAS into your Python packages if you desire by running the following command from the base package directory: diff --git a/make_daspk.bat b/make_daspk.bat new file mode 100644 index 0000000..b1d80dc --- /dev/null +++ b/make_daspk.bat @@ -0,0 +1,22 @@ +@echo off + +:: Set the Fortran compiler and compiler flags +set f77=gfortran +set cflags=-O3 + +echo Compiling DASPK3.1... +CALL %f77% %cflags% -c daspk31/solver/adf_dummy.f -o daspk/solver/adf_dummy.o +CALL %f77% %cflags% -c daspk31/solver/daux.f -o daspk/solver/daux.o +CALL %f77% %cflags% -c daspk31/solver/ddaskr.f -o daspk/solver/ddaskr.o +CALL %f77% %cflags% -c daspk31/solver/ddaspk.f -o daspk/solver/ddaspk.o +CALL %f77% %cflags% -c daspk31/solver/dlinpk.f -o daspk/solver/dlinpk.o +CALL %f77% %cflags% -c daspk31/solver/dsensd.f -o daspk/solver/dsensd.o +CALL %f77% %cflags% -c daspk31/solver/mpi_dummy.f -o daspk/solver/mpi_dummy.o + +CALL ar rcs dassl/libddaspk31.a daspk31/solver/adf_dummy.o daspk31/solver/daux.o daspk31/solver/ddaskr.o daspk31/solver/ddaspk.o daspk31/solver/dlinpk.o daspk31/solver/dsensd.o daspk31/solver/mpi_dummy.o + +echo Compiling PyDAS DASPK wrapper... +CALL python setup.py build_ext daspk --compiler=mingw32 --inplace + +:end +pause From 4df12b76fd6986e3f95558aca0278061a7f53573 Mon Sep 17 00:00:00 2001 From: Connie Gao <connieg@mit.edu> Date: Tue, 17 Feb 2015 13:57:59 -0500 Subject: [PATCH 14/15] Update the installation documentation --- documentation/source/users/installation.rst | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/documentation/source/users/installation.rst b/documentation/source/users/installation.rst index 9907d8b..f7929b1 100644 --- a/documentation/source/users/installation.rst +++ b/documentation/source/users/installation.rst @@ -24,6 +24,11 @@ provides these compilers. The DASSL, DASPK, and DASKR solvers are provided with the PyDAS package; you do not need to download them separately. +The DASPK3.1 solver is subject to copyright restrictions and therefore +must be downloaded separately either using the ``daspk31/download_daspk31.sh`` +script or by manually unpacking the files from the daspk31 source code +found on `Linda Petzold's software page <http://www.cs.ucsb.edu/~cse/software.html>`_ into the ``daspk31`` folder. + .. [#f1] The Fortran interfaces are exposed to Python via C, so the installer needs to be able to link object files from Fortran and C for this to work. @@ -48,6 +53,12 @@ Python package directory. At this point you can optionally run the unit test script ``test.py`` and/or any of the provided examples to confirm that PyDAS was compiled successfully. +If you wish to compile the DASPK3.1 solver and wrapper, use the command. +Make sure you have already downloaded the fortran source files. See the +``daspk/README`` file for where to download the files.:: + + $ make daspk + If you wish to formally install PyDAS, run the following command from the root package directory after the ``make`` command (you may need root privileges for this):: @@ -70,9 +81,11 @@ Windows from the ``cython-dev`` mailing list for more information. A batch script ``make.bat`` has been provided in the root package directory. -Double-clicking this script will cause all of the solvers -- DASSL, DASPK, and -DASKR -- to be compiled into static libraries and the PyDAS wrapper code to be -compiled. +Double-clicking this script will compile the DASSL solver into a static library and also compile the PyDAS wrapper code. + +The batch script ``make_daspk.bat`` has been provided to compile the DASPK3.1 +solver and the DASPK wrapper code. Make sure the source code for the DASPK3.1 +have been manually downloaded and stored inside the daspk31 folder. See ``daspk31/README`` for details on where to download the files. .. note:: From f6c304fd23f06ec061fa777d1ed183e298e64e32 Mon Sep 17 00:00:00 2001 From: Connie Gao <connieg@mit.edu> Date: Tue, 17 Feb 2015 16:40:42 -0500 Subject: [PATCH 15/15] Remove dummy senpar variables from residual and jacobian functions. This is so that users don't have to define their functions or call them with the dummy senpar variable. Keeping the dummy senpar as an optional argument in the initialize function is sufficient. --- pydas/dassl.pyx | 7 +++---- tests/dasslTest.py | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pydas/dassl.pyx b/pydas/dassl.pyx index a1134c0..622a613 100644 --- a/pydas/dassl.pyx +++ b/pydas/dassl.pyx @@ -185,8 +185,7 @@ cdef class DASSL: else: self.info[3] = 0 rwork[0] = 0 - - self.senpar = senpar # this is a dummy variable so that PyDAS and PyDASK can be used interchangeably + # Set whether or not jacobian function is provided # This is determined by whether or not you have implemented a # jacobian method @@ -391,7 +390,7 @@ cdef DASSL dasslObject cdef void residual(double* t, double* y, double* yprime, double* delta, int* ires, double* rpar, int* ipar): cdef np.ndarray[np.float64_t,ndim=1] res cdef int i - res, ires[0] = dasslObject.residual(dasslObject.t, dasslObject.y, dasslObject.dydt, dasslObject.senpar) + res, ires[0] = dasslObject.residual(dasslObject.t, dasslObject.y, dasslObject.dydt) for i in range(res.shape[0]): delta[i] = res[i] @@ -399,7 +398,7 @@ cdef void residual(double* t, double* y, double* yprime, double* delta, int* ire cdef void jacobian(double* t, double* y, double* yprime, double* pd, double* cj, double* rpar, int* ipar): cdef np.ndarray[np.float64_t,ndim=2] jac cdef int i, j - jac = dasslObject.jacobian(dasslObject.t, dasslObject.y, dasslObject.dydt, cj[0], dasslObject.senpar) + jac = dasslObject.jacobian(dasslObject.t, dasslObject.y, dasslObject.dydt, cj[0]) N = jac.shape[0] for i in range(N): for j in range(N): diff --git a/tests/dasslTest.py b/tests/dasslTest.py index ea61207..4346cdd 100644 --- a/tests/dasslTest.py +++ b/tests/dasslTest.py @@ -30,14 +30,14 @@ def __init__(self, k1=0.0, k2=0.0): self.k1 = k1 self.k2 = k2 - def residual(self, t, y, dydt, senpar): + def residual(self, t, y, dydt): delta = numpy.zeros(y.shape[0], numpy.float64) delta[0] = -self.k1 * y[0] - dydt[0] delta[1] = self.k1 * y[0] - self.k2 * y[1] - dydt[1] delta[2] = self.k2 * y[1] - dydt[2] return delta, 0 - def jacobian(self, t, y, dydt, cj, senpar): + def jacobian(self, t, y, dydt, cj): pd = -cj * numpy.identity(y.shape[0], numpy.float64) pd[0,0] += -self.k1 pd[1,0] += self.k1 @@ -82,7 +82,7 @@ def testSimple(self): k1 = 1.0; k2 = 0.25 model = SimpleModel(k1, k2) t0 = 0.0; y0 = numpy.array([1.0, 0.0, 0.0], numpy.float64) - dydt0 = model.residual(t0, y0, numpy.zeros(3, numpy.float64),numpy.zeros(3, numpy.float64))[0] + dydt0 = model.residual(t0, y0, numpy.zeros(3, numpy.float64))[0] model.initialize(t0, y0, dydt0, atol=1e-16, rtol=1e-8) tmax = 100; iter = 0; maxiter = 1000