Error Propagation of Verlet Algorithm

200 downloads 0 Views 455KB Size Report
Two Verlet Algorithms will be briefly discussed: the Original Verlet and the Velocity Verlet, and the updating procedures are as follows: Orignal Verlet: ( +Β ...
Error Propagation of Verlet Algorithm Binbin Li Civil and Environmental Engineering, UC Berkeley

1. Introduction Verlet Algorithm is a popular numerical integration method, especially in molecular dynamics (MD) simulation. The discussion of errors in Verlet Algorithm appears in almost all books about MD simulation, but many of their descriptions are conflicted, and none of them provides strictly mathematical, thus it confuses most of readers, like me. Here, I try to talk about the error analysis of Verlet Algorithm using mathematical derivations, but it is not guaranteed to be errorfree. 2. Verlet Algorithm Two Verlet Algorithms will be briefly discussed: the Original Verlet and the Velocity Verlet, and the updating procedures are as follows: Orignal Verlet: π‘Ÿ(𝑑 + Δ𝑑) = 2π‘Ÿ(𝑑) βˆ’ π‘Ÿ(𝑑 βˆ’ Δ𝑑) + π‘Ž(𝑑)Δ𝑑 2 (1) 𝑣(𝑑) =

π‘Ÿ(𝑑+Δ𝑑)βˆ’π‘Ÿ(π‘‘βˆ’Ξ”π‘‘)

(2)

2Δ𝑑

Velocity Verlet: 1

π‘Ÿ(𝑑 + Δ𝑑) = π‘Ÿ(𝑑) + 𝑣(𝑑)Δ𝑑 + 2 π‘Ž(𝑑)Δ𝑑 2 𝑣(𝑑 + Δ𝑑) = 𝑣(𝑑) +

Δ𝑑 2

[π‘Ž(𝑑) + π‘Ž(𝑑 + Δ𝑑)]

(3) (4)

where π‘Ÿ(𝑑), 𝑣(𝑑) and π‘Ž(𝑑) are displacement, velocity and acceleration at 𝑑, respectively, and Δ𝑑 is the integration time step. In fact, these two Verlet Algorithms are mathematically equivalent, i.e. we could derive one from the other1. 3. Error Analysis The errors considered here include the truncation error (local error) and global error. The basic mathematical tool used is Taylor expansion. 3.1 Original Verlet First, let’s consider the Original Verlet. Taking the Taylor expansion of π‘Ÿ(𝑑 + Δ𝑑) and π‘Ÿ(𝑑 βˆ’ Δ𝑑) at π‘Ÿ(𝑑) gives 1

1

1

1

π‘Ÿ(𝑑 + Δ𝑑) = π‘Ÿ(𝑑) + 𝑣(𝑑)Δ𝑑 + 2 π‘Ž(𝑑)Δ𝑑 2 + 6 𝑗(𝑑)Δ𝑑 3 + 𝑂(Δ𝑑 4 ) π‘Ÿ(𝑑 βˆ’ Δ𝑑) = π‘Ÿ(𝑑) βˆ’ 𝑣(𝑑)Δ𝑑 + 2 π‘Ž(𝑑)Δ𝑑 2 βˆ’ 6 𝑗(𝑑)Δ𝑑 3 + 𝑂(Δ𝑑 4 )

1

http://www.physics.udel.edu/~bnikolic/teaching/phys660/numerical_ode/node5.html

(5) (6)

where 𝑗(𝑑) is the β€œjerk” at 𝑑 (i.e. the third derivative of displacement). Summarizing Eqn. (5) and (6) and doing some elementary operations yields π‘Ÿ(𝑑 + Δ𝑑) = 2π‘Ÿ(𝑑) βˆ’ π‘Ÿ(𝑑 βˆ’ Δ𝑑) + π‘Ž(𝑑)Δ𝑑 2 + 𝑂(Δ𝑑 4 ) (7) Subtracting Eqn. (6) by (5) and doing some elementary operations gives 𝑣(𝑑) =

π‘Ÿ(𝑑+Δ𝑑)βˆ’π‘Ÿ(π‘‘βˆ’Ξ”π‘‘) 2Δ𝑑

+ 𝑂(Δ𝑑 2 )

(8)

By comparing Eqn. (1) and (7), (2) and (8), we can conclude that the truncation error of displacement and velocity are 𝑂(Δ𝑑 4 ) and (Δ𝑑 2 ) , respectively. Based on these truncation errors, the global error could be derived as follows2: First, we have π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[π‘Ÿ(𝑑 + Δ𝑑)] = 𝑂(Δ𝑑 4 ) and π‘Ÿ(𝑑 + 2Δ𝑑) = 2π‘Ÿ(𝑑 + Δ𝑑) βˆ’ π‘Ÿ(𝑑) + π‘Ž(𝑑 + Δ𝑑)Δ𝑑 2 + 𝑂(Δ𝑑 4 ) Then, π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[π‘Ÿ(𝑑 + 2Δ𝑑)] = 2 Γ— π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[π‘Ÿ(𝑑 + Δ𝑑)] + 𝑂(Δ𝑑 4 ) = 3𝑂(Δ𝑑 4 ) π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[π‘Ÿ(𝑑 + 3Δ𝑑)] = 2 Γ— π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[π‘Ÿ(𝑑 + 2Δ𝑑)] + 𝑂(Δ𝑑 4 ) = 6𝑂(Δ𝑑 4 ) π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[π‘Ÿ(𝑑 + 4Δ𝑑)] = 2 Γ— π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[π‘Ÿ(𝑑 + 2Δ𝑑)] + 𝑂(Δ𝑑 4 ) = 10𝑂(Δ𝑑 4 ) and so on. By induction, we get π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[π‘Ÿ(𝑑 + 𝑛Δ𝑑)] =

𝑛(𝑛+1) 2

𝑂(Δ𝑑 4 )

Considering the global error in displacement between π‘Ÿ(𝑑) and π‘Ÿ(𝑑 + 𝑇) with 𝑇 = 𝑛Δ𝑑, it is clear that 1 𝑇

𝑇

π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[π‘Ÿ(𝑑 + 𝑇)] = 2 Δ𝑑 (Δ𝑑 + 1) 𝑂(Δ𝑑 4 ) = 𝑂(Δ𝑑 2 )

(9)

Using the same way, we can derive the global error for velocity: π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[𝑣(𝑑 + Δ𝑑)] =

π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[π‘Ÿ(𝑑+2Δ𝑑)]βˆ’π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[π‘Ÿ(𝑑)]

π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[𝑣(𝑑 + 2Δ𝑑)] =

+ 𝑂(Δ𝑑 2 ) = 𝑂(Δ𝑑 3 ) + 𝑂(Δ𝑑 2 ) = 𝑂(Δ𝑑 2 )

2Δ𝑑 π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[π‘Ÿ(𝑑+3Δ𝑑)]βˆ’π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[π‘Ÿ(𝑑+Δ𝑑)] 2Δ𝑑

+ 𝑂(Δ𝑑 2 ) = 𝑂(Δ𝑑 2 )

… π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[𝑣(𝑑 + 𝑛Δ𝑑)] = 𝑂(Δ𝑑 2 ) Therefore, π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[𝑣(𝑑 + 𝑇)] = 𝑂(Δ𝑑 2 ) (10) We see that the error of velocity does not increase with time. Conclusively, Original Verlet is a second-order integrator both for displacement and velocity. 3.2 Velocity Verlet The error analysis of Velocity Verlet is a little more complex than Original Verlet. Let’s first show the truncation error for velocity. Taking Taylor expansion of π‘Ž(𝑑 +

Δ𝑑 2

) and π‘Ž(𝑑 + Δ𝑑) at π‘Ž(𝑑) gives

π‘Ž (𝑑 +

Δ𝑑 2

1

) = π‘Ž(𝑑) + 2 𝑗(𝑑)Δ𝑑 + 𝑂(Δ𝑑 2 )

π‘Ž(𝑑 + Δ𝑑) = π‘Ž(𝑑) + 𝑗(𝑑)Δ𝑑 + 𝑂(Δ𝑑 2 ) Eqn. (11) minus half of Eqn. (12) gives 2

http://www.saylor.org/site/wp-content/uploads/2011/06/MA221-6.1.pdf

(11) (12)

π‘Ž (𝑑 +

Δ𝑑

)= 2

π‘Ž(𝑑)+π‘Ž(𝑑+Δ𝑑) 2

+ 𝑂(Δ𝑑 2 )

Then, taking Taylor expansion of 𝑣(𝑑)and 𝑣(𝑑 + Δ𝑑) at 𝑣(𝑑 + 𝑣(𝑑) = 𝑣 (𝑑 +

Δ𝑑

) βˆ’ π‘Ž (𝑑 + 2

𝑣(𝑑 + Δ𝑑) = 𝑣 (𝑑 +

Δ𝑑 Δ𝑑

) 2

Δ𝑑

2

) + π‘Ž (𝑑 + 2

Δ𝑑

1

+ 2 𝑗 (𝑑 +

Δ𝑑 Δ𝑑

) 2

2

2

) gives

Δ𝑑

1

(13)

Δ𝑑 2

) ( 2 ) + 𝑂(Δ𝑑 3 ) 2

+ 2 𝑗 (𝑑 +

Δ𝑑 2

Δ𝑑 2

) ( 2 ) + 𝑂(Δ𝑑 3 )

(14) (15)

Eqn. (15) minus Eqn. (14) gives 𝑣(𝑑 + Δ𝑑) = 𝑣(𝑑) + π‘Ž (𝑑 +

Δ𝑑 2

) Δ𝑑 + 𝑂(Δ𝑑 3 )

(16)

Substituting Eqn. (13) into Eqn. (16) turns out 𝑣(𝑑 + Δ𝑑) = 𝑣(𝑑) + [ = 𝑣(𝑑) +

π‘Ž(𝑑)+π‘Ž(𝑑+Δ𝑑)

Δ𝑑 2

2

+ 𝑂(Δ𝑑 2 )] Δ𝑑 + 𝑂(Δ𝑑 3 )

[π‘Ž(𝑑) + π‘Ž(𝑑 + Δ𝑑)] + 𝑂(Δ𝑑 3 )

(17) 3 ).

