替代方案:适用于 Ubuntu 20.10 的 Odespy

替代方案:适用于 Ubuntu 20.10 的 Odespy

我对使用 Python 求解常量问题的数值方法感兴趣。我想参考:

Linge, S. 和 Langtangen, HP (2020)。计算编程 - Python:使用 Python 3.6 进行数值模拟的简单介绍 (p. 332)。Springer Nature

在这本书中奥德斯皮该包被视为常数(及系统)数值积分的一个里程碑。

我知道在我的 Ubuntu 上使用 Odespy由于我的 Ubuntu 版本,这是不可能的

不幸的是,我的最新版本的 Ubuntu 即 20.10 不支持 odespy(例如看这里)。这种包是为Python 2.7编写的,而我有Python 3。

是否有有效的选择这个包裹?

答案1

该软件可以安装在 20.10 上,但您需要从 20.04 LTS 存储库手动获取 NumPy for Python 2;从 18.04 LTS 获取 SciPy。使用以下命令:

sudo apt-get install python-dev gfortran-9 git

# set gfortran-9 as default (as in 20.04 LTS)
sudo apt-get remove gfortran # remove gfortran-10
sudo ln -s /usr/bin/gfortran-9 /usr/local/bin/gfortran

cd ~/Downloads
wget -c http://archive.ubuntu.com/ubuntu/pool/universe/p/python-numpy/python-numpy_1.16.5-2ubuntu7_amd64.deb
sudo apt-get install ./python-numpy_1.16.5-2ubuntu7_amd64.deb
wget -c http://archive.ubuntu.com/ubuntu/pool/universe/p/python-scipy/python-scipy_0.19.1-2ubuntu1_amd64.deb
sudo apt-get install ./python-scipy_0.19.1-2ubuntu1_amd64.deb

git clone https://github.com/hplgit/odespy
cd odespy
sudo python2 setup.py install

然后使用odespy

答案2

scipy积分用于 odes 积分。无论如何,对于严格的应用,我建议使用手工积分器,在其中设置时间步长。

相关内容