Skip to content

Commit

Permalink
Merge pull request #406 from JX278/master
Browse files Browse the repository at this point in the history
add a test for torch
  • Loading branch information
JX278 authored Dec 26, 2023
2 parents b34b021 + 2274d56 commit 3966bb0
Show file tree
Hide file tree
Showing 34 changed files with 1,079 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CPU_inferencce_validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
conda create -n libcantera python=3.8
conda activate libcantera
conda install -c cantera libcantera-devel=2.6
conda install -c cantera cantera
conda install pytorch pybind11
conda install pkg-config
conda install --channel https://conda.anaconda.org/zhaofeng-shu33 easydict
Expand All @@ -51,8 +52,7 @@ jobs:
&& unzip flare_CH4_SandiaD_4D.zip
&& ls $PWD
&& cp -r flare_CH4_SandiaD_4D.tbl examples/dfLowMachFoam/2DSandiaD_flareFGM/
&& git clone https://github.com/intelligent-algorithm-team/intelligent-combustion.git
&& cp -r intelligent-combustion/DeePCK/Model/HE04_Hydrogen_ESH2_GMS_sub_20221101/ mechanisms/ && source ~/miniconda3/etc/profile.d/conda.sh && conda activate libcantera && source /opt/openfoam7/etc/bashrc
&& source ~/miniconda3/etc/profile.d/conda.sh && conda activate libcantera && source /opt/openfoam7/etc/bashrc
&& . configure.sh --use_pytorch&& source ./bashrc && . install.sh
&& cd test && ./Allrun && conda deactivate "

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

