27
TVE 13 040 juni Examensarbete 15 hp Juni 2013 Fourth order accurate numerical solution of the sine-Gordon equation using the summation-by-parts simultaneous approximation term method David Jäderberg Andreas Gådin

Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

TVE 13 040 juni

Examensarbete 15 hpJuni 2013

Fourth order accurate numerical solution of the sine-Gordon equation

using the summation-by-parts simultaneous

approximation term method

David JäderbergAndreas Gådin

Page 2: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

Teknisk- naturvetenskaplig fakultet UTH-enheten Besöksadress: Ångströmlaboratoriet Lägerhyddsvägen 1 Hus 4, Plan 0 Postadress: Box 536 751 21 Uppsala Telefon: 018 – 471 30 03 Telefax: 018 – 471 30 00 Hemsida: http://www.teknat.uu.se/student

Abstract

Fourth order accurate numerical solution of thesine-Gordon equation

David Jäderberg, Andreas Gådin

This project deals with creating a numerical solver of the sine-Gordon equation using the summation- by- parts and simultaneous approximation term method in combination with a finite difference time- stepping method as well as a Runge-Kutta time-stepping method. All implementations were done with fourth order accuracy and the theoretical work involved in deriving such a finite difference time-stepping method for the sine-Gordon equation is presented.

Both the finite difference and the Runge-Kutta time- stepping methods conserved the energy of the solutions. The only significant difference between the two time-stepping methods was that the finite difference method executed significantly faster than the Runge-Kutta method. However, the Runge- Kutta method is easier to implement and may therefore be preferable when execution time is non-vital.

ISSN: 1401-5757, TVE 13 040 juniExaminator: Martin SjödinÄmnesgranskare: Maria StrömmeHandledare: Ken Mattsson

Page 3: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

Populärvetenskaplig sammanfattningSine-Gordon-ekvationen har under årens lopp dykt upp flera gånger första gången under 1800-talets mitt föratt sedan glömmas bort och återupptäckas igen i slutet på 1930-talet. Från första början användes ekvationenför att studera matematiska ytor med konstant negativ lutning. Vid återupptäckten kom den att beskrivadislokationer i kristaller. Det som är speciellt intressant med sine-Gordon-ekvationen är att den har ett flertalså kallade solitonlösningar.

En soliton är intressant ur den aspekten att det är en självförstärkande ensamstående våg. Det går attjämföra med en pulsvåg. Mer intressant är också att när flera solitoner interagerar med varandra lämnar devarandra oförändrade till exempel, om en stor snabb våg passerar en mindre långsammare våg kommer de attbygga på varandra i det skedet när deras position är samma för att sedan delas upp igen i den långsammarevågen och den snabbare vågen var för sig.

I projektet var syftet att skapa en modifierad finit differensmetod som var av fjärde ordningens noggrann-het i både tid och rum. Med noggrannhet menas att om rums eller tidssteget minskas så minskas också feletmed motsvarande noggrannhetsordning. I detta fall ska alltså felet, avvikelsen från den analytiska lösningenminska med en faktor fyra. I projektet skulle också en jämförelse mellan den modifierade finita differensme-toden och fjärde ordningens Runge-Kutta-tidsstegningsmetod göras. Först och främst skulle bevarandet avenergin jämföras mellan de två metoderna.

När man löser sine-Gordon ekvationen och andra ekvationer för den delen, kan man göra det på olikasätt t.ex. analytiskt eller numeriskt. I projektet sine-Gordon med SBP-SAT löstes sine-Gordon ekvationennumeriskt med SBP-SAT som är ett sätt att approximera rumsderivator. För att hela problemet ska bli löstnumeriskt måste derivatan i tiden approximeras. Det görs med hjälp av en finit differensmetod som modifieras.I enlighet med projektets syfte gjordes den modifierade tidsstegningsmetoden så att den hade en noggrannhetav fjärde ordningen i både tid och rum. Noggrannheten i rummet säkerställdes med en konvergensstudie tillatt vara av fjärde ordningen. Detta var väntat eftersom det är den noggrannhetsordning SBP-SAT metodenger. Alltså var det noggrannheten i tiden som behövde mest arbete.

För att den modifierade FDM tidsstegningsmetod skulle bli av fjärde ordningens noggrannhet användesTaylorutveckling tillsammans med den centrerade differensmetoden och det kunde ses att den i sitt grundut-förande var av andra ordningen. Alltså behövdes ett antal termer läggas till för att uppnå den teoretisktönskade noggrannheten. Sedan testades sedan noggrannheten i tiden på motsvarande sätt som i rummet ochresultatet blev att en fjärde ordningens tidsstegningsmetod hade uppnåtts.

Jämförelsen mellan den modifierade tidsstegningsmetoden och Runge-Kuttas tidsstegningsmetod sägeratt den modifierade metoden är avsevärt mycket snabbare i de beräkningar som genomförs. Ur ett energibe-varande perspektiv så är det ingen skillnad mellan den modifierade tidsstegningsmetoden och Runge-Kuttasmetod.

3

Page 4: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

Contents1 Introduction 5

2 Background 5

3 Purpose 5

4 Theory 64.1 Analytic solutions of sine-Gordon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64.2 The energy method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4.2.1 Analytic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74.2.2 Semi-discrete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4.3 Finite difference methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84.4 Runge-Kutta methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84.5 SBP-SAT method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94.6 Studying convergence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

