Saturday, July 2, 2011

RAIN: Robust simulation of the 2-D Cahn-Hilliard equation


Purpose
  • The package "Rain" simulates the 2-D isotropic Cahn-Hilliard equation. The Legendre-Galerkin method was used for the spatial discretization, and the first- and second-order energy stabilized methods were used for the temporal discretization.

Specifications
  • Name: Rain.
  • Author: Feng Chen.
  • Finishing date: 07/02/2011.
  • Languages: Fortran 90.
  • Required libraries: BLAS, LAPACK.

Simple Example
  • Equation: \begin{equation} \begin{aligned} & \phi_t= M \Delta \mu, && \quad \text{in } \Omega, \\ & \mu = \frac{\phi(\phi^2 -1)}{\epsilon^2} - \Delta \phi, && \quad \text{in } \Omega, \\ & \partial_{\boldsymbol{n}} \phi = \partial_{\boldsymbol{n}} \mu = 0 , && \quad \text{on } \partial \Omega. \end{aligned} \end{equation}
  • Parameters: \begin{equation} \Omega =(-1,1)^2, \, T=0.6, \, \delta t = 0.001, \, N_x = N_y= 128, \, M = 0.01, \, \epsilon=0.02, \, s=2. \end{equation}
  • Exact solution and input functions: \begin{equation} \phi(x,y,0) = \text{two separated balls} \end{equation} with radii $\frac{1}{2}$ and $\frac{1}{\sqrt{2}}$, and with centers $(-\frac12,\frac12)$ and $(\frac15,-\frac15)$. It is evolved through the first-order scheme.

Quick Start
  • Compiling and running:
    cd ./Rain
    make library
    gfortran Rain_Main.cu -llibrary -llapack -lblas
    ./a.out
    
  • Output:
     
    
    
  • CPU: Intel(R) Xeon(R) CPU X5550 @2.67GHz.
  • OS: CentOS release 6.4 (Final).
  • Compiler: gfortran 4.5.1.

References
Code Highlights
    
    !!Assign the initial condition for phi
    
    case (1)! one ball.
    phi(i,j) = dtanh((dsqrt(x*x+y*y)-r)/RainEps) 
    case (2)! two balls.
    phi(i,j) = dtanh((dsqrt((x+1d0/2d0)**2+&
         (y-1d0/2d0)**2)-1d0/4d0)/RainEps)-1d0 &
       + dtanh((dsqrt((x-1d0/5d0)**2+(y+1d0/5d0)**2)-1d0/2d0)/RainEps)-1d0
    phi(i,j) = phi(i,j) + 1d0 
    case (3)! three balls.
    phi(i,j) = dtanh((dsqrt((x+1d0/2d0)**2+(y-1d0/2d0)**2)-&
         1d0/4d0)/RainEps)-1d0 &
       + dtanh((dsqrt((x-1d0/4d0)**2+(y+1d0/4d0)**2)-1d0/2d0)/RainEps)-1d0 &
       + dtanh((dsqrt((x+1d0/2d0)**2+(y+1d0/2d0)**2)-1d0/5d0)/RainEps)-1d0
    phi(i,j) = phi(i,j) + 1d0
    case (4)! two kissing balls.
    phi(i,j) = dtanh((dsqrt((x+0.346d0)**2+y**2)-1d0/3d0)/RainEps)-1d0 &
       + dtanh((dsqrt((x-0.346d0)**2+y**2)-1d0/3d0)/RainEps)-1d0
    phi(i,j) = phi(i,j) + 1d0 
    case (5)  ! a single tilde line.
    phi(i,j) = dtanh((y-2d0*x)/RainEps)-1d0  
    phi(i,j) = phi(i,j) + 1d0    
    case (6) ! a single verticle line.
    phi(i,j) = dtanh(x/RainEps)-1d0  
    phi(i,j) = phi(i,j) + 1d0            
    
    

No comments:

Post a Comment