+ All Categories
Home > Documents > Using the Jupyter Notebooks as a tool for CFD simulations

Using the Jupyter Notebooks as a tool for CFD simulations

Date post: 18-Mar-2022
Category:
Upload: others
View: 21 times
Download: 0 times
Share this document with a friend
3
6th American Association for Wind Engineering Workshop (online) Clemson University, Clemson, SC, USA May 12-14, 2021 * Lead presenter Using the Jupyter Notebooks as a tool for CFD simulations Fei Ding a,* , Ahsan Kareem b a NatHaz Modeling Laboratory, University of Notre Dame, Notre Dame, IN, US, [email protected] b NatHaz Modeling Laboratory, University of Notre Dame, Notre Dame, IN, US, [email protected] ABSTRACT: The Jupyter Notebooks (www.jupyter.org) have been widely used in science and engineering communities as an open- source interactive literate programming paradigm. It has the capabilities of combining text, images or videos with research codes, and can easily document, share, and reproduce data analysis. As for computational fluid dynamics (CFD), an open-source software OpenFOAM is popularly used for computationally establishing wind effects on structures. To help beginners overcome the challenges of steep learning curve posed by OpenFOAM, we present the work to script the workflow for OpenFOAM simulations using the Jupyter Notebooks. The developed Jupyter Notebooks can aid in determining inflow conditions, creating mesh files for parameterized building geometries and running the selected solvers. This tool can also contribute to the education for CFD learning as online resources, which will be implemented in the DesignSafe cyberinfrastructure (CI) (www.designsafe-ci.org). Keywords: Jupyter Notebooks, CFD, OpenFOAM, DesignSafe 1. INTRODUCTION The Jupyter Notebooks has become an attractive venue for data processing, visualization and sharing due to its interactive feature with the code. The Jupyter Notebooks are composed of cells which can be categorized into three types: code, markdown and raw. A code cell can be executed, and a markdown cell contains text or images to illustrate the code. Tools that convert the Jupyter Notebooks into other formats can use raw cells for configuration (Pimentel et al., 2019). The Jupyter Notebooks can be accessed either through a local PC or through a web browser such as on the Jupyter Hub in the Discovery Workspace of DesignSafe CI (Rathje, et al. 2017). This makes it easy to use the same interface running on a remote server (Kluyver et al., 2016) to access and manipulate the files. In the digital age, the burgeoning growth of computational resources to conduct numerical experiments have promoted the use of CFD to address the evaluation of wind effects on structures. Moreover, OpenFOAM is a CFD open-source code that is used to solve turbulent flows and other complex fluid flows. However, OpenFOAM as well as commercial CFD software requires the expertise in computational wind engineering (Ding et al., 2019), which may hinder their practical use for non-CFD-experts. For example, the engineers or researchers lacking the knowledge about the necessary precision regarding the grid size close to the building envelope could lead to the failure in CFD simulations (Tamura & Van Phuc, 2015). To address this issue, we developed the Jupyter Notebooks as an open-source project to directly execute the functions for mesh generation, inflow settings, etc. in a user-friendly and interactive coding environment, aiming at alleviating the sophistication in running CFD models in OpenFOAM. In particular, this developed Jupyter notebooks will be implemented in the Jupyter Hub in the DesignSafe CI to expand the user base and contribution to research, education and practical use in the area of computational wind engineering. 228
Transcript

6th American Association for Wind Engineering Workshop (online) Clemson University, Clemson, SC, USA

May 12-14, 2021

* Lead presenter

Using the Jupyter Notebooks as a tool for CFD simulations

Fei Ding a,*, Ahsan Kareem b aNatHaz Modeling Laboratory, University of Notre Dame, Notre Dame, IN, US, [email protected] bNatHaz Modeling Laboratory, University of Notre Dame, Notre Dame, IN, US, [email protected] ABSTRACT: The Jupyter Notebooks (www.jupyter.org) have been widely used in science and engineering communities as an open-source interactive literate programming paradigm. It has the capabilities of combining text, images or videos with research codes, and can easily document, share, and reproduce data analysis. As for computational fluid dynamics (CFD), an open-source software OpenFOAM is popularly used for computationally establishing wind effects on structures. To help beginners overcome the challenges of steep learning curve posed by OpenFOAM, we present the work to script the workflow for OpenFOAM simulations using the Jupyter Notebooks. The developed Jupyter Notebooks can aid in determining inflow conditions, creating mesh files for parameterized building geometries and running the selected solvers. This tool can also contribute to the education for CFD learning as online resources, which will be implemented in the DesignSafe cyberinfrastructure (CI) (www.designsafe-ci.org). Keywords: Jupyter Notebooks, CFD, OpenFOAM, DesignSafe 1. INTRODUCTION The Jupyter Notebooks has become an attractive venue for data processing, visualization and sharing due to its interactive feature with the code. The Jupyter Notebooks are composed of cells which can be categorized into three types: code, markdown and raw. A code cell can be executed, and a markdown cell contains text or images to illustrate the code. Tools that convert the Jupyter Notebooks into other formats can use raw cells for configuration (Pimentel et al., 2019). The Jupyter Notebooks can be accessed either through a local PC or through a web browser such as on the Jupyter Hub in the Discovery Workspace of DesignSafe CI (Rathje, et al. 2017). This makes it easy to use the same interface running on a remote server (Kluyver et al., 2016) to access and manipulate the files. In the digital age, the burgeoning growth of computational resources to conduct numerical experiments have promoted the use of CFD to address the evaluation of wind effects on structures. Moreover, OpenFOAM is a CFD open-source code that is used to solve turbulent flows and other complex fluid flows. However, OpenFOAM as well as commercial CFD software requires the expertise in computational wind engineering (Ding et al., 2019), which may hinder their practical use for non-CFD-experts. For example, the engineers or researchers lacking the knowledge about the necessary precision regarding the grid size close to the building envelope could lead to the failure in CFD simulations (Tamura & Van Phuc, 2015). To address this issue, we developed the Jupyter Notebooks as an open-source project to directly execute the functions for mesh generation, inflow settings, etc. in a user-friendly and interactive coding environment, aiming at alleviating the sophistication in running CFD models in OpenFOAM. In particular, this developed Jupyter notebooks will be implemented in the Jupyter Hub in the DesignSafe CI to expand the user base and contribution to research, education and practical use in the area of computational wind engineering.

