如何在Python中建立热方程的3D模型?

问题描述 投票:0回答:1

给出:

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9lRHNFby5wbmcifQ==” alt =“在此处输入图像描述”>“ >>

我们有公式:

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9zQnNGeC5wbmcifQ==” alt =“在此处输入图像描述”>

我制作了3D模型,但是我不能给出类似当x = 0 u(0,t)= 0

]
import math
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
def u(x,t,n):
    for i in range(1,n):
        alpha=((6*(-1)**i-30)/(i**2*np.pi**2))
        e=np.exp((-(np.pi**2)*(i**2)*t))
        sin=np.sin((i*np.pi*x)/3)
        u=alpha*e*sin
    return u

N=20
L = 4  # length
att = 20 # iteration

x = np.linspace(0, L ,N) #x-array
t = np.linspace(0, L, N) #t-array
X, Y = np.meshgrid(x, t)

Z = u(X, Y, att)

fig = plt.figure(figsize = (10,10))

ax = fig.add_subplot(111, projection='3d')

ax.plot_wireframe(X, Y, Z, rstride=10, cstride=1000)
plt.show()

我的3D模型:

“在此处输入图像描述”

给出:并且我们有公式:我制作了3D模型,但我无法给出类似x = 0 u(0,t)= 0时的条件。 ...

python fft differential-equations
1个回答
0
投票

如果您只是在部分傅立叶总和计算中实际计算了总和,这会有所帮助,此时您只需返回该和的最后一项。

© www.soinside.com 2019 - 2024. All rights reserved.