<h1>Results</h1>
The explicit Euler time stepping scheme  ($\theta=0$) performs adequately for the problems we wish to solve. Unfortunately, a rather small time step has to be chosen due to stability issues --- $k\sim h/10$ appears to work for most the simulations we performed. On the other hand, the Crank-Nicolson scheme ($\theta=\frac{1}{2}$) is unconditionally stable, and (at least for the case of the 1D breather) we can pick the time step to be as large as $25h$ without any ill effects on the solution. The implicit Euler scheme ($\theta=1$) is "exponentially damped," so it is not a good choice for solving the sine-Gordon equation, which is conservative. However, some of the damped schemes in the continuum that is offered by the $\theta$-method were useful for eliminating spurious oscillations due to boundary effects.

In the simulations below, we solve the sine-Gordon equation on the interval $\Omega =
[-10,10]$ in 1D and on the square $\Omega = [-10,10]\times [-10,10]$ in 2D. In
each case, the respective grid is refined uniformly 6 times, i.e. $h\sim
2^{-6}$.

<h3>An (1+1)-d Solution</h3>
The first example we discuss is the so-called 1D (stationary) breather
solution of the sine-Gordon equation. The breather has the following
closed-form expression, as mentioned in the Introduction:
\f[
u_{\mathrm{breather}}(x,t) = -4\arctan \left(\frac{m}{\sqrt{1-m^2}} \frac{\sin\left(\sqrt{1-m^2}t +c_2\right)}{\cosh(mx+c_1)} \right),
\f]
where $c_1$, $c_2$ and $m<1$ are constants. In the simulation below, we have chosen $c_1=0$, $c_2=0$, $m=0.5$. Moreover, it is know that the period of oscillation of the breather is $2\pi\sqrt{1-m^2}$, hence we have chosen $t_0=-5.4414$ and $t_f=2.7207$ so that we can observe three oscillations of the solution. Then, taking $u_0(x) = u_{\mathrm{breather}}(x,t_0)$, $\theta=0$ and $k=h/10$, the program computed the following solution.

<img src="https://www.dealii.org/images/steps/developer/step-25.1d-breather.gif" alt="Animation of the 1D stationary breather.">

Though not shown how to do this in the program, another way to visualize the
(1+1)-d solution is to use output generated by the DataOutStack class; it
allows to "stack" the solutions of individual time steps, so that we get
2D space-time graphs from 1D time-dependent
solutions. This produces the space-time plot below instead of the animation
above.

<img src="https://www.dealii.org/images/steps/developer/step-25.1d-breather_stp.png" alt="A space-time plot of the 1D stationary breather.">

Furthermore, since the breather is an analytical solution of the sine-Gordon
equation, we can use it to validate our code, although we have to assume that
the error introduced by our choice of Neumann boundary conditions is small
compared to the numerical error. Under this assumption, one could use the
VectorTools::integrate_difference function to compute the difference between
the numerical solution and the function described by the
<code>ExactSolution</code> class of this program. For the
simulation shown in the two images above, the $L^2$ norm of the error in the
finite element solution at each time step remained on the order of
$10^{-2}$. Hence, we can conclude that the numerical method has been
implemented correctly in the program.


<h3>A few (2+1)D Solutions</h3>

The only analytical solution to the sine-Gordon equation in (2+1)D that can be found in the literature is the so-called kink solitary wave. It has the following closed-form expression:
  @f[
    u(x,y,t) = 4 \arctan \left[a_0 e^{s\xi}\right]
  @f]
with
  @f[
    \xi = x \cos\vartheta + \sin(\vartheta) (y\cosh\lambda + t\sinh \lambda)
  @f]
where $a_0$, $\vartheta$ and $\lambda$ are constants. In the simulation below
we have chosen $a_0=\lambda=1$. Notice that if $\vartheta=\pi$ the kink is
stationary, hence it would make a good solution against which we can
validate the program in 2D because no reflections off the boundary of the
domain occur.

The simulation shown below was performed with $u_0(x) = u_{\mathrm{kink}}(x,t_0)$, $\theta=\frac{1}{2}$, $k=20h$, $t_0=1$ and $t_f=500$. The $L^2$ norm of the error of the finite element solution at each time step remained on the order of $10^{-2}$, showing that the program is working correctly in 2D, as well as 1D. Unfortunately, the solution is not very interesting, nonetheless we have included a snapshot of it below for completeness.

