我有以下偏微分方程
我想知道如何在 Fipy python 中表示源术语。我试过以下
from fipy import *
nx = 50
ny = 1
dx = dy = 0.025 # grid spacing
L = dx * nx
mesh = Grid2D(dx=dx, dy=dy, nx=nx, ny=ny)
phi = CellVariable(name="solution variable", mesh=mesh, value=0.)
convCoeff = ((10.,), (10.,))
Gamma = 1.
eqX = TransientTerm() == DiffusionTerm(coeff=Gamma) - ConvectionTerm(coeff=convCoeff) + t*numerix(exp(x*y))
valueTopLeft = 0
valueBottomRight = 1
X, Y = mesh.faceCenters
facesTopLeft = ((mesh.facesLeft & (Y > L / 2)) | (mesh.facesTop & (X < L / 2)))
facesBottomRight = ((mesh.facesRight & (Y < L / 2)) |
(mesh.facesBottom & (X > L / 2)))
#
phi.constrain(valueTopLeft, facesTopLeft)
phi.constrain(valueBottomRight, facesBottomRight)
timeStepDuration = 10 * 0.9 * dx ** 2 / (2 * D)
steps = 10
results = []
for step in range(steps):
eqX.solve(var=phi, dt=timeStepDuration)
results.append(phi.value)
这是行不通的。根据 fipy 手册,我看到他们说源术语以它们出现的方式表示,并且建议使用 numerix 模块而不是 numpy 等其他模块。我不知道这段代码中缺少。谢谢