# A kink at a free end A kink of the sine-Gordon equation runs against the free end of its line and comes back turned over. ```python import sympy as sp import pdemagic as pm x, t = sp.symbols("x t", real=True) u = sp.Function("u")(x, t) kink = 4 * sp.atan(sp.exp((x - 3 * t / 5) / sp.Rational(4, 5))) line = pm.Problem( sp.Eq(u.diff(t, 2), u.diff(x, 2) - sp.sin(u)), domain=pm.Box({x: (-12, 12)}), time=(t, 0, 40), initial={u: kink.subs(t, 0), u.diff(t): kink.diff(t).subs(t, 0)}, boundary=sp.Eq(u.diff(x), 0), ) pm.solve(line).plot() ``` ## What it shows The sine-Gordon equation, $u_{tt} = u_{xx} - \sin u$, between two free ends: the slope is zero there. A kink is a step from $0$ to $2\pi$ that moves, here with the speed $\tfrac35$, and keeps its shape. At the free end it does not stop. The end swings from $2\pi$ down to $-2\pi$, and what comes back is a step the other way, an antikink. A free end acts like a mirror: the kink meets its mirror image, the two pass through each other, and the image is what is seen afterwards. ## What pdemagic decided The equation is of second order in time and has a nonlinear term, so the planner chose exponential time stepping in the modes of the box (`exponential_runge_kutta`). The wave equation is exact, for the unknown and its rate of change together, and $\sin u$ is stepped, in about 740 steps that are chosen during the solve. The grid has 256 Chebyshev points, the finest that the planner tries by itself, and its plan says that the kink is resolved to $4\cdot10^{-8}$ on it and not to the $10^{-10}$ it aims for. The diagnostic `solution_tail` is $3\cdot10^{-10}$ at the end. ## More - [Nonlinear equations in time](../topics/nonlinear-time.md) - [Boxes with boundary conditions](../topics/boxes.md) - [Nonlinear equations in time, the method](../methods/exponential.md) - [What is solved on boxes with walls](../ref/equations-boxes.md)