<img src="https://www.dealii.org/images/steps/developer/step-25.2d-kink.png" alt="Stationary 2D kink.">

Now that we have validated the code in 1D and 2D, we move to a problem where the analytical solution is unknown.

To this end, we rotate the kink solution discussed above about the $z$
axis: we let  $\vartheta=\frac{\pi}{4}$. The latter results in a
solitary wave that is not aligned with the grid, so reflections occur
at the boundaries of the domain immediately. For the simulation shown
below, we have taken $u_0(x)=u_{\mathrm{kink}}(x,t_0)$,
$\theta=\frac{2}{3}$, $k=20h$, $t_0=0$ and $t_f=20$. Moreover, we had
to pick $\theta=\frac{2}{3}$ because for any $\theta\le\frac{1}{2}$
oscillations arose at the boundary, which are likely due to the scheme
and not the equation, thus picking a value of $\theta$ a good bit into
the "exponentially damped" spectrum of the time stepping schemes
assures these oscillations are not created.

<img src="https://www.dealii.org/images/steps/developer/step-25.2d-angled_kink.gif" alt="Animation of a moving 2D kink, at 45 degrees to the axes of the grid, showing boundary effects.">

Another interesting solution to the sine-Gordon equation (which cannot be
obtained analytically) can be produced by using two 1D breathers to construct
the following separable 2D initial condition:
\f[
  u_0(x) =
  u_{\mathrm{pseudobreather}}(x,t_0) =
  16\arctan \left(
    \frac{m}{\sqrt{1-m^2}}
    \frac{\sin\left(\sqrt{1-m^2}t_0\right)}{\cosh(mx_1)} \right)
  \arctan \left(
    \frac{m}{\sqrt{1-m^2}}
    \frac{\sin\left(\sqrt{1-m^2}t_0\right)}{\cosh(mx_2)} \right),
\f]
where $x=(x_1,x_2)\in{R}^2$, $m=0.5<1$ as in the 1D case we discussed
above. For the simulation shown below, we have chosen $\theta=\frac{1}{2}$,
$k=10h$, $t_0=-5.4414$ and $t_f=2.7207$. The solution is pretty interesting
--- it acts like a breather (as far as the pictures are concerned); however,
it appears to break up and reassemble, rather than just oscillate.

<img src="https://www.dealii.org/images/steps/developer/step-25.2d-pseudobreather.gif" alt="Animation of a 2D pseudobreather.">


<a name="extensions"></a>
<h3>Possibilities for extensions</h3>

It is instructive to change the initial conditions. Most choices will not lead
to solutions that stay localized (in the soliton community, such
solutions are called "stationary", though the solution does change
with time), but lead to solutions where the wave-like
character of the equation dominates and a wave travels away from the location
of a localized initial condition. For example, it is worth playing around with
the <code>InitialValues</code> class, by replacing the call to the
<code>ExactSolution</code> class by something like this function:
@f[
  u_0(x,y) = \cos\left(\frac x2\right)\cos\left(\frac y2\right)
@f]
if $|x|,|y|\le \frac\pi 2$, and $u_0(x,y)=0$ outside this region.

A second area would be to investigate whether the scheme is
energy-preserving. For the pure wave equation, discussed in @ref
step_23 "step-23", this is the case if we choose the time stepping
parameter such that we get the Crank-Nicolson scheme. One could do a
similar thing here, noting that the energy in the sine-Gordon solution
is defined as
@f[
  E(t) = \frac 12 \int_\Omega \left(\frac{\partial u}{\partial
  t}\right)^2
  + \left(\nabla u\right)^2 + 2 (1-\cos u) \; dx.
@f]
(We use $1-\cos u$ instead of $-\cos u$ in the formula to ensure that all
contributions to the energy are positive, and so that decaying solutions have
finite energy on unbounded domains.)

Beyond this, there are two obvious areas:

- Clearly, adaptivity (i.e. time-adaptive grids) would be of interest
  to problems like these. Their complexity leads us to leave this out
  of this program again, though the general comments in the
  introduction of @ref step_23 "step-23" remain true.

- Faster schemes to solve this problem. While computers today are
  plenty fast enough to solve 2d and, frequently, even 3d stationary
  problems within not too much time, time dependent problems present
  an entirely different class of problems. We address this topic in
  step-48 where we show how to solve this problem in parallel and
  without assembling or inverting any matrix at all.
