Numerically Approximating the Wave Equation?
ObsessiveMathsFreak writes "I'm an applied mathematician who has recently needed to obtain good numerical approximations to the classic second-order wave equation, preferably in three space dimensions. A lot of googling has not revealed much on what I had assumed would be a well-studied problem. Most of the standard numerical methods, finite difference/finite element methods, don't seem to work very well in the case of variable wave speed at different points in the domain, which is exactly the case that I need. Are any in this community working on numerically solving wave equation problems? What numerical methods do you use, and which programs do you find best suited to the task? How do you deal with stability issues, boundary/initial values, and other pitfalls? Are there different methods for electromagnetic wave problems? Finally, when the numbers have all been crunched, how do you visualize your hard-earned data?"
FYI, googling: Wave Equation "three dimensions" approximation .brings up a lot of hits..
Not exactly my field, but if the issues with FE/FD are ones of stability and/or convergence, have you looked into using multigrid methods? It requires more memory, but a good preconditioned, multigrid method should help reduce problems of variable speeds, no?
and not make fun of this person for asking a question that has nothing to do with our hobby horses. I hope this question has a small number of posts. Only well-meaning and helpful ones.
Are you doing the time harmonic case (3-D Helmholtz) or an unsteady case?
What does the domain look like (regular/rectangular and you may be able to use spectral methods)? In irregular domains, multigrid methods seem to converge most quickly for elliptic equations, but again, that depends on their exact form.
You don't say what goes wrong with finite difference codes... For pure Adams-Bashforth schemes often give extremely good numerical stability. You talk about variable wave speeds, but the Mathworld equation you link to doesn't cover that. In many cases you can use multiple-scales/WKB approaches, but that depends on how the wave speed varies (relative to the wavelength).
Finally: there are many things for which Googling sucks. This is one. For an proper overview, try a proper textbook, like "Waves in Layered Media", mentioned above, or "Modern Methods in Analytical Acoustics" (Crighton, Dowling et al).
Athletic Scholarships to universities make as much sense as academic scholarships to sports teams.
Hi, I'm currently doing a Masters Thesis on Diffusion PDE's (Parabolic and Elliptic) correct me If i'm wrong but the wave equation is a hyperbolic PDE. I use a MATLAB Toolbox called PDE Toolbox GUI and although I don't use it I know it includes a hyperbolic solver. I haven't investigated how detailed it is, but I suggest having a look through the manual, to see if it meets your requirements. Cheers
I'm a plasma physicist and I work in the domain of radiofrequency waves propagation and absorption in fusion plasmas. I've been busy developping a code that solves the Maxwell's equations, which are equivalent to the wave equation (3-D full-wave calculation). The case of a plasma is tricky because it both time *and* space dispersive.
I won't be able to even start explaining this stuff in this post, but my code uses finite elements for the radial direction and Fourier decompositions for the two periodic directions of a fusion device. These numerical methods work well. I also know finite difference codes which work well. So, I think you should look a bit harder, because FE or FD methods usually do the trick, even for "variable wave speed at different points in the domain"... Regarding the boundary conditions, well, you'd better be very careful, because they will usually completely determine the solution. Again, it is my experience that Finite elements are well adapted to this task but you'll have to do some research.
Finally, for the vizualisation, matplotlib and vtk work for me.
First, try to determine and explain more precisely what it is you want to do: "to obtain good numerical approximations to the classic second-order wave equation, preferably in three space dimensions" sounds a but vague. Pick up the right textbooks, scientific journals, learn, exchange with the community. I know my post sounds a bit patronizing but this is science, and this kind of effort takes dedication, time and patience. I think Slashdot and Google are hardly the right places to start...
http://kim.oyhus.no/wave.html
It is a Java applet. Note the low dispersion. Try clicking on it!
In order to make this, I avoided the standard textbook methods.
They can give good waves, but at a high cost in computation and memory.
It is not standard finite differencing, since those methods introduce dispersion
and similar errors to an unnecessary degree. But it IS a finite differencing method,
and I have done variants of it with variable speed and in 3 dimensions.
Here is one with variable speed:
http://kim.oyhus.no/seismic.mpg
One of the tricks I use is to use a hexagonal grid.
Kim Øyhus, M.Sc. Physics
It's not entirely clear what you are trying to do, but one of the sweetest ways to 'visualize' wave data is to output it directly to /dev/audio and LISTEN to it as a sound waveform (actually /dev/dsp would work better for this, because it expects uncompressed data). All you have to do is open /dev/dsp, convert your data to a series of 8 bit integers, scaled to where 255 is the maximum and 0 is the minimum, do a write() on your data to /dev/dsp and viola! You have music! If you want to change things like the bitrate, look at the open sound system page.
Qxe4
XMDS
http://www.xmds.org/
...don't seem to work very well in the case of variable wave speed at different points in the domain, which is exactly the case that I need. Look closer. Wave speed is a parameter in the DE, and all solution methods of linear DEs are local. If you treat the parameter as variable, it will be obvious what you need to do in both FEM and FDM.What numerical methods do you use, and which programs do you find best suited to the task? Well, always fit the method to the problem. As usual, FEM if you've got an odd boundary conditions, FDM otherwise. And don't forget other methods like integral transforms and greens functions, which can simplify or complicate your problem to varying degrees. Mathematica and Maple are good for a lot of things, having features for symbolic manipulation. Of course, D/C/LISP/Python/your-favourite-language-here work well enough for the actual crunching.
How do you deal with stability issues, boundary/initial values, and other pitfalls? Stability issues: The best thing you can do is prove stability. See if you can fit backwards and forwards together a-la Crank-Nicholson, and check that for stability. Or, use something nicer like Runge-Kutta in the time domain.
Boundary/Initial Values: You do what you have to, I guess. That's a lot more problem specific. If you haven't got the standard initial-time/bounded space situation, you can approximate an unbounded region. It's a lot simpler than you would think, but you need to solve it for your specific problem. Bounded-time is different, but you can then do FDM in the time domain.
Other pitfalls: Stiffness can point to a flaw in your reasoning. Scaling is worth a try. Otherwise, there are always methods to deal with your specific problem. Talk to your friendly neighborhood mathematician.
Are there different methods for electromagnetic wave problems? I think they are usually easier with analytic methods. IANA electrodynamicist, but try a few things out.
Finally, when the numbers have all been crunched, how do you visualize your hard-earned data? Matplotlib is good if you work in Python. If your employer uses Matlab/Maple/Mathematica, use those. I find Matlab awkward, and Matplotlib is similar and has most of the same features.
We at slashdot are scientists, specialists and kernel hackers. Your FUD will be found out.
Just download OpenFOAM suite, then spend a few weeks studying how to use it, and you will learn how to make this code solve numerically almost any system of PDE-s that you throw on it. It's finite volume method.
Hey, we were doing this in an engineering class yesterday afternoon!
,where C = c (wave speed) * dt / dx so dx = c.dt (by memory) for the most stable condition with an exact solution at C=1. (you can have a slightly less accurate solution for 0C1). Of course, if c changes, your mesh size has to change, but I would have thought if you know the extrema of the wave speed c, you can just make sure your mesh is fine enough not to go unstable at sudden changes of c, but it will cost you in time to compute a solution, plus the whole 3d thing, which gives 4 degrees of freedom (x,y,z,t) instead of 2 (x,t). Still, most computer packages can solve this, heck, we do far more complex computational fluid dynamics turbulence modelling etc on current ~2Ghz machines. If all else fails, put a few boxes together, make a beowulf cluster, and Slashdot will certainly have you back!
For a 3d problem, you should be able to just apply something like a Forward-Time-Backwards-Space scheme (which is inherently convergent and stable for a wave equation) but put it in a tensor form x_j = [ x y z ].
The size of the time and space-step for stability is goverened by the Courant Condition C = 1
For plotting a solution, Gnuplot could do it if you have the inclination. You'd want a 3d (perhaps animated in time) plot, or some contour slices (x,y) through z or through t. 3d vector ('cone') plots might be a good way of showing velocity of the wave in 3d space too. For commercial packages, try MATLAB, or Tecplot (I don't work for these people, but they are commonly used at universities so plenty of people can help you out!)
Cheers
From Dan
you forgot: "I for one welcome our variable wave speed overlords".
I'm currently getting my PhD in that area, and I'd recommend looking into Discontinuous Galerkin methods. Those are higher-order finite-element methods, and they work very well for hyperbolic problems. I can whole-heartedly recommend a book by my advisor: Nodal DG Methods (it comes out next month).
DG Methods take a little time to implement, but their accuracy and speed is well worth the effort. If you'd like some precooked software, check out http://git.tiker.net/?p=hedge.git;a=summary. (but be aware that there's little to no documentation just yet--don't be afraid to ask, though)
I'm not sure if this will meet your needs, but when I did my high energy physics Ph.D. dissertation work at the D0 experiment at Fermilab we mainly used PAW http://paw.web.cern.ch/paw/ for our analysis/visualization IIRC. It is, I think, freely downloadable for multiple platforms and worked quite nicely for me back in 1988-1996. I've been out of the HEP field since so I haven't followed its development, but since it's still available, my guess is it's even more powerful now, although as I said, I'm not sure if it will meet your needs. Hope this helps and good luck.