AI Shock Sensor for Discontinuous Galerkin Higher-order Approximation
Creators: name: Zhao, Jianai
Publisher: name: Zenodo
Year: 2024

description: This serves as a README on how to use the developed AI sensor for shock detection in the current BoSSS Solver, using 2nd and 3rd polynomial degrees. The AI Shock Sensor algorithm was developed by Jianai Zhao as part of his master’s thesis from May 2024 to November 2024 under the guidance of Dr. Florian Kummer at TU Darmstadt FDY.

If you have further questions regarding the overall methodology, please do not hesitate to contact Jianai at Jianai.zhao@stud.tu-darmstadt.de. For logistical or BoSSS solver inquiries, please contact Dr. Kummer at kummer@fdy.tu-darmstadt.de.

There are two main Jupyter notebooks used to develop the AI Sensor with Discontinuous Galerkin (DG) methods for 2nd and 3rd polynomial degrees. The reason for having two separate files is that the number of features (vector length) corresponds to the degrees of freedom associated with each polynomial degree. The current model uses all degrees of freedom available to keep the AI model physics-informed. The two main files are DG2Main.ipynb and DG3Main.ipynb, primarily used for equally spaced selections of 10 timesteps among all saved timesteps. In these files, you will find commands to load saved sessions from Computational Fluid Dynamics simulations, generate plots of selected timesteps on VisIt 3.2.2, perform binarization (manual labeling of 0 or 1 by setting a threshold of 10^-6), observe shock distribution, conduct Spearman feature analysis, perform knowledge distillation for the ANN, and use GBDT models, as well as save .zip files. The AI sensor was developed using session `d93661db-ca86-4fcd-9da4-03580e603cc5` for DG2 and `e687cf33-a507-40ee-a0c3-6aa0d49b6082` for DG3.

The two main scripts used to train the GBDT on all timesteps and later save the models as .zip files are DG2MainALL.ipynb and DG3MainALL.ipynb. These files contain the GBDT model and save it as a .zip file. After loading all timesteps, the models are saved as PerssonAI2_All.zip and PerssonAI3_All.zip. Before properly using the AI Sensor, ensure these zip files are in the working folder. Switching between DG2 and DG3 cases in the CNSFieldSet.cs file is hard-coded; use `vectortype(24)` for DG2 with PerssonAI2_All.zip and `vectortype(40)` for DG3 with PerssonAI3_All.zip. For DG2, all values of 24 in CNSFieldSet.cs should be replaced with 40 to run CFD using DG3. Save changes and publish before running on the HPC cluster. All other steps are identical to those in the current BoSSS solver. The AI sensor-generated DMR results are `89901299-1941-4fc3-bfcb-fbd15ea2b060` for DG2 and `ebe9206a3a6a-4620-bea7-009ecda9718e` for DG3.

Most quantitative plots are generated with the script PlotMain_MT.ipynb, with data stored in .txt files copied from the DG2Main.ipynb, DG3Main.ipynb, DG2MainALL.ipynb, and DG3MainALL.ipynb scripts. The ProAt folder contains four .txt files storing density changes in coordinate (1, 0.4) across all simulated timesteps. All error analysis figures are generated from the following files: dg2plot.txt, dg2AIplot.txt, dg3plot.txt, and dg3AIplot.txt. Shock distribution plots use dg2vis.txt and dg3vis.txt, located in the distribution folder. For 10 selected timesteps, Lossdg2.txt and Lossdg3.txt are in the results folder. These files are used to generate ROC, AUC, Confusion Matrix, and training loss figures. Correlation plot results are directly copied from the Jupyter notebook script without additional data loading.

In summary, this research generated a total of four session results. Using session `d93661db-ca86-4fcd9da4-03580e603cc5`, the GBDT was trained and saved as PerssonAI2_All.zip. After running again, session `89901299-1941-4fc3-bfcb-fbd15ea2b060` was generated as the updated AI sensor for DG2. Similarly, session `e687cf33-a507-40ee-a0c3-6aa0d49b6082` was used to train the GBDT and saved as PerssonAI3_All.zip. Another run generated session `ebe9206a-3a6a-4620-bea7-009ecda9718e` as the updated AI sensor for DG3.