【发布时间】:2021-07-28 18:30:17
【问题描述】:
我有一组耦合方程,其中主 PDE(时间和位置 z 的函数)为:
第二个方程的类型是:
k_m = f(q) 和 q^* = f(c)。如您所见,第二个等式是 ODE(q 不直接依赖于空间)。我发现很难编写代码来耦合这两个方程。到目前为止,对于我忽略第二个方程并取:q = A*c,其中A 是一些常数的简单情况,我能够简化并仅求解以下对流扩散方程:
使用以下代码:
from fipy import Variable, FaceVariable, CellVariable, Grid1D, ExplicitDiffusionTerm, TransientTerm, DiffusionTerm, Viewer, AdvectionTerm, PowerLawConvectionTerm, VanLeerConvectionTerm
from fipy.tools import numerix
#define the grid
L = 3.
nx = L * 512
dx = L/nx
mesh = Grid1D(dx=dx, nx=nx)
# create the variable and initiate it's value on the mesh
conc = CellVariable(name="Conc", mesh=mesh, value=0.)
# physical parameters
Dapp = 1e-7
u = 0.1
A = 0.85
e = 0.4
F = (1-e)/e
# provide the simplified coefficients
DiffCoeff = Dapp/(1+A*F)
ConvCoeff = ((u/(1+A*F)),)
#Boundary conditions
valueLeft = 1
valueRight = 0.
conc.constrain(valueLeft, mesh.facesLeft)
conc.faceGrad.constrain(valueRight, where=mesh.facesRight)
# define the equation
eqX = TransientTerm() == (DiffusionTerm(coeff=DiffCoeff) - VanLeerConvectionTerm(coeff=ConvCoeff))
# time stepping parameters
timeStepDuration = 0.001
steps = 50000
from tqdm import tqdm
for step in tqdm(range(steps), desc="Iterating..."):
eqX.solve(var=conc,dt=timeStepDuration)
# plot every 5000 iterations
if step%5000 == 0:
viewer.plot()
有人可以帮助将对流扩散方程与 fipy 框架中的 ODE 耦合。我有点困惑如何取右手边,这在有限体积意义上应该只是一个源项。
(https://www.codecogs.com/latex/eqneditor.php 用于生成 Latex 方程)
【问题讨论】: