当前位置:网站首页>Solutions of ordinary differential equations (2) examples
Solutions of ordinary differential equations (2) examples
2022-07-05 08:44:00 【Royal fox God double blazing】
use SciPyのscipy.integrate.odeint Solve simultaneous differential equations , In time t(tの The scope is 0~ Just a few seconds , example :t=0~2 second ) Reconciliation x(t), y(t), z(t) Make a picture .
As t=0 Initial conditions of ,x(t=0) = -10, y (t=0) = 0, z (t=0) = 35.0. also , About the coefficient a,b,c, You can try a = 40, b = 5, c = 35 And a = 40, b = 10, c = 35 The situation of . And time division Δt Take a smaller value appropriately . in addition ,Δt If it is too small , The amount of calculation will become very large . Adjust according to the errors after the actual implementation .
Here are the solutions python Program :
import numpy as np
import scipy.integrate as sciin
import matplotlib.pyplot as plt
# Compare with the independent variable t The function name of the related derivative function is placed in F in
def f(F, t,params):
x,y,z = F
f_values = [a*(y-x),(c-a)*x-x*z+c*y,x*y-b*z] # Write separately x,y,z The derivative of is equal to the formula on the right of
return f_values
# Amplification coefficient
a = 40
b= 5
c = 35
# Put the above three coefficients into parameters in
parameters = [a,b,c]
# Set up x,y,z The initial value of the
x0 = -10
y0 = 0.0
z0 = 35
# Put the initial value into Y0 in
Y0 = [x0,y0,z0]
# Starting point , The end point , Interval setting
tStart = 0.0
tStop = 2
tInc = 0.01 # interval
# Summarize the above to t in
t = np.arange(tStart, tStop, tInc)
# sciin.odeint Explain ODE
solution = sciin.odeint(f, Y0, t, args=(parameters,))
# Make a picture
plt.figure(figsize=(9.5, 6.5))
plt.plot(t, solution[:, 0], color='black')
plt.plot(t, solution[:, 1], color='green')
plt.plot(t, solution[:, 2], color='red')
plt.xlabel('time, t' , fontsize=14)
plt.ylabel('theta(t)', fontsize=14)
plt.show()
I'm a genius .
边栏推荐
猜你喜欢
Guess riddles (3)
Guess riddles (11)
Arduino operation stm32
Halcon clolor_ pieces. Hedv: classifier_ Color recognition
Halcon shape_ trans
Example 002: the bonus paid by the "individual income tax calculation" enterprise is based on the profit commission. When the profit (I) is less than or equal to 100000 yuan, the bonus can be increase
319. Bulb switch
Example 008: 99 multiplication table
【NOI模拟赛】汁树(树形DP)
One question per day - replace spaces
随机推荐
Task failed task_ 1641530057069_ 0002_ m_ 000000
location search 属性获取登录用户名
第十八章 使用工作队列管理器(一)
多元线性回归(梯度下降法)
2022.7.4-----leetcode. one thousand and two hundred
How to write cover letter?
Example 003: a complete square is an integer. It is a complete square after adding 100, and it is a complete square after adding 168. What is the number?
Dynamic dimensions required for input: input, but no shapes were provided. Automatically overriding
GEO数据库中搜索数据
Guess riddles (142)
Affected tree (tree DP)
Basic number theory - fast power
Sword finger offer 06 Print linked list from end to end
Halcon shape_ trans
asp.net(c#)的货币格式化
U8g2 drawing
It cold knowledge (updating ing~)
[牛客网刷题 Day4] JZ55 二叉树的深度
Run菜单解析
使用arm Neon操作,提高内存拷贝速度