Sound waves

This program is suitable for exploring and demonstrating a variety of wave phenomena. The program calculates the propagation of waves in a two-dimensional area fast enough to be able to follow them directly on the screen. Arrangements of reflecting surfaces, apertures and resonators can be drawn as desired using the mouse. The sound emission can also be arranged anywhere in the image. In addition, absorbing areas can be added to suppress unwanted reflections. Drawn arrangements can be saved and reloaded, e.g. to prepare the best examples for a demonstration. In addition to the two-dimensional color display, pressure and velocity can also be displayed as a function along one-dimensional sections.


Operation

To draw arrangements, the first step is to select the type of pixels to be drawn. These can be 1. "Air" (black), 2. "Reflecting edge" (light gray), 3. "Sound source" (red) or 4. "Attenuation area" (dark gray). By pressing the left mouse button and simultaneously moving the mouse, the pixels are set to the preselected property. The image border is always reflective. If you have drawn a closed border around an area, you can fill it in by moving the cursor inside the area and pressing the right mouse button. The dimension of the arrangement (physical length scale) results from the size of a pixel (=small square), which is entered in cm under "pixel =". Once the arrangement has been drawn and the frequency entered, the calculation can be started with "Start". The sound waves begin to propagate at the sound sources (red), with overpressure shown in green and underpressure in blue. The time t is displayed in milliseconds. The brightness of the image display can be adjusted using the slider at the bottom. If the "Draw wave everywhere" box is checked, the wave is also drawn in the source and attenuation areas. The strength of the attenuation in the attenuation areas (dark gray), if present, can be set with "Strength of attenuation". The calculation is stopped with "Stop". It can then be restarted, but cannot be continued. The entire arrangement is deleted with "Clear". Even if the number of points nx or ny is changed, the entire arrangement is deleted. Zoom can be used to change the image size of the display, which is also possible during a calculation. With "Display speed" you can set how often the image is drawn. This means that the waves can also be followed in slow motion. The "Display speed" has no influence on the accuracy of the calculation. If you move the cursor over the image, the current pressure and the coordinates at the cursor location are always displayed.

The arrangement data can be saved (Save data) or loaded again (Open data) under the "File" menu item. When saving and loading the data, the set parameters (numbers and sliders) are also taken into account so that arrangements can be saved together with the optimum settings. The currently displayed image can be saved as a graphic file (bmp or jpg) in the currently displayed resolution.

Under the "Window" menu item, the display of pressure (black) and speed (red) can be shown as a function along a horizontal and/or vertical section through the image. For the horizontal section, the velocity component ux(x = horizontal) is displayed. For the vertical section, the velocity component uy(y = vertical). If one or both windows are open, the section lines are marked in white in the original image. The position of the section lines can be adjusted with the cursor by holding down the SHIFT key and pressing the left mouse button at the desired location. A menu for saving, printing and setting the character set and line thickness is available in the windows with the functions.


Numerical realization

For the pressure, the wave equation is solved using a second-order finite difference method. At the reflecting edges, the velocity perpendicular to the wall is set to zero. In source regions, the pressure is periodically increased/decreased. In attenuation regions, the amplitude of the pressure is reduced slightly at each time step. The velocities are calculated by integrating grad p over time.