Skip to content

This repository is linked to the research article "Prediction of equivalent sand-grain size and identification of drag-relevant scales of roughness - a data driven approach" JFM (2023) by J. Yang, A. Stroh, S. Lee, S. Bagheri, B. Frohnapfel and P. Forooghi.

License

JiashengY/Active-learning-codes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Active-learning-codes

This repository is associated with the research article authored by J. Yang, A. Stroh, S. Lee, S. Bagheri, B. Frohnapfel, and P. Forooghi, titled "Prediction of Equivalent Sand-Grain Size and Identification of Drag-Relevant Scales of Roughness - A Data-Driven Approach," which was published in the Journal of Fluid Mechanics 2023.

PS_PDF_NeuralNetwork

Table of Contents
  1. About The Project
  2. Getting Started
  3. Folders
  4. Usage
  5. Citation
  6. Contact
  7. License

About The Project

The current project encompasses a collection of Python scripts, spanning tasks such as analyzing roughness statistics, performing Bayesian optimization for neural network architecture, training ensemble neural network using predefined NN architectures as well as conducting active learning.

(back to top)

Built With

    v 3.8

(back to top)

Getting Started

Prerequisites

Python 3.8 along with following Python packages are required for running the code

  • Numpy

      pip3 install numpy==1.21.5
  • Scipy

      pip3 install scipy==1.7.3
  • Pandas

      pip3 install pandas==1.4.1
  • Matplotlib

      pip3 install matplotlib==3.6.2
  • TensorFlow

      pip3 install tensorflow==2.10.0
  • scikit-learn

      pip3 install -U scikit-learn==1.0.2
  • scikit-optimize

      pip3 install scikit-optimize==0.9.0

(back to top)

Installation

Clone the repository

git clone https://github.com/JiashengY/Active-learning-codes.git

(back to top)

Folders

  • rgh_class

    This folder contains roughness class rgh, rgh is a Python class that provides a convenient and efficient way to perform a variety of operations related to roughness analysis as well as conducing ML-prediction.
  • Bayesian_optimization

    This folder contains jupyter notebook titled NeuralNetwork_BO.ipynb which is used for Bayesian Optimization (BO) of the neural network architecture. Consequently, the optimized hyperparameters are documented in Hyperparameters_BO.csv.
  • enn_training

    This folder contains ENN training script titled NeuralNetwork_train.ipynb. The architecture of the members within the ENN is constructed based on the hyperparameters specified in Hyperparameters.csv, which can either be generated through the above BO process or user-defined. The trained ENN model members are stored in the Models sub-directory at the same location.

Usage

rgh Python class

rgh is a Python class that provides a convenient and efficient way to perform a variety of operations related to roughness analysis. You can move the rgh_class.py file from this repository and place it in your project directory.

Import rgh class:

import rgh_class as rgh

Create an instance of the rgh class:

surface=rgh.rgh(x,z,y) # x,z are streamwise, spanwise coordinates, y is 2-D roughness map

Attributes

The rgh class provides following attributes:

  • Lx, Lz : Streamwise and spanwise extents of the roughness patch, respectively.
  • kt : Peak-to-trough height of the roughness
  • k99 : 99% confidence interval of roughness PDF
  • sk : Skewness of the roughness PDF ${1\over Sk_{rms}^3}\int_S(k-k_{md})^3\text{d}S$, where $S$ is the projected area.
  • ku : Kurtosis of the roughness PDF with Pearson's definition ${1\over Sk_{rms}^4}\int_S(k-k_{md})^4\text{d}S$
  • krms : Standard diviation of roughness height $\sqrt{{1\over S}\int_{S}(k-k_{md})^2\text{d}S}$
  • kmd : Melt-down height of roughness, measuring bottom ${1\over S} \int_{S}k\text{d}A$
  • ra : Mean absolute diviation of roughness height around the mean plane ${1\over S}\int_{S}|k-k_{md}|\text{d}S$
  • por : Porosity of the roughness within the roughness region
  • ESx ESz : Effective slope in streamwise and spanwise directions, respectively ${1\over S}\int_{S}|{\partial k \over \partial x,z}|\text{d}S$
  • incx incz : Inclination of roughness in streamwise and spanwise directions, respectively $\text{tan}^{-1}({1\over 2}Sk({\partial k \over \partial x,z}))$