DeepFlame is a deep learning empowered computational fluid dynamics package for single or multiphase, laminar or turbulent, reacting flows at all speeds. It aims to provide an open-source platform to combine the individual strengths of [OpenFOAM](https://openfoam.org), [Cantera](https://cantera.org), and [PyTorch](https://pytorch.org/) libraries for deep learning assisted reacting flow simulations. It also has the scope to leverage the next-generation heterogenous supercomputing and AI acceleration infrastructures such as GPU and FPGA.

The deep learning algorithms and models used in the DeepFlame tutorial examples are developed and trained independently by our collaborators team – [Intelligent Combustion](https://github.com/intelligent-algorithm-team/intelligent-combustion.git). Please refer to their website for detailed information.
The neural network models used in the tutorial examples can be found at– [AIS Square](https://www.aissquare.com/). To run DeepFlame with DNN, download the DNN model [dfODENet](https://www.aissquare.com/models/detail?pageType=models&name=dfODENet_DNNmodel_V0.1&id=181) into the case folder you would like to run.

## Documentation
Detailed guide for installation and tutorials is available on [our documentation website](https://deepflame.deepmodeling.com).
Expand Down
16 changes: 2 additions & 14 deletions docs/source/qs/download_dnn_models.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
Download DNN Models
======================================
The neural network models used in the tutorial examples are indepentently trained
by our collaborators team – `Intelligent Combustion <https://github.com/intelligent-algorithm-team/intelligent-combustion.git>`_.
To run DeepFlame with DNN, first download the DeepCombustion repository into ``deepflame-dev/``:

.. code-block:: bash
cd $DF_ROOT
git clone https://github.com/intelligent-algorithm-team/intelligent-combustion.git.git
The neural network models used in the tutorial examples can be found at– `AIS Square <https://www.aissquare.com/>`_.
To run DeepFlame with DNN, download the DNN model `dfODENet <https://www.aissquare.com/models/detail?pageType=models&name=dfODENet_DNNmodel_V0.1&id=181>`_ into the case folder you would like to run.

Then copy the required DNN model into ``mechanisms/``, for example:

.. code-block:: bash
cp -r intelligent-combustion/DeePCK/Model/HE04_Hydrogen_ESH2_GMS_sub_20221101/ mechanisms/
.. Note:: Here ``HE04_Hydrogen_ESH2_GMS_sub_20221101`` is the default DNN model for all the tutorial cases in ``$DF_ROOT/examples/``.
5 changes: 2 additions & 3 deletions docs/source/qs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ Alternatively, one can `compile OpenFOAM-7 from source code <https://openfoam.or
conda create -n deepflame python=3.8
conda activate deepflame
conda install -c cantera libcantera-devel
conda install -c cantera libcantera-devel=2.6 cantera
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
conda install pybind11
conda install -c conda-forge easydict
conda install pybind11 pkg-config
.. Note:: Please go to PyTorch's official website to check your system compatability and choose the installation command line that is suitable for your platform. After installing torch, do check if torch.cuda.is_available() returns true to use GPU for DNN inference!

Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ file(COPY ./dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/postProcessing/sample/
file(COPY ./dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/postProcessing/sample/0.0001/data_T.xy DESTINATION 2DTGV/1)

file(COPY ./dfLowMachFoam/2DSandiaD_flareFGM/postProcessing/sample/1.1/data_T.xy DESTINATION 2DSandia)

file(COPY ./Tu500K-Phi1/fs DESTINATION flameSpeed)

enable_testing()

Expand Down
Binary file added test/Tu500K-Phi1/0/H.gz
Binary file not shown.
Binary file added test/Tu500K-Phi1/0/H2.gz
Binary file not shown.
Binary file added test/Tu500K-Phi1/0/H2O.gz
Binary file not shown.
Binary file added test/Tu500K-Phi1/0/H2O2.gz
Binary file not shown.
Binary file added test/Tu500K-Phi1/0/HO2.gz
Binary file not shown.
Binary file added test/Tu500K-Phi1/0/N2.gz
Binary file not shown.
Binary file added test/Tu500K-Phi1/0/O.gz
Binary file not shown.
Binary file added test/Tu500K-Phi1/0/O2.gz
Binary file not shown.
Binary file added test/Tu500K-Phi1/0/OH.gz
Binary file not shown.
Binary file added test/Tu500K-Phi1/0/T.gz
Binary file not shown.
40 changes: 40 additions & 0 deletions test/Tu500K-Phi1/0/U
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 1 -1 0 0 0 0];

internalField uniform (5.36 0 0);

boundaryField
{
boundary
{
type empty;
}
inlet
{
type fixedValue;
value uniform (5.36 0 0);
}
outlet
{
type zeroGradient;
}
}


// ************************************************************************* //
40 changes: 40 additions & 0 deletions test/Tu500K-Phi1/0/Ydefault
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object N2;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 0 0 0 0 0 0];

internalField uniform 0.0;

boundaryField
{
boundary
{
type empty;
}
inlet
{
type fixedValue;
value uniform 0.0;
}
outlet
{
type zeroGradient;
}
}


// ************************************************************************* //
41 changes: 41 additions & 0 deletions test/Tu500K-Phi1/0/p
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [1 -1 -2 0 0 0 0];

internalField uniform 101325;

boundaryField
{
boundary
{
type empty;
}
inlet
{
type zeroGradient;
}
outlet
{
type waveTransmissive;
gamma 1.4;
value uniform 101325;
}
}


// ************************************************************************* //
11 changes: 11 additions & 0 deletions test/Tu500K-Phi1/Allclean
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory

echo "Cleaning log.*"
rm log.*
echo "Cleaning processor*"
rm -r processor*
echo "Cleaning polyMesh/"
rm -r constant/polyMesh
echo "Cleaning last result"
rm 0.* -r
16 changes: 16 additions & 0 deletions test/Tu500K-Phi1/Allrun
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory

# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions

application=dfLowMachFoam

runApplication blockMesh
runApplication decomposePar
runApplication mpirun -np 4 --allow-run-as-root $application -parallel
reconstructPar
flameSpeed > log.fs
sed -n 's/.*flameSpeed = \([0-9]*\(\.[0-9]*\)\?\).*/\1/p' log.fs > fs


Loading

0 comments on commit 3966bb0

Please sign in to comment.