The Level-Set Method - CiteSeerX

14 downloads 0 Views 218KB Size Report
Notice that this function has negative slope and y-intercept, whereas the data .... If the speed function is not equal to zero at the point where the curvature is zero,.
The Level-Set Method Carolyn L. Phillips Abstract. We discuss a numerical algorithm for approximating the dynamics of moving curves and surfaces, called the Level-Set Method. This method allows us to write a program to predict the evolution of a propagating surface when the forces of propagation are known. Using the level-set method, we then create an easily coded numerical model of a disclination loop in the nematic liquid crystal 8CB (4, 40 -n-octylcynobiphenyl), a classic example of curvature-driven motion of a curve. We then discuss the first-order implementation of this numerical model and the various ways it may be improved.

1. Introduction. Ever since the first attempt to approximate a derivative by dividing the small change in height by a change in time, the problem of how best to approximate a continuous system with a discrete model has troubled mathematicians, scientists, and engineers alike. Systems with symbolic formulations that easily yield to symbolic differentiation, integration, and so forth are few and far between. For most real systems, the best that can be hoped for is to know the value of the system at a large number of discrete points with some degree of accuracy. The challenge is to find the method of modeling the system that provides sufficient accuracy within a manageable number of computations. Thus the linear approximation of a derivative was followed by higherorder Taylor expansions and then the Runge-Kutta Method. One of the contemporary and more complex examples of this problem is to create computer models for propagating interfaces. A propagating interface is a closed surface in some space that is moving under a function of local, global, and independent properties. Local properties are properties determined by local information about a curve, such as its curvature. Global properties are properties determined by the larger shape and positioning of the surface. Independent properties are properties not determined by the surface itself, such as an underlying flow of the surface. Propagating interfaces are found in every area of science and engineering, from a burning flame to the diffusion of one substance into another. Wherever there is a moving boundary separating two spaces, there is a propagating-interface problem. A simple method for modeling such an interface involves planting marker points along the surface and following their motion. However, small initial errors quickly become compounded, and awkward subjective methods must be used to add or remove marker points as they get too far apart or too close together. And, like many other simpler approaches to modeling propagating interfaces, the marker-point method fails in modeling some of the more complex motions of a surface. The level-set method is one computational technique for tracking a propagating interface over time, which in many problems has proven more accurate in handling topological complexities such as corners and cusps, and in handling complexities in the evolving interface such as entropy conditions and weak solutions. It is a robust scheme that is relatively easy to implement. 155

156

MIT Undergraduate Journal of Mathematics

The purpose of this paper is to demonstrate the level-set method by applying it to a real world problem: modeling the line of a defect in a liquid crystal. The geometric nature of the liquid crystal in its nematic phase causes defects to form along a plane. Viewed through an optical microscope, because of strong light scattering at deffects, these defects appear as a black line, and are called disclination lines. Via a method of analysis similar to the marker-point method, the author observed that these loops relaxed and disappear under forces of curvature. A more rigorous treatment of the level-set method can be found in [2], which provided the background for this paper. This work also provides examples of many other types of problems to which the level-set method can be applied. In Section 2, we discuss in greater detail how the real world data was generated experimentally. In Section 3, we apply the level-set method to this particular problem. In Sections 4 and 5, we discuss how to derive the approximations for a derivative and a gradient to be used in the computer algorithm. In Section 6, we discuss the actual implementation of the level-set method into code. We discuss the need for ghost cells, the results of running the code, and the various ways this particular implementation of the level-set method can be made more accurate and faster. 2. Experimental Data. When the 8CB (4, 40 -n-octylcynobiphenyl) is subjected to a shear flow while in its nematic phase, disclinations form in the flow. When the shear flow is stopped, in a matter of minutes all the disclinations have relaxed and disappeared. For our current purposes, it is not necessary to consider the more intricate geometry of these disclinations. Rather, we model the disclinations as a one-dimensional closed curve in a two-dimensional plane. Prior to this analysis, images were captured of these relaxing disclinations over small time increments (Figure 2-1). These images were processed (Figure 2-2) and analyzed, and demonstrated a dependence between the speed of relaxation and the curvature of

