我在尝试使用scipy.odeint整合毕达哥拉斯三体问题时遇到了困难。经过一番检查和网络搜索,我在这个非常有趣的集成中发现了以下内容discussion/tutorial:"After a discussion of the unit scaling in the next section many different integration algorithms are described in following sections. The author recommends, after writing your own integration program according to one of these algorithms, to begin the integration exercises with the figure “eight”, since it is easy to integrate due to its stability and the fact, that close encounters do not occur at all. Afterwards, you may try to solve the Pythagorean problem. The Pythagorean problem is difficult to integrate. A very accurate integrator must be used which is able to cope with the numerous close encounters."

因此,我的主要问题是:是否有其他python-ODE库可以参照上面的建议?或者,有人能帮我理解如何诱使odeint在这里工作吗?scipy.odeint每当我使用它时,它总是“刚刚工作”,所以这次我很惊讶。在

这个video和这个video都有很好的模拟结果

注意:标题不是打字错误-标题中有一个bot阻止了单词“problem”。在

我将在下面发布我的第一次尝试实现。我欢迎评论如何写得更好。通过调整tol(有时还有t中的间距,这很奇怪,因为这是插值,而不是{}的实际时间步长)。有一次我能画出一个看起来很正确的图(你可以在internet上看到它们),但我不记得是怎么画的。在

def deriv(X, t):

Y[:6] = X[6:]

r34, r35, r45 = X[2:4]-X[0:2], X[4:6]-X[0:2], X[4:6]-X[2:4]

thing34 = ((r34**2).sum())**-1.5

thing35 = ((r35**2).sum())**-1.5

thing45 = ((r45**2).sum())**-1.5

Y[6:8] = r34*thing34*m4 + r35*thing35*m5

Y[8:10] = r45*thing45*m5 - r34*thing34*m3

Y[10:12] = -r35*thing35*m3 - r45*thing45*m4

return Y

import numpy as np

import matplotlib.pyplot as plt

from scipy.integrate import odeint as ODEint

# Pythagorean Three Body Problem

# This script WILL NOT solve it yet, just for illustration of the problem

m3, m4, m5 = 3.0, 4.0, 5.0

x0 = [1.0, 3.0] + [-2.0, -1.0] + [1.0, -1.0]

v0 = [0.0, 0.0] + [ 0.0, 0.0] + [0.0, 0.0]

X0 = np.array(x0 + v0)

t = np.linspace(0, 60, 50001)

Y = np.zeros_like(X0)

tol = 1E-9 # with default method higher precision causes failure

hmax = 1E-04

answer, info = ODEint(deriv, X0, t, rtol=tol, atol=tol,

hmax=hmax, full_output=True)

xy3, xy4, xy5 = answer.T[:6].reshape(3,2,-1)

paths = [xy3, xy4, xy5]

plt.figure()

plt.subplot(2, 1, 1)

for x, y in paths:

plt.plot(x, y)

for x, y in paths:

plt.plot(x[:1], y[:1], 'ok')

plt.xlim(-6, 6)

plt.ylim(-4, 4)

plt.title("This result is WRONG!", fontsize=16)

plt.subplot(4,1,3)

for x, y in paths:

plt.plot(t, x)

plt.ylim(-6, 4)

plt.subplot(4,1,4)

for x, y in paths:

plt.plot(t, y)

plt.ylim(-6, 4)

plt.show()

