Thursday, January 8, 2009

JADE: Minimization of energy functionals with the spectral approximation


Purpose
  • The package "Jade" minimizes energy functionals with the space-time spectral approximation (Gauss quadratures based on Legendre Lobatto points). The underline optimization tool is the L-BFGS package.

Specifications
  • Name: Jade.
  • Author: Feng Chen.
  • Finishing date: 01/08/2009.
  • Language: Fortran 90, Fortran 77.
  • Required libraries: BLAS, L-BFGS.

Simple Example
  • Energy functional: \begin{equation} \min_{u(x) \in C[-1,1]} \mathcal E [u(x)] = \int_{-1}^1 [\frac{|u'|^2}{2} + \frac{(u^2-1)^2}{4\epsilon^2}] \text{d} x, \end{equation} subjected to \begin{equation} u(-1) = 1, \quad u(1) = -1. \end{equation}
  • Parameter: \begin{equation} \epsilon=0.03. \end{equation}
  • Initial guess: \begin{equation} u_N(x_0) = 1, \quad u_N(x_N) = -1, \quad u_N(x_i)=0, \quad 1\leqslant i \leqslant N-1. \end{equation}

Quick Start
  • Compiling and running:
    cd ./Jade
    make library
    ifort tst_Jade.f90 -llibrary -lblas
    ./a.out
    
  • Output:
     
    *************************************************
      N=   31   NUMBER OF CORRECTIONS= 7
           INITIAL VALUES
     F=  2.51833D+03   GNORM=  2.22146D+03
    *************************************************
    
       I   NFN    FUNC        GNORM       STEPLENGTH
    
       1    2     1.58380D+03   9.04231D+02   4.50155D-04
       2    3     1.41239D+03   4.71418D+02   1.00000D+00
       3    4     1.28633D+03   2.94799D+02   1.00000D+00
                   ...
      58   64     1.27280D+02   1.15318D-04   1.00000D+00
      59   65     1.27280D+02   1.69359D-04   1.00000D+00
      60   66     1.27280D+02   2.82277D-05   1.00000D+00
    
     THE MINIMIZATION TERMINATED WITHOUT DETECTING ERRORS.
     IFLAG = 3
     IFLAG =            3 Without error LBFGS done 
    
  • CPU: Intel(R) Xeon(R) CPU X5550 @2.67GHz.
  • OS: CentOS release 6.4 (Final).
  • Compiler: ifort 12.1.5.

References
Code Highlights
    
    !<
    !! Evaluate the objective functional and its derivative.
    !! These are required in the L-BFGS algorithm.
    !! Global: epsinv = 1/(epsilon*epsilon)
    !! Input:  n - number of Legendre collocation points
    !!         nn = n + 1
    !!         ua - function values
    !! Output: f - functional value
    !!         g - partial derivatives of f w.r.t. ua
    !<
    SUBROUTINE OBJ_GRAD_VALUE(n,nn,ua,f,G)
     INTEGER, INTENT(IN)          ::    N,NN
     DOUBLE PRECISION,INTENT(IN)  ::    ua(0:NN)
     DOUBLE PRECISION,INTENT(OUT) ::    F,G(1:N)
     DOUBLE PRECISION ::  du(0:NN),uf(0:NN)
    
     ! gradient of u
     du = MATMUL(D,ua)
     
     ! objective functional
     DO i=0,NN
        ! integrant values
        uf(i)=4.d0*du(i)*du(i)+epsinv*(ua(i)*ua(i)-1.d0)**2
     ENDDO
     ! quadrature
     f=DOT_PRODUCT(weight,uf)
    
     ! derivative of the functional
     DO j=1,NN-1
        G(j)=0.D0
        DO i=0,NN
        G(j)=G(j)+weight(i)*du(i)*D(i,j)
        ENDDO
        G(j)=8.D0*G(j)+4.D0*epsinv*weight(j)*(ua(j)**3-ua(j))
     ENDDO
    
     RETURN
    END SUBROUTINE OBJ_GRAD_VALUE
    
    
    

No comments:

Post a Comment