Coconote
AI notes
AI voice & video notes
Export note
Try for free
Writing Code for CFD (Computational Fluid Dynamics)
Jul 13, 2024
Writing Code for CFD (Computational Fluid Dynamics)
Introduction
Purpose
: Understanding how to write a CFD code from scratch
Use Case
: Trying new schemes or methods not available in software like ANSYS
Example Problem
: Lid-driven cavity problem
Problem Description
Domain
: Square domain with stationary left, right, and bottom walls (u, v = 0)
Moving Wall
: Top wall moving in X direction (u = U, v = 0)
Comparison
: Importance of benchmarking results for correctness
Discretization and Mesh Creation
Mesh Type
: Simple Cartesian structured mesh
Domain Division
: Divide square into smaller squares
Interior Nodes
: Points inside the square (green), boundary nodes (red)
Example Mesh Size
: 7x7 for representation
Avoiding Checkerboard Oscillations
Issue
: Checkerboard oscillations in direct equation solving
Solution
: Staggering the grids
Staggering Method
:
Displace u-velocities in Y direction
Displace v-velocities in X direction
Grid Details
u-velocity Grid
: 7x8 mesh (one additional row)
v-velocity Grid
: 8x7 mesh (one additional column)
Pressure Grid
: 8x8 mesh
Complex Grid
: Combining all variables (u, v, pressure)
Control Volumes
Purpose
: Define control volumes for solving the equations
X-Momentum Equation
:
Control Volume Definition
Equations for u-velocity
Terms:
Time derivative (∂u/∂t)
Convective terms (u²/∂x, uv/∂y)
Pressure gradient (∂p/∂x)
Viscous terms (∆²u/∂x², ∆²u/∂y²)
Y-Momentum Equation
: Similar to X-momentum, but in terms of v-velocity
Continuity Equation
Original Form
: Divergence of velocity = 0
Artificial Compressibility
: Adding a term to simplify and directly obtain pressure
Discretization
:
Time derivative of pressure
Spatial derivatives of velocities (∂u/∂x, ∂v/∂y)
Boundary Conditions
Importance
: Defining conditions on domain boundaries
u-velocity
:
Assign zero values at stationary walls
Adjust values near the boundary using additional layers (to ensure average velocities match physical conditions)
v-velocity
: Similar to u-velocity adjustments
Pressure
: Ensure no flow across boundaries by equalizing interior and exterior pressure points
Summary
Learning Outcome
: Understanding grid creation, equation discretization, and boundary condition implementation in CFD coding
Next Steps
: Follow-up video with actual code implementation
Conclusion
: Preparation for hands-on coding and application of discussed concepts
📄
Full transcript