5 Method 105.1 Application of the energy method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105.2 Application of the SBP-SAT method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105.3 Analytic boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115.4 Modified finite difference time-stepping method . . . . . . . . . . . . . . . . . . . . . . . . . . 125.5 Initialization of the modified finite difference time-stepping method . . . . . . . . . . . . . . . 135.6 Runge-Kutta time-stepping method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145.7 Generalization of the sine-Gordon equation to 2 dimensions . . . . . . . . . . . . . . . . . . . 15

6 Results 166.1 Convergence Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166.2 Kink-kink solution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176.3 Breather solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196.4 2 dimensional solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

7 Discussion 19

8 Conclusion 26

4

Page 5: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

1 IntroductionIn this project the sine-Gordon equation is solved numerically with a fourth order accurate energy preservingmethod. Sine-Gordon is a nonlinear partial differential equation on the form utt = uxx−sinu. The numericalmethod that will be used is the SBP-SAT method. SBP-SAT is an abbreviation for summation-by-parts andthe latter part is for simultaneous approximation term.

The theoretical work in this report is naturally split into two parts; the theory, which is general theorypertaining to the problems that this report deals with, and the method, which is the part where the cal-culations are shown and the main theoretical result is proven, the modified finite difference time-steppingmethod. The results contain plots of different solutions to the sine-Gordon equation as well as measurementsof the energy of those solutions.

2 BackgroundThe sine-Gordon equation was first introduced by Edmond Bour in 1862 to study surfaces of constant negativecurvature, e.g. an hyperboloid. For some time after that it went unused, but was later used again when apair of scientists looked at dislocations in crystals. It was, when it was reintroduced 1939, considered as avariant of the Klein-Gordon equation, in that it has a sine term instead of the linear term in Klein-Gordon.

To the sine-Gordon equation there are many solutions, some of which are soliton solutions. A soliton isself-reinforcing solitary wave, pulse, which maintains its velocity and shape. Also, interactions between severalsolitons leaves the shape of the solitons unchanged [2]. Different soliton solutions have different appearances.They can for example have a breather or a kink-appearance. Focus will be on the soliton solution which is akink. The name kink has its origin from the fact that when the solution is seen as an angle, a kink describesa full rotation, from 0 to 2π [2].

Even though solitons were first observed in 1830 as water wave pulses it took about 130 years until theywere first analyzed and applied to solve a problem. Solitons have then come to be applied in meteorology,plasma studies and laser physics. For this project, the sine-Gordon equation’s applications are not of sig-nificant interest. Examples of what the sine-Gordon equation is used to describe are phenomenons like themovement of a rigid body attached to a spring, dislocations in crystals etc [2].

3 PurposeTo construct a modified finite difference time-stepping method that is energy conservative to solve the sine-Gordon equation numerically while using the SBP-SAT method for the discretization of space. The solver willbe designed to be fourth order accurate in both space and time and to use Neumann boundary conditions.This will then be compared with the analytic solution and the solution from using the fourth order accurateRunge-Kutta time-stepping method. To analyze convergence and if the energy is preserved, both the modifiedFDM time-stepping method and the Runge-Kutta time-stepping method are to be implemented using thenumerical calculation software Matlab. Other aims are successfully approximating kink-kink and breather-breather interactions and to extend the sine-Gordon equation to two dimensions solve the extended version.This is also to be implemented and solved in Matlab.

5

Page 6: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

4 TheoryThe sine-Gordon equation can be presented as an initial value problem on the form

utt = uxx − sinu, a ≤ x ≤ b, t ≥ 0ga(t) = αu+ βux + γut, x = a, t ≥ 0gb(t) = αu+ βux − γut, x = b, t ≥ 0u = f(x), ut = r(x) a ≤ x ≤ b, t = 0

(4.1)

which is the problem that a large part of this report is focused on solving numerically. The energy of thesolution to the sine-Gordon equation can be calculated in parts as

Ep =

ˆ b

a

1− cos(u)dx

Ek =

ˆ b

a

1

2u2tdx (4.2)

Es =

ˆ b

a

1

2u2xdx

where Ep is the potential energy, Ek the kinetic energy and Es the strain energy [5]. The total energy canthen be calculated as the sum of all three parts,

E = Ep + Ek + Es. (4.3)

4.1 Analytic solutions of sine-GordonThe expression,

u(x, t) = 4 arctan emγ0(x−vt)+δ (4.4)

where γ20 =1

1− v2is a single soliton solution to the slightly more generalized version of the sine-Gordon

equation [2],utt = uxx −m2 sinu. (4.5)

Note that δ shifting of the location of the kink and the v is the velocity of the kink. Choosing the positiveroot of γ20 yields a kink solution (increasing from left to right) and the negative root yields an anti-kink.There also exists two-soliton solutions to the sine-Gordon equation on the form [7]

u = 4 arctan

(φ sinh(φmx)

cosh(φmt)

), (4.6)

where φ =

√m2 − 1

m.

The sine-Gordon equation also has another group of soliton solutions, known as breathers. These can beseparated into standing and moving breathers. A standing breather solution exists on the form

u = 4 arctan

