当前位置:网站首页>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 .
边栏推荐
- Chapter 18 using work queue manager (1)
- Warning: retrying occurs during PIP installation
- Numpy pit: after the addition of dimension (n, 1) and dimension (n,) array, the dimension becomes (n, n)
- Wheel 1:qcustomplot initialization template
- Halcon color recognition_ fuses. hdev:classify fuses by color
- Guess riddles (2)
- leetcode - 445. Add two numbers II
- Example 009: pause output for one second
- Matlab tips (28) fuzzy comprehensive evaluation
- IT冷知识(更新ing~)
猜你喜欢
猜谜语啦(6)
Business modeling of software model | object modeling
Hello everyone, welcome to my CSDN blog!
L298N module use
Halcon clolor_ pieces. Hedv: classifier_ Color recognition
RT-Thread内核快速入门,内核实现与应用开发学习随笔记
Example 005: three numbers sorting input three integers x, y, Z, please output these three numbers from small to large.
Business modeling | process of software model
Halcon shape_ trans
Example 004: for the day of the day, enter a day of a month of a year to judge the day of the year?
随机推荐
猜谜语啦(142)
js异步错误处理
Esphone Feixun DC1 soft change access homeassstant
696. 计数二进制子串
ECMAScript6介绍及环境搭建
Halcon wood texture recognition
Halcon affine transformations to regions
Guess riddles (11)
MATLAB skills (28) Fuzzy Comprehensive Evaluation
Affected tree (tree DP)
Example 006: Fibonacci series
12、动态链接库,dll
Business modeling | process of software model
Several problems to be considered and solved in the design of multi tenant architecture
Some pitfalls of win10 network sharing
Apaas platform of TOP10 abroad
The first week of summer vacation
[nas1] (2021cvpr) attentivenas: improving neural architecture search via attentive sampling (unfinished)
猜谜语啦(3)
Business modeling of software model | object modeling