Figure 2-1. Raw image of 8CB disclination line. the disclination loop. Although other forces within the 8CB can affect the relaxation of a disclination loop, in this analysis we concentrate solely on the effect of the force of curvature on the relaxation speed. For this analysis we use the speed function, F = −1.12 − 155.15κ microns/sec, in the outward normal direction. However, since the image is displayed in pixels, we

The Level-Set Method

157

Figure 2-2. Image of 8CB disclination line after image analysis. use a ratio of 53.5 microns/87 pixels and use the speed function, F = −1.8 − 410.29κ microns/sec, Notice that this function has negative slope and y-intercept, whereas the data displayed in Figure 2-3 has positive slope and y-intercept. The reason is that the velocity in Figure 2-3 was calculated with respect to an inward directed normal, whereas the level-set method assumes an outward directed normal. For the purpose of this paper, we remain consistent with the conventions of the level-set method rather than the conventions of the field of material science.

Figure 2-3. Curvature vs. velocity data with linear fit function F . The images of the disclination loops were originally in a grey scale, and are approximately 600 by 400 pixels. Image analysis was used to make the image binary, and reduce the disclination loop to a one-pixel thick loop. An image of a relaxing loop provides the initial data for our algorithm. 3. Level Set Algorithm. The general idea behind the level-set method is to apply a function φ(p, t) to the space the interface inhabits, where p is a point in that space, t a point in time. The function is initialized at t = 0, and then a scheme is used to approximate the value of φ(p, t) over small time increments. The first step in applying the level-set method is to pick a mesh, or a grid of points that covers the image. In general, the finer the mesh, the more accurate the level-set method. However, our digitized image puts a limit on how fine a mesh we can use. Since the image consists of several thousand pixels, the mesh must be at least as coarse as the individual pixels, and optimally even coarser.

158

MIT Undergraduate Journal of Mathematics

Once a mesh is chosen, the next step is to initialize the value of φ(p, t) at each point of the mesh. The function φ is defined as follows. For any point p in the mesh (which in our case is a point in the plane), we have φ(p, t) = ±d where d is the distance from the point p to the curve at the time t = 0. The positive sign is used if the point p is outside the closed curve; the negative sign is used if the point p is inside the closed curve. Thus the name of the level-set method is explained: at any time t0 , the evolving curve corresponds to the locus of all points p such that φ(p, t0 ) = 0, and that locus is a level curve of the φ function. The locus of all points p such that φ(p, t0 ) = c, contour around the original curve, where c is an arbitrary positive or negative constant. A computationally intensive algorithm is used to set up the initial value of function φ at each of the mesh points. For each mesh point, the distance between it and each point on the curve is determined and the minimum value is set as the mesh point’s φ value. There is only a finite number of points on the curve because of the curve’s pixel resolution. A challenging part of the initializing process is determining whether a point is in or outside of the curve. One of the simplest algorithms is to assume the boundary points are outside the curve and then repeatedly label as outside all points that both neighbor outside points and are not on the curve. All the points left must be on the inside. This process works as long as the curve is a solid set of points within the domain of points. Clearly, as the curve evolves in time, the value of the function φ at each mesh point evolves too. The rest of the level-set method consists of updating the value of function φ at each point using a good scheme over small increments of time. A derivation that gives an expression for the time derivative of φ follows. Consider a function p(t) that describes the path of a point on the curve through time. Then, φ(p(t), t) = 0. So the chain rule yields φt + ∇φ · p0 (t) = 0. Let n ~ be an outward directed normal to the curve (or a contour). Then n ~ can be rewritten in terms of φ as follows: n ~ =

∇φ . |∇φ|

The speed function F , defined in the outward normal direction, is then equivalent to F = p0 (t) · n ~. Substituting in the equations for F and n ~ yields φt + F |∇φ| = 0. We use a scheme to approximate the values of φ based on the convexity of Hamiltonian function F |∇φ| , a condition described in more detail on page 122 of [1]. If we rewrite this speed function as F = F0 − κ, then we can rewrite φ as follows, φt = −F0 |∇φ| + κ|∇φ|,

159

The Level-Set Method

