问题描述
from fipy import CellVariable,Grid2D,DiffusionTerm
nx = 20 # grid size on coordinate axes
dx = 1 # grid spacing
ny = nx; dy = dx; L = dx*nx
mesh = Grid2D(dx=dx,dy=dy,nx=nx,ny=ny)
phi = CellVariable(name = "phi",mesh = mesh,value = 0.5)
eq = (0. == DiffusionTerm( coeff=1.,var=phi))
valuetopLeft = 0.; valueBottomright = 1.
phi.constrain(valuetopLeft,where = mesh.facesLeft)
phi.constrain(valueBottomright,where = mesh.facesRight)
eq.solve(var=phi)
print (phi.value[:])
解决方法
如果您将网格间距指定为整数,则在 FiPy 中有一个 bug。更改为 select isdate2('20200229'); --> returned true,select isdate2('20210229'); --> returned false
select isdate2('2020-02-29'); --> returned true
select isdate2('2021-02-29'); --> returned false
导致
dx = 1.
,
非常感谢。我应该自己发现问题。现在我已经准备好迎接更多奇特的事情了!