Style Eddy Simulation (StylES) is a procedure to simulate plasma physics turbulence. Based on the use of Generative Adversarial Network (SyleGAN) it reconstructs the non linear terms necessary for the time integration in a Large Eddy Simulation (LES).
The idea is to train StyleGAN on DNS data and then use the GAN generator as deconvolution operator for LES. More details are in the following papers:
- J. Castagna and F. Schiavello, ACM PASC23: StyleGAN as Deconvolution operator for Large Eddy Simulation (2023).
- J. Castagna et al., Physics of Plasma: StyleGAN as an AI Deconvolution Operator for Large Eddy Simulations of Turbulent Plasma Equations in BOUT++ (2024).
We use TensorFlow = 2.10 (latest versions are not supported yet) installed via pip (see https://www.tensorflow.org/install/pip). We suggest to create a virtual enviroment using the latest list of python module used, available in the requirements.txt file. For the GPU version, make sure you have the following requirements:
cudatoolkit=11.2
cudnn=8.1.0
which you can easily install via conda. You will also need to download the TurboGenPY repo from https://github.com/saadgroup/TurboGenPY.git to find the energy spectra. Once cloned (at same directory level of StylES) modify the files using the patch file patch_TurboGenPY.patch.
You can quickly test StylES with BOUT++ using the weights for an already trained StyleGAN according to the following database:
Case | NxN | alpha | k | Weights | |
---|---|---|---|---|---|
HW | 1024x1024 | 1.0 | 1.0 | 10-6 | mHW_N1024 |
and the following steps:
- donwload BOUT++, checkout bout_with_StylES branch and compile the hasegawa-wakatani-3d test case as follows:
- compile BOUT++ as follows:
- cmake -S . -B build_release -DBOUT_BUILD_EXAMPLES=ON
- cmake --build /path_to_BOUT/BOUT-dev/build_release -j 16
- cmake --build build_release --target hw3d
- download the 1024x1024 weights from the link above and save in the folder /StylES/checkpoints/
- generate the restart point using python create_restart.py in the /StylES/bout_interfaces/ folder
- run the hasegawa-wakatani-3d test case in the folder /BOUT-dev/build_release/examples/hasegawa-wakatani-3d/ as ./hw3d
- generate the results below using the python convert_netCDF2png.py from /StylES/bout_interfaces/
Using Paraview and the .vts files in the /StylES/bout_interfaces/results/fields/ you can get the following animation of the vorticity field:
Animation vorticity field
You first need to generate the DNS data using BOUT++ and then you can train StyleGAN:
- checkout main version of BOUT++
- generate DNS data and save in a DATASET folder
- specify the DATASET path in the /StylES/parameters file
- make sure the BUFFER_SIZE is correctly set. For datasets larger than 50GB you need to change the flag cache to False in the /StylES/IO_functions.py file (and set the BUFFER_SIZE=1).
- set the parameter "randomize_noise = True"
- train styleGAN via python main.py.
Copyright (C): 2023 UKRI-STFC (Hartree Centre)
Author: Jony Castagna, Francesca Schiavello, Josh Williams
Licence: This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see GNU-licence.