FIPY 求解 PDE 和 ODE

问题描述

我有一组耦合方程,其中主偏微分方程(时间和位置 z 的函数)给出为:

eq1

第二个方程是这样的:

eq2

其中 k_m = f(q)q^* = f(c)。如您所见,第二个方程是 ODE(q 不直接依赖于空间)。我发现很难编写代码来耦合这两个方程。到目前为止,对于我忽略第二个方程并采用:q = A*c,其中 A 是某个常数的简单情况,我能够简化并求解以下对流扩散方程:

eq3

使用以下代码:

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 方程)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)