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:
u″=λu,t∈(0,T],u(0)=0,u′(0)=√−λ.
- Parameters:
T=10,λ=−400,δt=0.0001.
- Exact solution:
u(t)=sin(√−λt).
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