File size: 4,437 Bytes
e9053e0
 
 
 
 
 
 
 
 
 
 
 
752f1e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
---
title: Flow Visualiser
emoji: 🐨
colorFrom: blue
colorTo: yellow
sdk: streamlit
sdk_version: 1.44.1
app_file: app.py
pinned: false
license: mit
---

A Streamlit application for visualizing and exploring stream functions in fluid dynamics.

## Project Structure

The application is organized into the following files:

- `main.py`: Main entry point of the application
- `stream_functions.py`: Contains the mathematical implementations of various stream functions
- `ui_components.py`: Handles all the user interface elements and controls
- `visualization.py`: Creates and displays the visualizations

## Features

- Visualize different types of flow patterns: 
  - Uniform Flow
  - Source/Sink
  - Vortex
  - Doublet
  - Cylinder in Flow
  - Custom Combinations

- Interactive controls for:
  - Adjusting flow parameters
  - Setting domain size and resolution
  - Customizing visualization options

- Multiple visualization options:
  - Stream function contours
  - Streamlines
  - Velocity vectors

## Fluid Dynamics Theory

### Stream Functions

A stream function (ψ) is a mathematical tool used in fluid dynamics to describe two-dimensional, incompressible, and irrotational fluid flow. The key properties of stream functions include:

1. **Definition**: The stream function ψ(x,y) is defined such that:
   - u = ∂ψ/∂y (x-component of velocity)
   - v = -∂ψ/∂x (y-component of velocity)

2. **Streamlines**: Lines of constant ψ are streamlines, which are tangent to the velocity at every point. Fluid particles follow these paths in steady flow.

3. **Flow Rate**: The difference in ψ between any two streamlines represents the volume flow rate between them.

4. **Incompressibility**: The stream function automatically satisfies the continuity equation for incompressible flow (∇·V = 0).

### Elementary Flows

This application allows you to visualize several elementary flows:

#### Uniform Flow
- **Stream Function**: ψ = U·y
- **Physical Interpretation**: Flow with constant velocity U in the x-direction
- **Applications**: Free-stream flow, far-field conditions

#### Source/Sink
- **Stream Function**: ψ = (Q/2π)·θ
- **Physical Interpretation**: Fluid emanating from (source, Q>0) or converging to (sink, Q<0) a point
- **Applications**: Modeling wells, jets, or suction points

#### Vortex
- **Stream Function**: ψ = (Γ/2π)·ln(r)
- **Physical Interpretation**: Circular motion around a point with circulation Γ
- **Applications**: Modeling swirling flows, wing tip vortices

#### Doublet
- **Stream Function**: ψ = -κ·sin(θ)/r
- **Physical Interpretation**: Combination of a source and sink of equal strength as they approach each other
- **Applications**: Building block for more complex flow patterns

#### Cylinder in Flow
- **Stream Function**: ψ = U·(r - a²/r)·sin(θ)
- **Physical Interpretation**: Uniform flow around a circular cylinder of radius a
- **Applications**: Flow around bluff bodies, aerodynamics

### Principle of Superposition

For irrotational, incompressible flows, the principle of superposition applies. This means that complex flow fields can be constructed by adding together simpler elementary flows. For example:
- Cylinder in flow = Uniform flow + Doublet
- Flow around airfoils = Uniform flow + Vortex + Source/Sink distributions

This principle is utilized in the "Custom Combination" option in the application.

## Installation

1. Clone this repository:
```bash
git clone https://github.com/yourusername/flow-visualizer.git
cd flow-visualizer
```

2. Install dependencies:
```bash
pip install -r requirements.txt
```

3. Run the application:
```bash
streamlit run main.py
```

## Educational Use

This tool is particularly useful for:

- **Fluid Mechanics Students**: Visualize theoretical concepts learned in class
- **Engineering Courses**: Demonstrate the behavior of different flow patterns
- **Research Projects**: Quick validation of analytical flow solutions
- **Self-Study**: Interactive exploration of fluid behavior without complex CFD software

### Example Learning Exercises

1. Observe how streamlines change with different strengths of sources/sinks
2. Compare the velocity field of a vortex at different circulations
3. Explore how the stagnation points move in cylinder flow as parameters change
4. Create custom combinations to model more complex flow scenarios

## Requirements

- Python 3.6+
- Streamlit
- NumPy
- Matplotlib
- SymPy