Hi all,

I have written a program that numerically solves the Euler equations and it does this correctly. I am now trying to calculate the total energy at each time step using the following:

$\displaystyle E=\int_{0}^{L}{}\int_{0}^{L}\frac{1}{2}\rho (H(u^{2}+v^{2})+g\eta^{2})dxdy$

To calculate this I am using the following code:

Code:

for (int i = 1; i <= N-1; i++){
for (int j = 1; j <= N-1; j++){
double x = 0.5*rho*(H*(pow(u.getValue(i,j,N),2) + pow(v.getValue(i,j,N),2)) + g*pow(eta.getValue(i,j,N),2));//*Deltax*Deltay;
energy.setValue(i,j,N,x);
}
}

My question is this...

Do I need to include the dx and dy at the end of the calculation. I calculate the difference between the exact and the approximate after the energy reaches steady state and when I add the dxdy the value is huge 3.61x10^14. Since the lengthscale is 1,000,000 m and my grid is 10x10, dx and dy are 100,000 each. The analytic and numerical are supposed to converge as the number of grid sizes increases and they do but it is difficult to tell.

3.61x10^14, 2.7x10^14, 2.1x10^14...

when I don't include dxdy it is more like

908,767, 604,653, 477,999 ...

which seems more sensible

which of the following seem sensible for ocean gyre energy values?

7x10^15 J

or

230,000 J

really sorry for the long post