Skip to content

Commit

Permalink
Add TCI test (#217)
Browse files Browse the repository at this point in the history
* Update CMakeLists.txt

* Update Allrun

* Update corrtest.cpp

---------

Co-authored-by: xiao312 <[email protected]>
  • Loading branch information
JX278 and xiao312 authored Mar 10, 2023
1 parent 3b425fd commit 2305e99
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 23 deletions.
31 changes: 20 additions & 11 deletions .github/workflows/CPU_inferencce_validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: self-hosted
if: github.repository_owner == 'deepmodeling'
container:
image: ubuntu-20.04
image: ubuntu:20.04
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -26,36 +26,45 @@ jobs:
sudo apt-get update
export DEBIAN_FRONTEND=noninteractive
apt-get -y install openfoam7
git clone https://github.com/deepmodeling/deepflame-dev.git
cd deepflame-dev
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
wget https://mirrors.edge.kernel.org/ubuntu/pool/main/libf/libffi/libffi7_3.3-4_amd64.deb
bash Miniconda3-latest-Linux-x86_64.sh -b
. ~/miniconda3/etc/profile.d/conda.sh
conda create -n libcantera python=3.8
conda activate libcantera
conda install -c cantera libcantera-devel
conda install pytorch
conda install pybind11
conda install --channel https://conda.anaconda.org/zhaofeng-shu33 easydict
cd /github/home/miniconda3/envs/libcantera/lib
conda install pytorch pybind11
conda install --channel https://conda.anaconda.org/zhaofeng-shu33 easydict
git clone https://github.com/deepmodeling/deepflame-dev.git
cd deepflame-dev
- name: build and validation with CPU inference
env:
OMPI_ALLOW_RUN_AS_ROOT: 1
OMPI_ALLOW_RUN_AS_ROOT_CONFIRM: 1
OMPI_MCA_btl_vader_single_copy_mechanism: none
run:
/bin/bash -c "git clone https://github.com/deepcombustion/deepcombustion.git && cp -r deepcombustion/DeePCK/Model/HE04_Hydrogen_ESH2_GMS_sub_20221101/ mechanisms/ && source ~/miniconda3/etc/profile.d/conda.sh && conda activate libcantera && source /opt/openfoam7/etc/bashrc
/bin/bash -c " echo $PWD && ls $PWD
&& wget https://github.com/JX278/DeepFlame-flareFGM-table/raw/main/flareFGM_Table_Download.zip
&& unzip flareFGM_Table_Download.zip
&& ls $PWD
&& ls flareFGM_Table_Download
&& cp -r flareFGM_Table_Download/SandiaD/flare.tbl examples/dfLowMachFoam/2DSandiaD_flareFGM/
&& git clone https://github.com/deepcombustion/deepcombustion.git
&& cp -r deepcombustion/DeePCK/Model/HE04_Hydrogen_ESH2_GMS_sub_20221101/ mechanisms/ && 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 "

- name: test
run: |
cd test
cmake -B build
cmake --build build
cd build
ctest
ctest



2 changes: 1 addition & 1 deletion examples/dfHighSpeedFoam/oneD_detonationH2/Allrun
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ cp -r 0_orig/ 0/
runApplication blockMesh
runApplication setFields
runApplication decomposePar
runApplication mpirun --oversubscribe -np 8 $application -parallel
runApplication mpirun -np 8 $application -parallel
Empty file modified examples/dfLowMachFoam/2DSandiaD_flareFGM/Allclean
100644 → 100755
Empty file.
4 changes: 3 additions & 1 deletion examples/dfLowMachFoam/2DSandiaD_flareFGM/Allrun
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ runApplication blockMesh

runApplication decomposePar -force

runParallel $application
mpirun --oversubscribe -np 8 dfLowMachFoam -parallel

./postProcess



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ loadbalancing
{
active true;
log false;
algorithm allAverage;//headTail;
}


Expand Down
6 changes: 6 additions & 0 deletions examples/dfLowMachFoam/2DSandiaD_flareFGM/postProcess
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory

reconstructPar -time 0.3
postProcess -func sample -time 0.3

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ deltaT 1e-05;

writeControl runTime;

writeInterval 1e-3;
writeInterval 0.3;

purgeWrite 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ FoamFile
object decomposeParDict;
}

numberOfSubdomains 4;
numberOfSubdomains 8;

method scotch;

