Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,094 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,612 people online right now. Registration is fast and FREE... Join Now!




Modeling a 2D wave equation

 
Reply to this topicStart new topic

Modeling a 2D wave equation

ChopSuey
29 Nov, 2007 - 05:47 PM
Post #1

New D.I.C Head
*

Joined: 29 Nov, 2007
Posts: 3


My Contributions
The purpose of this program is to write a FORTRAN program which can be used to numerically solve the wave equation on a 2-Dimensional Cartesian grid with various boundaries and initial conditions.

Well so far in the main program I have the code which requests the user to input the name of the file which they would like the initial values read from. If this file is not in the correct directory or doesn't exist it reads from a file with default values.

The only part that I really need help on is the subroutine that does the mathematical calculations of the program. I don't fully understand the wave equation, and obviously this is giving me trouble in coding a FORTRAN program that calculates values for it.

Below are the requirements for the wave equation. Any help or just a point in the right direction would be greatly appreciated smile.gif



User is offlineProfile CardPM
+Quote Post

ChopSuey
RE: Modeling A 2D Wave Equation
29 Nov, 2007 - 05:52 PM
Post #2

New D.I.C Head
*

Joined: 29 Nov, 2007
Posts: 3


My Contributions
I'm having trouble adding an attachment to a post. Hopefully inserting it as an image will work.

IPB Image

This post has been edited by ChopSuey: 29 Nov, 2007 - 05:56 PM
User is offlineProfile CardPM
+Quote Post

New DIC Head Too!
RE: Modeling A 2D Wave Equation
29 Nov, 2007 - 07:25 PM
Post #3

New D.I.C Head
*

Joined: 29 Nov, 2007
Posts: 1


My Contributions
You in Dr. Sills class too?

User is offlineProfile CardPM
+Quote Post

ChopSuey
RE: Modeling A 2D Wave Equation
2 Dec, 2007 - 09:03 PM
Post #4

New D.I.C Head
*

Joined: 29 Nov, 2007
Posts: 3


My Contributions
Nevermind I finally figured it out.
User is offlineProfile CardPM
+Quote Post

Southland
RE: Modeling A 2D Wave Equation
21 Jan, 2008 - 07:05 PM
Post #5

New D.I.C Head
*

Joined: 21 Jan, 2008
Posts: 1

QUOTE(ChopSuey @ 2 Dec, 2007 - 10:03 PM) *

Nevermind I finally figured it out.



Im doing something similar to this and do not really understand how the wave equation works

How would i program fortran code to do the mathematical part of this?
User is offlineProfile CardPM
+Quote Post

GravityGuy
RE: Modeling A 2D Wave Equation
9 Feb, 2008 - 10:19 PM
Post #6

New D.I.C Head
*

Joined: 21 Jan, 2008
Posts: 45


My Contributions
QUOTE(Southland @ 21 Jan, 2008 - 08:05 PM) *

QUOTE(ChopSuey @ 2 Dec, 2007 - 10:03 PM) *

Nevermind I finally figured it out.



Im doing something similar to this and do not really understand how the wave equation works

How would i program fortran code to do the mathematical part of this?


That's only the whole thing...

This is why engineers write the algorithm and programmer take the algorithm and write the code.

You sucked me in though. I can't ignore an interesting math question...and fortran no less.

Chop Suey's math equation defines a 2nd order differential equation and the finite difference
equation that can approximate it when you use a very small time step, kind of like building
an animation video with clay figures that you move in very small increments.

i and j are the indexes to a 2-d array of real*8, u is the value stored at each i,j cell.
You need initial conditions for each cell to start. Zero probably for most of them but the wave
has to have non-zero starting conditions, say in the center or in one corner or along one edge.

These are all the u values at t=0.
The term for lamda squared is based on the real equation value for a, the time step increment
and the real distance x between cells (or the cell width). The will remain a constant.

Two nested loops, one for i and one for j. In the inner loop make the calculation for U(i,j) for t=1
by using all the initial values that you've filled the array with earlier. Be careful not to overwrite
the array values in one step because each value of u(i,j) at t=1, is dependent on it's neighbours
at t=0. The part in () includes values from the two adjoining cells in the same row and the two
in the same column, so you have to either use two arrays of equal size and swap back and forth
or come up with another way not to overwrite the old values that are still needed for the next row.

After the total number of iterations through the time span, you have the wave amplitudes in all the
array cells, which can be gridded and contoured to produce a contour image of the result.

By the way, if you look at the finite difference equation a bit closer, you'll see that the first two
terms combine to give the change in the cell from the last two time steps + a factored sum of the
same difference to its neighbours within the same time step. Looking at it as a growth rate,
its combining the growth rate of itself over the last time period, plus a percentage of the growth
rates of its neighbours.

And what is the 2nd order differential equation saying: that the growth rate of u over time is
proportional to the growth rates of u in the x and y directions. That would be the growth difference
of neighbouring values, not with time, but spacially within the same time.

See how closely the descriptions match.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 08:28PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month