( √1− w2 sin (w2t)

w2 cosh (√

1− w2x)

)(4.7)

where w2 ≤ 1 [4]. There also exists a moving breather solution on the form

u = 4 arctan

(1

w

√1− w2 sin (wγ0 (t− v(x+ δ))) sech

(√1− w2γ0(x+ δ − vt)

))(4.8)

where w2 ≤ 1 [6].

6

Page 7: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

4.2 The energy method4.2.1 Analytic

The energy method can be used to show that a problem is well-posed and stability of a semi-discrete ap-proximation by ensuring that the energy of the equation is constant or decreasing. In order to get an energyestimate of the PDE of choice, one must succeed in describing the energy of the equation as a norm. Thiscan be done through integration by parts and multiplication by the time-derivative that is one order lowerthan the highest time-derivative that exists in the equation and then adding the transpose. To illustrate thisprocedure, consider an initial value problem of the wave equation with Neumann boundary conditions.

The highest order spatial and temporal derivatives in the equation determine the number of boundaryand initial conditions, respectively, necessary for the problem to be well-posed. For instance, if the highestspatial derivative is of the first order one boundary condition is required; if it is second order, two boundaryconditions are required, and so on. The same is used for the initial conditions but instead of the highestspatial derivative, the highest temporal derivative is used.

utt = uxx 0 ≤ x ≤ 1 t ≥ 0g0(t) = αux + βut x = 0 t ≥ 0g1(t) = αux − βut x = 1 t ≥ 0f(x) = cos(x), vt = 0 0 ≤ x ≤ 1 t = 0

(4.9)

Integration by parts and multiplication with the lower order time-derivative will result in,

1

2

∂t‖ut‖ = utux

∣∣10−ˆ 1

0

utxuxdx. (4.10)

Then by adding the transpose a norm on both the left and right side is obtained,

∂t(||ut||+ ||ux||) = 2utux

∣∣10

(4.11)

This leaves the boundary conditions to be set in such a way that they are either negative or equal to zerofor the problem to be well-posed. An inequality can then be written, which is used to put limitations on theboundary conditions.

2utux∣∣1 − 2utux

∣∣0 ≤ 0 (4.12)

Then replace the the ux terms using the boundary conditions and set the data to zero (g0(t) = g1(t) = 0).This is allowed because the terms g0(t) and g1(t) do not affect whether the problem is well-posed.

−2β

α(u2t∣∣1 + u2t

∣∣0) ≤ 0 (4.13)

This shows that the problem is well-posed for any choice of α and β such thatβ

α≥ 0.

4.2.2 Semi-discrete

Using the energy method for the semi-discrete version of (4.1) is very similar to the analytic case, only thatone first multiplies the equation with vTt H instead of partial integration and multiplication. After this thetranspose is added to create the energy norm. From here the approach is the same as in the analytic case.

7

Page 8: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

4.3 Finite difference methodsFinite difference methods can be used to numerically approximate solutions to differential equations. A quitecommon approximation of the second derivative is provided by

uj+1 − 2uj + uj−1

k2

where uj represents the j:th point in the discretization of some dimension, usually a spatial or temporaldimension, and k is the distance between two nearby points, the step size. For example if uj = u(xj),

uxx ≈uj+1 − 2uj + uj−1

k2(4.14)

To show that this approximation holds, replace uj±1 with the Taylor expansions of uj±1 around uj ,

uj±1 = uj ± kujx +k2

2ujxx ±

k3

6ujxxx +

k4

24ujxxxx +

k5

120ujxxxxx +O(k6). (4.15)

Which gives

uj +kujx +

k2

2ujxx +

k3

6ujxxx +

k4

24ujxxxx +O(k5)− 2uj + uj −

kujx +k2

2ujxx −

k3

6ujxxx +

k4

24ujxxxx +O(k5)

k2,

(4.16)where apart from the marked terms all terms containing uj cancel as well, leaving

ujxx +k2

12ujxxxx +O(k4). (4.17)

Note that the error O depends on k4 since the fifth derivative, uxxxxx, terms will also cancel. This meansthat

uj+1 − 2uj + uj−1

k2= ujxx +

k2

12ujxxxx +O(k4) (4.18)

which makes it clear that (4.14) is a second order accurate approximation of uxx.

4.4 Runge-Kutta methodsThe standard fourth-order accurate Runge-Kutta method can be applied to a second order ODE, vtt = f(v),by first splitting it into a system of first order ODEs,

vt = wwt = f(v).

(4.19)

Each following step can then be calculated usingvn+1 = vn + k

6 (c1 + 2c2 + 2c3 + c4)wn+1 = wn + k

6 (d1 + 2d2 + 2d3 + d4)(4.20)

where each of the constants c1 to c4 as well as d1 to d4 are given by

c1 = wn

d1 = f(vn)c2 = wn + k

2d1d2 = f(vn + k

2 c1)c3 = wn + k

2d2d3 = f(vn + k

2 c2)c4 = wn + kd3d4 = f(vn + kc3).

(4.21)

8

Page 9: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

c1 is an approximation of the slope at n which is used to approximate the slope at the midpoint n + 1/2,giving c2, which is then used to make another approximation of the slope at the midpoint, c3. And finally c3is used to approximate the slope at n+ 1, which is c4 [1]. Since w is not interesting, d1 through d4 are onlyused to help in approximating v.

