# Re: [ferret_users] how to calculate the streamfunction and velocity potential

```Thank you very much Billy and Ryo for this.
Hanh

> Yes, thank you Ryo. I should have said that. The streamfunction
> exists only when the flow is nondivergent, typically when u and v are
> integrated from the ocean bottom to the surface.
>
> Another use is a vertical streamfunction, valid for a zonal, coast-to-
> coast integral. That is easier to calculate, because w is identically
> zero at the surface:
>
> let streamfn=v[x=@din,z=@iin]   ! where v is in a single, bounded basin
>
> And a velocity potential is valid only when the flow is irrotational
> (curl(v)=0), which is unlikely to be the case in the ocean. In the
> atmosphere, it can be used to describe the upper-level circulation
> which is predominantly zonal.
>
> Billy K
>
> On Aug 8, 2007, at 6:46 PM, Ryo Furue wrote:
>
>> Hi Billy and Hanh,
>>
>> | ! compute the horizontal streamfunction from vertically integrated u
>> | ! and v fields
>> | ! note that u and v must occur on the same spatial points (B-grid)
>> | ! arg1=variable name for u
>> | ! arg2=variable name for v
>> | ! arg1=x0 (must be on a gridpoint or set mode interp)
>> | ! arg2=y0 (likewise)
>> | ! psi=int(y0,y)u(x,y)dy - int(x0,x)v(x,y0)dx
>> | ! u=d(psi)/dy, v=-d(psi)/dx
>>
>> I guess this gives you a correct streamfunction only
>> when du/dx + dv/dy = 0, right?  (There's no function satisfying
>> both u=d(psi)/dy and v=-d(psi)/dx when du/dx + dv/dy is nonzero.)
>>
>> Hanh mentioned velocity potential, which suggests that a Helmholz
>> decomposition is required:
>>
>>
>> To obtain phi(x,y) and psi(x,y), you need to solve these Poisson
>> equations
>>
>>   div grad (phi) = div(u,v)
>>   div grad (psi) = curl(u,v)
>>
>> with some (probably arbitrary) boundary conditions.
>>
>> I myself haven't done this, but a colleague of mine uses the method
>> described by:
>>
>>   Watterson, I., 2001. Decomposition of global ocean currents using a
>>   simple iterative method. J. Atmos. Oceanic Tech., 18, 691?703.
>>
>> Hope this helps,
>> Ryo
>>
>
>

```