examples.diffusion.steadyState.mesh1D.tri2Dinput¶
To run this example from the base FiPy directory type:
$ python examples/diffusion/steadyState/mesh1D/tri2Dinput.py
at the command line. A contour plot should appear and the word finished in the terminal.
This example is similar to the example found in
examples.diffusion.mesh1D
, however, the mesh is a
fipy.meshes.tri2D.Tri2D
object rather than a
Grid1D()
object.
Here, one time step is executed to implicitly find the steady state
solution. We increase the solver tolerance from the default
>>> eq = DiffusionTerm()
>>> solver = eq.getDefaultSolver(tolerance=1e-8)
>>> eq.solve(var, solver=solver)
To test the solution, the analytical result is required. The x coordinates from the mesh are gathered and the length of the domain, Lx, is calculated. An array, analyticalArray, is calculated to compare with the numerical result,
>>> x = mesh.cellCenters[0]
>>> Lx = nx * dx
>>> analyticalArray = valueLeft + (valueRight - valueLeft) * x / Lx
Finally the analytical and numerical results are compared with a tolerance of 1e-10.
>>> print(var.allclose(analyticalArray))
True