Streamlines

Streamlines

This application was written as a final project for Advanced Fluids in 2011, a graduate course at UMass Lowell. The application was modeled on a similar application written in Matlab and used in class. My version added the ability edit the model being rendered with drawing tools.

This application rendered stream functions to show how stream-lines would look flowing around an object. This demo highlights the different tools added to draw primitives, and the mathematical foundation behind each.

Written using C++, Qt and OpenGL, this application was compiled on both Linux and Windows operating systems. The remainder of this page is based on a paper I submitted describing the application.

Introduction

Computers were built to solve complex problems. The increasing power of computers enables powerful computational methods to be done quickly. Programs have been created to explore fluid flow problems, and streamlines is one such example.

If you have ever seen smoke streaming over a car in a commercial, the path that the smoke travels is a streamline. For the path along the streamline, the volumetric flow rate, flux, is constant and its change is zero along the streamline. This results in the smoke traveling, rather cleanly, around an object. A variety of mathematical functions have been created that enable the simulation of physical bodies in a flow.

The stream function returns a value for a given x,y coordinate. Due to superposition the values from multiple functions can be combined to form more complicated shapes. The mathematics are not very complicated, however they require many computations and would be tedious when computed by hand. Computers can do all the computations in a matter of seconds and give almost instantaneous results.

Stream functions result in a gradient that can be contoured to create the lines that show where smoke would flow. The following demo highlights the effects of the stream functions alone and in combination to form objects in a flow.

Discussion

Potential and streamlines are two related properties. The potential flow and the streamlines are perpendicular to each other when plotted as contour lines. The potential, \(\Phi\), is based on the conservation of mass for an in-compressible irrotational flow. The stream function is represented by \(\Psi\).

\(\nabla^2\Phi=0\)

\(\nabla^2\Psi=0\)

The change in the stream functions and potential functions are also zero.

\(d\Phi=u\ {dx} + y\ {dy}\)

\(d\Psi=u\ {dy} - y\ {dx}\)

As these two equations show, the slopes of these two equations are negative compliments of each other reinforcing the idea that the results are perpendicular to each other.

From a programming perspective, computing the values for \(\Phi\) and \(\Psi\), then drawing the a contour map of these values creates potential lines and stream lines. We need to be able to compute these values at specific locations using stream functions, \(\Psi(x,y)\), and potential functions, \(\Phi(x,y)\).

From this point on we will only look at stream functions since these functions are needed to generate the stream lines. There are multiple stream functions, these include: free streams, vortexes, Rankin oval, doublet, and vortex panel. There is a different equation for each, and due to superposition their effects at a particular location can be added forming a combined effect.

Slide 1: The initial screen presents a toolbar and an edit area. Adding a velocity to the stream, the editor shows horizontal lines indicating that there is velocity, but nothing altering the flow. The free stream velocity, is a directional constant flow whose value is computed as:\[\Psi(x,y)=V_yx+V_xy\] Here, \(V_x\) and \(V_y\) are the magnitudes of the velocities in their respective directions. The values x and y are the locations at which the stream function value is being computed. These functions create a gradient that the contour routines convert to equally spaced horizontal lines.
Slide 2: A vortex is a function that causes rotation around a point. This is shown in the absence of free stream velocity as concentric circles. The gradient to superpose on the data is computed as:\[\Psi(x,y) = \frac{\Gamma}{2\pi}\ln\left(\sqrt{x^2+y^2}\right)\]This computation assumes that the point is located about the origin, offsetting \(x\) and \(y\) yields the vortex at other locations. \(\Gamma\) is the magnitude of the vortex.
Slide 3: Combining the free stream velocity and the vortex results in the stream-lines bending around an object.
Slide 4: The Rankin Oval is actually two simple parts. It consists of a source and a sink of equal strength. Due to a discontinuity in the values the source has not been included on its own. A discontinuity on its own causes a very steep angle at \(\pi\) radians. The contouring routines respond by placing a very thick band of contours on the graph. By adding the source and sink the discontinuity is not as visible when represented as contours. They are presented in this program only as the pair. The following equation computes the stream value for a Rankin oval.\[\Psi(x,y) = \frac{M}{2\pi}\left\{\tan^{-1}\left(\frac{y}{x - x_1}\right)-\tan^{-1}\left(\frac{y}{x - x_2}\right)\right\}\]$M$ is the magnitude, \(x_1\) and \(x_2\) are the endpoints of a horizontal line. If some other angle is required the values can be rotated and translated into position. The velocity of the flow and the distance between the source and sink controls the dimensions of the oval created.
Slide 5: A Rankin Oval with added free stream velociy.
Slide 6: The doublet is a building block that can be used to create the effect of a circle in the flow. The equation for a doublet follows.\[\Psi(x,y) = \frac{M\,y}{2\pi\left(x^2+y^2\right)}\]The doublet is computed parallel to the x-axis and can be rotated to provide additional orientations.
Slide 7: A Rankin Oval with added free stream velocity.
Slide 8: Multiple vortexes and the other constructs can be used to simulate the streamlines around a physical object. In its simplest form the vortex alone can be used to simulate a solid structure, as shown in this picture. By placing a large number of vortexes in the desired shape the streamlines can be made to follow around a contour.
Slide 9: Using vortexes to represent physical objects has limitations. The vortex points will never create a smooth line as there will be valleys between the vortexes. This can be solved with the vortex panel. It is computed as:\[\begin{align*} \Psi(x,y) & = \frac{M {x_1\,\ln(y^2+x_1^2)}}{4\pi}\\ & - \frac{M x_2\,\ln(y^2+x_2^2)}{4\pi}\\ & - \frac{M 2\left[\,y\left(\arctan{\frac{x_1}{-y}} - \arctan{\frac{x_2}{-y}}\right)+x_1-x_2\right]}{4\pi} \end{align*}\]These equations only create a panel along a horizontal line from \(x_1\) to \(x_2\). In order to enable the program to draw the panel at any angle the \(x\) and \(y\) position values were rotated and translated into position.
Slide 10: Creating a simple drawing program enables people to explore the effects of these constructs and create object profiles. Here a crude representation of an airfoil is rendered using just vortexes.
Slide 11: This demonstration of the streamlines application culminates with a view of a crude airfoil represented by multiple panels.

Software Demonstrations CAD Sketch