# Wave simulation without reflection on the boundaries [duplicate]

This question already has an answer here:

I would like to numerically simulate a wave (let's say in a string) with different boundary conditions:

1. Fixed endpoints
2. Periodic
3. Boundless

$$\varphi(x, t)$$ is the value of the wave (vertical position of the string) at pixel $$x$$ captured by a 1-D array phi. For fixed endpoints, I simply pad my array with a zero on the left and one on the right (for numerical differentiation purposes). For the periodic boundary, I pad the left side with the last element (phi[-1] in Python syntax) and I pad the right side with the first element (phi[+1]).

How do I handle the boundless case so a pulse would just travel without reflection similar to the figure below? What is the common term for this type of boundary? (I do not want to sufficiently increase the number of pixels to solve this problem).

## marked as duplicate by tpg2114♦, Jon Custer, GiorgioP, stafusa, ZeroTheHeroMar 6 at 2:54

• What you ask for is called PML for perfectly matched layer, but I never succeeded to implementit it in my case because I have to accommodate evanescent waves and standard methods fail in such case. – Jhor Mar 5 at 11:30
• @lemon It's not the Neumann condition -- that will also generate a wave reflection. See the "soft boundary condition" on this page – tpg2114 Mar 5 at 11:40
• Side note @Miladiouss -- did you take this image from this website? Because the author explicitly states the images can't be used other places without permission. If so, please find another source that has a usable license. – tpg2114 Mar 5 at 11:45
• @tpg2114, I'll replace the image. – Miladiouss Mar 5 at 12:01
• Can't you just compute the movement of the last element as if it were connected to another one, without computing the movement of this next element ? I assume you are solving the wave equation in time domain ? – David Mar 5 at 12:52

You are looking for outflow boundary conditions. The constraint in this case is that the derivative is constant: $$\frac {\partial u}{\partial n}=0$$ where $$n$$ is the normal direction of the surface (e.g., $$x$$). This is also probably more commonly known as the Neumann boundary condition.

In numerical language, this would be akin to using phi[N]=phi[N-1].

• The Neumann condition is reflective for this case (and for compressible Navier-Stokes as well -- low-Mach preconditioning relaxes the reflectivity though). A wave will move back into the domain, not perfectly exit the domain as desired. – tpg2114 Mar 5 at 17:48
• You would know more than I on that; all the CFD I worked on was "simple" MHD & never needed to worry about BCs (bc I kept the domain large enough to never worry about it). – Kyle Kanos Mar 5 at 17:53
• The curse of working on internal flows... boundary conditions are a major PITA. – tpg2114 Mar 5 at 17:55
• This seems to reflect as well. Unless I'm doing something wrong. I just set phi[-1] = phi[-2] before updating for each step. – Miladiouss Mar 5 at 21:24
• @Miladiouss I imagine it depends on your stencil also. Could need to be phi[N]=2*phi[N-1]-phi[N-2], for example, if you have higher orders. – Kyle Kanos Mar 5 at 21:36

One picture is worth 1000 words. Consider a simple example. For the wave equation $$u_{tt}=u_{xx}$$, initial and boundary conditions are given:

$$u(0,x)=0,u_t(0,x)=0,u(t,0)=f(t),u_t(t,2)+u_x(t,2)=0$$

$$f(t)=0,t\le 0.01$$ or $$t\ge1.01$$, $$f(t)=\sin {t}, 0.01

To solve this problem we use Method Of Lines. The solution on a coarse grid is shown in the animation.

We give an explanation. We write the wave equation in the form

$$v=u_t+u_x, v_t-v_x=0$$

The general solution of the first equation for $$v=0$$ is $$u=f(x-t)$$ - wave moving to the right.The general solution of the second equation is $$v=g(x+t)$$ -wave moving to the left. So that the wave does not reflect from the right border, the condition should be set on the right border $$v=u_t+u_x=0$$.

How to implement this conditions in the numerical method? The answer depends on the method.

• I don't see how this answers the question. Also, please investigate the cases environment in LaTeX. – Kyle Kanos Mar 5 at 16:49
• @KyleKanos You do not see that this is a wave without reflection or do not understand the boundary conditions for a wave without reflection? – Alex Trounev Mar 5 at 17:10
• No, I don't see how your contrived example gives a general solution to the issue OP has. – Kyle Kanos Mar 5 at 17:26
• @KyleKanos This example exactly matches what Miladiouss asks. – Alex Trounev Mar 5 at 17:34
• I disagree. You show an animation that shows an outflow boundary, but don't mention how it's implemented (which is what OP is asking for). – Kyle Kanos Mar 5 at 17:36