228

2. OPENFOAM WORKFLOW The overall concept of the OpenFOAM workflow may be expressed as meshing-solution-analysis-optimization-visualization. In the input contexts, three folders named “0”, “Constant” and “System” should be predefined by users, among which “0” contains initial and boundary conditions, “constant” involves physical properties and turbulence modelling properties, and “system” covers the run-time control and solver numeric (Jasak et al., 2007). The commonly used solvers for turbulent flows include PisoFoam which is a transient solver for incompressible and turbulent flows and simpleFoam as a steady-state solver. The parallel computation in OpenFOAM allows the simulation to run in the distributed processors simultaneously. In addition, flow simulations can also be set on the OpenFOAM interface on the website of Discovery Workspace in the DesignSafe CI. The job can be submitted to the HPC resources at TACC by simply clicking the Run button. The status of the job can be viewed through the Job Status on the right of the website. Simulation results are stored in the Data Depot and available to be post-processed by users. 3. DEVELOPMENT OF THE JUPYTER NOTEBOOKS CONNECTING OPENFOAM DICTIONARIES To overcome the challenges of steep learning curve posed by OpenFOAM, an illustrative example for an end-to-end flow simulation as shown in Fig. 1 will be provided for a rectangular building in which its envelope is parameterized by the aspect ratio. OpenFOAM command lines for mesh generation and simulation in parallel are written in the code cells and executed using the kernel in the Jupyter Notebooks. We will also implement TAPIS which is a scriptable command line interface in Python to access to TACC HPC resources. To introduce more flexibilities and bring the maximum automation in CFD modelling including parameterization of the building geometry and boundary conditions, an OpenFOAM library named PyFoam needs to be utilized. PyFoam is written in Python, therefore can be used in Jupyter Notebooks to execute OpenFOAM solvers and manipulate the parameter files in OpenFOAM. With the aid of PyFoam, the Jupyter Notebooks can manipulate the parameter files and dictionaries in OpenFOAM cases as regular Python dictionaries without looking into the OpenFOAM C++ libraries. In this study, the automated mesh generation and inflow configuration using the Jupyter Notebooks with the aid of PyFoam will be illustrated through wind flow simulations around rectangular buildings with various aspect ratios and inflow conditions.

229

Figure 1. Schematic of an end-to-end flow simulation implemented in the Jupyter Notebooks

5. CONCLUSIONS This study demonstrates the Jupyter Notebooks developed for scripting the OpenFOAM workflow for the wind flow simulation around a building. In particular, this tool is expanded to the direct use of the Jupyter Hub in the DesignSafe CI and HPC resources provided by TACC, through which the script can be easily published and shared with broader research communities and engineering groups. ACKNOWLEDGEMENTS Support for this work is in part provided by the NSF Grant # CMMI-2022469. REFERENCES Ding, F., Kareem, A. and Wan, J., 2019. Aerodynamic tailoring of structures using computational fluid dynamics.

Structural Engineering International, 29(1), 26-39. Jasak, H., Jemcov, A. and Tukovic, Z., 2007. OpenFOAM: A C++ library for complex physics simulations, Vol. 1000,

1-20. IUC Dubrovnik Croatia. Kluyver, T., Ragan-Kelley, B., Pérez, F., Granger, B.E., Bussonnier, M., Frederic, J., Kelley, K., Hamrick, J.B., Grout,

J., Corlay, S. and Ivanov, P., 2016. Jupyter Notebooks-a publishing format for reproducible computational workflows, Vol. 2016, 87-90.

Pimentel, J.F., Murta, L., Braganholo, V. and Freire, J., 2019. A large-scale study about quality and reproducibility of jupyter notebooks. In 2019 IEEE/ACM 16th International Conference on Mining Software Repositories (MSR), 507-517. IEEE.

Rathje, E. M., Dawson, C., Padgett, J. E., Pinelli, J-P, Stanzione, D., Adair, A., Arduino, P., Brandenberg, S. J., Cockerill, T., Dey, C., Esteva, M., Haan Jr, F. L., Hanlon, M., Kareem, A., Lowes, L., Mock, S. and Mosqueda, G., 2017. DesignSafe: new cyberinfrastructure for natural hazards engineering, Natural Hazards Review 18(3), 06017001.

Tamura, Y. and Van Phuc, P., 2015. Development of CFD and applications: Monologue by a non-CFD-expert. Journal of Wind Engineering and Industrial Aerodynamics, 144, 3-13.

230


Recommended