Skip to content

Implements a parallel programming solution, simulating the movement of a cloud of material in the atmospheric boundary layer using a 2D advection equation.

Notifications You must be signed in to change notification settings

nmac-dev/parallel-2D-advection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

parallel-2D-advection

A 2D advection program which advects a Gaussian u(x,y) at a fixed velocity

Content

How To Run?

In a terminal...

  • Navigate to the parallel-2D-advection directory
  • Use the command bash build.sh
    • If a permission error is given, use the command chmod +x and try again
  • Wait for the terminal to report the process was successful
  • Check the out directory for the .png files generated by gnuplot
    • Alternatively checkout the plots directory to see a history of the 2D advection plots as the program was improved

Requirements

  • OpenMP
  • gcc
  • gnuplot

WARNING!

  • GCC 9 or older implements the changes made to default(none) in OpenMP 4.0
    • default(none) NO LONGER predetermines "const variables with no mutable members" as shared (breaking backwards compatibility)
    • To implement a program which compiles for any GCC version, any const variables will be declared as firstprivate
  • Read more about the issue here

Purpose

The closest atmosphere to the Earth's surface is called the "Atmospheric Boundary Layer", and at this level the wind speed increases with height.
For example material emitted from a chimmey is advected at different horizontal speeds depending on its height.

parallel-2D-advection implements its own version of a numerical solution to calculate the advection equation, thus simulating the movement of a cloud of material in the atmospheric boundary layer.

Plots

The final plots for the 2D advection with all modifications implemented. (all stages can be found in the plots directory)

Initial Final Vertically Averaged Distribution
Intial Intial Intial

Development

Several changes were made to the program over its development.

Parallel Implementation

Ten loops were present in the initial program however not all could be implemented with parallel execution. (Loops are labeled within the code)

No. Parallel Implementation Status
1 Successful
2 Successful
3 Successful
4 Failed: Writing to a singular file using multiple threads breaks output dependency. Each thread overwrites the other threads changes
5 Failed: Each iteration of the outer loop depends upon the updates made by the previous. Flow dependency is broken in parallel as the time steps become unordered
6 Successful
7 Successful
8 Successful
9 Successful
10 Failed: same case as LOOP 4
11 Failed: same case as LOOP 4

Configuration Modification for Realism

The initial calculation was not particularly realistic. Several configuration modifications were made to improve the realism.

Variable Initial Improved
MAX_X 1.0 30.0
MAX_Y 1.0 30.0
CENTER_X 0.1 3.0
CENTER_Y 0.1 15.0
SIGMA_X 0.03 1.0
SIGMA_Y 0.03 5.0
N_STEPS 1500 800
VEL_X 0.01 1.0
VEL_Y 0.01 0.0

Adding Vertical Shear

To simulate a realistic advection, modifications are implimented so the horizontal velocity varies with height.
NB: Added (A) / Modified (M)

A/M Name Desc
A calc_vel_x() Calculates the horizontal velocity using a logarithmic profile (adds vertical shear)
A F_VEL Friction velocity (meters per second)
A R_LEN Roughness length
A VK_CONST Von Karman's constant
M VEL_X Calls 'calc_vel_x()' instead of using a literal value
M Loop 8 Horizontal velocity is calculated using 'calc_vel_x()' instead of a constant

Calculating Vertically Averaged Distribution

To understand the advection better, an additional plot is created for the horizontal profile of advected material see Plots

  • vavg_u was added: Stores vertical averages for u_val[x,y] (calloc: init indexes as 0)
  • Loop 9 was modifed: inner loop sums the u values (y), outer loop divides the sum by total points of y to get vertical average
    • Once the loop completes vavg_u conntains the vertically averaged distribution of u[x,y]
  • Loop 11 was added: prints values of vavg_u to v_averaged.dat which is used by v_averaged.gnuplot to create the additional plot

About

Implements a parallel programming solution, simulating the movement of a cloud of material in the atmospheric boundary layer using a 2D advection equation.

Topics

Resources

Stars

Watchers

Forks