and approximate the derivatives of the first term using an entropy satisfying scheme and approximate the derivative of the second term using a central difference approximation. The value of φ after a small time interval ∆t is then approximated using the first-order Taylor expansion with respect to t: φ(p, t + ∆t) = φ(p, t) + (∆t)φt .

4. Central Difference Approximation. A central di erence approximation is a method for approximating a derivative, usually a spatial derivative, using the value of nearby points. The absolute value of the gradient of φ is defined as the following: s   2 2 ∂φ ∂φ + . |∇φ| ≡ ∂x ∂y Let u(x, t) be a function. The forward difference approximation D+x u is defined by the familiar expression, u(x + h, t) − u(x, t) D+x u ≡ , h and the backward difference approximation is defined by the similar expression, D−x u ≡

u(x, t) − u(x − h, t) . h

Averaging the two approximations gives the central difference approximation: D0x u ≡

u(x + h, t) − u(x − h, t) . 2h

This approximation is usually used for spatial derivative approximations, and not for time derivatives, because to determine the derivative of a function at a point in time it is necessary to know the value of the function in the future. In most mathematical modeling, the future is exactly what we are trying to predict. However, the forward and backward approximation for a derivative is used in the entropy satisfying scheme. The following is an expression for calculating curvature: κ=

φxx φ2y − 2φy φx φx y + φy yφ2x . (φ2x + φ2y )3/2

We use the central difference approximation to approximate each of the derivatives of φ. So our curvature is also a central difference approximated quantity. 5. Entopy Satisfying Scheme. If our speed function were such that F (0) = 0, or had no constant part, then the entropy satisfying scheme would not be necessary. As a matter of fact, data for very small curvatures of 8CB disclination loops suggests that the real speed function makes a sharp curve down to the origin, and is linear only in a certain range of curvatures. However, to model the first-order approximation of the real speed function, we need the entropy satisfying scheme. This process also provides an opportunity to illustrate the principles of the entropy satisfying scheme.

160

MIT Undergraduate Journal of Mathematics

If the speed function is not equal to zero at the point where the curvature is zero, then when the curvature is zero (that is, the curve is a straight line), and the curve is still moving at a constant speed in the direction of its normal. This flow in the normal direction is not an underlying fluid flow, since a straight section of the curve on an opposite section of the loop flows in the opposite direction. Imagine we had a curve like that in Figure 5-1.

Figure 5-1. Loop wall with a corner. Under a constant-speed function in the normal direction, there is a shock in the system. If the curve were under pure-curvature forces, then the shock, a point of high curvature, would disappear. But under a constant-speed function, the simplest model of the motion of the two straight segments causes them to cross (Figure 5-2).

Figure 5-2. Loop movement before introduction of shock. However, most propagating interfaces don’t exhibit that behavior. Instead the shock moves. One reason why the numerical method for modeling this sort of behavior is called entropy satisfying is that shocks cause irreversibility. As a section of the curve flows into the shock, information about that section is lost. If the motion were in the opposite direction of the direction indicated in Figure 5-3, the curves would flow out of the shock, rather than in. This behavior is called rarefaction. In real systems, however, rarefaction almost never happens, since rarefaction is associated with a localized reversal of entropy.

Figure 5-3. Normal motion of loop wall. As just shown, in approximating the gradient function under a constant speed function, it is important first to know which way the speed function points, and whether it is negative or positive. Suppose then that the constant is negative, like the constant in

161

The Level-Set Method

