From eeeaa57e68f8933ae6adb3cd5b6b340315f9f7bf Mon Sep 17 00:00:00 2001 From: JX278 Date: Sun, 13 Nov 2022 18:54:47 +0800 Subject: [PATCH 1/7] Update Validation --- ...uild.yml => CPU_inferencce_validation.yml} | 14 +- .github/workflows/cvode_validate.yml | 46 -- .gitignore | 4 +- Allwclean | 0 .../solvers/dfLowMachFoam/dfLowMachFoam.C | 2 +- mechanisms/H2/pytorchDNN/ESH2-sub1.json | 85 +++ mechanisms/H2/pytorchDNN/ESH2-sub2.json | 85 +++ mechanisms/H2/pytorchDNN/ESH2-sub3.json | 85 +++ test/CMakeLists.txt | 4 +- test/corrtest.cpp | 67 +- .../H2/cvodeSolver => }/0/H2.gz | Bin .../H2/cvodeSolver => }/0/N2.gz | Bin .../H2/cvodeSolver => }/0/O2.gz | Bin .../H2/cvodeSolver => }/0/T.gz | Bin .../CH4/cvodeSolver => }/0/U.gz | Bin .../CH4/cvodeSolver => }/0/Ydefault.gz | Bin .../CH4/cvodeSolver => }/0/alphat.gz | Bin .../H2/cvodeSolver => }/0/p.gz | Bin .../CH4/cvodeSolver => }/Allclean | 4 +- .../CH4/cvodeSolver => }/Allrun | 3 +- test/df0DFoam/ES80_H2-7-16.yaml | 1 + .../constant/CanteraTorchProperties | 23 +- .../constant/thermophysicalProperties | 0 .../constant/turbulenceProperties | 0 test/df0DFoam/inference.py | 209 ++++++ test/df0DFoam/pytorchDNN | 1 + .../H2/cvodeSolver => }/system/blockMeshDict | 2 +- .../CH4/cvodeSolver => }/system/controlDict | 4 +- .../decomposeParDict} | 36 +- .../CH4/cvodeSolver => }/system/fvSchemes | 0 .../CH4/cvodeSolver => }/system/fvSolution | 0 .../H2/cvodeSolver => }/system/probes | 2 +- .../CH4/cvodeSolver/0/CH4.gz | Bin 361 -> 0 bytes .../CH4/cvodeSolver/0/N2.gz | Bin 359 -> 0 bytes .../CH4/cvodeSolver/0/O2.gz | Bin 358 -> 0 bytes .../zeroD_cubicReactor/CH4/cvodeSolver/0/T.gz | Bin 361 -> 0 bytes .../zeroD_cubicReactor/CH4/cvodeSolver/0/p.gz | Bin 366 -> 0 bytes .../CH4/cvodeSolver/drm19.yaml | 600 ------------------ .../CH4/cvodeSolver/system/blockMeshDict | 62 -- .../CH4/cvodeSolver/system/probes | 21 - .../zeroD_cubicReactor/H2/cvodeSolver/0/U.gz | Bin 355 -> 0 bytes .../H2/cvodeSolver/0/Ydefault.gz | Bin 358 -> 0 bytes .../H2/cvodeSolver/0/alphat.gz | Bin 357 -> 0 bytes .../H2/cvodeSolver/Allclean | 9 - .../zeroD_cubicReactor/H2/cvodeSolver/Allrun | 10 - .../H2/cvodeSolver/ES80_H2-7-16.yaml | 205 ------ .../constant/thermophysicalProperties | 18 - .../cvodeSolver/constant/turbulenceProperties | 20 - .../H2/cvodeSolver/system/controlDict | 57 -- .../H2/cvodeSolver/system/fvSchemes | 59 -- .../H2/cvodeSolver/system/fvSolution | 73 --- .../constant/CanteraTorchProperties | 29 +- .../constant/CanteraTorchProperties | 20 +- .../H2/cvodeSolver/inference.py | 209 ++++++ .../H2/cvodeSolver/pytorchDNN | 1 + 55 files changed, 782 insertions(+), 1288 deletions(-) rename .github/workflows/{torch_build.yml => CPU_inferencce_validation.yml} (77%) delete mode 100644 .github/workflows/cvode_validate.yml mode change 100644 => 100755 Allwclean create mode 100644 mechanisms/H2/pytorchDNN/ESH2-sub1.json create mode 100644 mechanisms/H2/pytorchDNN/ESH2-sub2.json create mode 100644 mechanisms/H2/pytorchDNN/ESH2-sub3.json rename test/df0DFoam/{zeroD_cubicReactor/H2/cvodeSolver => }/0/H2.gz (100%) rename test/df0DFoam/{zeroD_cubicReactor/H2/cvodeSolver => }/0/N2.gz (100%) rename test/df0DFoam/{zeroD_cubicReactor/H2/cvodeSolver => }/0/O2.gz (100%) rename test/df0DFoam/{zeroD_cubicReactor/H2/cvodeSolver => }/0/T.gz (100%) rename test/df0DFoam/{zeroD_cubicReactor/CH4/cvodeSolver => }/0/U.gz (100%) rename test/df0DFoam/{zeroD_cubicReactor/CH4/cvodeSolver => }/0/Ydefault.gz (100%) rename test/df0DFoam/{zeroD_cubicReactor/CH4/cvodeSolver => }/0/alphat.gz (100%) rename test/df0DFoam/{zeroD_cubicReactor/H2/cvodeSolver => }/0/p.gz (100%) rename test/df0DFoam/{zeroD_cubicReactor/CH4/cvodeSolver => }/Allclean (71%) rename test/df0DFoam/{zeroD_cubicReactor/CH4/cvodeSolver => }/Allrun (69%) create mode 120000 test/df0DFoam/ES80_H2-7-16.yaml rename test/df0DFoam/{zeroD_cubicReactor/H2/cvodeSolver => }/constant/CanteraTorchProperties (71%) rename test/df0DFoam/{zeroD_cubicReactor/CH4/cvodeSolver => }/constant/thermophysicalProperties (100%) rename test/df0DFoam/{zeroD_cubicReactor/CH4/cvodeSolver => }/constant/turbulenceProperties (100%) create mode 100644 test/df0DFoam/inference.py create mode 120000 test/df0DFoam/pytorchDNN rename test/df0DFoam/{zeroD_cubicReactor/H2/cvodeSolver => }/system/blockMeshDict (94%) rename test/df0DFoam/{zeroD_cubicReactor/CH4/cvodeSolver => }/system/controlDict (95%) rename test/df0DFoam/{zeroD_cubicReactor/CH4/cvodeSolver/constant/CanteraTorchProperties => system/decomposeParDict} (64%) rename test/df0DFoam/{zeroD_cubicReactor/CH4/cvodeSolver => }/system/fvSchemes (100%) rename test/df0DFoam/{zeroD_cubicReactor/CH4/cvodeSolver => }/system/fvSolution (100%) rename test/df0DFoam/{zeroD_cubicReactor/H2/cvodeSolver => }/system/probes (95%) delete mode 100644 test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/CH4.gz delete mode 100644 test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/N2.gz delete mode 100644 test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/O2.gz delete mode 100644 test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/T.gz delete mode 100644 test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/0/p.gz delete mode 100644 test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/drm19.yaml delete mode 100644 test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/system/blockMeshDict delete mode 100644 test/df0DFoam/zeroD_cubicReactor/CH4/cvodeSolver/system/probes delete mode 100644 test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/U.gz delete mode 100644 test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/Ydefault.gz delete mode 100644 test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/0/alphat.gz delete mode 100755 test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/Allclean delete mode 100755 test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/Allrun delete mode 100644 test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/ES80_H2-7-16.yaml delete mode 100644 test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/constant/thermophysicalProperties delete mode 100644 test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/constant/turbulenceProperties delete mode 100644 test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/system/controlDict delete mode 100644 test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/system/fvSchemes delete mode 100644 test/df0DFoam/zeroD_cubicReactor/H2/cvodeSolver/system/fvSolution create mode 100644 test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/inference.py create mode 120000 test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/pytorchDNN diff --git a/.github/workflows/torch_build.yml b/.github/workflows/CPU_inferencce_validation.yml similarity index 77% rename from .github/workflows/torch_build.yml rename to .github/workflows/CPU_inferencce_validation.yml index 816258a3..22030c00 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: @@ -33,17 +34,18 @@ jobs: conda create -n libcantera python=3.8 conda activate libcantera conda install -c cantera libcantera-devel - conda install pytorch + conda install pytorch torchvision torchaudio -c pytorch -c nvidia conda install pybind11 + conda install -c conda-forge easdydict 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" + \ No newline at end of file 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/applications/solvers/dfLowMachFoam/dfLowMachFoam.C b/applications/solvers/dfLowMachFoam/dfLowMachFoam.C index 2b62d5d8..6c11674d 100644 --- a/applications/solvers/dfLowMachFoam/dfLowMachFoam.C +++ b/applications/solvers/dfLowMachFoam/dfLowMachFoam.C @@ -197,7 +197,7 @@ int main(int argc, char *argv[]) Info<< "============================================"<> 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 92a6f0d987f3b5cc7c41298313b5dabf57a8a89d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 361 zcmV-v0hazBiwFpkM+{>C14BqO0IgENP69Cyz4t379+yB@BQasafnZiIgabqmVobL? zNKI)s-7XP@f4AEfC0^jb>!qD}^Jd1Avva zRXw0oJDsIw>z+36ZLzOzYheVcJRT38(9}-K72kQLqk1AtfGJTmGIrXL#TnZ;8wn-3 z8!#6V$+vI334{3FH@!6T!KF59X2Yzk=0b!pm#nU%g^iXo&LlH=yV{VKn*T27D!mFp zU3?&qTI0vtjO+=ekX-CgN=PZzs9GCwx|bA=&TB@9P!^41GLIjjQKB^oX)o>fGfJzK z7+w=n=th;yY&|V*h&P4cZ-BceWB40hLr-94gUAeF!7czh1T*9l8%{{ HO#=V`LtCTt 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 c46b52f66f9fd882bbbe3a645b8d27e77ecb24ab..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 359 zcmV-t0hsQ>6N0+< zKpwRo`y+B7ltOZ~Ln$Gp*q~}%#Nl32I61E)LWHtt6q8x}2aOV~M@V~v{@sYuYAwdM zgcQ0_B{MruiwojSA^6)d<3l0Q!tN?O{dZqz^n+ogKxKpdgELILq&TTEcJ;r<0n-5JJVP99*TwXF1~(}*HY0t#rjp;l-WHJ*9Z3d<(|8*7_( zg0XfwYfZOfZQlE0U)|Tj3{-tS9z1c=Iw@Ct@0pJ3iLd~wMAOOG>43^BwsAEQjEEbM z2+7g6Z@deG_}MIXWVYA-UPX7@=Bhx$0fS;a*ZWJFhuHLRoGUl_dUyPKn+lq~k10bBvpfnBE~& z=}y(u>^&_mh;@}Nk8g+vd#Z}|DY`{G7F8d?jkY_NZHhLN{?EA*Cs08mvf2}}b3 E0Oy3DZvX%Q 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 2664edbf44167960820750e9633afce7f9873812..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 361 zcmV-v0hazBiwFpENep8E15^O5Qax|NFc97SD^83-;Lrt$r~{%()d4XOwL?=?j$?`| zV@HmIN(=wJ{(_<|Fz_rz&fU9r_fE#i-~y5X%=TqIg*i2&}8fdAOrY*~go2FQUk zQU7IO(J+}Wrt=9DYv%u8sX9#=%<=~)loFNtvKmpuO27gdritN7MvWI%wcM}?z}lFm zonWl2&PtKZQ0Wg>?5kZZOhMM?QhGy7n3c4Y^AM(jv~9GoRbokrAUb!e4SAvHX+gcT7lNw# zWHf3O89E@0A-UPX7@?YPm~&D`02T>A HP6Ge{SWc_L 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 a187d772b9e6cdbd59dff9bb40537711da320d11..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 366 zcmV-!0g?V6iwFpyNDN~D18@MXQn7BrFc97S6{n6t!3h0VDJ4qvX*Gg~m4F2_OcTSE3>wd@Y`I|*fQ>Ot zJHc34owXwMQ0e!+*j4wnFa=qijt5Unw^qs)-#MnGIwH)0NZxcJblRihf^A%k2&3E% zm~+9r~KCfb#pz8y0zl-=e*Fx|7 M2TFn2@=^l;0N&)Qp#T5? 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 3126670b909dab2f4a5724f95832f41b349b8e19..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 355 zcmV-p0i6CHiwFp}o}yv^162U6Qn7BrFc97S6(^=PC^&Sf1nPjO(g`t?(xFt9lN`mB z@kNeY~-E*9a=0aB2t zioYyOOVsIfG#S8bh5iMPRGS=OoZiEXNM-ctG+GfS0aGZ^2rEgq8qb(j(&7MMWo=mv zI47sGB(d(1d2fn+byEu?(8ck1Fh^54DOY^!nU3m-Fae=uS*y0wjxEmE#@UECOWlB} zRLH)4<4qXE_rB>RLmym{SqmFx6;&=}2D`pGgino>c&Jn+e-p{i2IO)^EzZqYKuk-mA3z&*0S*kSDtb07#Y>N z5N7Kc?QZfqllj{r<3l0Qz-~)C{&HVv=)s6WqPD^L-kD|I?xoP!{Q($5r;SGg003h_ BsoMYm 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 355dc649c45bd7df2d67756ff100e51b1f3d9f84..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 358 zcmV-s0h#_EiwFp}o}yv^16gEcW?^+~bO5bV!A=4(5WV*+CLEVQi5C+#9tftM2nUG9 zxW;t5gVdCE)9n&b_;$$=eZVZuQoJ3R5Q;uZ7O%4@om)zefWA E0L@;ie*gdg 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 47f73f02b2e4a0768468f9ff998d79827364adbc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 357 zcmV-r0h<0FiwFp}o}yv^17U1%Xkl~!tx~aW!Y~ls{S_z1pkUgi5~u^Bawo(9YKNw( z9Oo#mj2$@+DlPnb9ow|13k*DGaPHl`yLU3p@-xVCnD+aSpH1|s1p&A}0{&y~*`kPd z3cx_3s{UA**QnWiG8@5ijo}X#rnLfL${t{8j4I8i*GM8>0_ISojHzS$QL*jA5a8(H=-@2csnv76p0RQSL5lE`$B6TEw3bM7o8uxPZFG73!T#+0xl(1M*{!= DjkTib 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..6bcbed14 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..b7f3f952 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 From 70e1606aeb6f44e768d6c75260cb27ea54d7ff1d Mon Sep 17 00:00:00 2001 From: JX278 <113102069+JX278@users.noreply.github.com> Date: Sun, 13 Nov 2022 19:48:27 +0800 Subject: [PATCH 2/7] Update CPU_inferencce_validation.yml --- .github/workflows/CPU_inferencce_validation.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CPU_inferencce_validation.yml b/.github/workflows/CPU_inferencce_validation.yml index 22030c00..148c0f32 100644 --- a/.github/workflows/CPU_inferencce_validation.yml +++ b/.github/workflows/CPU_inferencce_validation.yml @@ -34,9 +34,9 @@ jobs: conda create -n libcantera python=3.8 conda activate libcantera conda install -c cantera libcantera-devel - conda install pytorch torchvision torchaudio -c pytorch -c nvidia + conda install pytorch conda install pybind11 - conda install -c conda-forge easdydict + conda install easdydict cd /github/home/miniconda3/envs/libcantera/lib ln -s libmkl_rt.so.1 libmkl_rt.so.2 @@ -48,4 +48,4 @@ jobs: run: /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" - \ No newline at end of file + From 4b6d8879e7961b40cfb95d1b838ea69962e5d981 Mon Sep 17 00:00:00 2001 From: JX278 <113102069+JX278@users.noreply.github.com> Date: Sun, 13 Nov 2022 20:00:56 +0800 Subject: [PATCH 3/7] install easydict --- .github/workflows/CPU_inferencce_validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CPU_inferencce_validation.yml b/.github/workflows/CPU_inferencce_validation.yml index 148c0f32..6581e547 100644 --- a/.github/workflows/CPU_inferencce_validation.yml +++ b/.github/workflows/CPU_inferencce_validation.yml @@ -36,7 +36,7 @@ jobs: conda install -c cantera libcantera-devel conda install pytorch conda install pybind11 - conda install easdydict + conda install -c auto easdydict cd /github/home/miniconda3/envs/libcantera/lib ln -s libmkl_rt.so.1 libmkl_rt.so.2 From 7c14c2a650765fff40a3dda52a2d9ca801fda6f9 Mon Sep 17 00:00:00 2001 From: JX278 <113102069+JX278@users.noreply.github.com> Date: Sun, 13 Nov 2022 20:08:05 +0800 Subject: [PATCH 4/7] install easydict --- .github/workflows/CPU_inferencce_validation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CPU_inferencce_validation.yml b/.github/workflows/CPU_inferencce_validation.yml index 6581e547..c1efbc71 100644 --- a/.github/workflows/CPU_inferencce_validation.yml +++ b/.github/workflows/CPU_inferencce_validation.yml @@ -36,7 +36,7 @@ jobs: conda install -c cantera libcantera-devel conda install pytorch conda install pybind11 - conda install -c auto easdydict + 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 From fb74c558fd0c482e25a47b1539681265e4c0ca86 Mon Sep 17 00:00:00 2001 From: JX278 <113102069+JX278@users.noreply.github.com> Date: Sun, 13 Nov 2022 20:20:21 +0800 Subject: [PATCH 5/7] Update dfChemistryModel.H --- src/dfChemistryModel/dfChemistryModel.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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_; From 976b1b0d90f81a77bc2c0c64c23bf754b4a4f738 Mon Sep 17 00:00:00 2001 From: JX278 <113102069+JX278@users.noreply.github.com> Date: Sun, 13 Nov 2022 22:00:45 +0800 Subject: [PATCH 6/7] Update CanteraTorchProperties --- .../oneD_detonationH2/constant/CanteraTorchProperties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/dfHighSpeedFoam/oneD_detonationH2/constant/CanteraTorchProperties b/test/dfHighSpeedFoam/oneD_detonationH2/constant/CanteraTorchProperties index 6bcbed14..eab63f28 100644 --- a/test/dfHighSpeedFoam/oneD_detonationH2/constant/CanteraTorchProperties +++ b/test/dfHighSpeedFoam/oneD_detonationH2/constant/CanteraTorchProperties @@ -21,8 +21,8 @@ CanteraMechanismFile "H2_Li.xml"; transportModel "Mix";//"UnityLewis"; odeCoeffs { - "relTol" 1e-15; - "absTol" 1e-24; + //"relTol" 1e-15; + //"absTol" 1e-24; } inertSpecie "N2"; zeroDReactor From e4da5ce7c3f79bdf513fd3ed94307e2af9a1a05d Mon Sep 17 00:00:00 2001 From: JX278 <113102069+JX278@users.noreply.github.com> Date: Sun, 13 Nov 2022 22:01:10 +0800 Subject: [PATCH 7/7] Update CanteraTorchProperties --- .../H2/cvodeSolver/constant/CanteraTorchProperties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/constant/CanteraTorchProperties b/test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/constant/CanteraTorchProperties index b7f3f952..17ae27cb 100644 --- a/test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/constant/CanteraTorchProperties +++ b/test/dfLowMachFoam/twoD_reactingTGV/H2/cvodeSolver/constant/CanteraTorchProperties @@ -21,8 +21,8 @@ CanteraMechanismFile "ES80_H2-7-16.yaml"; transportModel "Mix";//"UnityLewis"; odeCoeffs { - "relTol" 1e-15; - "absTol" 1e-24; + //"relTol" 1e-15; + //"absTol" 1e-24; } inertSpecie "N2"; zeroDReactor