examples.diffusion.explicit.tri2DΒΆ

This input file again solves a 1D diffusion problem as in ./examples/diffusion/steadyState/mesh1D.py. The difference in this example is that the solution method is explicit. The equation used is the ExplicitDiffusionEquation. In this case many steps have to be taken to reach equilibrium. The timeStepDuration parameter specifies the size of each time step and steps is the number of time steps.

>>> dx = 1.
>>> dy = 1.
>>> nx = 10
>>> ny = 1
>>> valueLeft = 0.
>>> valueRight = 1.
>>> timeStepDuration = 0.02
>>> steps = 10

A loop is required to execute the necessary time steps:

>>> from builtins import range
>>> for step in range(steps):
...     eq.solve(var, solver=solver, dt=timeStepDuration)

The result is again tested in the same way:

>>> Lx = nx * dx
>>> x = mesh.cellCenters[0]
>>> print(var.allclose(answer, rtol = 1e-8))
1
Last updated on Jun 26, 2024. Created using Sphinx 7.1.2.