By comparing Eqn. (4) and Eqn. (17), it easy to see the truncation error of velocity is 𝑂(Δ𝑑 For the truncation error of displacement, just taking Taylor expansion of π‘Ÿ(𝑑 + Δ𝑑) at π‘Ÿ(𝑑) gives the answer 1

π‘Ÿ(𝑑 + Δ𝑑) = π‘Ÿ(𝑑) + 𝑣(𝑑)Δ𝑑 + 2 π‘Ž(𝑑)Δ𝑑 2 + 𝑂(Δ𝑑 3 )

(18)

Thus, the truncation error of displacement is also 𝑂(Δ𝑑 3 ). Now, let’s consider the global error of Velocity Verlet. Starting from 𝑣(𝑑 + Δ𝑑) = 𝑂(Δ𝑑 3 ) and (𝑑 + 2Δ𝑑) = 𝑣(𝑑 + Δ𝑑) +

Δ𝑑 2

[π‘Ž(𝑑 + Δ𝑑) + π‘Ž(𝑑 + 2Δ𝑑)] + 𝑂(Δ𝑑 3 ) , we have

π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[𝑣(𝑑 + 2Δ𝑑)] = π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[𝑣(𝑑 + Δ𝑑)] + 𝑂(Δ𝑑 3 ) = 2𝑂(Δ𝑑 3 ) π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[𝑣(𝑑 + 3Δ𝑑)] = π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[𝑣(𝑑 + 2Δ𝑑)] + 𝑂(Δ𝑑 3 ) = 3𝑂(Δ𝑑 3 ) …… π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[𝑣(𝑑 + 𝑛Δ𝑑)] = 𝑛𝑂(Δ𝑑 3 ) For the global error in velocity between 𝑣(𝑑) and 𝑣(𝑑 + 𝑇) with 𝑇 = 𝑛Δ𝑑, it is clear that 𝑇

π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[𝑣(𝑑 + 𝑇)] = Δ𝑑 𝑂(Δ𝑑 3 ) = 𝑂(Δ𝑑 2 )

(19)

About the global error in displacement, π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[π‘Ÿ(𝑑 + Δ𝑑)] = 𝑂(Δ𝑑 3 ), π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[𝑣(𝑑 + Δ𝑑)] = 1

𝑂(Δ𝑑 3 ) and π‘Ÿ(𝑑 + 2Δ𝑑) = π‘Ÿ(𝑑 + Δ𝑑) + 𝑣(𝑑 + Δ𝑑)Δ𝑑 + 2 π‘Ž(𝑑 + Δ𝑑)Δ𝑑 2 + 𝑂(Δ𝑑 3 ), then π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[π‘Ÿ(𝑑 + 2Δ𝑑)] = π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[π‘Ÿ(𝑑 + Δ𝑑)] + π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[𝑣(𝑑 + Δ𝑑)]Δ𝑑 + 𝑂(Δ𝑑 3 ) = 2𝑂(Δ𝑑 3 ) π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[𝑣(𝑑 + 3Δ𝑑)] = π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[𝑣(𝑑 + 2Δ𝑑)] + π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[𝑣(𝑑 + 2Δ𝑑)]Δ𝑑 + 𝑂(Δ𝑑 3 ) = 3𝑂(Δ𝑑 3 ) …… π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[π‘Ÿ(𝑑 + 𝑛Δ𝑑)] = 𝑛𝑂(Δ𝑑 3 ) Therefore, the global error in displacement between π‘Ÿ(𝑑) and π‘Ÿ(𝑑 + 𝑇) with 𝑇 = 𝑛Δ𝑑 is 𝑇

π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ[π‘Ÿ(𝑑 + 𝑇)] = Δ𝑑 𝑂(Δ𝑑 3 ) = 𝑂(Δ𝑑 2 )

(20)

We see that the global error in Velocity Verlet are both 𝑂(Δ𝑑 2 ) for displacement and velocity, and it is the same as Original Verlet. Conclusion This paper is concluded by the follow table:

Order Truncation error Global error

Table 1 Error in Verlet Algorithm Original Verlet Velocity Verlet Displacement Velocity Displacement Velocity 𝑂(Δ𝑑 4 ) 𝑂(Δ𝑑 2 ) 𝑂(Δ𝑑 3 ) 𝑂(Δ𝑑 3 ) 2) 2) 2) 𝑂(Δ𝑑 𝑂(Δ𝑑 𝑂(Δ𝑑 𝑂(Δ𝑑 2 )