Skip to main content
Have a personal or library account? Click to login
PyPlume: An Automated Python-Based Library for Analyzing Turbulent Plumes from bplume-WRF-LES Model Cover

PyPlume: An Automated Python-Based Library for Analyzing Turbulent Plumes from bplume-WRF-LES Model

By: Thanh Tran and  Kiran Bhaganagar  
Open Access
|Nov 2024

Full Article

Overview

Introduction

Wildland fires, volcanic plumes, and chemical plumes that are released into the atmosphere, interactions of the wind turbine wakes with the atmospheres [11] belong to an important class of buoyancy-driven turbulent flows, where atmospheric stability influences the dynamics of the plumes or the wakes. With recent advances in computational modeling, the research has reached a state in which it is possible to simulate wildland fires and such extreme events with a high degree of fidelity. Of these numerical weather forecasting models, the Weather Research and Forecasting model (WRF) is a mesoscale weather model, and the large-eddy-simulation (LES) introduces the capability of explicitly resolving turbulence. WRF-LES is a cross-scale coupling system in which the mesoscale-microscale mean flow fields and the turbulence stresses and fluxes are resolved. BhimiReddy & Bhaganagar [4] modified the WRF-LES to introduce plume capability within WRF and we refer to this modification as bplume-WRF-LES model. The solver can be used to simulate plumes such as dispersion of chemicals in the atmosphere [2]. However, the data generated by the LES model is vast, characterizing the plume and quantifying the mixing dynamics is not trivial. For this purpose, an open source python framework – Pyplume – has been developed that can process the bplume-WRF-LES model-generated data and plume characteristics. An analysis framework has been implemented within the Pyplume. Pyplume is an automated software that generated key characteristics of plume dynamics based on turbulence principles. The mean characteristics of the plume are the time-averaged velocity and the buoyancy. After the release from the source, the plume initially accelerates before it slows down. The numerical data obtained from the solver consists of the instantaneous velocity, temperature, and density field of the plume. In the Pyplume framework, the input is the instantaneous data sets from the time of the release of the plume to the time the plume reaches the top of the domain. First-principles are used to calculate the plume characteristics. The plume height is defined as the forecast location of the plume in the axial direction, and the plume width is defined using a density threshold criterion. The focus of this manuscript is to present the details of the Pyplume model formulation and model implementation.

Such similar python software have been developed for other applications, such as, forest growth in terrestrial ecosystems [12]; integrating different models pre-processing into one processing environment and combining with model-specific parameter calculation functions [10]; to extract vertical structures from LIDAR data [9].

Implementation and architecture

The PyPlume Python Library has been developed using the data generated from the bplume-WRF-LES model [4]. The model has been well validated [7, 8, 5]. The representation of the library for Pyplume is given in Figure 1. The model generates the data in the netCDF format. The PyPlume library extracts the specific variables from the netCDF data files. Classes from the library compute and visualize the time-averaged mean flow field and the turbulence characteristics of the plume. The library also includes a vortex identification method for detecting the dominant vortices in the plume. PyPlume library streamlines the processing steps of the turbulent buoyant plume data and makes it easier for researchers to extract plume characteristics from the data without any computational background.

Figure 1

Flow chart of the automated PyPlume library Flowchart. Refer to Table A2 and Table A3 for the definitions of the Python functions and classes, respectively.

