The objective was to implement a data driven and physics driven neural network for inferring potential flow given sparse data points from the bulk. This was achieved by integrating inbuilt functions of the PyTorch C++ API with OpenFOAM.
- Tomislav Maric
- Andre Weiner
For the OpenFOAM and libtorch installation check README.md
For the other python scripts used here in the repository:
python >= 3.7
requirements.txt
- for Bayesian Optimisation
-
Copy the
pinnFoam
application into thepinnPotentialFoam
application, rename it + compile it.- Rename the
pinnFoam
topinnPotentialFoam
. - Rename all
pinnFoams
in the code topinnPotentialFoam
.grep -r pinnFoam
- Rename the
-
Edit
createFields.H
and read the potientialFoam fields Phi and U. -
Adapt the Neural Network (NN)
$\Psi(x,y,z,\theta)$ to map a point in space$\boldsymbol{x} =(x,y,z)$ to the output vector$O=(\Phi,U_x, U_y, U_z)$ , with$\boldsymbol{U}=(U_x, U_y, U_z)$ being the potential-flow velocity, and$\Phi$ the velocity-potential. -
Remove the existing PiNN residual MSE and train the NN as a Multilayer Perceptron on the Phi and U fields computed by OpenFOAM’s
potentialFoam
solver. -
Extend the NN into a PiNN for potential flow, by programming the potential-flow PDE residual
This means:
- Implementing the Laplace operator for
$\Phi$ . - Implementing the divergence operator for
$\boldsymbol{U}$ . - Combining both into the residual MSE, and summing the residual MSE with the data MSE.
- Implementing the Laplace operator for
physics-based-dl-solution-03-4/
---applications/
---pinnFoam
---pinnFoamSetSphere
---dnnPotentialFoam
---pinnPotentialFoam
---run/
---Cylinder
---dnnCylinder
---pinnCylinder
---dnnCylinderHOPT_grid
---dnnCylinderHOPT_bayes
---pinnCylinderHOPT_grid
---pinnCylinderHOPT_bayes
---README.md
---Allrun
---Allmake
---Allclean
---Presentation.pdf
---ProjectReport.pdf
According to the physics of the problem and solver, there has been changes made in different dictionaries.
Bayesian Optimization has been implemented to the solver.
Follow this procedure to run the code and see the results.
open the terminal and navigate Cylinder testcase and execute the command below:
cd run/unit_box_domain/cylinder
./Allclean
./Allrun
pinnPotentialFoam
paraFoam
CPU time and accuracy of using the NN as the MLP without the PiNN residual and the PiNN approach for approximating Psi ,u is being compared.