4.5 SBP-SAT methodSummation-by-parts (SBP) is an analogue to integration by parts, by using SBP operators one can approx-imate the spatial derivative. Simultaneous approximation term (SAT) is a way to enforce the boundaryconditions weakly at the same time as the numerical approximation of the PDE. When the SAT terms arechosen appropriately, this will render the opportunity to prove that the semi-discrete version of the problemis stable with the energy method.

4.6 Studying convergenceThe convergence rate in the spatial dimension of a numerical approximation is defined as

q = log10

(||u− v(m1)||h||u− v(m2)||h

)/ log10

(m2

m1

)(4.22)

where m1 and m2 are the solutions with the corresponding number of unknowns in space. Using the l2-norm,the error ||u− v(m1)||h is calculated as

||u− v(m1)||h ≡1√m1

√√√√m1∑j=1

(u(xj)− vj)2 (4.23)

and similarly for the solution using m2 points in space.

If the time-stepping method is not guaranteed to be stable for any step length, as is often the case,measuring the convergence in the temporal dimension can be somewhat more troublesome than measuringthe convergence rate in the spatial dimension. To be able to measure the error in time well, it is preferableto ensure that the spatial error is small compared to the error in space, which would otherwise affect themeasured convergence rate. Therefore one would like to choose a large time-step compared to the step betweentwo points in space, but this is not always possible as a relatively large time-step can lead to instability.

These problems with measuring the convergence rate in time can be avoided if one expects the same rateof convergence in space as in time. Then one can simply change the discretization of both time and space(making sure to keep the solution stable) and measure the convergence rate the same way as for measuringthe convergence rate in space. This will measure the convergence rate for both the temporal and the spatialapproximations and the measured convergence rate will deviate from the expected value if the temporalapproximation does not have the same convergence rate as the spatial approximation.

9

Page 10: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

5 Method

5.1 Application of the energy methodTo examine for what boundary conditions the problem (4.1) is well-posed, one can use the energy method.Assume that β 6= 0, then multiply eq. (4.1) by ut, integrate and let (f, g) =

´ bafgdx to get

(ut, utt) = (ut, uxx), (5.1)

(when letting sinu = 0, since it will not affect whether the problem is well-posed) then partially integratethe right-hand side, (ut, uxx) = utux

∣∣ba− (utx, ux). Using this and adding the transpose gives

(utt, ut) + (ut, utt) = 2uxut∣∣ba− (ux, uxt)− (uxt, ux) (5.2)

From this, identify that∂

∂t||ut||2 = (utt, ut) + (ut, utt) and − ∂

∂t||ux||2 = −(ux, uxt)− (uxt, ux),

∂t

(||ut||2 + ||ux||2

)= 2uxut

∣∣ba

(5.3)

and so, to make sure the energy does not increase over time, one can let

uxut∣∣ba≤ 0 ⇐⇒ uxut

∣∣b − uxut∣∣a ≤ 0. (5.4)

Since β 6= 0 one can solve for ux in the boundary conditions of eq. (4.1) to get(g1 − αu+ γut

β

)ut∣∣b − (g0 − αu− γut

β

)ut∣∣a ≤ 0. (5.5)

The terms g0 and g1 will not affect whether the problem is well-posed or not and can therefore be set to zeroin this analysis, which gives

1

β

((−αuut + γu2t )

∣∣b − (−αuut − γu2t )∣∣a) ≤ 0 (5.6)

From this, one can identify the requirement thatγ

β≤ 0 for the problem to be well-posed. One can also see

that γ = 0 is required for the energy to be preserved. This in turn can be used to simplify the inequality to

1

β

(−αuut

∣∣b + αuut∣∣a) ≤ 0 (5.7)

From this it’s simple to see that when α = 0 the problem is well-posed and conserves the energy. Therefore,when α = γ = 0 the energy of the problem is conserved. If α 6= 0 one can see from eq. (5.7) that the energywill be conserved only when

uut∣∣a = uut

∣∣b, (5.8)

which is a form of periodic boundary conditions.

5.2 Application of the SBP-SAT methodTo apply the SBP-SAT method to this problem, first let α = 0 to simplify the analysis. Then introducethe summation-by-parts approximation of the second derivative, D2 = H−1(−M − e1S1 + emSm) whereH = H> > 0, M = M> ≥ 0, e1 = [1, 0, 0, 0...]>, em = [0, 0, ..., 0, 1]> and S1, Sm are fourth order accurate

10

Page 11: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

approximations of ux at the left and right boundary respectively [3]. A semi-discrete approximation of theproblem (4.1) can be written

vtt = D2v − sin v + SAT, (5.9)

where SAT represents the SAT terms which can be written

SAT = τ0H−1e1

(βS1v + γe>1 vt

)+ τ1H

−1em(βSmv − γe>mvt

). (5.10)

The term sin v will not affect whether the problem is stable or not and will therefore be set to zero in thefollowing analysis, which will show stability of the approximation. Use D2 and the SAT terms to write (5.9)as

v>t Hvtt = v>t (−M − e1S1 + emSm)v + τ0v>t e1(βS1v + γe>1 vt) + τ1v

>t em(βSmv − γe>mvt) (5.11)

