# A damped string A pulse on a damped string at five times: it runs to the wall, comes back upside down, and fades all the way. ```python import sympy as sp import pdemagic as pm x, t = sp.symbols("x t", real=True) u = sp.Function("u")(x, t) pulse = sp.exp(-400 * (x - 0.3) ** 2) string = pm.Problem( sp.Eq(u.diff(t, 2) + u.diff(t), u.diff(x, 2)), domain=pm.Box({x: (0, 1)}), time=(t, 0, 1.25), initial={u: pulse, u.diff(t): -pulse.diff(x)}, boundary=sp.Eq(u, 0), ) pm.solve(string).plot(time=[0, 0.25, 0.5, 1.0, 1.25]) ``` ## What it shows The wave equation with a first derivative in time, $u_{tt} + u_t = u_{xx}$, on a string that is held at both ends. The first derivative damps the waves. The initial rate of change, $-\partial_x$ of the pulse, sends the whole pulse to the right. It moves with the speed 1 and loses height nearly as $e^{-t/2}$: 0.79 of it is left at $t = 0.5$. At $t = 0.7$ it meets the wall, which throws it back with the opposite sign. Without the damping the pulse would keep its height for good. ## What pdemagic decided The planner chose exact propagation in the modes of the box (`mode_propagator`): the damping is part of how each mode evolves, and each of the 21 recorded times is exact in time. The narrow pulse needs 192 Chebyshev points. ## More - [Problems in time](../topics/time.md) - [Boxes with walls](../topics/boxes.md) - [Boxes with boundary conditions](../methods/collocation.md) - [What is solved on boxes with walls](../ref/equations-boxes.md)