# 研究目的 跳過 # 概要 / 流程 使用 CFD 軟體 `OpenFOAM` 來模擬翼剖面剪應力的分布,並使用 CFD 生成的剪應力分布數據來訓練 DNNs 網路模型,預期模型表現能達到一定程度的準確度 ```mermaid graph TB subgraph CFD cfd_input1[Freestream Velocity vectors] cfd_input2[Airfoils] cfd_process{CFD} cfd_input1 & cfd_input2 --> cfd_process --> cfd_output(Shear Stress distribution) cfd_output --> train_output[Training dataset] & test_output[Testing dataset] end ``` ```mermaid graph TB subgraph Model Training subgraph input dnn_input1[Training airfoils] & dnn_input2[Freestream Velocity vectors] end subgraph target dnn_target[Training shear stress] end train_output[Training dataset] train_output --> dnn_input1 & dnn_input2 & dnn_target dnn_input1 & dnn_input2 & dnn_target --> dnn_process{DNNs} dnn_process --> dnn_output((Trained Model)) end ``` ```mermaid graph LR subgraph Model Testing test_input[Test airfoils] --> dnn_output((Trained Model)) --> test_predict(Predictions of shear stress) test_predict & test_dataset[Testing dataset] --- compare --> output(Model Performence) end ``` # CFD 生成數據 > 使用 [Code](https://github.com/PGGO26/OpenFOAM-DataBase.git) > 參考 [Deep-Flow-Prediction](https://github.com/thunil/Deep-Flow-Prediction) - `OpneFOAM` case - 增加了紊流模型 ($k - \omega$ model) - `postprocess` 部分使用`wall shear stress`計算剪應力 > [Turbulent flow over NACA0012 airfoil (2D)](https://www.openfoam.com/documentation/guides/latest/doc/verification-validation-naca0012-airfoil-2d.html) ![](https://hackmd.io/_uploads/ry9Bv_WkT.png) 比對上面資料中的數據與 CFD case 執行的結果,確認現在使用的 CFD case 產生的數據有足夠的準確度 ![](https://hackmd.io/_uploads/SJvHEYbyT.png) - `outputprocess` 資料後處理使用剪應力係數分布與自由流速度分量與翼剖面外型作為輸出 - `key='input'` (1, 103, 1), npz - 自由流速度分量 - 翼剖面外型 - `key='cf'` (1, 101, 1), npz - 翼剖面剪應力係數分布 - `multiprocessing` (不是那麼重要,報告裡面可以不用寫,如果內容不夠再考慮) 再將 `OpenFOAM case` 加上紊流模型後,平均生成 1 筆數據需要約 30 分鐘 - 使用 python 函式庫 `multiprocessing` - 透過調整同時調用的 cpu 數量 - 將數據生成的時間壓縮到每 10 筆 60 分鐘 # DNNs 模型 > 參考 [CFD-based deep neural networks (DNN) model for predicting the hydrodynamics of fluidized beds](https://www.sciencedirect.com/science/article/pii/S2772508123000315#abs0001) CFD-based DNN model *** NOTED 上面的文章挺重要的 DNNs 的介紹可以參考他的,都整理好了 *** ## Training & Testing > https://zhuanlan.zhihu.com/p/100419971 > 幹 有夠坐牢 - 透過不斷嘗試不同的超參數組合並觀察模型的表現,先初步決定模型的架構,再透過調整其中的部分超參數來嘗試優化模型 - 模型的表現是透過比對對翼剖面 `ah94156` 的預測結果與 CFD 數據 - 使用 MAPE (平均絕對百分比誤差) 觀察每個模型在該翼剖面下的誤差來判斷模型的優劣 - 由於增加參數數量會影響模型 `loss` 收斂 - 會需要透過增加 `epochs` 的大小 - 提高 `learning rate` 來加快模型收斂 - 參考[論文](https://doi.org/10.1016/j.ast.2020.105949)中模型優化的方法 - 固定 `learning rate`, `batch_size` 等超參數 - 觀察模型架構在不同層數下的表現 - 先使用三層隱藏層並調整超參數來觀察模型表現 - 確定 `loss` 能收斂 - 調整每層的神經元數量 - 紀錄最佳表現的誤差及超參數設定 - 增加隱藏層數量到5層並調整超參數 - [模型優化紀錄](/G6UuMljgS2Gck3HdYwIDPg) ### 三層 `hidden layer` #### 固定每層神經元數量 ![](https://hackmd.io/_uploads/SJ8CrOrba.png) - `learning rate` : 0.0005 - `batch_size` : 16 - `epochs` : 3000 ![](https://hackmd.io/_uploads/SkBnL_rb6.png) ![](https://hackmd.io/_uploads/SJunLuB-a.png) - `MAPE` - 上表面 : 23.119 % - 下表面 : 23.221 % ### 五層 `hidden layer` #### 固定每層神經元數量 ![](https://hackmd.io/_uploads/BkgAi5rb6.png) - `batch_size` : 30 - `learning rate` : 0.002 - `epochs` : 6000 ![](https://hackmd.io/_uploads/BkRiqorbT.png) ![](https://hackmd.io/_uploads/Hk-35jBZT.png) - `MAPE` - 上表面 : 20.79 % - 下表面 : 22.01 %