which can be rewritten as

v>t Hvtt = v>t (−M + (τ0β − 1)e1S1 + (τ1β + 1)emSm) v + γv>t(τ0e1e

>1 − τ1eme>m

)vt (5.12)

here we can see that we want to choose τ0 =1

βand τ1 = − 1

βto cancel the terms containing S1 and Sm. The

expression will be simplified to

v>ttHvtt = −v>t Mv +γ

βv>t(e1e>1 + eme

>m

)vt. (5.13)

Then, add the transpose of each side and add it to their respective sides to get

∂t

(||vt||2H + ||v||2M

)= 2

γ

βv>t(e1e>1 + eme

>m

)vt. (5.14)

This leaves only the requirement that

βv>t(e1e>1 + eme

>m

)vt ≤ 0 (5.15)

to ensure that the problem is stable, and since e1e>1 +eme>m ≥ 0 it is required that

γ

β≤ 0 for the semidiscrete

approximation to be stable, which is the same requirement as for the continuous problem. Thus, with thisdiscretization of the problem, it holds that if the analytic version is stable, so is the semi-discrete version.Furthermore, the convergence rate can be determined by using matrices and vectors (i.e. D2 or S1) that areapproximations of the wanted order.

5.3 Analytic boundary conditionsWe want to compare the solution (4.4) with our numerical solution with the goal of measuring the convergenceof the numerical solution. To get this particular solution the boundary and initial conditions have to be setin a way that is consistent with the solution. The initial conditions can easily be found from the solutionitself and considering the boundary conditions

ga(t) = αu+ βux x = a t ≥ 0gb(t) = αu+ βux x = b t ≥ 0

, (5.16)

one can determine the functions ga(t) and gb(t) using (4.4) and its first spatial derivative,

ux = 4mγ0emγ0(x−vt)+δ

1 + e2(mγ0(x−vt)+δ)(5.17)

11

Page 12: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

which gives ga(t) = 4α arctan

(emγ0(a−vt)+δ

)+ 4βmγ0

emγ0(a−vt)+δ

1 + e2(mγ0(a−vt)+δ)

gb(t) = 4α arctan(emγ0(b−vt)+δ

)+ 4βmγ0

emγ0(b−vt)+δ

1 + e2(mγ0(b−vt)+δ)

(5.18)

5.4 Modified finite difference time-stepping methodThe goal of this section is to derive a fourth order accurate finite difference time-stepping method, whichshould also conserve the energy of the problem. With this in mind, introduce the second order accurate finitedifference time-stepping method,

vtt =vn+1 − 2vn + vn−1

k2. (5.19)

Using this and the Taylor expansion of vn±1,

vn±1 = vn ± kvnt +k2

2vntt ±

k3

6vnttt +

k4

24vntttt ±

k5

120vnttttt +O(k6). (5.20)

to replace vn±1 in (5.19), which gives

vn+1 − 2vn + vn−1

k2=

2

(vn +

k2

2vntt +

k4

24+O(k6)

)− 2vn

k2= vntt +

k2

12vntttt +O(k4). (5.21)

Which explicitly shows the first error term when letting (5.19) approximate vtt. If one could approximatethat error term (to fourth order accuracy) it would be possible to subtract the error from (5.19) and the only

error terms left would be O(k4). I.e. if one could describek2

12vntttt and subtract it from the time-stepping

method, the time-stepping method would be fourth order accurate. To find what vntttt is, start with thesemi-discrete equation,

vntt = D2vn − sin vn + SAT. (5.22)

And then, for Neumann boundary conditions,

vntt = −H−1Mvn − sin vn ⇐⇒ vntt = Avn − sin vn, (5.23)

where A = −H−1M . Derive with respect to time twice to get

vtttt = Avtt −∂2

∂t2sin v. (5.24)

To achieve an overall time-stepping method that is fourth order accurate, we need to approximate∂2

∂t2sin v

with a second order accurate method, since it will be multiplied with k2. The second time derivative of sin vis

∂2

∂t2sin v =

∂tvt cos v = vtt cos v − v2t sin v = (Av − sin v) cos v − v2t sin v. (5.25)

One can not use an approximation of vt containing vn+1, since this will effectively make the method implicit,instead one can use the approximation

vnt ≈

3

2vn − 2vn−1 +

1

2vn−2

k. (5.26)

12

Page 13: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

Now, consider the approximation

vn+1 − 2vn + vn−1

k2− k2

12vntttt = Avn − sin vn (5.27)

and replace vntttt according to (5.24) and (5.25) to get

vn+1 − 2vn + vn−1

k2− k2

12

(A(Avn − sin vn)− (Avn − sin vn) cos vn + (vnt )2 sin vn

)= Avn − sin vn (5.28)

and then replace vt as per (5.26). This method can be applied by solving (5.28) for vn+1.

5.5 Initialization of the modified finite difference time-stepping methodThe presented time-stepping method makes use of the terms vn−1 and vn−2 which means it can not be usedto approximate v1 or v2. Instead this section will describe special approximations for those two time-steps,which will both be fourth order accurate to ensure that the error from the first two approximations will beof similar size as the average error for each step.

To approximate v1, start with the idea that the second derivative can be approximated using the Eulerforward method on the first derivatives. To do this, one only has to approximate v1t since v0t is already knownfrom the initial conditions to the problem. An approximation of v1t can similarly be found using the Eulerforward method, which gives