Methods

The rgh class provides the following methods:

  • print_stat() : Generate a table containing roughness statistical parameters
    • Returns: a Pandas dataframe containing roughness statistical parameters
  • show_surface(representation="2D") : Plot surface geometry.
    • representation : String, showing the representation of roughness geometry either in "2D" or "3D".
  • plot_PDF(n_bins=10,normalization=True) : Present roughness height PDF, where:
    • n_bins: Integer, number of bins.
    • normalization : Boolean, if the plot is noramalized to density.
  • plot_PS(normalization=True,circular_average=False,moving_average=False,n_iter=3): Present roughness height PS, where:
    • normalization : Boolean, if the PS is noramalized with root-mean-square roughness height.
    • azimuthal_average: Boolean, azimuthally averaged PS around origin of spectral space i.e. (qx,qz)=(0,0), to acquire 1-d PS.
    • moving_average: Boolean, once azimuthal average is done, moving average over 1-d PS can be carried out on demand.
    • n_iter: Integer, number of moving averaging iterations.
  • FFT_filter(lmax,lmin): Spectral filtering of the surface, lmax, lmin are the desired largest and smallest roughness wavelengths, respectively.
    • Returns: filtered rgh instance
  • get_model_input(lmax=2,lmin=0.04,azimuthal_average=False,moving_average=False,n_iter=3,do_plots=False): Generate input vector for the ML model proposed in the publication, where:
    • lmax: largest incorporated wavelength
    • lmin: smallest incorporated wavelength
    • azimuthal_average: azimuthally averaged PS around origin of spectral space i.e. (qx,qz)=(0,0), to acquire 1-d PS.
    • moving_average: once azimuthal average is done, moving average over 1-d PS can be carried out on demand.
    • n_iter: number of moving averaging iterations.
    • do_plots: plotting input elements for ML model corresponding to PDF and PS.
    • Returns: 1-d Numpy array for model input: $[k_t/k_{99},\lambda_0/k_{99},\lambda_1/k_{99},PDF_1, ..., PDF_{30}, PS_1, ..., PS_{30}]$

Roughness prediction

rgh.predict(surface_input,n_models=50,n_p=4) is the function to predict given inputs, i.e. surface_input, with the ensemble neural network comprising n_models number of model members. The prediction process is parallelized on n_p CPUs.

  • surface_input is the input vector for the current model, this can be obtained by get_model_input method in rgh class. For instance:
import multiprocessing as mp
prediction=rgh.predict(surface.get_model_input(),n_p=mp.cpu_count())

You can choose the model for prediction from the pop-up window:

“Model_selection_window”

Application examples

Application example of rgh class can be found in the jupyter notbook 1_rgh_class/Class_Example.ipynb

(back to top)

Citation

If you find this project usful, please cite:

@misc{yang2023prediction,
      title={Prediction of equivalent sand-grain size and identification of drag-relevant scales of roughness -- a data driven approach}, 
      author={Jiasheng Yang and Alexander Stroh and Sangseung Lee and Shervin Bagheri and Bettina Frohnapfel and Pourya Forooghi},
      year={2023},
      eprint={2304.08958},
      archivePrefix={arXiv},
      primaryClass={physics.flu-dyn}
}

Contact

Pourya Forooghi @ Aarhus University

Alexander Stroh @ KIT

Jiasheng Yang @ KIT

License

This repository is released under the MIT license

About

This repository is linked to the research article "Prediction of equivalent sand-grain size and identification of drag-relevant scales of roughness - a data driven approach" JFM (2023) by J. Yang, A. Stroh, S. Lee, S. Bagheri, B. Frohnapfel and P. Forooghi.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published