NOAA-ORR-ERD / gridded

A single API for accessing / working with gridded model results on multiple grid types
https://noaa-orr-erd.github.io/gridded/index.html
The Unlicense
65 stars 14 forks source link

Correct the Sine Channel analytical solution #88

Open ChrisBarker-NOAA opened 2 months ago

ChrisBarker-NOAA commented 2 months ago

In gen_analytical_datasets, there is:

def gen_sinusoid(filename=None)

however, it has:

vx = np.ones_like(x)
vy = np.cos(x / 2) / 2

which makes the y -direction velocity constant -- which is almost a sinusoidal flow, but not quite parallell to the chennel.

It should have a constant magnitude, the the y component should also change sinusoidally (out of phase).

Somethign like this:

# Create the velocity flow
V = 3
xv = np.linspace(0, 1, 10)
yv = A * np.sin(xv * 2 * np.pi / L)

#constant velocity in the x direction == not quite right

v =  V * A * (2 * np.pi / L) * np.cos(xv * 2 * np.pi / L)
# v = vA / 10 * np.ones_like(xv)
# vx = vA * np.ones_like(xv)
# vx = 3 + 0.01* vA * np.sin(xv * 2 * np.pi / L)
u = np.sqrt(V**2 - v**2)

theta = np.arctan(A * (2 * np.pi / L) * np.cos(xv * 2 * np.pi / L))
u = V * np.cos(theta)
v = V * np.sin(theta)
jay-hennen commented 2 months ago

Are you sure this is still correct when we take the sinusoidal shape of the grid into account plus the 'angle' variable? Actually when I look at this again it appears the mistake is actually that vy should be zero. That's how it would appear in a 'normal' sgrid file right?

If you want to put this math in feel free. At the moment the sinusoid file is only used in loading tests; the data within is actually never used. Of course it should still be a 'correct' file!

ChrisBarker-NOAA commented 2 months ago

well, it depends on the goal, but if we want a uniform flow parallel to the sides, it's needs adjustment -- this came up when someone was testing a new interpolation method.

i put in the issue so I wouldn't forget ....