v0tt ≈v1t − v0t

k=

v1 − v0

k− v0t

k. (5.29)

But it can be shown that this is not an approximation of v0tt but rather an approximation of1

2v0tt. This hints

that one could instead use the approximation,

v0tt ≈ 2

v1 − v0

k− v0t

k, (5.30)

which can be shown to be a first order accurate approximation of v0tt by using the Taylor expansion of v1 interms of v0,

2

v1 − v0

k− v0t

k= 2

1

k

(v0 +

kv0t +k2

2v0tt +

k3

6v0ttt +

k4

24v0tttt +

k5

120v0ttttt +O(k6)

)−v0

k− v

0t

k=

= v0tt +k

3v0ttt +

k2

12v0tttt +

k3

60v0ttttt +O(k4). (5.31)

With this in mind it is quite easy to choose an approximation of v0tt that is fourth order accurate,

v0tt = 2

v1 − v0

k− v0t

k−k

3v0ttt −

k2

12v0tttt −

k3

60v0ttttt. (5.32)

Then solve for v1 to get

v1 = v0 + kv0t +k2

2v0tt +

k3

6v0ttt +

k4

24v0tttt +

k5

120v0ttttt, (5.33)

13

Page 14: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

which one can recognize as the Taylor expansion of v1 around v0. To do this, one must calculate the derivativesof v0 that are present in (5.33). Remember that v0t is determined by an initial condition to the problem andthat one can use the PDE itself to find v0tt,

vtt = vxx − sin v = Av − sin v. (5.34)

where Av is a fourth order accurate approximation of vxx. To find vttt, simply derive vtt once with respectto time,

vttt = Avt − vt cos v, (5.35)

Then similarly for the following two derivatives

vtttt = Avtt +∂2

∂t2sin v = Avtt − vtt cos v + v2t sin v, (5.36)

vttttt = Avttt − vttt cos v + vttvt sin v + 2vttvt sin v + v3t cos v, (5.37)

where one can replace the higher order derivatives as necessary to be left with only v and vt.

To approximate v1tt, use the approximation from section 4.3 and subtract the first error term,

v1tt =v2 − 2v1 + v0

k2− k2

12v1tttt (5.38)

and replace v0 and v2 with their Taylor expansions around v1,(v1 +

kv1t +k2

2v1tt +

k3

6v1ttt +

k4

24v1tttt +O(k5)

)−2v1 +

(v1 −

kv1t +k2

2v1tt −

k3

6v1ttt +

k4

24v1tttt +O(k5)

)k2

k2

12v1tttt =

(5.39)

= v1tt +O(k4). (5.40)

The error will depend on k4 since the k5 terms in Taylor expansion will cancel. Then one only needs todescribe v1tt and v1tttt,

v1tt = Av1 − sin(v1) (5.41)

v1tttt = Av1tt − v1tt cos(v1) + (v1t )2 sin(v1). (5.42)

Since the error in vt will be multiplied by k4, it is enough to approximate vt with the Euler forward method,

v1t =v1 − v0

k. (5.43)

5.6 Runge-Kutta time-stepping methodTo use the fourth order accurate Runge-Kutta method as the time-stepping method for the semi-discreteversion of (5.9) it is necessary to describe the second order PDE as a system of first order PDEs,

vt = wwt = Av − sin v

(5.44)

14

Page 15: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

And using the standard fourth order accurate Runge-Kutta method to approximate wt and vt,vn+1 = vn + k

6 (c1 + 2c2 + 2c3 + c4)wn+1 = wn + k

6 (d1 + 2d2 + 2d3 + d4) .(5.45)

where

c1 = wn

d1 = Avn − sin vn

c2 = wn + k2d1

d2 = A(vn + k2 c1)− sin(vn + k

2 c1)c3 = wn + k

2d2d3 = A(vn + k

2 c2)− sin(vn + k2 c2)

c4 = wn + kd3d4 = A(vn + kc3)− sin(vn + kc3)

(5.46)

as per section 4.4.

5.7 Generalization of the sine-Gordon equation to 2 dimensionsThe sine-Gordon equation can be generalized into 2 dimensions by replacing the spatial derivative with theLaplacian, utt = ∆u− sinu, a ≤ x, y ≤ b, t ≥ 0,

∇u = 0, x, y ∈ δΩ, t ≥ 0u = f(x, y), ut = g(x, y), a ≤ x, y ≤ b t = 0,

(5.47)

where ∆u = uxx + uyy and δΩ is the boundary of the domain. To be able to use a similar implementationas for the 1 dimensional case, introduce the Kronecker product for matrix multiplication,

A⊗B =

a1,1B . . . a1,mB...

. . ....

am,1B . . . am,mB

, (5.48)

which uses the same number of equally spaced points in both spatial dimensions. Then use the approximationvtt = Av − sin v where A = (H−1M) ⊗ E + E ⊗ (H−1M). Note that with the boundary condition ∇u = 0the SAT terms and part of D2 disappears, so one does not need to handle them. Also define v as a vector ofvectors,

v = [v1,1, v1,2, . . . , v1,m, v2,1, v2,2, . . . , v2,m, . . . , vm,m] . (5.49)

