examples.levelSet.surfactant.circleΒΆ
This example first imposes a circular distance function:
\[\phi \left( x, y \right) = \left[ \left( x - \frac{ L }{ 2 } \right)^2 + \left( y - \frac{ L }{ 2 } \right)^2 \right]^{1/2} - \frac{L}{4}\]
then the variable is advected with,
\[\frac{ \partial \phi } { \partial t } + \vec{u} \cdot \nabla \phi = 0\]
Also a surfactant is present of the interface, governed by the equation:
\[\frac{d \theta}{d t} = J v \theta\]
The result can be tested with the following code:
>>> surfactantBefore = numerix.sum(surfactantVariable * mesh.cellVolumes)
>>> from builtins import range
>>> for step in range(steps):
... distanceVariable.updateOld()
... surfactantEquation.solve(surfactantVariable, dt=1.)
... advectionEquation.solve(distanceVariable, dt = timeStepDuration)
>>> surfactantEquation.solve(surfactantVariable, dt=1.)
>>> surfactantAfter = numerix.sum(surfactantVariable * mesh.cellVolumes)
>>> print(surfactantBefore.allclose(surfactantAfter))
1
>>> areas = (distanceVariable.cellInterfaceAreas < 1e-6) * 1e+10 + distanceVariable.cellInterfaceAreas
>>> answer = initialSurfactantValue * initialRadius / (initialRadius + distanceToTravel)
>>> coverage = surfactantVariable * mesh.cellVolumes / areas
>>> error = (coverage / answer - 1)**2 * (coverage > 1e-3)
>>> print(numerix.sqrt(numerix.sum(error) / numerix.sum(error > 0)))
0.00813776069241
Last updated on Nov 20, 2024.
Created using Sphinx 7.1.2.