matlab ode45三体问题,“毕达哥拉斯3Body Proxblem”ODE解算器测试的下一步相关推荐

  1. matlab ode45三体问题,小白急求~~关于ode45不能解的问题

    ode45本身是变步长的呀,怎么设置最小步长?我改用其它ode函数计算都会出现这个警告Warning: Failure at t=5.373174e-001.  Unable to meet inte ...

  2. matlab ode45三体问题,关于ode45中erf函数(输入必须为实数完全数的报错问题)

    最近在做有关ODE45的微分方程求解,在微分方程中,运用到了erf函数,虽然之前也出现过类似的问题,已经解决,但是这次丝毫找不到问题的原因所在,毫无头绪. 主程序如下: [code] %------x ...

  3. matlab ode45例子,matlab的ode45

    matlab ode45 解微分方程在用 odesolver(ode45, od... 在控制系统仿真中,常用的求微分方程数值解的函 数是ode23和ode45. 2 1. ode23 在MATLAB ...

  4. C++:实现量化ODE模型测试实例

    C++:实现量化ODE模型测试实例 #include "ode.hpp" #include "utilities.hpp" #include <ql/ex ...

  5. 使用matlab中PCA包进行训练集与测试集处理

    使用matlab中PCA包进行训练集与测试集处理 1. matlab中PCA包的使用与分析 2. 训练集与测试集降维处理 1. matlab中PCA包的使用与分析 [coeff, score, lat ...

  6. matlab定步长ode,[转载]matlab ode45 函数传自定义参数用法及定步长ode

    要用的时候总是忘记,这回给把它写在这里! %%程序1 arg1 = 2; arg2 = 1; [T,Y] = ode45('vdp1000',[0 10],[2 0], [], arg1, arg2) ...

  7. matlab生成有向网络,matlab ode45和矩阵生成有向网络图

    Matlab中解常微分方程的ode45 ode是专门用于解微分方程的功能函数,他有ode23,ode45,ode23s等等,采用的是Runge-Kutta算法.ode45表示采用四阶,五阶runge- ...

  8. matlab ode45使用,ODE45函数的使用——翻译

    <ODE45函数的使用--翻译>由会员分享,可在线阅读,更多相关<ODE45函数的使用--翻译(7页珍藏版)>请在人人文库网上搜索. 1.在Matlab中使用ode45简介Ma ...

  9. 【Matlab】一、解常微分方程ODE

    文章目录 求解常微分方程 ODE (1)求解解析解 (2)求解数值解 求解常微分方程 ODE ​ 在matlab中,我们可以求解常微分方程的解析解,和数值解,一般使用dsolve来求解常微分方程的解析 ...

最新文章

  1. 大厂线上案例复盘--代码漏洞
  2. liferay中使用自己的数据库
  3. eBay是如何进行大数据集元数据发现的
  4. 可以从max中导出静态模型并渲染了。
  5. hive 去重 字符串_hive函数
  6. 前端学习(593):使用devtools作为代码编辑器
  7. 搞定mac的bashrc
  8. C语言基础--字符串
  9. is running beyond physical memory limits. Current usage: 2.0 GB of 2 GB physical memory used; 2.6 GB
  10. 一款基于SpringBoot + Spring Security的后台管理系统,强烈推荐,直接用
  11. f分布表完整图a=0.01_【知识】二元概率分布
  12. Shell脚本介绍(资源)
  13. 用 Python 制作“会跳舞”的动态图表
  14. 劝学:不积跬步,无以至千里,不积小流,无以成江海.
  15. 音视频技术开发周刊 | 273
  16. JavaScript复习
  17. python正弦函数拟合_python生成任意频率正弦波方式
  18. 单模光纤与多模光纤区别
  19. 线性代数笔记:逆矩阵及伪逆矩阵,最小二乘估计,最小范数估计
  20. 减震透气的清爽跑鞋,让跑步更轻松,咕咚10K悦弹体验

热门文章

  1. qwt+qt5.4.1+win7 环境搭建(完美版)
  2. Linux/Document: Livepatch
  3. Linux内核 eBPF基础:ftrace源码分析:过滤函数和开启追踪
  4. Java 3D编程实践_Java 3D编程实践——网络上的三维动画[学习笔记]
  5. python pyqt5 线程 暂停 重启_如何在PyQT5中暂停/播放线程?
  6. 西南在线平台教育计算机应用基础答案,西南交《计算机应用基础》在线作业一...
  7. 【Cinemachine智能相机教程】VirtualCamera(二):Body属性
  8. OpenShift 4 之AMQ Streams(1) - 多个Consumer从Partition接收数据
  9. OpenShift 4 之获取OpenShif的最新开发进度
  10. Abp vnext Web应用程序开发教程 7 —— 作者:数据库集成