The following are the elements of the PyPlume python library:

  • Description of the software: The software automates the following: 1. Buoyancy and Reduced Gravity parameters, 2. Plume Metrics (plume height, plume width, plume maximum velocity, plume Reynolds number, 3. Plume turbulence metrics (turbulent kinetic energy profiles, Turbulent kinetic energy (TKE) production from shear- and buoyancy sources, root-mean-square (r.m.s.) of velocity- and buoyancy-fluctuations.

  • Installation: The PyPlume library is installed by using pip install on the command line “pip install pyplumewrfles”. It should be noted that first an upgrade is performed with pip install using the command line “ python -m pip install –upgrade pip ”. Detailed documentation of PyPlume is available on GitHub at the following address: https://github.com/CFD-UTSA/bplume-WRF.

  • Extracting Data: The netCDF output data from WRF-bPlume consists of instantaneous velocity in the Cartesian coordinates. The coordinate system is x, y along the horizontal direction and z along the axial direction. The corresponding axial velocity is w, and the horizontal velocities are u and v, respectively.The temperature (T) and the plume gas mixing ratio (Qplume) are used to calculate plume temperature density ρ, and reduced gravity g′. The function pyplume.WRF2npy() extracts the variables from the netCDF files and saves them as NumPy array files. The shape of the data is a four dimensions array (time, z, y, x).

  • Metadata (class): The Metadata class is used to store the required inputs variable required to analyze the output data. This class is not a requirement and the variables can be stored individually. A list of the input variables is available in the namelist file, which is the input for the WRF-bPlume simulation. The metadata includes the array size of the variables, and it corresponds to the shape of the data, the mesh spacing (dz,dy,dx), and the time-step of the data output, dt. The class also includes the source heat flux, the gas constant, the source diameter D, the ambient temperature, the dynamic viscosity, and the density of the ambient gas and of the released gas.

  • Buoyancy and Reduced gravity parameters: The reduced gravity is a robust metric to determine the interface of the plume. Using a threshold criterion, the data has been separated into plume-area and non-plume-area. The reduced gravity has been calculated using the relative temperature difference between the released gas and the ambient gas scaled by the ambient temperature. This is calculated using the function: pyplume.gprimeT().

  • Plume Metrics (class): Plume metrics class is a built-in function to calculate the instantaneous plume metrics. Plume metrics class requires gT and axial velocity w as inputs. The plume interface and plume height are calculated using the reduced gravity by setting a threshold criterion. The T and w data are also used to calculate the non-dimensionless parameters, such as the plume Reynolds number, maximum mean velocity at the centerline (wc¯max), plume half-width (l˜) at the axial-location (z˜) of the maximum velocity, the Froude number and Turbulence Reynolds number. Refer to [6] for details on the formulation. This class also includes the visualization tool to visualize the plume interface in real-time.

  • Plume Turbulence Metrics (class): This class calculates the time-averaged turbulence statistics. The input data is a 3-D array. The input data includes the temperature difference between the ambiance and the plume, volume fraction, and velocity components (u,v,w). The class generates the turbulent characteristics of the plume such as Reynolds stress, turbulent kinetic energy (TKE), TKE production from buoyancy, TKE production from shear. The class also includes a visualization function to plot the 2-D and 1-D turbulence fields. The axial- and radial- profiles of root-mean-square (r.m.s.) of velocity fluctuations (urms, vrms, wrms) and buoyancy fluctuations (gρbrms,gTbrms) are also evaluated. In addition, the momentum flux and the buoyancy flux are evaluated. The turbulence kinetic energy (TKE) and the terms of the TKE transport equations are evaluated next. The TKE transport equation includes the shear- and buoyancy production terms, the mean advection, and the transport of TKE terms. The terms of the transport equation of the temperature variance equations are also calculated. Refer to [3] for further details.

  • Vortex identification Method (function): The PyPlume library includes the λ2 vortex identification method. The vortex Identification method is used to extract the Coherent structures and the large-scale features of the flow. The input is the velocity field (u, v, w). λ2 vortex criteria is a vortex visualization technique based on the using minimum pressure criterion to define a vortex. Using vortex criteria, three-dimensional Iso-surfaces visuals are generated.

  • Data Availability: The plume data for release of gases Co2, So2, He into neutral and convective environment is available for dissemination.

Case Study

A case study for the release of CO2 plume into the neutral atmosphere is demonstrated here. A neutral atmosphere refers to the case, wherein, the ambiance is maintained at a constant temperature and without any air moments. The physical domain of the simulation is 7 km (height) × 1.8 km × 1.8 km (horizontal direction). A circular source is placed at the bottom center of the bottom surface. The diameter of the circular source (D) of the released gas is 400 meters. The buoyancy generated at the source is characterized based on the density and the temperature differences between the gas at the source and the ambiance. The mesh resolution is 40 meters along the horizontal direction and 10 meters along the vertical direction. The ambient condition is still air maintained at a constant temperature of 300 K. First, data were extracted using the function pyplume.WRF2npy(). to convert from the netCDF format to the NumPy array files.

Plume Metrics Class (Mean characteristics)

Using metadata, potential temperature T, and axial W velocity as input fields, the Plume Metrics class automates the processes of computing the characteristics (metrics) of the plume – the plume height, the plume width, the plume trajectory, the front velocity, the maximum velocity. A threshold criterion based on reduced gravity gT has been used to identify the plume interface. The plume interface is obtained using the 0.01% threshold criterion of normalized gT.

Figure 2a and b show the front height and the velocity fields plotted versus time for the CO2 plume, respectively. It is observed that it takes 3500 s to reach the maximum height of the domain during the simulation. Further, after initial transience, the plumes go through an acceleration stage and they reach a peak velocity [1]. The plume takes about 500 s to reach the peak velocity of 7m/s. After reaching the peak velocity, the plume decelerates to a quasi-steady state with an average velocity of 1.8 m/s. Details of the plume characteristics are given in Table 1.

Table 1

Initial conditions and dimensionless number for CO2 Plume Simulation.

R0(J/kg * k)188.92
H0(kms1)2.5
wc¯max(ms1)7.278
l˜(m)354.136
Rewc2.163e10
wb(s–1)13.728
Frwc0.53
Figure 2

Plume Front Metrics calculated using the Plume Metrics class of the PyPlume library: (a) Variation of the Plume Front height vs. time, (b) Variation of the Plume front velocity vs. time as the plume is evolving from rest.

The plume Metrics class has been used to plot the instantaneous contours of the temperature as shown in Figure 3. The spatial growth of the plume over time is evident. The contours are colored using reduced gravity gT which indicates the dilution of the plume as it ascends and mixes with the atmosphere. As seen in Figure 3a, during the initial stage of the plume, the plume accelerates from the starting point to the point at which it attains a maximum front velocity (Figure 2b). During this stage, the turbulent plume rises axially without any significant radial expansion. Figure 3b and 3c show the formation of the plume head. The last contour plot shows the final stage of the plume. The plume is now fully developed. At this stage, the plume is now of two distinct regions: The lower region is close to the source which is the relatively undiluted region and has the same diameter as the source. The undiluted cylindrical-shaped region is capped by a head region that is unstable, resulting in drastic mixing, and is separated into two different segments as seen in Figure 3d. The upper region is the plume head with jet-like characters.

Figure 3

Plume interface calculated based on the temperature difference between the plume and the ambiance, at time corresponding to, (a) t = 540 s, (b) 1080 s, (c) 1620 s, (d) 2160 s, after the release of the plume.

Plume Turbulence Metrics Class

The next step is to characterize the turbulence generated by the plumes. By importing the gas ratio data, and the Cartesian velocity data, U,V,W into the Plume turbulence metrics, the turbulence state of the plume is characterized using turbulence statistics, including, turbulence kinetic energy (TKE), production of TKE due to shear- and buoyancy-generated components (See Figure 5). This step is followed by characterizing the mean state of the plume, including the mean velocity and the mean buoyancy. Figure 4a shows the time-averaged TKE along the centerline. The Wrms dominates compares to Urms and Vrms. TKE buoyant- production PB and shear- production Ps along the centerline are shown in Figure 4b.

Figure 4

(a) Time-averaged velocity and Turbulent Kinetic Energy along the axial direction at the centerline, (b) Time-averaged Buoyant production of TKE and Shear Production of Turbulent Kinetic Energy plotted along the axial direction at the centerline.

Figure 5

Contour plots along the xz plane at y = 0 for (a) Turbulence kinetic Energy, (b) Buoyant production of Turbulent Kinetic Energy, (c) Shear production of Turbulent Kinetic Energy.

Plume Vortex Identification Class

The Cartesian velocity U,V,W data are used to calculate λ2 vortex criteria. Using the function lambda2(), λ2 vortex criteria of the CO2 plume data was calculated. The λ2 was then converted into Tecplot format (plotting software) using the Tecplot generated function included within the PyPlume library. It was imported into the ParaView program for visualization. Three-dimensional Isosurfaces visuals were generated using ParaView as shown in Figure 6 using λ2 data at a time of 950 s with an Isosurface value of –e12. The Isosurface contour is colored using gT data. At 950 s, the plume is in a deceleration regime due to active mixing as seen in Figure 2b. During this stage, a well-defined circular vortex structure is evident at 8 z/D. There is significant mixing that is initiated. Close to the source, the plume is relatively unmixed, however, in the bulged region corresponding to the head, the mixing is dominant, resulting in significant dilution of the plume.

Figure 6

Using a vortex-criterion (λ2) with contours plotted at time corresponding to t = 950s.

Availability

Operating system

This package can be run on any operating system where python can be run (GNU/Linux, Mac OSX, Windows)

Programming language

Python 3.7+

Additional system requirements

none

Dependencies

Numpy = 1.16.5 or higher, matplotlib = 3.3.0 or higher, Jupyter Notebook, Anaconda. The PyPlume library is installed by using pip install on the command line “pip install pyplumewrfles”. It should be noted that first an upgrade is performed with pip install using the command line “python -m pip install –upgrade pip”.

List of contributors

Kiran Bhaganagar, Thanh Tran, Sudheer BhimiReddy

Software location

Archive

Name: Zenodo

Persistent identifier: https://zenodo.org/doi/10.5281/zenodo.12628277

License: GNU General Public License (GPL) V3.0 or later

Publisher: Kiran Bhaganagar

Version published: 1.0.2

Date published: 07/02/2024

Code repository

Name: Github

Identifier: https://github.com/CFD-UTSA/WRF-bLES-PyPlume

License: GNU General Public License (GPL) V3.0 or later

Language

English

Reuse potential

The software is a automated software that can be used in the areas of dispersion of smoke plumes, fire plumes, buoyant plume transport, chemical release into the atmosphere and convective plumes. Using the software, both mean and turbulence characteristics of the plume can be extracted and plotted. The WRF-LES data base for Co2 plume will be valuable for fundamental studies such as developing dispersion models, plume entrainment models, plume height models. The flow visualization tool is helpful to plot 1-D, 2-D and 3-D of plume. The high-frequency and high-resolution data is valuable and be used as training data for Artificial Intelligence models. The software can be modified by generating more data using WRF-LES model. As the software is modular, new features such as plume entrainment can be included in the model. The authors will provide any support required to modify the tool.

Competing interests

The authors have no competing interests to declare.

DOI: https://doi.org/10.5334/jors.512 | Journal eISSN: 2049-9647
Language: English
Submitted on: May 7, 2024
Accepted on: Sep 14, 2024
Published on: Nov 6, 2024
Published by: Ubiquity Press
In partnership with: Paradigm Publishing Services
Publication frequency: 1 issue per year

© 2024 Thanh Tran, Kiran Bhaganagar, published by Ubiquity Press
This work is licensed under the Creative Commons Attribution 4.0 License.