These changes in total allow for an implementation very similar to the 1 dimensional case to be used for the2 dimensional case.

To be able use the approximation for the 2D case, it is necessary to find initial conditions that satisfy thethe 2 dimensional version of the sine-Gordon equation. This can for example be done with a moving breathersolution,

u = −4 arctan

(w√

1− w2sin(φ(t)− vx)sech(wx)sech(wy)

), (5.50)

where w2 ≤ 1 [5].

15

Page 16: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

Figure 1: An illustration of the solution used to approximate the different convergence rates. Note that thisexample is at time t = 5s and that the soliton is moving right with v = 0.9 units/s. The marks represent thenumerical solution while the line is the analytic solution.

Table 1: A study of the l2 error at time tend = 5s with the time step 10−5 where m denotes the number ofpoints used in the spatial dimension.

Number of points, m l2-error101 0.00928201 6.089e-04401 5.185e-05

6 Results

6.1 Convergence StudyArguably the most important property of a numerical approximation is that it is convergent. To show thatthis is the case for the methods used in this report, a convergence study was performed which will first showthat the spatial approximation is convergent and then show that both the implementations of the modifiedfinite difference time-stepping method as well as the Runge-Kutta method are convergent. The convergencerate in the spatial dimension was measured for the kink solution (4.4) with v = 0.9, m = 1 and δ = 8.5 · γ0for the initial conditions. The analytic solution and an approximation using the modified finite differencetime-stepping method are presented in fig. (1). The time-step was chosen as k = 1e − 5 and the end timewas tend = 5s. The problem was solved in space on the interval [−15, 15] and the measured l2-errors can beseen in table (1). The measured convergence rates can be seen in table (2) where it is also clear that theconvergence rate is 4.

16

Page 17: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

Table 2: A study of the convergence rate of the numerical solution at time tend = 5s with the time step10−5s where m is the number of points used in the spatial dimension on the interval [−15, 15].

Lower m Upper m Convergence rate, q51 101 3.990951 201 3.9932101 201 4.0009

Table 3: A study of the l2 error using the modified finite difference time-stepping method until time t = 20swith m points in space and where k denotes the time step used.

Time step, k Number of points, m l2-error0.1 151 0.008370.05 251 9.937e-040.01 401 1.6087e-04

Two studies similar to the earlier study of convergence in space were performed to measure the convergencerate in time but some adjustments were made to ensure that the solution was stable, see section 4.6. Theparameters in the initial conditions were the same but with a different end time, tend = 20. One study usedthe modified finite difference time-stepping method and the other used the fourth-order accurate Runge-Kuttatime-stepping method.

The l2 error and convergence rate using the modified finite difference time-stepping method can be seenin table (3) and table (4) respectively. The l2 error and convergence rate using the fourth-order accurateRunge-Kutta time-stepping method can be seen in table (5) and table (6) respectively. From these tables itis also clear that both time-stepping methods have the convergence rate 4.

6.2 Kink-kink solutionA simulation was run with the initial conditions being two somewhat overlapping stationary kinks. Thissolution is shown for different times in fig. (2). The energy of this solution was also approximated and ispresented in fig. (3). One can note that the kinetic energy is 0 at time t = 0, clarifying that the kinks arestationary initially. But the kinks quickly start to repel each other, leaving them moving away from eachother. The execution time for this solution was measured using the modified finite difference time-steppingmethod and was tFDM = 18.0s. The execution time was also measured for the Runge-Kutta time-steppingmethod and was tRK = 186.1s.

Table 4: A study of the convergence rate of the numerical solution using the modified finite difference time-stepping method until time t = 20s with m points in space and different time steps used. Time steps givenas in table (3).

Lower m Upper m Convergence rate, q151 251 4.1932151 401 4.0461251 401 3.8866

17

Page 18: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

Table 5: A study of the l2 error using the fourth order accurate Runge-Kutta time-stepping method untiltime t = 20s with m points in space and where k denotes the time step used.

Time step, k Number of points, m l2-error0.1 151 0.009990.05 251 0.001100.01 401 1.611e-04

Table 6: A study of the convergence rate of the numerical solution using the fourth order accurate Runge-Kutta time-stepping method until time t = 20s with m points in space and different time steps used. Timesteps given as in table (5).

Lower m Upper m Convergence rate, q151 251 4.3465151 401 4.2265251 401 4.0963

Figure 2: Solution starting with two overlapping stationary kinks at times t = 1s, t = 5s and t = 20s.

18

Page 19: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

Figure 3: Energy of the solution in fig. (2). For times t ≤ 5s the kinetic energy is increasing as the kinks repeleach other and the strain energy is decreasing. After that, the different energies remain mostly constant.

6.3 Breather solutionsA solution containing both a standing and moving breather was created using superposition of standing andmoving breather solutions using the analytical forms in (4.7) and (4.8). As is shown in fig. (4) the behavioris as expected, both breathers retain their shape after the collision with the standing breather having beenshifted to the left. This solution was calculated using the modified finite difference time-stepping method andthe energy was approximated, which is shown in fig. (5). The calculation was also performed with the sameparameters but using the Runge-Kutta time-stepping method. The energy approximations for that solutioncan be seen in fig. (6).

