边界约束导致内部循环,这里发生了什么,为什么?

Boundary constrain leads to internal loop, what happens here and why?

我的脚本因我的简单传导问题而停止工作。有人可以向我解释为什么以下代码行 T.faceValue.constrain(alp/lam*(Tu-T.faceValue),where=mesh.exteriorFaces) # Boundary Condition for Solver 会导致 fipy 放弃我吗?

完整代码:

cv=900.
lam=5.
alp=300.

T0 = 25.
Tu = 400.


cellSize = 0.05
radius = 1.


mesh = Gmsh2D('''
              cellSize = %(cellSize)g;
              radius = %(radius)g;
              Point(1) = {0, 0, 0, cellSize};
              Point(2) = {-radius, 0, 0, cellSize};
              Point(3) = {0, radius, 0, cellSize};
              Point(4) = {radius, 0, 0, cellSize};
              Point(5) = {0, -radius, 0, cellSize};
              Circle(6) = {2, 1, 3};
              Circle(7) = {3, 1, 4};
              Circle(8) = {4, 1, 5};
              Circle(9) = {5, 1, 2};
              Line Loop(10) = {6, 7, 8, 9};
              Plane Surface(11) = {10};
              ''' % locals()) # doctest: +GMSH

T = CellVariable(name = "HeatingUp",mesh = mesh,value = T0)


viewer = None
if __name__ == '__main__':
     try:
         viewer = Viewer(vars=T, datamin=T0, datamax=Tu)
         viewer.plotMesh()
         input("Irregular circular mesh. Press <return> to proceed") # doctest: +GMSH
     except:
         print("Unable to create a viewer for an irregular mesh (try Matplotlib2DViewer or MayaviViewer)")
# =============================================================================



eq = TransientTerm(coeff=rho*cv)==DiffusionTerm(coeff=lam)

T.faceValue.constrain(alp/lam*(Tu-T.faceValue),where=mesh.exteriorFaces) # Boundary Condition for Solver



timeStepDuration = 0.1
steps = 10
for step in range(steps):
    eq.solve(var=T, dt=timeStepDuration) # doctest: +GMSH
    if viewer is not None:
        viewer.plot() # doctest: +GMSH
``

你写到T.faceValue依赖于T.faceValue,依赖于T.faceValue,依赖于T.faceValue,...FiPy尽职尽责地为你提供了您请求的无限循环。

就写T.faceValue.constrain(Tu * (alp/lam) / (1 + alp/lam), where=mesh.exteriorFaces).

如果您想将梯度与边界值相关联,请参阅 Robin conditions 上的讨论。