[Python][编程][笔记] Python符号计算——求偏微分方程 (Python symbolic computation — solving partial differential equations)

实干、实践、积累、思考、创新。


最近忙,放松时间学学python。

python中的 sympy库是一款符号运算库,功能强大。这里测试其求微分方程的功能。The sympy library in python is a symbolic operation library with powerful functions. Here we test its function of finding differential equations.

我们可以试试用sumpy求解单自由度粘滞阻尼体系自由振动的运动方程。We can try to use sumpy to solve the equation of motion of the free vibration of a single degree of freedom viscous damped system.

单自由度粘滞阻尼体系的自由振动的运动方程可以表示为以下的偏微分方程。The equation of motion of the free vibration of a single degree of freedom viscous damping system can be expressed as the following partial differential equation.

\[\ddot u{\rm{ + 2}}\zeta {w_n}\dot u{\rm{ + }}{w_n}^2u = 0\]

式中:\(u\)是位移,\(\zeta \)是阻尼比,\({w_n}\)是体系的自振频率。

以下是python代码

from sympy import*
y = symbols('y', cls=Function)
t = symbols('t')
ζ = symbols('ζ')
w = symbols('w')
eq = Eq(y(t).diff(t, t)+2*ζ*w*y(t).diff(t)+w*w*y(t), 0)
print(dsolve(eq, y(t)) )

程序运行结果为:

Eq(y(t), C1*exp(t*w*(-ζ - sqrt(ζ**2 - 1))) + C2*exp(t*w*(-ζ + sqrt(ζ**2 - 1))))

写成公式的形式即为:

\[u(t) = {C_1}{e^{{w_n}t( – \zeta – \sqrt {{\zeta ^2} – 1} )}} + {C_2}{e^{{w_n}t( – \zeta + \sqrt {{\zeta ^2} – 1} )}}\]

该公式可进一步写成以下形式,

\[u(t) = {e^{ – \zeta {w_n}t}}\left[ {{C_1}{e^{ – {w_n}t\sqrt {{\zeta ^2} – 1} }} + {C_2}{e^{{w_n}t\sqrt {{\zeta ^2} – 1} }}} \right]\]

由上可见,阻尼衰减项\({e^{ – \zeta {w_n}t}}\)就出现了,进一步可根据阻尼比ζ是大于1或者小于1或者等于1,对上述公式进行整理,即可得到过阻尼、临界阻尼及欠阻尼体系的自由振动运动方程。


You already voted!

  • 相关话题 ( Related Topics)

[01]. Python 出现”invalid literal for int() with base 10: \xef\xbb\xbf0″ 错误

[02]. [编程笔记] Tuple in Python [Python中的元组]

[03]. [Python][编程][笔记] Python海龟绘图 —— 多边形 Polygon

[04]. [Python][编程][笔记] Python符号计算——求偏微分方程 (Python symbolic computation — solving partial differential equations)

  • 微信公众号 ( Wechat Subscription)

WeChat_QRCode

欢迎关注 “结构之旅” 微信公众号

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.