1

我正在尝试除 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 我选择源文件夹,我选择不同的构建文件夹,使用配置并选择 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 上尝试所有这些。

4

0 回答 0