Wednesday, July 24, 2013

VERLET: Symplectic integration for Hamiltonian systems and adjoint solvers


Purpose
  • The package "Verlet" solves the second-order differential equation (or a Hamiltonian system) with the velocity Verlet scheme. It is second-order accurate in both position and velocity. In addition, the velocity Verlet scheme almost preserves the Hamiltonian (oscillating around a constant mean). The package also provides the corresponding adjoint solver.

Specifications
  • Name: Verlet.
  • Author: Feng Chen.
  • Finishing date: 07/24/2013.
  • Languages: MATLAB.

Simple Example
  • Equation: \begin{equation} \begin{aligned} & u''=\lambda u, \quad t \in (0,T],\\ & u(0) = 0, \quad u'(0) = \sqrt{-\lambda}. \end{aligned} \end{equation}
  • Parameters: \begin{equation} T=10, \quad \lambda=-400, \quad \delta t = 0.0001. \end{equation}
  • Exact solution: \begin{equation} u(t) = \sin(\sqrt{-\lambda} t). \end{equation}

Quick Start
  • Compiling and running:
    matlab Verlet_Driver
    
  • Output:
    maximum error of position and velocity =
         5.821930990741464e-04
    
  • CPU: Intel(R) Xeon(R) CPU X5550 @2.67GHz.
  • OS: CentOS release 6.4 (Final).
  • Release: MATLAB R2012a.

References
  • Verlet integration. Link.

Code Highlights
    
    % the velocity-Verlet time stepping.
    
    K = -lambda;
    
    r = u0(1);
    v = u0(2);
    a = -K*r;
    
    for i = 1:nt
     rt = r; 
     r = (1-K*dt*dt/2)*r + dt*v; 
     v = (1-K*dt*dt/2)*v + dt*(K*dt*dt/4-1)*K*rt; 
    end
    u = [r; v];
    
    

No comments:

Post a Comment