Expand Down
38 changes: 38 additions & 0 deletions examples/dfLowMachFoam/2DSandiaD_flareFGM/system/sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*--------------------------------*- C++ -*----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 7
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
FoamFile
{
format ascii;
class dictionary;
location "system";
object sample;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

type sets;
libs ("libsampling.so");

interpolationScheme cellPoint;

setFormat raw;

sets
(
data
{
type lineUniform;
axis x;
start (0 0 0.1);
end (0.03 0 0.1);
nPoints 7;
}
);

fields ( T );

// ************************************************************************* //
4 changes: 3 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ FetchContent_MakeAvailable(googletest)

file(COPY ./pytorchIntegrator/postProcessing/probes/0/T DESTINATION 0DH2)

file(COPY ./oneD_detonationH2/postProcessing/minMax/0/fieldMinMax.dat DESTINATION 1Ddetonation)
#file(COPY ./oneD_detonationH2/postProcessing/minMax/0/fieldMinMax.dat DESTINATION 1Ddetonation)
file(COPY ./dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/postProcessing/sample/0.0005/data_T.xy DESTINATION 2DTGV/5)
file(COPY ./dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/postProcessing/sample/0.0004/data_T.xy DESTINATION 2DTGV/4)
file(COPY ./dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/postProcessing/sample/0.0003/data_T.xy DESTINATION 2DTGV/3)
file(COPY ./dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/postProcessing/sample/0.0002/data_T.xy DESTINATION 2DTGV/2)
file(COPY ./dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/postProcessing/sample/0.0001/data_T.xy DESTINATION 2DTGV/1)

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


enable_testing()

Expand Down
60 changes: 54 additions & 6 deletions test/corrtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ float readmidTH2();
float readmaxTH2();

float readTGV(int k, string file);
float readHighSpeed();
float v = readHighSpeed();
//float readHighSpeed();
//float v = readHighSpeed();

float H2maxT = readmaxTH2();
float H2midT = readmidTH2();
Expand All @@ -24,9 +24,19 @@ float TGV300 = readTGV(1064,"2DTGV/3/data_T.xy");
float TGV400 = readTGV(1098,"2DTGV/4/data_T.xy");


float readSandia(int k, string file);
float T1 = readSandia(1,"2DSandia/data_T.xy");
float T2 = readSandia(2,"2DSandia/data_T.xy");
float T3 = readSandia(3,"2DSandia/data_T.xy");
float T4 = readSandia(4,"2DSandia/data_T.xy");
float T5 = readSandia(5,"2DSandia/data_T.xy");
float T6 = readSandia(6,"2DSandia/data_T.xy");

TEST(corrtest,df0DFoam_H2){
EXPECT_FLOAT_EQ(H2maxT,2588.48); // compare the maximum temperature of H2 case
EXPECT_FLOAT_EQ(H2midT,1021.41); // compare the temperature of H2 case at the maximum gradient when t = 0.000245s
//EXPECT_FLOAT_EQ(H2maxT,2586.21); // compare the maximum temperature of H2 case
//EXPECT_FLOAT_EQ(H2midT,1020.71); // compare the temperature of H2 case at the maximum gradient when t = 0.000245s
}


Expand All @@ -39,12 +49,20 @@ TEST(corrtest,dfLowMachFoam_TGV){
EXPECT_FLOAT_EQ(TGV100,364.018);
}

TEST(corrtest,dfHighSpeedFoam){
EXPECT_NEAR(v,1979.33,19.79); // within 1% of the theroetical value
//TEST(corrtest,dfHighSpeedFoam){
// EXPECT_NEAR(v,1979.33,19.79); // within 1% of the theroetical value
//}

TEST(corrtest,2DSandia){
EXPECT_FLOAT_EQ(T1,762.5418507);
EXPECT_FLOAT_EQ(T2,1155.163112);
EXPECT_FLOAT_EQ(T3,1570.283118);
EXPECT_FLOAT_EQ(T4,1225.380702);
EXPECT_FLOAT_EQ(T5,651.8790951);
EXPECT_FLOAT_EQ(T6,458.1680004);

}



float readmaxTH2(){
float a;
string inFileName = "0DH2/T" ;
Expand Down Expand Up @@ -170,3 +188,33 @@ float readHighSpeed(){

return slope;
}




float readSandia(int k, string file){

float T,x;
float b;
int i = 0;

string inFileName = file;
ifstream inFile;
inFile.open(inFileName.c_str());

if (inFile.is_open())
{
while (inFile >> x >> T){
i ++ ;
if (i == k){
b = T;
}
}

}
else { //Error message
cerr << "Can't find input file " << inFileName << endl;
}

return b;
}
1 change: 1 addition & 0 deletions test/dfLowMachFoam/2DSandiaD_flareFGM
1 change: 0 additions & 1 deletion test/oneD_detonationH2

This file was deleted.

0 comments on commit 2305e99

Please sign in to comment.