除了SciPy的odeint外,我还在尝试其他ODE求解器。我找到了一个可能的scikits.odes包。要求包括C和FORTRAN编译器(我下载了MinGW-w64,没有问题),LAPACK(下载,构建,测试,看起来还不错)和SUNDIALS(LAPACK问题)。如果SUNDIALS中未启用LAPACK,则安装和运行scikits.odes.test()会出现一些错误。任何可以帮助我解决此问题的人。
在Python 3.5.5上安装scikits.odes并运行后:
import scikits.odes as od
od.test()
我有以下输出:
Running unit tests for scikits.odes
NumPy version 1.15.1
NumPy relaxed strides checking option: True
NumPy is installed in C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\numpy
Python version 3.5.5 |Anaconda, Inc.| (default, Apr 7 2018, 04:52:34) [MSC v.1900 64 bit (AMD64)]
nose version 1.3.7
Ecannot import name 'cvode'
.EEEEEE.EE.EEEE
======================================================================
ERROR: Failure: ImportError (No module named 'scikits.odes.sundials.common_defs')
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\loader.py", line 417, in loadTestsFromName
addr.filename, addr.module)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\imp.py", line 235, in load_module
return load_source(name, filename, file)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 693, in _load
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 697, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\tests\test_dae.py", line 15, in <module>
from scikits.odes.sundials.common_defs import DTYPE
ImportError: No module named 'scikits.odes.sundials.common_defs'
======================================================================
ERROR: test_get_info_is_exposed_on_ode (scikits.odes.tests.test_get_info.GetInfoTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\tests\test_get_info.py", line 23, in setUp
self.ode = ode('cvode', rhs, old_api=False)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: test_get_info_returns_dict (scikits.odes.tests.test_get_info.GetInfoTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\tests\test_get_info.py", line 23, in setUp
self.ode = ode('cvode', rhs, old_api=False)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: test_ode_exposes_num_rhs_evals (scikits.odes.tests.test_get_info.GetInfoTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\tests\test_get_info.py", line 23, in setUp
self.ode = ode('cvode', rhs, old_api=False)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: test_we_integrated_correctly (scikits.odes.tests.test_get_info.GetInfoTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\tests\test_get_info.py", line 23, in setUp
self.ode = ode('cvode', rhs, old_api=False)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: test_ode_exposes_num_njtimes_evals (scikits.odes.tests.test_get_info.GetInfoTestSpils)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\tests\test_get_info.py", line 50, in setUp
self.ode = ode('cvode', rhs, linsolver="spgmr", old_api=False)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: test_odeint (scikits.odes.tests.test_odeint.TestOdeint)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\tests\test_odeint.py", line 47, in test_odeint
self._do_problem(problem)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\tests\test_odeint.py", line 33, in _do_problem
sol = odeint(problem.f, t, problem.z0, method=method)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\odeint.py", line 215, in odeint
solver = ode(int_name, rhsfun, **options)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: scikits.odes.tests.test_odeint.test_odeint_banded_jacobian
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\case.py", line 197, in runTest
self.test(*self.arg)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\tests\test_odeint.py", line 292, in test_odeint_banded_jacobian
jacfn=jac)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\odeint.py", line 215, in odeint
solver = ode(int_name, rhsfun, **options)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: scikits.odes.tests.test_odeint.test_odeint_errors
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\case.py", line 197, in runTest
self.test(*self.arg)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\tests\test_odeint.py", line 403, in test_odeint_errors
assert_raises(ZeroDivisionError, odeint, bad1, [0, 1], [1.0])
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\numpy\testing\_private\utils.py", line 1244, in assert_raises
return _d.assertRaises(*args,**kwargs)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\unittest\case.py", line 733, in assertRaises
return context.handle('assertRaises', args, kwargs)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\unittest\case.py", line 178, in handle
callable_obj(*args, **kwargs)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\odeint.py", line 215, in odeint
solver = ode(int_name, rhsfun, **options)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\ode.py", line 273, in __init__
integrator = find_ode_integrator(integrator_name)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\ode.py", line 486, in find_ode_integrator
raise ValueError('Integrator name %s does not exist' % name)
ValueError: Integrator name cvode does not exist
======================================================================
ERROR: Failure: ImportError (No module named 'scikits.odes.sundials.cvode')
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\loader.py", line 417, in loadTestsFromName
addr.filename, addr.module)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\imp.py", line 235, in load_module
return load_source(name, filename, file)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 693, in _load
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 697, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\tests\test_on_funcs.py", line 16, in <module>
from scikits.odes.sundials.cvode import StatusEnum
ImportError: No module named 'scikits.odes.sundials.cvode'
======================================================================
ERROR: Failure: ImportError (No module named 'scikits.odes.sundials.ida')
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\loader.py", line 417, in loadTestsFromName
addr.filename, addr.module)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\imp.py", line 235, in load_module
return load_source(name, filename, file)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 693, in _load
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 697, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\tests\test_on_funcs_ida.py", line 16, in <module>
from scikits.odes.sundials.ida import StatusEnumIDA
ImportError: No module named 'scikits.odes.sundials.ida'
======================================================================
ERROR: Failure: ImportError (No module named 'scikits.odes.sundials.cvode')
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\loader.py", line 417, in loadTestsFromName
addr.filename, addr.module)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\imp.py", line 235, in load_module
return load_source(name, filename, file)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 693, in _load
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 697, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\tests\test_user_return_vals_cvode.py", line 5, in <module>
from ..sundials.cvode import StatusEnum
ImportError: No module named 'scikits.odes.sundials.cvode'
======================================================================
ERROR: Failure: ImportError (No module named 'scikits.odes.sundials.ida')
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\loader.py", line 417, in loadTestsFromName
addr.filename, addr.module)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\nose\importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\imp.py", line 235, in load_module
return load_source(name, filename, file)
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\imp.py", line 172, in load_source
module = _load(spec)
File "<frozen importlib._bootstrap>", line 693, in _load
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 697, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "C:\Users\f_lon_000\Anaconda3\envs\Python_35\lib\site-packages\scikits\odes\tests\test_user_return_vals_ida.py", line 5, in <module>
from ..sundials.ida import StatusEnumIDA
ImportError: No module named 'scikits.odes.sundials.ida'
----------------------------------------------------------------------
Ran 16 tests in 0.422s
FAILED (errors=13)
Out[2]: <nose.result.TextTestResult run=16 errors=13 failures=0>
根据https://scikits-odes.readthedocs.io/en/latest/installation.html#troubleshooting中发现的scikits.odes的故障排除过程,这是由于SUNDIALS未链接到LAPACK引起的。
我遵循了https://icl.cs.utk.edu/lapack-for-windows/lapack/#build中描述的过程,使用MinGW-w64轻松构建了Windows LAPACK。 当我跑步时:
C:/Program_Files/mingw-w64/x86_64-8.1.0-posix-sjlj-rt_v6-rev0/mingw64/bin/mingw32-make.exe test
在命令提示符下测试LAPACK构建是否正常(所有测试均通过)。
要安装SUNDIALS 2.7.0,请遵循类似的步骤。使用CMake,我选择源文件夹,选择其他构建文件夹,使用configure并选择LAPACK_ENABLE。当我再次配置时,我收到以下错误。
CMake错误:
The Fortran compiler identification is GNU 8.1.0
Searching for a Fortran compiler... C:/Program_Files/mingw-w64/x86_64-8.1.0-posix-sjlj-rt_v6-rev0/mingw64/bin/x86_64-w64-mingw32-gfortran.exe
Trying to compile and link a simple Fortran program... OK
Determining Fortran name-mangling scheme... OK
Looking for LAPACK libraries... OK
Checking if Lapack works... FAILED
WARNING: LAPACK not functional.
Blas/Lapack support will not be provided.
Added NVECTOR_SERIAL module
Added ARKODE module
Added CVODE module
Added CVODES module
Added IDA module
Added IDAS module
Added KINSOL module
Configuring done
顺便说一下,这是编程的一种新方法,我正在Windows 10,Python 3.5.5,LAPACK 3.8.0,SUNDIALS 2.7.0,CMake 3.11.4上尝试所有这些。