diff --git a/.github/workflows/torch_build.yml b/.github/workflows/CPU_inferencce_validation.yml similarity index 78% rename from .github/workflows/torch_build.yml rename to .github/workflows/CPU_inferencce_validation.yml index 816258a3..c1efbc71 100644 --- a/.github/workflows/torch_build.yml +++ b/.github/workflows/CPU_inferencce_validation.yml @@ -1,4 +1,4 @@ -name: build with torch +name: Build and Validation with CPU inference on: push: branches: @@ -8,7 +8,8 @@ on: - master jobs: gpu_build: - runs-on: ubuntu-latest + runs-on: self-hosted + if: github.repository_owner == 'deepmodeling' container: image: ubuntu:20.04 steps: @@ -35,15 +36,16 @@ jobs: 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 ln -s libmkl_rt.so.1 libmkl_rt.so.2 - - name: build_notorch + - 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 "source ~/miniconda3/etc/profile.d/conda.sh && conda activate libcantera && source /opt/openfoam7/etc/bashrc && . install.sh --use_pytorch" + /bin/bash -c "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 && cmake -B build && cmake --build build && cd build && ctest" diff --git a/.github/workflows/cvode_validate.yml b/.github/workflows/cvode_validate.yml deleted file mode 100644 index 090af448..00000000 --- a/.github/workflows/cvode_validate.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: Build and Validation -on: - push: - branches: - - master - pull_request: - branches: - - master -jobs: - gpu_build: - runs-on: self-hosted - if: github.repository_owner == 'deepmodeling' - container: - image: ubuntu:20.04 - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: install dependencies - env: - DEBIAN_FRONTEND: noninteractive - run: | - apt-get update - apt-get install -y sudo wget unzip git software-properties-common make cmake g++ mpich openmpi-bin libopenmpi-dev libscalapack-mpi-dev vim - sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -" - sudo add-apt-repository http://dl.openfoam.org/ubuntu - 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 - sh 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 - - - name: build_notorch - 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 "source ~/miniconda3/etc/profile.d/conda.sh && conda activate libcantera && source /opt/openfoam7/etc/bashrc && . install.sh && cd test && ./Allrun && cmake -B build && cmake --build build && cd build && ctest" - - \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8cbd18ed..c614d0b0 100644 --- a/.gitignore +++ b/.gitignore @@ -45,7 +45,7 @@ build/ *.tar *.tgz *.gtgz -*.pt + cantera_build/ log.* @@ -54,7 +54,7 @@ log.* dynamicCode/ postProcessing/ *.out -*.json + processor*/ chemkin/ *.foam diff --git a/Allwclean b/Allwclean old mode 100644 new mode 100755 diff --git a/mechanisms/H2/pytorchDNN/ESH2-sub1.json b/mechanisms/H2/pytorchDNN/ESH2-sub1.json new file mode 100644 index 00000000..feaf5111 --- /dev/null +++ b/mechanisms/H2/pytorchDNN/ESH2-sub1.json @@ -0,0 +1,85 @@ +{ + "seed":20, + "mech_path":"/home/yaojunjie/data/mechanism/ES80_H2-7-16.yaml", + "shuffle":true, + "batch_size":1024, + "valid_batch_size":8192, + "train_size":10735978, + "valid_size":1192887, + "valid_ratio":0.1, + "prefetch":10, + "num_workers":16, + "pin_memory":true, + "power_transform":0.1, + "delta_t":1e-06, + "dim":9, + "layers":[ + 9, + 1600, + 800, + 400, + 9 + ], + "net_type":"fc", + "actfun":"CustomGELU", + "max_epoch":5000, + "epoch_decay":2500, + "learnrate":0.0001, + "lr_decay_rate":0.1, + "batch_grow_rate":128, + "lossfun":"L1", + "optim":"Adam", + "device":"cuda:0", + "n_gpu":8, + "use_DP":false, + "use_DDP":true, + "local_rank":-1, + "world_size":8, + "backend":"nccl", + "description":"test", + "current_time":"2022-10-28 00:02:52", + "Xmu":[ + 956.4666683951323, + 1.2621251609602075, + -8.482865855078037, + -8.60195200775564, + -7.5687249938092975, + -8.739604352829021, + -3.0365348658864555, + -4.044646973729736, + -0.12868046894653598 + ], + "Xstd":[ + 144.56082979138094, + 0.4316114858005481, + 1.3421800304159297, + 1.3271564927376922, + 1.964747648182199, + 1.1993472911833807, + 1.2594695379275647, + 1.3518816605077604, + 0.17392016053354714 + ], + "Ymu":[ + 115735.41509559377, + 4.2646672113712347e-13, + 8901.112679962635, + 27135.624769093312, + 30141.97503208172, + 24712.755148584696, + -372.9651472886253, + -493.34322699725413, + -4.31138850114707e-12 + ], + "Ystd":[ + 115735.41509559377, + 1.1513875522375139e-10, + 8901.112679962635, + 27135.624769093312, + 30141.97503208172, + 24712.755148584696, + 372.96514728862553, + 493.3432269972544, + 9.409165181242247e-11 + ] +} \ No newline at end of file diff --git a/mechanisms/H2/pytorchDNN/ESH2-sub2.json b/mechanisms/H2/pytorchDNN/ESH2-sub2.json new file mode 100644 index 00000000..bc78b10b --- /dev/null +++ b/mechanisms/H2/pytorchDNN/ESH2-sub2.json @@ -0,0 +1,85 @@ +{ + "seed": 2022, + "mech_path": "Chem/ESH2.yaml", + "shuffle": true, + "batch_size": 1024, + "valid_batch_size": 8192, + "train_size": 5792898, + "valid_size": 643656, + "valid_ratio": 0.1, + "prefetch": 10, + "num_workers": 16, + "pin_memory": true, + "power_transform": 0.1, + "delta_t": 1e-06, + "dim": 9, + "layers": [ + 9, + 1600, + 800, + 400, + 9 + ], + "net_type": "fc", + "actfun": "CustomGELU", + "max_epoch": 5000, + "epoch_decay": 2500, + "learnrate": 0.0001, + "lr_decay_rate": 0.1, + "batch_grow_rate": 128, + "lossfun": "L1", + "optim": "Adam", + "device": "cuda:6", + "n_gpu": 8, + "use_DP": false, + "use_DDP": false, + "local_rank": -1, + "world_size": 1, + "backend": "nccl", + "description": "test", + "current_time": "2022-10-19 17:09:44", + "Xmu":[ + 1933.118541482812, + 1.2327983023706526, + -5.705591538151852, + -6.446971251373195, + -4.169802387800032, + -6.1200334699867165, + -4.266343396329115, + -2.6007437468608616, + -0.4049762774428252 + ], + "Xstd":[ + 716.6568054751183, + 0.43268544913281914, + 2.0857655247141387, + 2.168997234412133, + 2.707064105162402, + 2.2681157746245897, + 2.221785173612795, + 1.5510851480805254, + 0.30283229364455927 + ], + "Ymu":[ + 6381847.837202463, + 4.751063937334583e-14, + 175072.98234441387, + 125434.41067566245, + 285397.9376620931, + 172924.8443087139, + -97451.53428068386, + -7160.953630852251, + -9.791262408691773e-10 + ], + "Ystd":[ + 6396799.801910002, + 1.3523423408265769e-10, + 179830.51132577812, + 256152.83860126554, + 285811.9455262339, + 263600.5448448552, + 98110.53711881173, + 11752.979335965118, + 4.0735353885293555e-09 + ] +} \ No newline at end of file diff --git a/mechanisms/H2/pytorchDNN/ESH2-sub3.json b/mechanisms/H2/pytorchDNN/ESH2-sub3.json new file mode 100644 index 00000000..1ed66ee9 --- /dev/null +++ b/mechanisms/H2/pytorchDNN/ESH2-sub3.json @@ -0,0 +1,85 @@ +{ + "seed":20, + "mech_path":"/home/yaojunjie/data/mechanism/ES80_H2-7-16.yaml", + "shuffle":true, + "batch_size":1024, + "valid_batch_size":8192, + "train_size":2392228, + "valid_size":265804, + "valid_ratio":0.1, + "prefetch":10, + "num_workers":16, + "pin_memory":true, + "power_transform":0.1, + "delta_t":1e-06, + "dim":9, + "layers":[ + 9, + 1600, + 800, + 400, + 9 + ], + "net_type":"fc", + "actfun":"CustomGELU", + "max_epoch":5000, + "epoch_decay":2500, + "learnrate":0.0001, + "lr_decay_rate":0.1, + "batch_grow_rate":128, + "lossfun":"L1", + "optim":"Adam", + "device":"cuda:0", + "n_gpu":6, + "use_DP":false, + "use_DDP":true, + "local_rank":-1, + "world_size":6, + "backend":"nccl", + "description":"test", + "current_time":"2022-10-27 15:06:21", + "Xmu":[ + 2717.141719004927, + 1.2871371577864235, + -5.240181052513087, + -4.8947914078286345, + -3.117070179161789, + -4.346362771443917, + -4.657258124450032, + -4.537442872141596, + -0.11656950757756744 + ], + "Xstd":[ + 141.48030419772115, + 0.4281422992061657, + 0.6561518672685264, + 0.9820405777881894, + 1.0442969662425572, + 0.7554583907448359, + 1.7144519099198097, + 1.1299391466695952, + 0.15743252221610685 + ], + "Ymu":[ + 592947.6742955892, + 5.1584233576272535e-14, + -611.0636921032669, + -915.1244682112174, + 519.5930550881994, + -11.949500174512165, + -2660.9187297995336, + 159.56360614662788, + -7.136459430073843e-11 + ], + "Ystd":[ + 592947.6742955892, + 1.2527170559513018e-10, + 611.0636921032669, + 915.1244682112174, + 519.5930550881994, + 342.3100987934528, + 2754.8463649064784, + 313.3717647966624, + 2.463374792192512e-10 + ] +} \ No newline at end of file diff --git a/src/dfChemistryModel/dfChemistryModel.H b/src/dfChemistryModel/dfChemistryModel.H index 60a006df..a0aafa34 100644 --- a/src/dfChemistryModel/dfChemistryModel.H +++ b/src/dfChemistryModel/dfChemistryModel.H @@ -181,7 +181,7 @@ public IOdictionary scalar Qdotact2_; scalar Tact3_; scalar Qdotact3_; - int coresPerGPU; + int coresPerGPU_; // profiling double time_allsolve_; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 611016f3..f82bfde7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -12,8 +12,8 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) FetchContent_MakeAvailable(googletest) -file(COPY ./df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/postProcessing/probes/0/T DESTINATION 0DH2) -file(COPY ./df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/postProcessing/probes/0/T DESTINATION 0DCH4) +file(COPY ./df0DFoam/postProcessing/probes/0/T DESTINATION 0DH2) + file(COPY ./dfHighSpeedFoam/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) diff --git a/test/corrtest.cpp b/test/corrtest.cpp index 331d5f06..a2b68593 100644 --- a/test/corrtest.cpp +++ b/test/corrtest.cpp @@ -8,16 +8,15 @@ using namespace std; float readmidTH2(); float readmaxTH2(); -float readmidTCH4(); -float readmaxTCH4(); + float readTGV(int k, string file); float readHighSpeed(); float v = readHighSpeed(); float H2maxT = readmaxTH2(); float H2midT = readmidTH2(); -float CH4maxT = readmaxTCH4(); -float CH4midT = readmidTCH4(); + + float TGV500 = readTGV(806,"2DTGV/5/data_T.xy"); float TGV100 = readTGV(1100,"2DTGV/1/data_T.xy"); float TGV200 = readTGV(1064,"2DTGV/2/data_T.xy"); @@ -26,21 +25,18 @@ float TGV400 = readTGV(1098,"2DTGV/4/data_T.xy"); TEST(corrtest,df0DFoam_H2){ - EXPECT_FLOAT_EQ(H2maxT,2588.88); // compare the maximum temperature of H2 case - EXPECT_FLOAT_EQ(H2midT,1298.12); // compare the temperature of H2 case at the maximum gradient when t = 0.000245s + 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 } -TEST(corrtest,df0DFoam_CH4){ - EXPECT_FLOAT_EQ(CH4maxT,2816.82); // compare the maximum temperature of CH4 case - EXPECT_FLOAT_EQ(CH4midT,2410.39); // compare the temperature of CH4 case at the maximum gradient when t = 0.000249s -} + TEST(corrtest,dfLowMachFoam_TGV){ EXPECT_FLOAT_EQ(TGV500,1533.48); // compare the maximum temperature along y direction in 2D TGV after 500 time steps EXPECT_FLOAT_EQ(TGV400,1296.99); // ..........400 time steps - EXPECT_FLOAT_EQ(TGV300,878.071); - EXPECT_FLOAT_EQ(TGV200,545.819); - EXPECT_FLOAT_EQ(TGV100,364.017); + EXPECT_FLOAT_EQ(TGV300,878.07); + EXPECT_FLOAT_EQ(TGV200,545.818); + EXPECT_FLOAT_EQ(TGV100,364.018); } TEST(corrtest,dfHighSpeedFoam){ @@ -69,25 +65,7 @@ float readmaxTH2(){ return a; } -float readmaxTCH4(){ - float a; - string inFileName = "0DCH4/T" ; - ifstream inFile; - inFile.open(inFileName.c_str()); - if (inFile.is_open()) - { - inFile.ignore(80); - while (inFile >> a){ - } - - } - else { //Error message - cerr << "Can't find input file " << inFileName << endl; - } - cout << a << endl; - return a; -} float readmidTH2(){ @@ -118,33 +96,6 @@ float readmidTH2(){ } -float readmidTCH4(){ - - float a; - float b; - int i = 0; - - string inFileName = "0DCH4/T"; - ifstream inFile; - inFile.open(inFileName.c_str()); - - if (inFile.is_open()) - { - inFile.ignore(80); - while (inFile >> a){ - i ++ ; - if (i == 498 ){ // t = 0.000249 dt = 84.165, maximum gradient - b = a; - } - } - - } - else { //Error message - cerr << "Can't find input file " << inFileName << endl; - } - - return b; -} float readTGV(int k, string file){ diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/H2.gz b/test/df0DFoam/0/H2.gz similarity index 100% rename from test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/H2.gz rename to test/df0DFoam/0/H2.gz diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/N2.gz b/test/df0DFoam/0/N2.gz similarity index 100% rename from test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/N2.gz rename to test/df0DFoam/0/N2.gz diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/O2.gz b/test/df0DFoam/0/O2.gz similarity index 100% rename from test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/O2.gz rename to test/df0DFoam/0/O2.gz diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/T.gz b/test/df0DFoam/0/T.gz similarity index 100% rename from test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/T.gz rename to test/df0DFoam/0/T.gz diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/U.gz b/test/df0DFoam/0/U.gz similarity index 100% rename from test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/U.gz rename to test/df0DFoam/0/U.gz diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/Ydefault.gz b/test/df0DFoam/0/Ydefault.gz similarity index 100% rename from test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/Ydefault.gz rename to test/df0DFoam/0/Ydefault.gz diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/alphat.gz b/test/df0DFoam/0/alphat.gz similarity index 100% rename from test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/alphat.gz rename to test/df0DFoam/0/alphat.gz diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/p.gz b/test/df0DFoam/0/p.gz similarity index 100% rename from test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/p.gz rename to test/df0DFoam/0/p.gz diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/Allclean b/test/df0DFoam/Allclean similarity index 71% rename from test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/Allclean rename to test/df0DFoam/Allclean index cfd3b14e..540fdc29 100755 --- a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/Allclean +++ b/test/df0DFoam/Allclean @@ -1,9 +1,11 @@ #!/bin/sh cd ${0%/*} || exit 1 # Run from this directory -echo "Cleaning log.*" +echo "Cleaning logfiles*" rm log.* echo "Cleaning polyMesh/" rm -r constant/polyMesh echo "Cleaning postProcessing/" rm -r postProcessing +echo "Cleaning processor/" +rm -rf processor* \ No newline at end of file diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/Allrun b/test/df0DFoam/Allrun similarity index 69% rename from test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/Allrun rename to test/df0DFoam/Allrun index d060ec7b..e135a676 100755 --- a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/Allrun +++ b/test/df0DFoam/Allrun @@ -7,4 +7,5 @@ cd ${0%/*} || exit 1 # Run from this directory application=df0DFoam runApplication blockMesh -runApplication $application +runApplication decomposePar +runApplication mpirun -np 4 $application -parallel diff --git a/test/df0DFoam/ES80_H2-7-16.yaml b/test/df0DFoam/ES80_H2-7-16.yaml new file mode 120000 index 00000000..c2b0ba14 --- /dev/null +++ b/test/df0DFoam/ES80_H2-7-16.yaml @@ -0,0 +1 @@ +../../mechanisms/H2/ES80_H2-7-16.yaml \ No newline at end of file diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/constant/CanteraTorchProperties b/test/df0DFoam/constant/CanteraTorchProperties similarity index 71% rename from test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/constant/CanteraTorchProperties rename to test/df0DFoam/constant/CanteraTorchProperties index 52358492..13d5fc9a 100644 --- a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/constant/CanteraTorchProperties +++ b/test/df0DFoam/constant/CanteraTorchProperties @@ -11,27 +11,38 @@ FoamFile format ascii; class dictionary; location "constant"; - object thermophysicalProperties; + object chemistryProperties; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + chemistry on; CanteraMechanismFile "ES80_H2-7-16.yaml"; -transportModel "UnityLewis"; +transportModel "Mix";//"UnityLewis"; odeCoeffs { - // "relTol" 1e-6; - // "absTol" 1e-10; + "relTol" 1e-15; + "absTol" 1e-24; } inertSpecie "N2"; zeroDReactor { - constantProperty "pressure"; + constantProperty "pressure";//cvorcp "UV"; +} + +TorchSettings +{ + torch on; + GPU off; + log on; + torchModel1 "ESH2-sub1.pt"; + torchModel2 "ESH2-sub2.pt"; + torchModel3 "ESH2-sub3.pt"; + coresPerGPU 4; } loadbalancing { active false; //log true; } - // ************************************************************************* // diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/constant/thermophysicalProperties b/test/df0DFoam/constant/thermophysicalProperties similarity index 100% rename from test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/constant/thermophysicalProperties rename to test/df0DFoam/constant/thermophysicalProperties diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/constant/turbulenceProperties b/test/df0DFoam/constant/turbulenceProperties similarity index 100% rename from test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/constant/turbulenceProperties rename to test/df0DFoam/constant/turbulenceProperties diff --git a/test/df0DFoam/inference.py b/test/df0DFoam/inference.py new file mode 100644 index 00000000..6b0e5780 --- /dev/null +++ b/test/df0DFoam/inference.py @@ -0,0 +1,209 @@ +from builtins import Exception, print +from calendar import prcal +import torch +import numpy as np +import math +import time +import json +import os +from easydict import EasyDict as edict +import torch.profiler +import os + +torch.set_printoptions(precision=10) + + +class MyGELU(torch.nn.Module): + def __init__(self): + super(MyGELU, self).__init__() + self.torch_PI = 3.1415926536 + + def forward(self, x): + return 0.5 * x * (1 + torch.tanh( + math.sqrt(2 / self.torch_PI) * (x + 0.044715 * torch.pow(x, 3)))) + + +def json2Parser(json_path): + """load json and return parser-like object""" + with open(json_path, 'r') as f: + args = json.load(f) + return edict(args) + + +class Net(torch.nn.Module): + def __init__(self): + super(Net, self).__init__() + neurons = layers + self.depth = len(neurons) - 1 + self.actfun = MyGELU() + self.layers = [] + for i in range(self.depth - 1): + self.layers.append(torch.nn.Linear(neurons[i], neurons[i + 1])) + self.layers.append(self.actfun) + self.layers.append(torch.nn.Linear(neurons[-2], neurons[-1])) # last layer + self.fc = torch.nn.Sequential(*self.layers) + + def forward(self, x): + x = self.fc(x) + return x +try: + #load variables from constant/CanteraTorchProperties + path_r = r"./constant/CanteraTorchProperties" + with open(path_r, "r") as f: + data = f.read() + i = data.index('torchModel1') + a = data.index('"',i) + b = data.index('.',a+1) + moduleName1 = data[a+1:b] + + i = data.index('torchModel2') + a = data.index('"',i) + b = data.index('.',a+1) + moduleName2 = data[a+1:b] + + i = data.index('torchModel3') + a = data.index('"',i) + b = data.index('.',a+1) + moduleName3 = data[a+1:b] + + i = data.index('GPU') + a = data.index(';', i) + b = data.rfind(' ',i+1,a) + switch_GPU = data[b+1:a] + + #load OpenFOAM switch + switch_on = ["true", "True", "on", "yes", "y", "t", "any"] + switch_off = ["false", "False", "off", "no", "n", "f", "none"] + if switch_GPU in switch_on: + device = torch.device("cuda") + device_ids = range(torch.cuda.device_count()) + elif switch_GPU in switch_off: + device = torch.device("cpu") + device_ids = [0] + else: + print("invalid setting!") + os._exit(0) + + + + #glbal variable will only init once when called interperter + #load parameters from json + setting0 = json2Parser(str("pytorchDNN/"+moduleName1+".json")) + setting1 = json2Parser(str("pytorchDNN/"+moduleName2+".json")) + setting2 = json2Parser(str("pytorchDNN/"+moduleName3+".json")) + + lamda = setting0.power_transform + delta_t = setting0.delta_t + dim = setting0.dim + layers = setting0.layers + + Xmu0 = torch.tensor(setting0.Xmu).unsqueeze(0).to(device) + Xstd0 = torch.tensor(setting0.Xstd).unsqueeze(0).to(device=device) + Ymu0 = torch.tensor(setting0.Ymu).unsqueeze(0).to(device=device) + Ystd0 = torch.tensor(setting0.Ystd).unsqueeze(0).to(device=device) + + Xmu1 = torch.tensor(setting1.Xmu).unsqueeze(0).to(device=device) + Xstd1 = torch.tensor(setting1.Xstd).unsqueeze(0).to(device=device) + Ymu1 = torch.tensor(setting1.Ymu).unsqueeze(0).to(device=device) + Ystd1 = torch.tensor(setting1.Ystd).unsqueeze(0).to(device=device) + + Xmu2 = torch.tensor(setting2.Xmu).unsqueeze(0).to(device=device) + Xstd2 = torch.tensor(setting2.Xstd).unsqueeze(0).to(device=device) + Ymu2 = torch.tensor(setting2.Ymu).unsqueeze(0).to(device=device) + Ystd2 = torch.tensor(setting2.Ystd).unsqueeze(0).to(device=device) + + #load module + model0 = Net() + model1 = Net() + model2 = Net() + check_point0 = torch.load(str("pytorchDNN/"+moduleName1+".pt")) + check_point1 = torch.load(str("pytorchDNN/"+moduleName2+".pt")) + check_point2 = torch.load(str("pytorchDNN/"+moduleName3+".pt")) + model0.load_state_dict(check_point0) + model1.load_state_dict(check_point1) + model2.load_state_dict(check_point2) + model0.to(device=device) + model1.to(device=device) + model2.to(device=device) + if len(device_ids) > 1: + model0 = torch.nn.DataParallel(model0, device_ids=device_ids) + model1 = torch.nn.DataParallel(model1, device_ids=device_ids) + model2 = torch.nn.DataParallel(model2, device_ids=device_ids) +except Exception as e: + print(e.args) + + +def inference(vec0, vec1, vec2): + ''' + use model to inference + ''' + #args = np.reshape(args, (-1, 9)) #reshape to formed size + #vec0 = np.reshape(vec0, (-1, 24)) + #vec1 = np.reshape(vec1, (-1, 24)) + #vec2 = np.reshape(vec2, (-1, 24)) + vec0 = np.reshape(vec0, (-1, 10)) + vec1 = np.reshape(vec1, (-1, 10)) + vec2 = np.reshape(vec2, (-1, 10)) + + try: + with torch.no_grad(): + input0_ = torch.from_numpy(vec0).double().to(device=device) #cast ndarray to torch tensor + input1_ = torch.from_numpy(vec1).double().to(device=device) #cast ndarray to torch tensor + input2_ = torch.from_numpy(vec2).double().to(device=device) #cast ndarray to torch tensor + + # pre_processing + rho0 = input0_[:, 0].unsqueeze(1) + input0_Y = input0_[:, 3:].clone() + input0_bct = input0_[:, 1:] + input0_bct[:, 2:] = (input0_bct[:, 2:]**(lamda) - 1) / lamda #BCT + input0_normalized = (input0_bct - Xmu0) / Xstd0 + # input0_normalized[:, -1] = 0 #set Y_AR to 0 + input0_normalized = input0_normalized.float() + + rho1 = input1_[:, 0].unsqueeze(1) + input1_Y = input1_[:, 3:].clone() + input1_bct = input1_[:, 1:] + input1_bct[:, 2:] = (input1_bct[:, 2:]**(lamda) - 1) / lamda #BCT + input1_normalized = (input1_bct - Xmu1) / Xstd1 + # input1_normalized[:, -1] = 0 #set Y_AR to 0 + input1_normalized = input1_normalized.float() + + + rho2 = input2_[:, 0].unsqueeze(1) + input2_Y = input2_[:, 3:].clone() + input2_bct = input2_[:, 1:] + input2_bct[:, 2:] = (input2_bct[:, 2:]**(lamda) - 1) / lamda #BCT + input2_normalized = (input2_bct - Xmu2) / Xstd2 + # input2_normalized[:, -1] = 0 #set Y_AR to 0 + input2_normalized = input2_normalized.float() + + #inference + output0_normalized = model0(input0_normalized) + output1_normalized = model1(input1_normalized) + output2_normalized = model2(input2_normalized) + + + # post_processing + output0_bct = (output0_normalized * Ystd0 + Ymu0) * delta_t + input0_bct + output0_Y = (lamda * output0_bct[:, 2:] + 1)**(1 / lamda) + output0_Y = output0_Y / torch.sum(input=output0_Y, dim=1, keepdim=True) + output0 = (output0_Y - input0_Y) * rho0 / delta_t + output0 = output0.cpu().numpy() + + output1_bct = (output1_normalized * Ystd1 + Ymu1) * delta_t + input1_bct + output1_Y = (lamda * output1_bct[:, 2:] + 1)**(1 / lamda) + output1_Y = output1_Y / torch.sum(input=output1_Y, dim=1, keepdim=True) + output1 = (output1_Y - input1_Y) * rho1 / delta_t + output1 = output1.cpu().numpy() + + output2_bct = (output2_normalized * Ystd2 + Ymu2) * delta_t + input2_bct + output2_Y = (lamda * output2_bct[:, 2:] + 1)**(1 / lamda) + output2_Y = output2_Y / torch.sum(input=output2_Y, dim=1, keepdim=True) + output2 = (output2_Y - input2_Y) * rho2 / delta_t + output2 = output2.cpu().numpy() + + result = np.append(output0, output1, axis=0) + result = np.append(result, output2, axis=0) + return result + except Exception as e: + print(e.args) diff --git a/test/df0DFoam/pytorchDNN b/test/df0DFoam/pytorchDNN new file mode 120000 index 00000000..170826ba --- /dev/null +++ b/test/df0DFoam/pytorchDNN @@ -0,0 +1 @@ +../../mechanisms/H2/pytorchDNN/ \ No newline at end of file diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/system/blockMeshDict b/test/df0DFoam/system/blockMeshDict similarity index 94% rename from test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/system/blockMeshDict rename to test/df0DFoam/system/blockMeshDict index 35edbf14..b762a930 100644 --- a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/system/blockMeshDict +++ b/test/df0DFoam/system/blockMeshDict @@ -31,7 +31,7 @@ vertices blocks ( - hex (0 1 2 3 4 5 6 7) (1 1 1) simpleGrading (1 1 1) + hex (0 1 2 3 4 5 6 7) (10 10 10) simpleGrading (1 1 1) ); edges diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/system/controlDict b/test/df0DFoam/system/controlDict similarity index 95% rename from test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/system/controlDict rename to test/df0DFoam/system/controlDict index f974f450..8d64da2b 100644 --- a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/system/controlDict +++ b/test/df0DFoam/system/controlDict @@ -15,7 +15,7 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -application dfLMFoam; +application df0DFoam; startFrom startTime; @@ -23,7 +23,7 @@ startTime 0; stopAt endTime; -endTime 0.004; +endTime 1e-3; deltaT 1e-06; diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/constant/CanteraTorchProperties b/test/df0DFoam/system/decomposeParDict similarity index 64% rename from test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/constant/CanteraTorchProperties rename to test/df0DFoam/system/decomposeParDict index cc24cd4f..45c7f859 100644 --- a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/constant/CanteraTorchProperties +++ b/test/df0DFoam/system/decomposeParDict @@ -10,28 +10,36 @@ FoamFile version 2.0; format ascii; class dictionary; - location "constant"; - object thermophysicalProperties; + location "system"; + object decomposeParDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -chemistry on; -CanteraMechanismFile "drm19.yaml"; -transportModel "UnityLewis"; -odeCoeffs +numberOfSubdomains 4; + +method scotch; + +simpleCoeffs { - // "relTol" 1e-6; - // "absTol" 1e-10; + n (4 1 1); + delta 0.001; } -inertSpecie "N2"; -zeroDReactor + +hierarchicalCoeffs { - constantProperty "pressure"; + n (1 1 1); + delta 0.001; + order xyz; } -loadbalancing + +manualCoeffs { - active false; - //log true; + dataFile ""; } +distributed no; + +roots ( ); + + // ************************************************************************* // diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/system/fvSchemes b/test/df0DFoam/system/fvSchemes similarity index 100% rename from test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/system/fvSchemes rename to test/df0DFoam/system/fvSchemes diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/system/fvSolution b/test/df0DFoam/system/fvSolution similarity index 100% rename from test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/system/fvSolution rename to test/df0DFoam/system/fvSolution diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/system/probes b/test/df0DFoam/system/probes similarity index 95% rename from test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/system/probes rename to test/df0DFoam/system/probes index 2790ce65..e327da35 100644 --- a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/system/probes +++ b/test/df0DFoam/system/probes @@ -12,7 +12,7 @@ Description #includeEtc "caseDicts/postProcessing/probes/probes.cfg" -fields (T); +fields (T Qdot);// Writes out T probeLocations ( (0.0025 0.0025 0.0025) diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/CH4.gz b/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/CH4.gz deleted file mode 100644 index 92a6f0d9..00000000 Binary files a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/CH4.gz and /dev/null differ diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/N2.gz b/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/N2.gz deleted file mode 100644 index c46b52f6..00000000 Binary files a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/N2.gz and /dev/null differ diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/O2.gz b/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/O2.gz deleted file mode 100644 index d5a3326d..00000000 Binary files a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/O2.gz and /dev/null differ diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/T.gz b/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/T.gz deleted file mode 100644 index 2664edbf..00000000 Binary files a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/T.gz and /dev/null differ diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/p.gz b/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/p.gz deleted file mode 100644 index a187d772..00000000 Binary files a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/p.gz and /dev/null differ diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/drm19.yaml b/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/drm19.yaml deleted file mode 100644 index 321c72c1..00000000 --- a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/drm19.yaml +++ /dev/null @@ -1,600 +0,0 @@ -generator: cti2yaml -cantera-version: 2.5.1 -date: Thu, 28 Jul 2022 12:32:02 +0800 -input-files: [drm19.cti] - -units: {length: cm, quantity: mol, activation-energy: cal/mol} - -phases: -- name: gas - thermo: ideal-gas - elements: [O, H, C, N, Ar] - species: [H2, H, O, O2, OH, H2O, HO2, CH2, CH2(S), CH3, CH4, CO, CO2, - HCO, CH2O, CH3O, C2H4, C2H5, C2H6, N2, AR] - kinetics: gas - reactions: all - transport: mixture-averaged - state: - T: 300.0 - P: 1.01325e+05 - -species: -- name: H2 - composition: {H: 2} - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [2.34433112, 7.98052075e-03, -1.9478151e-05, 2.01572094e-08, -7.37611761e-12, - -917.935173, 0.683010238] - - [3.3372792, -4.94024731e-05, 4.99456778e-07, -1.79566394e-10, 2.00255376e-14, - -950.158922, -3.20502331] - transport: - model: gas - geometry: linear - diameter: 2.92 - well-depth: 38.0 - polarizability: 0.79 - rotational-relaxation: 280.0 - note: TPIS78 -- name: H - composition: {H: 1} - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [2.5, 7.05332819e-13, -1.99591964e-15, 2.30081632e-18, -9.27732332e-22, - 2.54736599e+04, -0.446682853] - - [2.50000001, -2.30842973e-11, 1.61561948e-14, -4.73515235e-18, 4.98197357e-22, - 2.54736599e+04, -0.446682914] - transport: - model: gas - geometry: atom - diameter: 2.05 - well-depth: 145.0 - note: L7/88 -- name: O - composition: {O: 1} - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [3.1682671, -3.27931884e-03, 6.64306396e-06, -6.12806624e-09, 2.11265971e-12, - 2.91222592e+04, 2.05193346] - - [2.56942078, -8.59741137e-05, 4.19484589e-08, -1.00177799e-11, 1.22833691e-15, - 2.92175791e+04, 4.78433864] - transport: - model: gas - geometry: atom - diameter: 2.75 - well-depth: 80.0 - note: L1/90 -- name: O2 - composition: {O: 2} - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [3.78245636, -2.99673416e-03, 9.84730201e-06, -9.68129509e-09, 3.24372837e-12, - -1063.94356, 3.65767573] - - [3.28253784, 1.48308754e-03, -7.57966669e-07, 2.09470555e-10, -2.16717794e-14, - -1088.45772, 5.45323129] - transport: - model: gas - geometry: linear - diameter: 3.458 - well-depth: 107.4 - polarizability: 1.6 - rotational-relaxation: 3.8 - note: TPIS89 -- name: OH - composition: {H: 1, O: 1} - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [3.99201543, -2.40131752e-03, 4.61793841e-06, -3.88113333e-09, 1.3641147e-12, - 3615.08056, -0.103925458] - - [3.09288767, 5.48429716e-04, 1.26505228e-07, -8.79461556e-11, 1.17412376e-14, - 3858.657, 4.4766961] - transport: - model: gas - geometry: linear - diameter: 2.75 - well-depth: 80.0 - note: RUS78 -- name: H2O - composition: {H: 2, O: 1} - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [4.19864056, -2.0364341e-03, 6.52040211e-06, -5.48797062e-09, 1.77197817e-12, - -3.02937267e+04, -0.849032208] - - [3.03399249, 2.17691804e-03, -1.64072518e-07, -9.7041987e-11, 1.68200992e-14, - -3.00042971e+04, 4.9667701] - transport: - model: gas - geometry: nonlinear - diameter: 2.605 - well-depth: 572.4 - dipole: 1.844 - rotational-relaxation: 4.0 - note: L8/89 -- name: HO2 - composition: {H: 1, O: 2} - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [4.30179801, -4.74912051e-03, 2.11582891e-05, -2.42763894e-08, 9.29225124e-12, - 294.80804, 3.71666245] - - [4.0172109, 2.23982013e-03, -6.3365815e-07, 1.1424637e-10, -1.07908535e-14, - 111.856713, 3.78510215] - transport: - model: gas - geometry: nonlinear - diameter: 3.458 - well-depth: 107.4 - rotational-relaxation: 1.0 - note: L5/89 -- name: CH2 - composition: {C: 1, H: 2} - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [3.76267867, 9.68872143e-04, 2.79489841e-06, -3.85091153e-09, 1.68741719e-12, - 4.60040401e+04, 1.56253185] - - [2.87410113, 3.65639292e-03, -1.40894597e-06, 2.60179549e-10, -1.87727567e-14, - 4.6263604e+04, 6.17119324] - transport: - model: gas - geometry: linear - diameter: 3.8 - well-depth: 144.0 - note: LS/93 -- name: CH2(S) - composition: {C: 1, H: 2} - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [4.19860411, -2.36661419e-03, 8.2329622e-06, -6.68815981e-09, 1.94314737e-12, - 5.04968163e+04, -0.769118967] - - [2.29203842, 4.65588637e-03, -2.01191947e-06, 4.17906e-10, -3.39716365e-14, - 5.09259997e+04, 8.62650169] - transport: - model: gas - geometry: linear - diameter: 3.8 - well-depth: 144.0 - note: LS/93 -- name: CH3 - composition: {C: 1, H: 3} - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [3.6735904, 2.01095175e-03, 5.73021856e-06, -6.87117425e-09, 2.54385734e-12, - 1.64449988e+04, 1.60456433] - - [2.28571772, 7.23990037e-03, -2.98714348e-06, 5.95684644e-10, -4.67154394e-14, - 1.67755843e+04, 8.48007179] - transport: - model: gas - geometry: linear - diameter: 3.8 - well-depth: 144.0 - note: L11/89 -- name: CH4 - composition: {C: 1, H: 4} - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [5.14987613, -0.0136709788, 4.91800599e-05, -4.84743026e-08, 1.66693956e-11, - -1.02466476e+04, -4.64130376] - - [0.074851495, 0.0133909467, -5.73285809e-06, 1.22292535e-09, -1.0181523e-13, - -9468.34459, 18.437318] - transport: - model: gas - geometry: nonlinear - diameter: 3.746 - well-depth: 141.4 - polarizability: 2.6 - rotational-relaxation: 13.0 - note: L8/88 -- name: CO - composition: {C: 1, O: 1} - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [3.57953347, -6.1035368e-04, 1.01681433e-06, 9.07005884e-10, -9.04424499e-13, - -1.4344086e+04, 3.50840928] - - [2.71518561, 2.06252743e-03, -9.98825771e-07, 2.30053008e-10, -2.03647716e-14, - -1.41518724e+04, 7.81868772] - transport: - model: gas - geometry: linear - diameter: 3.65 - well-depth: 98.1 - polarizability: 1.95 - rotational-relaxation: 1.8 - note: TPIS79 -- name: CO2 - composition: {C: 1, O: 2} - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [2.35677352, 8.98459677e-03, -7.12356269e-06, 2.45919022e-09, -1.43699548e-13, - -4.83719697e+04, 9.90105222] - - [3.85746029, 4.41437026e-03, -2.21481404e-06, 5.23490188e-10, -4.72084164e-14, - -4.8759166e+04, 2.27163806] - transport: - model: gas - geometry: linear - diameter: 3.763 - well-depth: 244.0 - polarizability: 2.65 - rotational-relaxation: 2.1 - note: L7/88 -- name: HCO - composition: {C: 1, H: 1, O: 1} - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [4.22118584, -3.24392532e-03, 1.37799446e-05, -1.33144093e-08, 4.33768865e-12, - 3839.56496, 3.39437243] - - [2.77217438, 4.95695526e-03, -2.48445613e-06, 5.89161778e-10, -5.33508711e-14, - 4011.91815, 9.79834492] - transport: - model: gas - geometry: nonlinear - diameter: 3.59 - well-depth: 498.0 - note: L12/89 -- name: CH2O - composition: {C: 1, H: 2, O: 1} - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [4.79372315, -9.90833369e-03, 3.73220008e-05, -3.79285261e-08, 1.31772652e-11, - -1.43089567e+04, 0.6028129] - - [1.76069008, 9.20000082e-03, -4.42258813e-06, 1.00641212e-09, -8.8385564e-14, - -1.39958323e+04, 13.656323] - transport: - model: gas - geometry: nonlinear - diameter: 3.59 - well-depth: 498.0 - rotational-relaxation: 2.0 - note: L8/88 -- name: CH3O - composition: {C: 1, H: 3, O: 1} - thermo: - model: NASA7 - temperature-ranges: [300.0, 1000.0, 3000.0] - data: - - [2.106204, 7.216595e-03, 5.338472e-06, -7.377636e-09, 2.07561e-12, - 978.6011, 13.152177] - - [3.770799, 7.871497e-03, -2.656384e-06, 3.944431e-10, -2.112616e-14, - 127.83252, 2.929575] - transport: - model: gas - geometry: nonlinear - diameter: 3.69 - well-depth: 417.0 - dipole: 1.7 - rotational-relaxation: 2.0 - note: '121686' -- name: C2H4 - composition: {C: 2, H: 4} - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [3.95920148, -7.57052247e-03, 5.70990292e-05, -6.91588753e-08, 2.69884373e-11, - 5089.77593, 4.09733096] - - [2.03611116, 0.0146454151, -6.71077915e-06, 1.47222923e-09, -1.25706061e-13, - 4939.88614, 10.3053693] - transport: - model: gas - geometry: nonlinear - diameter: 3.971 - well-depth: 280.8 - rotational-relaxation: 1.5 - note: L1/91 -- name: C2H5 - composition: {C: 2, H: 5} - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [4.30646568, -4.18658892e-03, 4.97142807e-05, -5.99126606e-08, 2.30509004e-11, - 1.28416265e+04, 4.70720924] - - [1.95465642, 0.0173972722, -7.98206668e-06, 1.75217689e-09, -1.49641576e-13, - 1.285752e+04, 13.4624343] - transport: - model: gas - geometry: nonlinear - diameter: 4.302 - well-depth: 252.3 - rotational-relaxation: 1.5 - note: L12/92 -- name: C2H6 - composition: {C: 2, H: 6} - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [4.29142492, -5.5015427e-03, 5.99438288e-05, -7.08466285e-08, 2.68685771e-11, - -1.15222055e+04, 2.66682316] - - [1.0718815, 0.0216852677, -1.00256067e-05, 2.21412001e-09, -1.9000289e-13, - -1.14263932e+04, 15.1156107] - transport: - model: gas - geometry: nonlinear - diameter: 4.302 - well-depth: 252.3 - rotational-relaxation: 1.5 - note: L8/88 -- name: N2 - composition: {N: 2} - thermo: - model: NASA7 - temperature-ranges: [300.0, 1000.0, 5000.0] - data: - - [3.298677, 1.4082404e-03, -3.963222e-06, 5.641515e-09, -2.444854e-12, - -1020.8999, 3.950372] - - [2.92664, 1.4879768e-03, -5.68476e-07, 1.0097038e-10, -6.753351e-15, - -922.7977, 5.980528] - transport: - model: gas - geometry: linear - diameter: 3.621 - well-depth: 97.53 - polarizability: 1.76 - rotational-relaxation: 4.0 - note: '121286' -- name: AR - composition: {Ar: 1} - thermo: - model: NASA7 - temperature-ranges: [300.0, 1000.0, 5000.0] - data: - - [2.5, 0.0, 0.0, 0.0, 0.0, -745.375, 4.366] - - [2.5, 0.0, 0.0, 0.0, 0.0, -745.375, 4.366] - transport: - model: gas - geometry: atom - diameter: 3.33 - well-depth: 136.5 - note: '120186' - -reactions: -- equation: O + H + M <=> OH + M # Reaction 1 - type: three-body - rate-constant: {A: 5.0e+17, b: -1.0, Ea: 0.0} - efficiencies: {AR: 0.7, C2H6: 3.0, CH4: 2.0, CO: 1.5, CO2: 2.0, H2: 2.0, - H2O: 6.0} -- equation: O + H2 <=> H + OH # Reaction 2 - rate-constant: {A: 5.0e+04, b: 2.67, Ea: 6290.0} -- equation: O + HO2 <=> OH + O2 # Reaction 3 - rate-constant: {A: 2.0e+13, b: 0.0, Ea: 0.0} -- equation: O + CH2 <=> H + HCO # Reaction 4 - rate-constant: {A: 8.0e+13, b: 0.0, Ea: 0.0} -- equation: O + CH2(S) <=> H + HCO # Reaction 5 - rate-constant: {A: 1.5e+13, b: 0.0, Ea: 0.0} -- equation: O + CH3 <=> H + CH2O # Reaction 6 - rate-constant: {A: 8.43e+13, b: 0.0, Ea: 0.0} -- equation: O + CH4 <=> OH + CH3 # Reaction 7 - rate-constant: {A: 1.02e+09, b: 1.5, Ea: 8600.0} -- equation: O + CO + M <=> CO2 + M # Reaction 8 - type: three-body - rate-constant: {A: 6.02e+14, b: 0.0, Ea: 3000.0} - efficiencies: {AR: 0.5, C2H6: 3.0, CH4: 2.0, CO: 1.5, CO2: 3.5, H2: 2.0, - H2O: 6.0, O2: 6.0} -- equation: O + HCO <=> OH + CO # Reaction 9 - rate-constant: {A: 3.0e+13, b: 0.0, Ea: 0.0} -- equation: O + HCO <=> H + CO2 # Reaction 10 - rate-constant: {A: 3.0e+13, b: 0.0, Ea: 0.0} -- equation: O + CH2O <=> OH + HCO # Reaction 11 - rate-constant: {A: 3.9e+13, b: 0.0, Ea: 3540.0} -- equation: O + C2H4 <=> CH3 + HCO # Reaction 12 - rate-constant: {A: 1.92e+07, b: 1.83, Ea: 220.0} -- equation: O + C2H5 <=> CH3 + CH2O # Reaction 13 - rate-constant: {A: 1.32e+14, b: 0.0, Ea: 0.0} -- equation: O + C2H6 <=> OH + C2H5 # Reaction 14 - rate-constant: {A: 8.98e+07, b: 1.92, Ea: 5690.0} -- equation: O2 + CO <=> O + CO2 # Reaction 15 - rate-constant: {A: 2.5e+12, b: 0.0, Ea: 4.78e+04} -- equation: O2 + CH2O <=> HO2 + HCO # Reaction 16 - rate-constant: {A: 1.0e+14, b: 0.0, Ea: 4.0e+04} -- equation: H + O2 + M <=> HO2 + M # Reaction 17 - type: three-body - rate-constant: {A: 2.8e+18, b: -0.86, Ea: 0.0} - efficiencies: {AR: 0.0, C2H6: 1.5, CO: 0.75, CO2: 1.5, H2O: 0.0, N2: 0.0, - O2: 0.0} -- equation: H + 2 O2 <=> HO2 + O2 # Reaction 18 - rate-constant: {A: 3.0e+20, b: -1.72, Ea: 0.0} -- equation: H + O2 + H2O <=> HO2 + H2O # Reaction 19 - rate-constant: {A: 9.38e+18, b: -0.76, Ea: 0.0} -- equation: H + O2 + N2 <=> HO2 + N2 # Reaction 20 - rate-constant: {A: 3.75e+20, b: -1.72, Ea: 0.0} -- equation: H + O2 + AR <=> HO2 + AR # Reaction 21 - rate-constant: {A: 7.0e+17, b: -0.8, Ea: 0.0} -- equation: H + O2 <=> O + OH # Reaction 22 - rate-constant: {A: 8.3e+13, b: 0.0, Ea: 1.4413e+04} -- equation: 2 H + M <=> H2 + M # Reaction 23 - type: three-body - rate-constant: {A: 1.0e+18, b: -1.0, Ea: 0.0} - efficiencies: {AR: 0.63, C2H6: 3.0, CH4: 2.0, CO2: 0.0, H2: 0.0, H2O: 0.0} -- equation: 2 H + H2 <=> 2 H2 # Reaction 24 - rate-constant: {A: 9.0e+16, b: -0.6, Ea: 0.0} -- equation: 2 H + H2O <=> H2 + H2O # Reaction 25 - rate-constant: {A: 6.0e+19, b: -1.25, Ea: 0.0} -- equation: 2 H + CO2 <=> H2 + CO2 # Reaction 26 - rate-constant: {A: 5.5e+20, b: -2.0, Ea: 0.0} -- equation: H + OH + M <=> H2O + M # Reaction 27 - type: three-body - rate-constant: {A: 2.2e+22, b: -2.0, Ea: 0.0} - efficiencies: {AR: 0.38, C2H6: 3.0, CH4: 2.0, H2: 0.73, H2O: 3.65} -- equation: H + HO2 <=> O2 + H2 # Reaction 28 - rate-constant: {A: 2.8e+13, b: 0.0, Ea: 1068.0} -- equation: H + HO2 <=> 2 OH # Reaction 29 - rate-constant: {A: 1.34e+14, b: 0.0, Ea: 635.0} -- equation: H + CH2 (+ M) <=> CH3 (+ M) # Reaction 30 - type: falloff - low-P-rate-constant: {A: 3.2e+27, b: -3.14, Ea: 1230.0} - high-P-rate-constant: {A: 2.5e+16, b: -0.8, Ea: 0.0} - Troe: {A: 0.68, T3: 78.0, T1: 1995.0, T2: 5590.0} - efficiencies: {AR: 0.7, C2H6: 3.0, CH4: 2.0, CO: 1.5, CO2: 2.0, H2: 2.0, - H2O: 6.0} -- equation: H + CH3 (+ M) <=> CH4 (+ M) # Reaction 31 - type: falloff - low-P-rate-constant: {A: 2.477e+33, b: -4.76, Ea: 2440.0} - high-P-rate-constant: {A: 1.27e+16, b: -0.63, Ea: 383.0} - Troe: {A: 0.783, T3: 74.0, T1: 2941.0, T2: 6964.0} - efficiencies: {AR: 0.7, C2H6: 3.0, CH4: 2.0, CO: 1.5, CO2: 2.0, H2: 2.0, - H2O: 6.0} -- equation: H + CH4 <=> CH3 + H2 # Reaction 32 - rate-constant: {A: 6.6e+08, b: 1.62, Ea: 1.084e+04} -- equation: H + HCO (+ M) <=> CH2O (+ M) # Reaction 33 - type: falloff - low-P-rate-constant: {A: 1.35e+24, b: -2.57, Ea: 1425.0} - high-P-rate-constant: {A: 1.09e+12, b: 0.48, Ea: -260.0} - Troe: {A: 0.7824, T3: 271.0, T1: 2755.0, T2: 6570.0} - efficiencies: {AR: 0.7, C2H6: 3.0, CH4: 2.0, CO: 1.5, CO2: 2.0, H2: 2.0, - H2O: 6.0} -- equation: H + HCO <=> H2 + CO # Reaction 34 - rate-constant: {A: 7.34e+13, b: 0.0, Ea: 0.0} -- equation: H + CH2O (+ M) <=> CH3O (+ M) # Reaction 35 - type: falloff - low-P-rate-constant: {A: 2.2e+30, b: -4.8, Ea: 5560.0} - high-P-rate-constant: {A: 5.4e+11, b: 0.454, Ea: 2600.0} - Troe: {A: 0.758, T3: 94.0, T1: 1555.0, T2: 4200.0} - efficiencies: {C2H6: 3.0, CH4: 2.0, CO: 1.5, CO2: 2.0, H2: 2.0, H2O: 6.0} -- equation: H + CH2O <=> HCO + H2 # Reaction 36 - rate-constant: {A: 2.3e+10, b: 1.05, Ea: 3275.0} -- equation: H + CH3O <=> OH + CH3 # Reaction 37 - rate-constant: {A: 3.2e+13, b: 0.0, Ea: 0.0} -- equation: H + C2H4 (+ M) <=> C2H5 (+ M) # Reaction 38 - type: falloff - low-P-rate-constant: {A: 1.2e+42, b: -7.62, Ea: 6970.0} - high-P-rate-constant: {A: 1.08e+12, b: 0.454, Ea: 1820.0} - Troe: {A: 0.9753, T3: 210.0, T1: 984.0, T2: 4374.0} - efficiencies: {AR: 0.7, C2H6: 3.0, CH4: 2.0, CO: 1.5, CO2: 2.0, H2: 2.0, - H2O: 6.0} -- equation: H + C2H5 (+ M) <=> C2H6 (+ M) # Reaction 39 - type: falloff - low-P-rate-constant: {A: 1.99e+41, b: -7.08, Ea: 6685.0} - high-P-rate-constant: {A: 5.21e+17, b: -0.99, Ea: 1580.0} - Troe: {A: 0.8422, T3: 125.0, T1: 2219.0, T2: 6882.0} - efficiencies: {AR: 0.7, C2H6: 3.0, CH4: 2.0, CO: 1.5, CO2: 2.0, H2: 2.0, - H2O: 6.0} -- equation: H + C2H6 <=> C2H5 + H2 # Reaction 40 - rate-constant: {A: 1.15e+08, b: 1.9, Ea: 7530.0} -- equation: H2 + CO (+ M) <=> CH2O (+ M) # Reaction 41 - type: falloff - low-P-rate-constant: {A: 5.07e+27, b: -3.42, Ea: 8.435e+04} - high-P-rate-constant: {A: 4.3e+07, b: 1.5, Ea: 7.96e+04} - Troe: {A: 0.932, T3: 197.0, T1: 1540.0, T2: 1.03e+04} - efficiencies: {AR: 0.7, C2H6: 3.0, CH4: 2.0, CO: 1.5, CO2: 2.0, H2: 2.0, - H2O: 6.0} -- equation: OH + H2 <=> H + H2O # Reaction 42 - rate-constant: {A: 2.16e+08, b: 1.51, Ea: 3430.0} -- equation: 2 OH <=> O + H2O # Reaction 43 - rate-constant: {A: 3.57e+04, b: 2.4, Ea: -2110.0} -- equation: OH + HO2 <=> O2 + H2O # Reaction 44 - rate-constant: {A: 2.9e+13, b: 0.0, Ea: -500.0} -- equation: OH + CH2 <=> H + CH2O # Reaction 45 - rate-constant: {A: 2.0e+13, b: 0.0, Ea: 0.0} -- equation: OH + CH2(S) <=> H + CH2O # Reaction 46 - rate-constant: {A: 3.0e+13, b: 0.0, Ea: 0.0} -- equation: OH + CH3 <=> CH2 + H2O # Reaction 47 - rate-constant: {A: 5.6e+07, b: 1.6, Ea: 5420.0} -- equation: OH + CH3 <=> CH2(S) + H2O # Reaction 48 - rate-constant: {A: 2.501e+13, b: 0.0, Ea: 0.0} -- equation: OH + CH4 <=> CH3 + H2O # Reaction 49 - rate-constant: {A: 1.0e+08, b: 1.6, Ea: 3120.0} -- equation: OH + CO <=> H + CO2 # Reaction 50 - rate-constant: {A: 4.76e+07, b: 1.228, Ea: 70.0} -- equation: OH + HCO <=> H2O + CO # Reaction 51 - rate-constant: {A: 5.0e+13, b: 0.0, Ea: 0.0} -- equation: OH + CH2O <=> HCO + H2O # Reaction 52 - rate-constant: {A: 3.43e+09, b: 1.18, Ea: -447.0} -- equation: OH + C2H6 <=> C2H5 + H2O # Reaction 53 - rate-constant: {A: 3.54e+06, b: 2.12, Ea: 870.0} -- equation: HO2 + CH2 <=> OH + CH2O # Reaction 54 - rate-constant: {A: 2.0e+13, b: 0.0, Ea: 0.0} -- equation: HO2 + CH3 <=> O2 + CH4 # Reaction 55 - rate-constant: {A: 1.0e+12, b: 0.0, Ea: 0.0} -- equation: HO2 + CH3 <=> OH + CH3O # Reaction 56 - rate-constant: {A: 2.0e+13, b: 0.0, Ea: 0.0} -- equation: HO2 + CO <=> OH + CO2 # Reaction 57 - rate-constant: {A: 1.5e+14, b: 0.0, Ea: 2.36e+04} -- equation: CH2 + O2 <=> OH + HCO # Reaction 58 - rate-constant: {A: 1.32e+13, b: 0.0, Ea: 1500.0} -- equation: CH2 + H2 <=> H + CH3 # Reaction 59 - rate-constant: {A: 5.0e+05, b: 2.0, Ea: 7230.0} -- equation: CH2 + CH3 <=> H + C2H4 # Reaction 60 - rate-constant: {A: 4.0e+13, b: 0.0, Ea: 0.0} -- equation: CH2 + CH4 <=> 2 CH3 # Reaction 61 - rate-constant: {A: 2.46e+06, b: 2.0, Ea: 8270.0} -- equation: CH2(S) + N2 <=> CH2 + N2 # Reaction 62 - rate-constant: {A: 1.5e+13, b: 0.0, Ea: 600.0} -- equation: CH2(S) + AR <=> CH2 + AR # Reaction 63 - rate-constant: {A: 9.0e+12, b: 0.0, Ea: 600.0} -- equation: CH2(S) + O2 <=> H + OH + CO # Reaction 64 - rate-constant: {A: 2.8e+13, b: 0.0, Ea: 0.0} -- equation: CH2(S) + O2 <=> CO + H2O # Reaction 65 - rate-constant: {A: 1.2e+13, b: 0.0, Ea: 0.0} -- equation: CH2(S) + H2 <=> CH3 + H # Reaction 66 - rate-constant: {A: 7.0e+13, b: 0.0, Ea: 0.0} -- equation: CH2(S) + H2O <=> CH2 + H2O # Reaction 67 - rate-constant: {A: 3.0e+13, b: 0.0, Ea: 0.0} -- equation: CH2(S) + CH3 <=> H + C2H4 # Reaction 68 - rate-constant: {A: 1.2e+13, b: 0.0, Ea: -570.0} -- equation: CH2(S) + CH4 <=> 2 CH3 # Reaction 69 - rate-constant: {A: 1.6e+13, b: 0.0, Ea: -570.0} -- equation: CH2(S) + CO <=> CH2 + CO # Reaction 70 - rate-constant: {A: 9.0e+12, b: 0.0, Ea: 0.0} -- equation: CH2(S) + CO2 <=> CH2 + CO2 # Reaction 71 - rate-constant: {A: 7.0e+12, b: 0.0, Ea: 0.0} -- equation: CH2(S) + CO2 <=> CO + CH2O # Reaction 72 - rate-constant: {A: 1.4e+13, b: 0.0, Ea: 0.0} -- equation: CH3 + O2 <=> O + CH3O # Reaction 73 - rate-constant: {A: 2.675e+13, b: 0.0, Ea: 2.88e+04} -- equation: CH3 + O2 <=> OH + CH2O # Reaction 74 - rate-constant: {A: 3.6e+10, b: 0.0, Ea: 8940.0} -- equation: 2 CH3 (+ M) <=> C2H6 (+ M) # Reaction 75 - type: falloff - low-P-rate-constant: {A: 1.77e+50, b: -9.67, Ea: 6220.0} - high-P-rate-constant: {A: 2.12e+16, b: -0.97, Ea: 620.0} - Troe: {A: 0.5325, T3: 151.0, T1: 1038.0, T2: 4970.0} - efficiencies: {AR: 0.7, C2H6: 3.0, CH4: 2.0, CO: 1.5, CO2: 2.0, H2: 2.0, - H2O: 6.0} -- equation: 2 CH3 <=> H + C2H5 # Reaction 76 - rate-constant: {A: 4.99e+12, b: 0.1, Ea: 1.06e+04} -- equation: CH3 + HCO <=> CH4 + CO # Reaction 77 - rate-constant: {A: 2.648e+13, b: 0.0, Ea: 0.0} -- equation: CH3 + CH2O <=> HCO + CH4 # Reaction 78 - rate-constant: {A: 3320.0, b: 2.81, Ea: 5860.0} -- equation: CH3 + C2H6 <=> C2H5 + CH4 # Reaction 79 - rate-constant: {A: 6.14e+06, b: 1.74, Ea: 1.045e+04} -- equation: HCO + H2O <=> H + CO + H2O # Reaction 80 - rate-constant: {A: 2.244e+18, b: -1.0, Ea: 1.7e+04} -- equation: HCO + M <=> H + CO + M # Reaction 81 - type: three-body - rate-constant: {A: 1.87e+17, b: -1.0, Ea: 1.7e+04} - efficiencies: {C2H6: 3.0, CH4: 2.0, CO: 1.5, CO2: 2.0, H2: 2.0, H2O: 0.0} -- equation: HCO + O2 <=> HO2 + CO # Reaction 82 - rate-constant: {A: 7.6e+12, b: 0.0, Ea: 400.0} -- equation: CH3O + O2 <=> HO2 + CH2O # Reaction 83 - rate-constant: {A: 4.28e-13, b: 7.6, Ea: -3530.0} -- equation: C2H5 + O2 <=> HO2 + C2H4 # Reaction 84 - rate-constant: {A: 8.4e+11, b: 0.0, Ea: 3875.0} diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/system/blockMeshDict b/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/system/blockMeshDict deleted file mode 100644 index 35edbf14..00000000 --- a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/system/blockMeshDict +++ /dev/null @@ -1,62 +0,0 @@ -/*--------------------------------*- 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 dictionary; - object blockMeshDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -convertToMeters 0.001; - -vertices -( - (0 0 0) - (5 0 0) - (5 5 0) - (0 5 0) - (0 0 5) - (5 0 5) - (5 5 5) - (0 5 5) -); - - -blocks -( - hex (0 1 2 3 4 5 6 7) (1 1 1) simpleGrading (1 1 1) -); - -edges -( -); - -boundary -( - cubic_boundary - { - type wall; - faces - ( - (0 3 2 1) - (4 5 6 7) - (0 4 7 3) - (2 6 5 1) - (3 7 6 2) - (1 5 4 0) - ); - } -); - -// mergePatchPairs -// ( -// ); - -// ************************************************************************* // diff --git a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/system/probes b/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/system/probes deleted file mode 100644 index 69419544..00000000 --- a/test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/system/probes +++ /dev/null @@ -1,21 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Version: 7 - \\/ M anipulation | -------------------------------------------------------------------------------- -Description - Writes out values of fields from cells nearest to specified locations. - -\*---------------------------------------------------------------------------*/ - -#includeEtc "caseDicts/postProcessing/probes/probes.cfg" - -fields (T);// Writes out T -probeLocations -( - (0.0025 0.0025 0.0025) -); - -// ************************************************************************* // diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/U.gz b/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/U.gz deleted file mode 100644 index 3126670b..00000000 Binary files a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/U.gz and /dev/null differ diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/Ydefault.gz b/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/Ydefault.gz deleted file mode 100644 index 355dc649..00000000 Binary files a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/Ydefault.gz and /dev/null differ diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/alphat.gz b/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/alphat.gz deleted file mode 100644 index 47f73f02..00000000 Binary files a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/alphat.gz and /dev/null differ diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/Allclean b/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/Allclean deleted file mode 100755 index cfd3b14e..00000000 --- a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/Allclean +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -echo "Cleaning log.*" -rm log.* -echo "Cleaning polyMesh/" -rm -r constant/polyMesh -echo "Cleaning postProcessing/" -rm -r postProcessing diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/Allrun b/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/Allrun deleted file mode 100755 index d060ec7b..00000000 --- a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/Allrun +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions - -application=df0DFoam - -runApplication blockMesh -runApplication $application diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/ES80_H2-7-16.yaml b/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/ES80_H2-7-16.yaml deleted file mode 100644 index 9ffb7c04..00000000 --- a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/ES80_H2-7-16.yaml +++ /dev/null @@ -1,205 +0,0 @@ -generator: ctml2yaml -cantera-version: 2.6.0 -date: Wed, 08 Jun 2022 13:32:25 +0800 -input-files: [ES80_H2-8-16.xml] - -phases: -- name: gas - elements: [O, H, N] - species: [H, O, H2O, OH, O2, H2, N2] - thermo: ideal-gas - transport: mixture-averaged - kinetics: gas - reactions: all - state: {T: 300.0 K, P: 1.01325e+05 Pa} - -species: -- name: H - composition: {H: 1.0} - note: L7/88 - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [2.5, 7.05332819e-13, -1.99591964e-15, 2.30081632e-18, -9.27732332e-22, 2.54736599e+04, - -0.446682853] - - [2.50000001, -2.30842973e-11, 1.61561948e-14, -4.73515235e-18, 4.98197357e-22, - 2.54736599e+04, -0.446682914] - transport: - model: gas - geometry: atom - well-depth: 145.0 - diameter: 2.05 - dipole: 0.0 - polarizability: 0.0 - rotational-relaxation: 0.0 - dispersion-coefficient: 0.0 - quadrupole-polarizability: 0.0 -- name: O - composition: {O: 1.0} - note: L1/90 - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [3.1682671, -3.27931884e-03, 6.64306396e-06, -6.12806624e-09, 2.11265971e-12, - 2.91222592e+04, 2.05193346] - - [2.56942078, -8.59741137e-05, 4.19484589e-08, -1.00177799e-11, 1.22833691e-15, - 2.92175791e+04, 4.78433864] - transport: - model: gas - geometry: atom - well-depth: 80.0 - diameter: 2.75 - dipole: 0.0 - polarizability: 0.0 - rotational-relaxation: 0.0 - dispersion-coefficient: 0.0 - quadrupole-polarizability: 0.0 -- name: H2O - composition: {H: 2.0, O: 1.0} - note: L8/89 - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [4.19864056, -2.0364341e-03, 6.52040211e-06, -5.48797062e-09, 1.77197817e-12, - -3.02937267e+04, -0.849032208] - - [3.03399249, 2.17691804e-03, -1.64072518e-07, -9.7041987e-11, 1.68200992e-14, - -3.00042971e+04, 4.9667701] - transport: - model: gas - geometry: nonlinear - well-depth: 572.4 - diameter: 2.605 - dipole: 1.844 - polarizability: 0.0 - rotational-relaxation: 4.0 - dispersion-coefficient: 0.0 - quadrupole-polarizability: 0.0 -- name: OH - composition: {H: 1.0, O: 1.0} - note: S9/01 - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 6000.0] - data: - - [4.12530561, -3.22544939e-03, 6.52764691e-06, -5.79853643e-09, 2.06237379e-12, - 3381.53812, -0.69043296] - - [2.86472886, 1.05650448e-03, -2.59082758e-07, 3.05218674e-11, -1.33195876e-15, - 3718.85774, 5.70164073] - transport: - model: gas - geometry: linear - well-depth: 80.0 - diameter: 2.75 - dipole: 0.0 - polarizability: 0.0 - rotational-relaxation: 0.0 - dispersion-coefficient: 0.0 - quadrupole-polarizability: 0.0 -- name: O2 - composition: {O: 2.0} - note: TPIS89 - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [3.78245636, -2.99673416e-03, 9.84730201e-06, -9.68129509e-09, 3.24372837e-12, - -1063.94356, 3.65767573] - - [3.28253784, 1.48308754e-03, -7.57966669e-07, 2.09470555e-10, -2.16717794e-14, - -1088.45772, 5.45323129] - transport: - model: gas - geometry: linear - well-depth: 107.4 - diameter: 3.458 - dipole: 0.0 - polarizability: 1.6 - rotational-relaxation: 3.8 - dispersion-coefficient: 0.0 - quadrupole-polarizability: 0.0 -- name: H2 - composition: {H: 2.0} - note: TPIS78 - thermo: - model: NASA7 - temperature-ranges: [200.0, 1000.0, 3500.0] - data: - - [2.34433112, 7.98052075e-03, -1.9478151e-05, 2.01572094e-08, -7.37611761e-12, - -917.935173, 0.683010238] - - [3.3372792, -4.94024731e-05, 4.99456778e-07, -1.79566394e-10, 2.00255376e-14, - -950.158922, -3.20502331] - transport: - model: gas - geometry: linear - well-depth: 38.0 - diameter: 2.92 - dipole: 0.0 - polarizability: 0.79 - rotational-relaxation: 280.0 - dispersion-coefficient: 0.0 - quadrupole-polarizability: 0.0 -- name: N2 - composition: {N: 2.0} - note: '121286' - thermo: - model: NASA7 - temperature-ranges: [300.0, 1000.0, 5000.0] - data: - - [3.298677, 1.4082404e-03, -3.963222e-06, 5.641515e-09, -2.444854e-12, -1020.8999, - 3.950372] - - [2.92664, 1.4879768e-03, -5.68476e-07, 1.0097038e-10, -6.753351e-15, -922.7977, - 5.980528] - transport: - model: gas - geometry: linear - well-depth: 97.53 - diameter: 3.621 - dipole: 0.0 - polarizability: 1.76 - rotational-relaxation: 4.0 - dispersion-coefficient: 0.0 - quadrupole-polarizability: 0.0 - -reactions: -- equation: H2 + M => 2 H + M - type: three-body - rate-constant: {A: 5.5e+15, b: -1.0, Ea: 1.033e+05 cal/mol} -- equation: 2 H + M => H2 + M - type: three-body - rate-constant: {A: 1.8e+12, b: -1.0, Ea: 0.0 cal/mol} -- equation: O2 + M => 2 O + M - type: three-body - rate-constant: {A: 7.2e+15, b: -1.0, Ea: 1.1791e+05 cal/mol} -- equation: 2 O + M => O2 + M - type: three-body - rate-constant: {A: 4.0e+11, b: -1.0, Ea: 0.0 cal/mol} -- equation: H2O + M => OH + H + M - type: three-body - rate-constant: {A: 5.2e+18, b: -1.5, Ea: 1.18e+05 cal/mol} -- equation: OH + H + M => H2O + M - type: three-body - rate-constant: {A: 4.4e+14, b: -1.5, Ea: 0.0 cal/mol} -- equation: OH + M => O + H + M - type: three-body - rate-constant: {A: 8.5e+15, b: -1.0, Ea: 1.01e+05 cal/mol} -- equation: O + H + M => OH + M - type: three-body - rate-constant: {A: 7.1e+12, b: -1.0, Ea: 0.0 cal/mol} -- equation: H2O + O => 2 OH - rate-constant: {A: 5.8e+10, b: 0.0, Ea: 1.8e+04 cal/mol} -- equation: 2 OH => H2O + O - rate-constant: {A: 5.3e+09, b: 0.0, Ea: 1000.0 cal/mol} -- equation: H2O + H => OH + H2 - rate-constant: {A: 8.4e+10, b: 0.0, Ea: 2.01e+04 cal/mol} -- equation: OH + H2 => H2O + H - rate-constant: {A: 2.0e+10, b: 0.0, Ea: 5166.0 cal/mol} -- equation: O2 + H => OH + O - rate-constant: {A: 2.2e+11, b: 0.0, Ea: 1.68e+04 cal/mol} -- equation: OH + O => O2 + H - rate-constant: {A: 1.5e+10, b: 0.0, Ea: 0.0 cal/mol} -- equation: H2 + O => OH + H - rate-constant: {A: 7.5e+10, b: 0.0, Ea: 1.11e+04 cal/mol} -- equation: OH + H => H2 + O - rate-constant: {A: 3.0e+10, b: 0.0, Ea: 8800.0 cal/mol} diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/constant/thermophysicalProperties b/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/constant/thermophysicalProperties deleted file mode 100644 index 7f207bb7..00000000 --- a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/constant/thermophysicalProperties +++ /dev/null @@ -1,18 +0,0 @@ -/*--------------------------------*- 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 dictionary; - location "constant"; - object thermophysicalProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// ************************************************************************* // diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/constant/turbulenceProperties b/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/constant/turbulenceProperties deleted file mode 100644 index 1e6753df..00000000 --- a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/constant/turbulenceProperties +++ /dev/null @@ -1,20 +0,0 @@ -/*--------------------------------*- 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 dictionary; - location "constant"; - object turbulenceProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -simulationType laminar; - -// ************************************************************************* // diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/system/controlDict b/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/system/controlDict deleted file mode 100644 index a324a3e2..00000000 --- a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/system/controlDict +++ /dev/null @@ -1,57 +0,0 @@ -/*--------------------------------*- 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 dictionary; - location "system"; - object controlDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -application dfLMFoam; - -startFrom startTime; - -startTime 0; - -stopAt endTime; - -endTime 0.001; - -deltaT 1e-06; - -maxDeltaT 1e-03; - -adjustTimeStep off; - -writeControl runTime; - -writeInterval 10000; - -purgeWrite 0; - -writeFormat ascii; - -// writePrecision 6; - -writeCompression on; - -timeFormat general; - -timePrecision 6; - -runTimeModifiable true; - -functions -{ - # includeFunc probes -} - -// ************************************************************************* // diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/system/fvSchemes b/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/system/fvSchemes deleted file mode 100644 index 0b7dcc26..00000000 --- a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/system/fvSchemes +++ /dev/null @@ -1,59 +0,0 @@ -/*--------------------------------*- 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 dictionary; - location "system"; - object fvSchemes; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -ddtSchemes -{ - default Euler; -} - -gradSchemes -{ - default Gauss linear; -} - -divSchemes -{ - default none; - - div(phi,U) Gauss limitedLinearV 1; - div(phi,Yi) Gauss limitedLinear01 1; - div(phi,h) Gauss limitedLinear 1; - div(phi,K) Gauss limitedLinear 1; - div(phid,p) Gauss limitedLinear 1; - div(phi,epsilon) Gauss limitedLinear 1; - div(phi,Yi_h) Gauss limitedLinear01 1; - div(phi,k) Gauss limitedLinear 1; - div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; -} - -laplacianSchemes -{ - default Gauss linear orthogonal; -} - -interpolationSchemes -{ - default linear; -} - -snGradSchemes -{ - default orthogonal; -} - - -// ************************************************************************* // diff --git a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/system/fvSolution b/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/system/fvSolution deleted file mode 100644 index c8b4eb91..00000000 --- a/test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/system/fvSolution +++ /dev/null @@ -1,73 +0,0 @@ -/*--------------------------------*- 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 dictionary; - location "system"; - object fvSolution; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -solvers -{ - "rho.*" - { - solver diagonal; - } - - p - { - solver PCG; - preconditioner DIC; - tolerance 1e-6; - relTol 0.01; - } - - pFinal - { - $p; - relTol 0; - } - - "(U|h|k|epsilon)" - { - solver PBiCGStab; - preconditioner DILU; - tolerance 1e-6; - relTol 0.1; - } - - "(U|h|k|epsilon)Final" - { - $U; - } - - "Yi.*" - { - solver PBiCG; - preconditioner DILU; - tolerance 1e-12; - relTol 0; - } -} - -PIMPLE -{ - momentumPredictor no; - nOuterCorrectors 1; - nCorrectors 2; - nNonOrthogonalCorrectors 0; - - maxDeltaT 1e-4; - maxCo 0.25; -} - - -// ************************************************************************* // diff --git a/test/dfHighSpeedFoam/oneD_detonationH2/constant/CanteraTorchProperties b/test/dfHighSpeedFoam/oneD_detonationH2/constant/CanteraTorchProperties index 640b9e14..eab63f28 100644 --- a/test/dfHighSpeedFoam/oneD_detonationH2/constant/CanteraTorchProperties +++ b/test/dfHighSpeedFoam/oneD_detonationH2/constant/CanteraTorchProperties @@ -18,18 +18,31 @@ FoamFile chemistry on; CanteraMechanismFile "H2_Li.xml"; -transportModel "UnityLewis"; -loadbalancing +transportModel "Mix";//"UnityLewis"; +odeCoeffs { - active true; - log true; + //"relTol" 1e-15; + //"absTol" 1e-24; } -odeCoeffs -{} inertSpecie "N2"; - zeroDReactor { - //cvorcp "UV"; + constantProperty "pressure";//cvorcp "UV"; +} + +TorchSettings +{ + torch off; + GPU off; + log on; + torchModel1 "ESH2-sub1.pt"; + torchModel2 "ESH2-sub2.pt"; + torchModel3 "ESH2-sub3.pt"; + coresPerGPU 4; +} +loadbalancing +{ + active false; + //log true; } // ************************************************************************* // diff --git a/test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/constant/CanteraTorchProperties b/test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/constant/CanteraTorchProperties index f89b9b1e..17ae27cb 100644 --- a/test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/constant/CanteraTorchProperties +++ b/test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/constant/CanteraTorchProperties @@ -21,18 +21,28 @@ CanteraMechanismFile "ES80_H2-7-16.yaml"; transportModel "Mix";//"UnityLewis"; odeCoeffs { - "relTol" 1e-6; - "absTol" 1e-10; + //"relTol" 1e-15; + //"absTol" 1e-24; } inertSpecie "N2"; - zeroDReactor { - //cvorcp "UV"; + constantProperty "pressure";//cvorcp "UV"; +} + +TorchSettings +{ + torch off; + GPU off; + log on; + torchModel1 "ESH2-sub1.pt"; + torchModel2 "ESH2-sub2.pt"; + torchModel3 "ESH2-sub3.pt"; + coresPerGPU 4; } loadbalancing { - active true; + active false; //log true; } // ************************************************************************* // diff --git a/test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/inference.py b/test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/inference.py new file mode 100644 index 00000000..6b0e5780 --- /dev/null +++ b/test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/inference.py @@ -0,0 +1,209 @@ +from builtins import Exception, print +from calendar import prcal +import torch +import numpy as np +import math +import time +import json +import os +from easydict import EasyDict as edict +import torch.profiler +import os + +torch.set_printoptions(precision=10) + + +class MyGELU(torch.nn.Module): + def __init__(self): + super(MyGELU, self).__init__() + self.torch_PI = 3.1415926536 + + def forward(self, x): + return 0.5 * x * (1 + torch.tanh( + math.sqrt(2 / self.torch_PI) * (x + 0.044715 * torch.pow(x, 3)))) + + +def json2Parser(json_path): + """load json and return parser-like object""" + with open(json_path, 'r') as f: + args = json.load(f) + return edict(args) + + +class Net(torch.nn.Module): + def __init__(self): + super(Net, self).__init__() + neurons = layers + self.depth = len(neurons) - 1 + self.actfun = MyGELU() + self.layers = [] + for i in range(self.depth - 1): + self.layers.append(torch.nn.Linear(neurons[i], neurons[i + 1])) + self.layers.append(self.actfun) + self.layers.append(torch.nn.Linear(neurons[-2], neurons[-1])) # last layer + self.fc = torch.nn.Sequential(*self.layers) + + def forward(self, x): + x = self.fc(x) + return x +try: + #load variables from constant/CanteraTorchProperties + path_r = r"./constant/CanteraTorchProperties" + with open(path_r, "r") as f: + data = f.read() + i = data.index('torchModel1') + a = data.index('"',i) + b = data.index('.',a+1) + moduleName1 = data[a+1:b] + + i = data.index('torchModel2') + a = data.index('"',i) + b = data.index('.',a+1) + moduleName2 = data[a+1:b] + + i = data.index('torchModel3') + a = data.index('"',i) + b = data.index('.',a+1) + moduleName3 = data[a+1:b] + + i = data.index('GPU') + a = data.index(';', i) + b = data.rfind(' ',i+1,a) + switch_GPU = data[b+1:a] + + #load OpenFOAM switch + switch_on = ["true", "True", "on", "yes", "y", "t", "any"] + switch_off = ["false", "False", "off", "no", "n", "f", "none"] + if switch_GPU in switch_on: + device = torch.device("cuda") + device_ids = range(torch.cuda.device_count()) + elif switch_GPU in switch_off: + device = torch.device("cpu") + device_ids = [0] + else: + print("invalid setting!") + os._exit(0) + + + + #glbal variable will only init once when called interperter + #load parameters from json + setting0 = json2Parser(str("pytorchDNN/"+moduleName1+".json")) + setting1 = json2Parser(str("pytorchDNN/"+moduleName2+".json")) + setting2 = json2Parser(str("pytorchDNN/"+moduleName3+".json")) + + lamda = setting0.power_transform + delta_t = setting0.delta_t + dim = setting0.dim + layers = setting0.layers + + Xmu0 = torch.tensor(setting0.Xmu).unsqueeze(0).to(device) + Xstd0 = torch.tensor(setting0.Xstd).unsqueeze(0).to(device=device) + Ymu0 = torch.tensor(setting0.Ymu).unsqueeze(0).to(device=device) + Ystd0 = torch.tensor(setting0.Ystd).unsqueeze(0).to(device=device) + + Xmu1 = torch.tensor(setting1.Xmu).unsqueeze(0).to(device=device) + Xstd1 = torch.tensor(setting1.Xstd).unsqueeze(0).to(device=device) + Ymu1 = torch.tensor(setting1.Ymu).unsqueeze(0).to(device=device) + Ystd1 = torch.tensor(setting1.Ystd).unsqueeze(0).to(device=device) + + Xmu2 = torch.tensor(setting2.Xmu).unsqueeze(0).to(device=device) + Xstd2 = torch.tensor(setting2.Xstd).unsqueeze(0).to(device=device) + Ymu2 = torch.tensor(setting2.Ymu).unsqueeze(0).to(device=device) + Ystd2 = torch.tensor(setting2.Ystd).unsqueeze(0).to(device=device) + + #load module + model0 = Net() + model1 = Net() + model2 = Net() + check_point0 = torch.load(str("pytorchDNN/"+moduleName1+".pt")) + check_point1 = torch.load(str("pytorchDNN/"+moduleName2+".pt")) + check_point2 = torch.load(str("pytorchDNN/"+moduleName3+".pt")) + model0.load_state_dict(check_point0) + model1.load_state_dict(check_point1) + model2.load_state_dict(check_point2) + model0.to(device=device) + model1.to(device=device) + model2.to(device=device) + if len(device_ids) > 1: + model0 = torch.nn.DataParallel(model0, device_ids=device_ids) + model1 = torch.nn.DataParallel(model1, device_ids=device_ids) + model2 = torch.nn.DataParallel(model2, device_ids=device_ids) +except Exception as e: + print(e.args) + + +def inference(vec0, vec1, vec2): + ''' + use model to inference + ''' + #args = np.reshape(args, (-1, 9)) #reshape to formed size + #vec0 = np.reshape(vec0, (-1, 24)) + #vec1 = np.reshape(vec1, (-1, 24)) + #vec2 = np.reshape(vec2, (-1, 24)) + vec0 = np.reshape(vec0, (-1, 10)) + vec1 = np.reshape(vec1, (-1, 10)) + vec2 = np.reshape(vec2, (-1, 10)) + + try: + with torch.no_grad(): + input0_ = torch.from_numpy(vec0).double().to(device=device) #cast ndarray to torch tensor + input1_ = torch.from_numpy(vec1).double().to(device=device) #cast ndarray to torch tensor + input2_ = torch.from_numpy(vec2).double().to(device=device) #cast ndarray to torch tensor + + # pre_processing + rho0 = input0_[:, 0].unsqueeze(1) + input0_Y = input0_[:, 3:].clone() + input0_bct = input0_[:, 1:] + input0_bct[:, 2:] = (input0_bct[:, 2:]**(lamda) - 1) / lamda #BCT + input0_normalized = (input0_bct - Xmu0) / Xstd0 + # input0_normalized[:, -1] = 0 #set Y_AR to 0 + input0_normalized = input0_normalized.float() + + rho1 = input1_[:, 0].unsqueeze(1) + input1_Y = input1_[:, 3:].clone() + input1_bct = input1_[:, 1:] + input1_bct[:, 2:] = (input1_bct[:, 2:]**(lamda) - 1) / lamda #BCT + input1_normalized = (input1_bct - Xmu1) / Xstd1 + # input1_normalized[:, -1] = 0 #set Y_AR to 0 + input1_normalized = input1_normalized.float() + + + rho2 = input2_[:, 0].unsqueeze(1) + input2_Y = input2_[:, 3:].clone() + input2_bct = input2_[:, 1:] + input2_bct[:, 2:] = (input2_bct[:, 2:]**(lamda) - 1) / lamda #BCT + input2_normalized = (input2_bct - Xmu2) / Xstd2 + # input2_normalized[:, -1] = 0 #set Y_AR to 0 + input2_normalized = input2_normalized.float() + + #inference + output0_normalized = model0(input0_normalized) + output1_normalized = model1(input1_normalized) + output2_normalized = model2(input2_normalized) + + + # post_processing + output0_bct = (output0_normalized * Ystd0 + Ymu0) * delta_t + input0_bct + output0_Y = (lamda * output0_bct[:, 2:] + 1)**(1 / lamda) + output0_Y = output0_Y / torch.sum(input=output0_Y, dim=1, keepdim=True) + output0 = (output0_Y - input0_Y) * rho0 / delta_t + output0 = output0.cpu().numpy() + + output1_bct = (output1_normalized * Ystd1 + Ymu1) * delta_t + input1_bct + output1_Y = (lamda * output1_bct[:, 2:] + 1)**(1 / lamda) + output1_Y = output1_Y / torch.sum(input=output1_Y, dim=1, keepdim=True) + output1 = (output1_Y - input1_Y) * rho1 / delta_t + output1 = output1.cpu().numpy() + + output2_bct = (output2_normalized * Ystd2 + Ymu2) * delta_t + input2_bct + output2_Y = (lamda * output2_bct[:, 2:] + 1)**(1 / lamda) + output2_Y = output2_Y / torch.sum(input=output2_Y, dim=1, keepdim=True) + output2 = (output2_Y - input2_Y) * rho2 / delta_t + output2 = output2.cpu().numpy() + + result = np.append(output0, output1, axis=0) + result = np.append(result, output2, axis=0) + return result + except Exception as e: + print(e.args) diff --git a/test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/pytorchDNN b/test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/pytorchDNN new file mode 120000 index 00000000..e774e027 --- /dev/null +++ b/test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/pytorchDNN @@ -0,0 +1 @@ +../../../../../mechanisms/H2/pytorchDNN/ \ No newline at end of file