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.

>>> DiffusionTerm().solve(var)

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))
1
Last updated on Jun 26, 2024. Created using Sphinx 7.1.2.