/[escript]/trunk/doc/user/levelset.tex
ViewVC logotype

Diff of /trunk/doc/user/levelset.tex

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2115 by lgraham, Tue Dec 2 01:21:07 2008 UTC revision 2128 by lgraham, Thu Dec 4 03:48:22 2008 UTC
# Line 235  Further work is needed in the reinitiali Line 235  Further work is needed in the reinitiali
235    
236  \subsection{Benchmark Problem}  \subsection{Benchmark Problem}
237    
238  The Rayleigh-Taylor instability problem is used as a benchmark to validate CFD implementations \cite{VANKEKEN1997}. Figure \ref{RT2DSETUP} shows the setup of the problem. A rectangular domain with two different fluids is considered, with the greater density fluid on the top and the lighter density fluid on the bottom. The viscosities of the two fluids are equal (isoviscous). An initial perturbation is given to the interface of $\phi=0.02cos(\frac{\pi x}{\lambda}) + 0.2$. The aspect ratio $\lambda = L/H = 0.9142$ is chosen such that it gives the greatest disturbance of the fluids.  The Rayleigh-Taylor instability problem is used as a benchmark to validate CFD implementations \cite{VANKEKEN1997}. Figure \ref{RT2DSETUP} shows the setup of the problem. A rectangular domain with two different fluids is considered, with the greater density fluid on the top and the lighter density fluid on the bottom. The viscosities of the two fluids are equal (isoviscous). An initial perturbation is given to the interface of $\phi=0.02cos(\frac{\pi x}{\lambda}) + 0.2$. The aspect ratio $\lambda = L/H = 0.9142$ is chosen such that it gives the greatest disturbance of the fluids. The fluid properties is chosen such that the compositional Rayleigh number is equal to one:
239    %
240    \begin{equation}
241    R\hackscore{b} = \frac{\Delta \rho H^{3}}{\kappa \eta} = 1.
242    \label{RAYLEIGH NUMBER}
243    \end{equation}
244    %
245    where $\Delta \rho$ is the difference in density between the two fluids, $\eta$ is the viscosity and $\kappa$ is the thermal diffusivity; arbitrarily taken equal to 1 for a ``non thermal'' case.
246    %
247  %  %
248  \begin{figure}  \begin{figure}
249  \center  \center
250  \scalebox{0.7}{\includegraphics{figures/RT2Dsetup.eps}}  \scalebox{0.7}{\includegraphics{figures/RT2Dsetup.eps}}
251  \caption{Parameters, initial interface and boundary conditions for the Rayleigh-Taylor instability problem. The interface is defined as $\phi=0.02cos(\frac{\pi x}{\lambda}) + 0.2$. The fluids have been assigned different densities and equal viscosity (isoviscous).}  \caption{Parameters, initial interface and boundary conditions for the Rayleigh-Taylor instability problem. The interface is defined as $\phi=0.02cos(\frac{\pi x}{\lambda}) + 0.2$. The fluids have been assigned different densities and equal viscosity (isoviscous) \cite{BOURGOUIN2006}.}
252  \label{RT2DSETUP}  \label{RT2DSETUP}
253  \end{figure}  \end{figure}
254    %
255    %
256    The following python code is for the Rayleigh-Taylor instability problem, which is available in the example directory as 'RT2D.py'. This script uses the 'StokesProblemCartesian' class for solving the Stokes equation, along with the incompressibility condition. A class called 'LevelSet' is also used, which performs the advection and reinitialization procedures to track the movement of the interface of the fluids. The details and use of these classes are described in Chapter \ref{MODELS CHAPTER} (Models Chapter).
257    
258  %The Level Set Method can be applied to many areas of science, for example simulating subduction zones in geophysics, motion of bubbles, and flame propagation. Its also used in image processing. However, the Level Set Method does have limitations. The level set function can still become irregular after reinitialisation, leading to artifacts in the simulations, requiring more thought into the implementation of the reinitialisation step.  The script starts off by importing the necessary classes. The physical properties of the two fluids are defined, such as density and viscosity. Acceleration due to gravity is taken as 10.0 $ms^{-2}$. Solver settings are set for solving the Stokes problem, with the number of time-steps, solver tolerance, maximum solver iterations, and the option to use the Uzawa scheme or not; the default solver is the PCG solver. A regular mesh is defined with 200$\times$200 elements. Level set parameters are set for the reinitialization procedure, such as the convergence tolerance, number of reinitialization steps, the frequency of the reinitialization, for example, every third time-step, and the smoothing parameter to smooth the physical properties across the interface. A no-slip boundary condition is set for the top and bottom of the domain, while on the left and right-hand sides there is a slip condition. The initial interface between the two fluids is defined as in Figure \ref{RT2DSETUP}. Instances of the StokesProblemCartesian and LevelSet class are created. The iteration throughout the time-steps involves the update of the physical parameters of the fluids; the initialization of the boundary conditions, viscosity, and body forces; the solving of the Stokes problem for velocity and pressure; then the level set procedure. The output of the level set function, velocity and pressure is saved to file. The time-step size is selected based on the Courant condition. The simulation may take a long time to complete on a desktop computer due to the number of elements, so it is recommended to run it on the super computer.  
259    %
260  \begin{python}  \begin{python}
261    
262    from esys.escript import *
263    import esys.finley
264    from esys.escript.models import StokesProblemCartesian
265    from esys.finley import finley
266    from esys.finley import Rectangle
267    from LevelSet import *
268    
269    #physical properties
270    rho1 = 1000     #fluid density on bottom
271    rho2 = 1010     #fluid density on top
272    eta1 = 100.0        #fluid viscosity on bottom
273    eta2 = 100.0        #fluid viscosity on top
274    g=10.0
275    
276    #solver settings
277    dt = 0.001
278    t_step = 0
279    t_step_end = 2000
280    TOL = 1.0e-5
281    max_iter=400
282    verbose=True
283    useUzawa=True
284    
285    #define mesh
286    l0=0.9142
287    l1=1.0
288    n0=200      
289    n1=200
290    
291    mesh=Rectangle(l0=l0, l1=l1, order=2, n0=n0, n1=n1)
292    #get mesh dimensions
293    numDim = mesh.getDim()
294    #get element size
295    h = Lsup(mesh.getSize())
296    
297    #level set parameters
298    tolerance = 1.0e-6
299    reinit_max = 30
300    reinit_each = 3
301    alpha = 1
302    smooth = alpha*h
303    
304    #boundary conditions
305    x = mesh.getX()
306    #left + bottom + right + top
307    b_c = whereZero(x[0])*[1.0,0.0] + whereZero(x[1])*[1.0,1.0] + whereZero(x[0]-l0)*[1.0,0.0] + whereZero(x[1]-l1)*[1.0,1.0]
308    
309    velocity = Vector(0.0, ContinuousFunction(mesh))
310    pressure = Scalar(0.0, ContinuousFunction(mesh))
311    Y = Vector(0.0,Function(mesh))
312    
313    #define initial interface between fluids
314    xx = mesh.getX()[0]
315    yy = mesh.getX()[1]
316    func = Scalar(0.0, ContinuousFunction(mesh))
317    h_interface = Scalar(0.0, ContinuousFunction(mesh))
318    h_interface = h_interface + (0.02*cos(math.pi*xx/l0) + 0.2)
319    func = yy - h_interface
320    func_new = func.interpolate(ReducedSolution(mesh))
321    
322    #Stokes Cartesian
323    solution=StokesProblemCartesian(mesh,debug=True)
324    solution.setTolerance(TOL)
325    solution.setSubProblemTolerance(TOL**2)
326    
327    #level set
328    levelset = LevelSet(mesh, func_new, reinit_max, reinit_each, tolerance, smooth)    
329    
330    while t_step <= t_step_end:
331      #update density and viscosity
332      rho = levelset.update_parameter(rho1, rho2)
333      eta = levelset.update_parameter(eta1, eta2)
334    
335      #get velocity and pressure of fluid
336      Y[1] = -rho*g
337      solution.initialize(fixed_u_mask=b_c,eta=eta,f=Y)
338      velocity,pressure=solution.solve(velocity,pressure,max_iter=max_iter,verbose=verbose,useUzawa=useUzawa)
339      
340      #update the interface
341      func = levelset.update_phi(velocity, dt, t_step)  
342    
343      print "##########################################################"
344      print "time step:", t_step, " completed with dt:", dt
345      print "Velocity: min =", inf(velocity), "max =", Lsup(velocity)
346      print "##########################################################"
347    
348      #save interface, velocity and pressure
349      saveVTK("phi2D.%2.4i.vtu"%t_step,interface=func,velocity=velocity,pressure=pressure)
350      #Courant condition
351      dt = 0.4*Lsup(mesh.getSize())/Lsup(velocity)
352      t_step += 1
353    
354  \end{python}  \end{python}
355    %
356    %
357    The results from the simulation can be viewed by visualization software such as \textit{visIt}. If the software is installed, it can be opened by simply executing the following command:
358    %
359    \begin{python}
360    visit
361    \end{python}
362    %
363    In the visIt main window, vtk/vtu files can be opened from the File menu; contours and vectors can then be displayed by selecting them from the Plots menu and pressing the Draw button. A movie of the simulation can be watched by pressing the Play button. The graphics are displayed in the Vis window. For more information on \textit{visIt} see the website \cite{VisIt}.
364    
365    The simulation output is shown in Figures \ref{RT2D OUTPUT1} and \ref{RT2D OUTPUT1} showing the progression of the interface of the two fluids. A diapir can be seen rising on the left-hand side of the domain, and then later on, a second one rises on the right-hand side.
366    \begin{figure}
367    \center
368    \subfigure[t=300]{\label{RT OUTPUT300}\includegraphics[scale=0.252]{figures/RT2D200by200t300.eps}}
369    \subfigure[t=600]{\label{RT OUTPUT600}\includegraphics[scale=0.252]{figures/RT2D200by200t600.eps}}
370    \subfigure[t=900]{\label{RT OUTPUT900}\includegraphics[scale=0.252]{figures/RT2D200by200t900.eps}}
371    \subfigure[t=1200]{\label{RT OUTPUT1200}\includegraphics[scale=0.252]{figures/RT2D200by200t1200.eps}}
372    \caption{Simulation output of Rayleigh-Taylor instability, showing the movement of the interface of the fluids. The contour line represents the interface between the two fluids; the zero contour of the level set function. Velocity vectors are displayed showing the flow field. Computational mesh used was 200$\times$200 elements.}
373    \label{RT2D OUTPUT1}
374    \end{figure}
375    %
376    \begin{figure}
377    \center
378    \subfigure[t=1500]{\label{RT OUTPUT1500}\includegraphics[scale=0.252]{figures/RT2D200by200t1500.eps}}
379    \subfigure[t=1800]{\label{RT OUTPUT1800}\includegraphics[scale=0.252]{figures/RT2D200by200t1800.eps}}
380    \caption{Simulation output of Rayleigh-Taylor instability.}
381    \label{RT2D OUTPUT2}
382    \end{figure}
383    %
384    %
385    %The Level Set Method can be applied to many areas of science, for example simulating subduction zones in geophysics, motion of bubbles, and flame propagation. Its also used in image processing. However, the Level Set Method does have limitations. The level set function can still become irregular after reinitialisation, leading to artifacts in the simulations, requiring more thought into the implementation of the reinitialisation step.
386    %

Legend:
Removed from v.2115  
changed lines
  Added in v.2128

  ViewVC Help
Powered by ViewVC 1.1.26