our experimentally derived function. As recalled above, the absolute value of a gradient is equal to s   2 2 ∂φ ∂φ + . |∇φ| = ∂x ∂y When we consider whether a spatial point may be a shock, it becomes important to look separately at its forward and backward derivative. If the forward derivative has a different sign than the backward derivative, then the curve is either flowing out or into our point. Consider the following scheme, where the term on the left is shorthand for +x the absolute value of the gradient of φ when the speed function is negative, and Di,j is shorthand for the forward partial derivative of φ with respect to x at the point (i, j): +y −y −x +x , 0)2 , 0)2 + max(Dij ∇− = min(Dij , 0)2 + max(Dij , 0)2 + min(Dij

1/2

.

In this scheme (covered in much greater mathematical detail in Chapter 4 of [2], it is apparent that, if the backward partial derivative with respect to x (or the derivative approximated from its left side) is positive and the forward partial derivative with respect to x (or the derivative approximated from its right side) is negative, then the x-direction contribution to the gradient is zero. A curve intersecting that point would contain a shock at that point. The shock might move in the y-direction, but not sideto-side.” If our speed function is positive instead of negative, we use instead +y −y −x +x , 0)2 , 0)2 + min(Dij ∇+ = max(Dij , 0)2 + min(Dij , 0)2 + max(Dij

1/2

.

The following is a generalized case of F , a constant speed function F = F0 , times the absolute value of the gradient if the sign of the constant is not known ahead of time:  F0 |∇| ≈ max(F0ij , 0)∇+ + min(F0ij , 0)∇− . So, putting together the schemes for approximating terms, we use the following scheme for updating φ:    0y 2 1/2  n 0x2 φn+1 = φnij + ∆t max(F0ij , 0)∇+ + min(F0ij , 0)∇− + Kij ) (Dij + Dij ij n where the term φnij means the value of φ at point i, j at time nDt. The term Kij is the central difference approximation to the curvature expression.

6. The Computer Code. When we actually implement the level-set method as a computer program, the issue of having only a finite grid of mesh points becomes significant in another way too. Our grid of mesh points must have a boundary, and it would seem that with each time step, our boundary is going to shrink by one layer of mesh points. Since the neighbors of a point are needed to compute the derivative for a time step, what should be done with a point on the boundary that lacks a neighbor? Rather than dropping away these points with each time step, we use ghost cells. After φ has been computed for all interior points, we map the value of φ to the boundary mesh points from their most immediate neighbor. Ghost cells are the boundary points of the grid that mirror the value of their neighbor. Using ghost cells induces some error to the system over time, but it is small and manageable if the initial grid of mesh points is large enough and the time steps reasonable.

162

MIT Undergraduate Journal of Mathematics

Using the scheme described, the level-set method was encoded using the language Java. As expected, using too large a time step or too large a mesh caused the program to return inaccurate data. On the other hand, using too small a time step, too fine a mesh, or asking the computer to perform too many iterations, caused the computer to have to perform too slowly. A mesh that used every tenth pixel in the x and y direction and a time step of 0.05 seconds provided sufficient accuracy for nice images. The output of this program is not a curve, but is the set of all mesh points contained on or within the evolved curve. The ouput data has been laid over the initial curve to better visualize the evolution. As Figure 6-1 shows, loops of complicated curvature are easily handled by the computer code.

Figure 6-1. A weird curve evolving under the force of curvature. Figure 6-2 shows the data from the 8CB diclination line evolved for eleven seconds under the effect of the predetermined speed function. Figure 6-3 shows the real data after eleven seconds. There is noticeable error between the computer-generated data and the real data. This discrepancy might be caused by the inaccuracy of the first-order expansions of the various derivatives. It might be caused by unaccounted-for forces within the disclination, including an underlying fluid flow that is causing the loop to drift. But the discrepancy is probably caused by errors in the speed function used. The scheme described should be considered a first-order application of the level-set method. Several improvements can be made to the current scheme to make it more accurate. The derivatives of each point currently used are only the first term of the

163

The Level-Set Method

Figure 6-2. Computer-generated curve.

Figure 6-3. Real curve. Taylor approximation. Higher orders of the Taylor approximation could be used or a different derivative approximating scheme altogether, such as the RungaKutta Method. Also the derivatives in the entropy satisfying scheme have been approximated only to the first order. A higher-order approximation for the forward and backward derivatives increases the accuracy. The adaptive-mesh-refinement method increases accuracy by increasing the refinement of the mesh around areas of high curvature or finer detail. There are also techniques that allow the level-set method to be computed in less time. Currently, the algorithm described is a full-matrix approach, one that asks the computer to calculate the value of φ at every point. Narrow banding uses an algorithm to build a mesh around only the curve, which significantly reduces the number of computations that the computer must perform. References [1] Apostol, T. M., Calculus, Volume I, Second Edition, Blaisdell, 1967. [2] Sethian, J. A., Level Set Mehods: Evolving interfaces in geometry, fluid mechanics, computer vision, and material science, Cambridge University Press, 1996.

164

This page will be blank.