# Compute streamfunction from numerical velocity field

1. Sep 30, 2016

### Niles

1. The problem statement, all variables and given/known data
I have a discrete two-dimensional velocity field (u,v). I want to plot the streamlines by finding the streamfunction ψ and from that plot the streamlines by finding the curves where ψ=constant.

2. Relevant equations
In order to find ψ I then have to solve the equations (see link)

$$udy = d\Psi \\ vdx = -d\Psi$$

3. The attempt at a solution
My main issue is that I'm not sure how to integrate these two equations. Say I start with the component u at point (i=1, j=1). If I have to integrate (=sum) this along y, then I basically get a number for the row i=1. But is this the way to do it?

2. Sep 30, 2016

### Staff: Mentor

Is it on a rectangular grid? Are the velocities known to satisfy the incompressible continuity equation? Do you know any of the bounding streamlines?

3. Oct 1, 2016

### Niles

It is on a rectangular 2D grid, grid points equally spaced. It is a simulated velocity field, so it obeys continuity. I don't know any of the streamlines by default

4. Oct 1, 2016

### Staff: Mentor

Well, the outside surface of the rectangular region has to be a streamline, since there is no flow across this boundary. Call the value of the stream function on this boundary zero. I don't know the best way to get the stream function values at the interior grid points, but a crude method would be to integrate each of the two equations numerically, one of them vertically and the other horizontally, and then take the average at each grid point. If integration along a vertical line does not give a value of zero of the stream function at the far boundary, I would distribute the excess uniformly among all the grid points in that column. The same goes for the horizontal direction.