要了解 FiPy 的工作原理,我想求解具有固定端点的Euler–Bernoulli 梁方程:
w''''(x) = q(x,t), w(0) = w(1) = 0, w'(0) = w'(1) = 0.
为简单起见,让q(x,t) = sin(x)
.
如何在 FiPy 中定义和解决它?如何sin(x)
针对方程中唯一的自变量指定源项?
from fipy import CellVariable, Grid1D, DiffusionTerm, ExplicitDiffusionTerm
from fipy.tools import numerix
nx = 50
dx = 1/nx
mesh = Grid1D(nx=nx, dx=dx)
w = CellVariable(name="deformation",mesh=mesh,value=0.0)
valueLeft = 0.0
valueRight = 0.0
w.constrain(valueLeft, mesh.facesLeft)
w.constrain(valueRight, mesh.facesRight)
w.faceGrad.constrain(valueLeft, mesh.facesLeft)
w.faceGrad.constrain(valueRight, mesh.facesRight)
# does not work:
eqX = DiffusionTerm((1.0, 1.0)) == numerix.sin(x)
eqX.solve(var=w)