Interesting Examples of Computational Physics
  • Welcome to the blog of Computational Physics at the IFM!
  • Dynamical Systems
    • The simple pendulum
    • The spherical pendulum
  • The wave equation
    • The simple discretization
    • Boundary conditions
    • Interfaces between mediums
    • Knots on ropes
    • 2D wave equation
  • Time dependent Schrödinger equation
    • The Crank-Nicolson method
    • Free wave packet
    • Quantum Tunneling
    • Harmonic Oscillator
    • Forced Harmonic Oscillator
    • 2D Harmonic Oscillator
    • Wave-particle duality
Powered by GitBook
On this page
  1. The wave equation

Boundary conditions

PreviousThe simple discretizationNextInterfaces between mediums

Last updated 9 months ago

Boundary conditions are part of the initial value problem. Depending on the physical phenomena that one is trying to simulate, the boundary conditions maybe of some sort or another. The esiest boundary conditions that one can implement are the fixed boundaries or Dirichlet conditions. In this case, the value of the function f is specified at the borders of the domain at all times. This means that:

f(x0,t)=s(t),f(xN,t)=w(t)\begin{align}f(x_0,t) &= s(t), \nonumber\\ f(x_N,t) &= w(t) \nonumber \end{align}f(x0​,t)f(xN​,t)​=s(t),=w(t)​

One can use this to simulate a lot of things. Take a look at the animation below:

The animation represents the physical situation of a pulse traveling in a string that gets reflected by a wall. After the pulse gets reflected, the wave function becomes negative. This was done by setting all the initial conditions to 0 and playing with the boundary conditions. On the right boundary, the function is always 0. But on the left boundary, the function is equal to a sin function that changes over time. After half a period, the boundary conditions changes to a new type: outgoing wave boundary condition. Lets take a look at another animation:

In this case, the right boundary has a Neumann boundary condition. In this case, the function is not specified at the boundary, instead the partial derivative with respect to x is specified. For the case of the massless ring, the space derivative must be 0 at all times. If that was not the case, an infinite vertical acceleration would arise. To implement this condition, we can use an approximation of the derivative of second order and set it to 0:

fNi=4fN−1i−fN−2i3f_{N}^i = \frac{4f_{N-1}^i-f_{N-2}^i}{3}fNi​=34fN−1i​−fN−2i​​

The last type of boundary condition is the outgoing wave condition. In this case, we don't want to let any waves come in, we only want to let waves go out. To achieve this on the right boundary, we have to solve the advection equation on the point N:

∂f∂x+∂f∂t=0\frac{\partial f}{\partial x}+\frac{\partial f}{\partial t} = 0∂x∂f​+∂t∂f​=0

which can be done by substituting the discrete versions of the partial derivatives:

fNi=vc(4fN−1i−fN−2i)+4fNi−1−fNi−23(1+vc)c=ΔtΔx\begin{align} f_{N}^i &= \frac{ vc(4f_{N-1}^i-f_{N-2}^i) + 4f_{N}^{i-1} - f_{N}^{i-2} }{ 3(1 + vc)} \nonumber\\ c &= \frac{\Delta t}{\Delta x} \end{align}fNi​c​=3(1+vc)vc(4fN−1i​−fN−2i​)+4fNi−1​−fNi−2​​=ΔxΔt​​​

With the boundary conditions seen, a lot of different experimental arrays can be simulated.

Pulso traveling on a string gets reflected by a wall to which the string is attached
The rope is now attached to a massless ring which is free to move along a vertical rod.
Segment of a string through which a pulse travels