6.4 2 dimensional solutionsAn implementation of the extension of the sine-Gordon into 2 dimensions was executed for initial conditionsusing (5.50) with v = 0.9, w = 3/4, φ(0) = π/2 where ut was approximated using an Euler forward step tothe time k with φ(k) = π/2−0.01. Figures (7), (8) and (9) show the breather moving from a central positionto the upper left boundary. What can’t be as clearly seen is that the breather moves forward in the samefashion as its 1 dimensional counterpart, with one negative part and one positive with them slowly changingamplitudes and position inside the soliton.

7 DiscussionThe main purpose of this project was to derive a fourth order accurate finite difference time-stepping methodand to implement this in Matlab in combination with the SBP-SAT method as a numerical solver to thesine-Gordon equation. This was done successfully, as is shown by the convergence study in section 6.1. This

19

Page 20: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

Figure 4: Solution containing two breathers, one standing and one moving at the different times t =10, 36.5, 80s from top to bottom.

20

Page 21: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

Figure 5: Energy of the solution in fig. (4) calculated using the modified finite difference time-steppingmethod. The potential energy is the smallest part of the energy while the kinetic is the largest and the strainis in between the other two except during the collision, when the strain energy is slightly larger than thekinetic.

21

Page 22: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

Figure 6: Energy of the solution in fig. (4) calculated using the Runge-Kutta time-stepping method. Thepotential energy is the smallest part of the energy while the kinetic is the largest and the strain is in betweenthe other two except during the collision, when the strain energy is slightly larger than the kinetic.

implementation is able to correctly solve the sine-Gordon to fourth order accuracy with different solitonconfigurations as initial conditions, such as kink-kink and breather-breather interactions.

To be able to compare the fourth order finite difference time-stepping method with the common fourthorder accurate Runge-Kutta time-stepping method, the Runge-Kutta method was also implemented. Bothtime-stepping methods were used to solve the same problem (including initial conditions). The energy of bothsolutions was also measured, from which one can see that there doesn’t appear to be any notable differencebetween the two time-stepping methods, with both of them being energy preserving. Considering thatthe Runge-Kutta method is not generally energy preserving, this was somewhat surprising. One possibleexplanation for this is that the sine-Gordon equation, unlike, for example, the wave equation, requires aspecific shape from its solutions, e.g. a kink with a certain velocity can only be of a certain width to be asolution of the equation. This would mean that any convergent numerical approximation must retain theshape of the solution, forcing it to maintain the energy as well. If this is correct, one would expect themodified finite difference time-stepping method to preserve the energy, regardless of whether it is energypreserving in general.

The two different time-stepping methods were also compared in terms of execution time in section 6.3,showing that implementation of the modified finite difference time-stepping method executed approximately10 times faster than the implementation of the Runge-Kutta method. Even though the implementationswere not particularly optimized, the execution times still clearly show an advantage for the modified finitedifference time-stepping method and so the modified finite difference time-stepping method is probably the

22

Page 23: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

Figure 7: Moving breather solution to a 2 dimensional extension of the sine-Gordon equation at t = 0.1s.

23

Page 24: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

Figure 8: Moving breather solution to a 2 dimensional extension of the sine-Gordon equation at t = 10s.

24

Page 25: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

Figure 9: Moving breather solution to a 2 dimensional extension of the sine-Gordon equation at t = 20s.

25

Page 26: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

best choice if one is looking to minimize execution time.

8 ConclusionThis project was largely successful in numerically solving the sine-Gordon equation with fourth order accuracyusing the SBP-SAT method and a modified finite difference time-stepping method as well as a Runge-Kuttatime-stepping method. Both methods solved different kinds of initial conditions correctly and preserved theenergy of the solutions, but the modified finite difference time-stepping method executed significantly faster.Therefore, if the execution time is important it may preferable to choose the modified finite difference time-stepping method, but otherwise it may be easier to implement the Runge-Kutta time-stepping method as itdoes not need to specialized for the sine-Gordon equation.

26

Page 27: Fourth order accurate numerical solution of the sine-Gordon …uu.diva-portal.org/smash/get/diva2:632361/FULLTEXT01.pdf · 2013. 6. 24. · TVE 13 040 juni Examensarbete 15 hp Juni

References[1] S. C. Chapra. Applied Numerical Methods with MATLAB for Engineers and Scientists. McGraw-Hill,

New York, 2 edition, 2008.

[2] R. K. Dodd. Solitons and nonlinear wave equations. Academic Press, London, 1982.

[3] K. Mattsson and J. Nordström. Finite difference approximations of second derivatives on summation byparts form. Technical Report 2003-012, Department of Information Technology, Uppsala University, Feb.2003. Updated 2003-03-21.

[4] J. Ramos. The sine-gordon equation in the finite line. Applied Mathematics and Computation, 124(1):45– 93, 2001.

[5] P. Rigge. Numerical Solutions to the Sine-Gordon Equation. ArXiv e-prints, Dec. 2012.

[6] A. Sánchez, R. Scharf, A. R. Bishop, and L. Vázquez. Sine-gordon breathers on spatially periodic poten-tials. Phys. Rev. A, 45:6031–6037, Apr 1992.

[7] E. W. Weisstein. "sine-gordon equation.". http://mathworld.wolfram.com/Sine-GordonEquation.html, 05 2013.

27