pm and pn for calculating derivatives

Report or discuss software problems and other woes

Moderators: arango, robertson

Post Reply
Message
Author
dputrasahan
Posts: 12
Joined: Mon May 15, 2006 1:18 pm
Location: Scripps Institution of Oceanography

pm and pn for calculating derivatives

#1 Unread post by dputrasahan »

Hi there,

I'm hoping to calculate derivatives with pm and pn. Given that dx=1/pm and dy=1/pn (metric distance between grid points), why is pm and pn still on rho-grid? So for instance, is
pm(i,j)=2/(x(i+1,j)-x(i-1,j))? How are the boundaries handled?

Thank you so much for all the help.

Cheers,
Dian

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: pm and pn for calculating derivatives

#2 Unread post by kate »

ROMS reads these values from the grid file, so the details would depend on what grid generation software you used and how it handled things. The software I use builds a grid at double the resolution from wall boundary to wall boundary and has to extrapolate for the values outside. I think seagrid also uses twice the resolution, while its domain goes from the outside rho point to outside rho point. You'd still have to do something funky for the outside pm/pn values.

Why are they on rho points? They provide the horizontal area of the grid box which has a rho point at the center - that is the natural place for them to be.

dputrasahan
Posts: 12
Joined: Mon May 15, 2006 1:18 pm
Location: Scripps Institution of Oceanography

Re: pm and pn for calculating derivatives

#3 Unread post by dputrasahan »

Thank you Kate.
So pm and pn that correspond to interior rho-points can be used as is, but extra precaution has to be taken at the boundaries?

I can now see how to create derivatives using pm and pn with u- and v-grids. Somehow, rho-grid is still rather fuzzy. Do you think it would be okay to interpolate variables with rho-grids onto u- and v-grids, then compute the derivatives with pm and pn? Or should I avoid this since it involves more interpolation than needed? I guess more fundamental to this is, is there an advantage to using (pm,pn) versus (x_rho, y_rho) in computing derivatives?

Thank you once again.

Cheers,
Dian

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: pm and pn for calculating derivatives

#4 Unread post by kate »

What exactly is your aim here? What sorts of conservation conditions do you need to satisfy? How consistent with ROMS internals do you have to be? I expect that anything sensible you do would be second-order accurate.

dputrasahan
Posts: 12
Joined: Mon May 15, 2006 1:18 pm
Location: Scripps Institution of Oceanography

Re: pm and pn for calculating derivatives

#5 Unread post by dputrasahan »

Nothing too complicated, I'm just trying to do post processing, such as computing SST gradients, divergence, curls, vorticity, etc. Previously, I've assumed constant metric resolution (20km) and just calculated derivatives using center finite difference method for the interior points and either forward/backward finite difference method for the boundaries.

Now that the metric resolution is not constant (varies from 17km to 23km), I was hoping to compute the derivatives more accurately with (1/pm and 1/pn) or (x_rho,y_rho). The goal is to create a general matlab function that would be able to take any horizontal field (rho, u or v grid), along with (pm and pn) or (x_rho,y_rho) and compute it's horizontal derivative. I've been trying to use (pm and pn) for this purpose and ended up evaluating either u- or v-grid field derivatives onto psi-grids. However, when it came to rho-grid fields, I got stumped. I believe using (dx=1/pm and dy=1/pn) rather than dx=dy=20km would be more accurate, but I'm rather confused as to how pm and pn actually works.

Thanks again for all your help.

Cheers,
Dian

User avatar
kate
Posts: 4091
Joined: Wed Jul 02, 2003 5:29 pm
Location: CFOS/UAF, USA

Re: pm and pn for calculating derivatives

#6 Unread post by kate »

If you look at the ROMS code, you will see that to get say dx at u points, you average pm first, then do the inverse of it. Look for instance at metrics.F.

Post Reply