我正在尝试使用 fipy 在 python 中解决对流扩散方程。我想操纵对流系数,使其指向域的中心。
我的代码是
from fipy import *
# Setting mesh and discretising space
nx = 10
dx = 1.
mesh = Grid1D(nx=nx, dx=dx)
x = mesh.cellCenters[0]
# Setting variable of results and adding inicial conditions
phi = CellVariable(name="solution variable", mesh=mesh, value=0.)
phi.setValue(1., where=(4 < x) & (6 > x))
# Plotting inicial conditions
if __name__ == '__main__':
viewer = Viewer(vars=phi, datamin=-0.1, datamax=1.5)
viewer.plot()
# Diffusion and convection coefficients
D = 1.
C = (1.,)
# Setting PDE
eqX = TransientTerm() == DiffusionTerm(coeff=D) - \
ConvectionTerm(coeff=C)
# Solving Transient term
timeStepDuration = 0.1
steps = 15
t = timeStepDuration * steps
for step in range(steps):
eqX.solve(var=phi, dt=timeStepDuration)
# Plotting results
if __name__ == '__main__':
viewer = Viewer(vars=phi, datamin=0., datamax=1.)
viewer.plot()
正如你所看到的,随着时间的推移,波的移动方向由对流系数向量确定。操纵波的对流系数的代码如何仅向我的域中心移动?
任何建议将不胜感激!