diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/Allclean b/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/Allclean deleted file mode 100755 index cfd3b14e..00000000 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/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/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/system/blockMeshDict b/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/system/blockMeshDict deleted file mode 100644 index 35edbf14..00000000 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/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/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/system/probes b/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/system/probes deleted file mode 100644 index 69419544..00000000 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/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/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/0/CH4.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/CH4.gz similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/0/CH4.gz rename to examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/CH4.gz diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/0/N2.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/N2.gz similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/0/N2.gz rename to examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/N2.gz diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/0/O2.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/O2.gz similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/0/O2.gz rename to examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/O2.gz diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/0/T.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/T.gz similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/0/T.gz rename to examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/T.gz diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/0/U.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/U.gz similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/0/U.gz rename to examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/U.gz diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/0/Ydefault.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/Ydefault.gz similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/0/Ydefault.gz rename to examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/Ydefault.gz diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/0/alphat.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/alphat.gz similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/0/alphat.gz rename to examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/alphat.gz diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/0/p.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/p.gz similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/0/p.gz rename to examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/p.gz diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/Allclean b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/Allclean similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/Allclean rename to examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/Allclean diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/Allrun b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/Allrun similarity index 69% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/Allrun rename to examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/Allrun index d060ec7b..e135a676 100755 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/Allrun +++ b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/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/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/constant/CanteraTorchProperties b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/constant/CanteraTorchProperties new file mode 100644 index 00000000..16236420 --- /dev/null +++ b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/constant/CanteraTorchProperties @@ -0,0 +1,61 @@ +/*--------------------------------*- 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 chemistryProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +chemistry on; +CanteraMechanismFile "drm19.yml"; +transportModel "Mix";//"UnityLewis"; +odeCoeffs +{ + "relTol" 1e-15; + "absTol" 1e-24; +} +inertSpecie "N2"; + +zeroDReactor +{ + constantProperty "pressure";//cvorcp "UV"; +} + +torch on; +GPU on; +torchModel1 "modeldrm19_0.pt"; +torchModel2 "modeldrm19_1.pt"; +torchModel3 "modeldrm19_2.pt"; + +torchParameters1 +{ + Tact 700 ; + Qdotact 3e7; + coresPerGPU 4; +} +torchParameters2 +{ + Tact 2000; + Qdotact 3e7; +} +torchParameters3 +{ + Tact 2000; + Qdotact 7e8; +} +loadbalancing +{ + active false; + //log true; +} +// ************************************************************************* // diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/constant/thermophysicalProperties b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/constant/thermophysicalProperties similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/constant/thermophysicalProperties rename to examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/constant/thermophysicalProperties diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/constant/turbulenceProperties b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/constant/turbulenceProperties similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/constant/turbulenceProperties rename to examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/constant/turbulenceProperties diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/drm19.yaml b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/drm19.yaml new file mode 100644 index 00000000..321c72c1 --- /dev/null +++ b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/drm19.yaml @@ -0,0 +1,600 @@ +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/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/inference.py b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/inference.py new file mode 100644 index 00000000..bf0bd7b7 --- /dev/null +++ b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/inference.py @@ -0,0 +1,173 @@ +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) +print('position 0 in inference.py') +device = torch.device("cuda") +device_ids = range(torch.cuda.device_count()) + + + +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: + #glbal variable will only init once when called interperter + #load parameters from json + setting0 = json2Parser('settingsdrm19_0.json') + setting1 = json2Parser('settingsdrm19_1.json') + setting2 = json2Parser('settingsdrm19_2.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) + print('position 1 in inference.py') + + #load module + model0 = Net() + model1 = Net() + model2 = Net() + check_point0 = torch.load('modeldrm19_0.pt') + check_point1 = torch.load('modeldrm19_1.pt') + check_point2 = torch.load('modeldrm19_2.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) + print('call init') +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)) + + 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/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/system/blockMeshDict b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/blockMeshDict similarity index 94% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/system/blockMeshDict rename to examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/blockMeshDict index 35edbf14..b762a930 100644 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/system/blockMeshDict +++ b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/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/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/system/controlDict b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/controlDict similarity index 95% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/system/controlDict rename to examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/controlDict index f974f450..8d64da2b 100644 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/system/controlDict +++ b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/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/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/system/decomposeParDict b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/decomposeParDict similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/system/decomposeParDict rename to examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/decomposeParDict diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/system/fvSchemes b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/fvSchemes similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/system/fvSchemes rename to examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/fvSchemes diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/system/fvSolution b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/fvSolution similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/system/fvSolution rename to examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/fvSolution diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/system/probes b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/probes similarity index 95% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/system/probes rename to examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/probes index 69419544..e327da35 100644 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/system/probes +++ b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/probes @@ -12,7 +12,7 @@ Description #includeEtc "caseDicts/postProcessing/probes/probes.cfg" -fields (T);// Writes out T +fields (T Qdot);// Writes out T probeLocations ( (0.0025 0.0025 0.0025) diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/CH4.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/CH4.gz deleted file mode 100644 index 15e4e0cb..00000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/CH4.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/N2.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/N2.gz deleted file mode 100644 index 4d74eb02..00000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/N2.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/O2.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/O2.gz deleted file mode 100644 index 4e9b582a..00000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/O2.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/T.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/T.gz deleted file mode 100644 index 87f98f60..00000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/T.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/U.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/U.gz deleted file mode 100644 index 3126670b..00000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/U.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/Ydefault.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/Ydefault.gz deleted file mode 100644 index 355dc649..00000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/Ydefault.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/alphat.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/alphat.gz deleted file mode 100644 index 47f73f02..00000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/alphat.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/p.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/p.gz deleted file mode 100644 index 841ae144..00000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/0/p.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/Allrun b/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/Allrun deleted file mode 100755 index d060ec7b..00000000 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/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/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/constant/CanteraTorchProperties b/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/constant/CanteraTorchProperties deleted file mode 100644 index 5b963032..00000000 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/constant/CanteraTorchProperties +++ /dev/null @@ -1,150 +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; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -chemistry on; -CanteraMechanismFile "drm19.yaml"; -transportModel "UnityLewis"; -odeCoeffs -{ - // "relTol" 1e-6; - // "absTol" 1e-10; -} -inertSpecie "N2"; -zeroDReactor -{ - constantProperty "pressure"; -} - -torch on; -torchModel "new_modle.pt"; -torchParameters -{ - Xmu - ( - 2217.681756356299 - 1.2372712155690098 - -6.609314703664828 - -7.199323262359706 - -7.332119442940071 - -5.536742631230836 - -7.141802501972486 - -6.333364316313202 - -8.281175325793479 - -8.060951482192744 - -8.49172604048069 - -7.4362163282010165 - -7.260022789860538 - -5.901163772303269 - -7.06737218812143 - -8.399800896426937 - -7.837104938350125 - -9.101106174651347 - -6.740307445673868 - -8.599370078438403 - -8.527557104158248 - -0.7933260588414361 - -10.0 - ); - - Xstd - ( - 431.02496274992524 - 0.43376378804689036 - 2.250444184227253 - 1.5647416107504606 - 2.0410742923466034 - 2.75788270699218 - 1.7690213388390568 - 2.6060105142365306 - 1.2877128635203885 - 1.5196568528155139 - 1.187695396994965 - 1.8513826185906734 - 2.3900253720056415 - 2.5641309214772487 - 2.2930767685500215 - 1.0796313028856495 - 1.5875358125877437 - 0.7985642336685125 - 2.8916261288345817 - 1.2874033801112403 - 1.5502545098064442 - 1.172788655352323 - 0.0 - ); - - Ymu - ( - 8611599.996488582 - 1.0052402090809686e-13 - 306261.2582791327 - 302952.5661750507 - 246191.97294072132 - 55748.11516946665 - 282740.30622731353 - 338184.77009267046 - 154989.97473252448 - 161933.173349431 - 116333.18977890848 - 223721.37434340312 - 121632.89085603201 - 385655.7343662997 - 236970.81031441092 - 120921.61016921779 - 196030.99284250094 - 10072.793690942817 - 217110.811370787 - 66131.62556631157 - 62348.07619523203 - 1.541860153892557e-08 - 0.0 - ); - - Ystd - ( - 43905478.14125182 - 2.1250436459521883e-10 - 931519.7384718517 - 910510.3349682757 - 974754.1196238518 - 521783.8276859063 - 1007243.1555762171 - 1080286.1639236603 - 750969.551828101 - 813498.3823317331 - 699083.7766516082 - 935639.3875055335 - 700980.8395528512 - 1128324.3659794962 - 787883.0462028814 - 802501.6759949023 - 866138.6664999034 - 570611.085616025 - 911540.1747972643 - 735083.0620995432 - 691625.7072341049 - 3.357557946945996e-05 - 0.0 - ); -} -loadbalancing -{ - active false; - //log true; -} - -// ************************************************************************* // diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/system/controlDict b/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/system/controlDict deleted file mode 100644 index 04266ca8..00000000 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/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 0.01 - -purgeWrite 0; - -writeFormat ascii; - -// writePrecision 6; - -writeCompression on; - -timeFormat general; - -timePrecision 6; - -runTimeModifiable true; - -functions -{ - # includeFunc probes -} - -// ************************************************************************* // diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/system/fvSchemes b/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/system/fvSchemes deleted file mode 100644 index 0b7dcc26..00000000 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/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/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/system/fvSolution b/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/system/fvSolution deleted file mode 100644 index c8b4eb91..00000000 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/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/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/Allclean b/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/Allclean index cfd3b14e..7c527e99 100755 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/Allclean +++ b/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/Allclean @@ -1,7 +1,7 @@ #!/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 diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/Allrun b/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/Allrun index d060ec7b..e135a676 100755 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/Allrun +++ b/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/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/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/constant/CanteraTorchProperties b/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/constant/CanteraTorchProperties index 52358492..d7cb78da 100644 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/constant/CanteraTorchProperties +++ b/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/constant/CanteraTorchProperties @@ -11,27 +11,51 @@ 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"; +} + +torch off; +GPU off; +torchModel1 "ESH2-sub1.pt"; +torchModel2 "ESH2-sub2.pt"; +torchModel3 "ESH2-sub3.pt"; + +torchParameters1 +{ + Tact 700 ; + Qdotact 3e7; + coresPerGPU 4; +} +torchParameters2 +{ + Tact 2000; + Qdotact 3e7; +} +torchParameters3 +{ + Tact 2000; + Qdotact 7e8; } loadbalancing { active false; //log true; } - // ************************************************************************* // diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/inference.py b/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/inference.py new file mode 100644 index 00000000..9238a55f --- /dev/null +++ b/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/inference.py @@ -0,0 +1,211 @@ +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) +print('position 0 in inference.py') + + +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) + switch_GPU = data[i+4:a] + + #load OpenFOAM switch + switch_on = ["True", "on", "yes", "y", "t", "any"] + switch_off = ["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) + print('position 1 in inference.py') + + #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) + print('call init') +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/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/pytorchDNN b/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/pytorchDNN new file mode 120000 index 00000000..e774e027 --- /dev/null +++ b/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/pytorchDNN @@ -0,0 +1 @@ +../../../../../mechanisms/H2/pytorchDNN/ \ No newline at end of file diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/system/blockMeshDict b/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/system/blockMeshDict index 35edbf14..b762a930 100644 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/system/blockMeshDict +++ b/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/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/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/system/controlDict b/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/system/controlDict index a324a3e2..8d64da2b 100644 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/system/controlDict +++ b/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/system/controlDict @@ -15,7 +15,7 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -application dfLMFoam; +application df0DFoam; startFrom startTime; @@ -23,7 +23,7 @@ startTime 0; stopAt endTime; -endTime 0.001; +endTime 1e-3; deltaT 1e-06; @@ -33,7 +33,7 @@ adjustTimeStep off; writeControl runTime; -writeInterval 10000; +writeInterval 0.01; purgeWrite 0; diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/system/decomposeParDict b/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/system/decomposeParDict similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/system/decomposeParDict rename to examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/system/decomposeParDict diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/system/probes b/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/system/probes index 2790ce65..e327da35 100644 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/system/probes +++ b/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/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/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/Allrun b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/Allrun index d060ec7b..e135a676 100755 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/Allrun +++ b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/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/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/constant/CanteraTorchProperties b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/constant/CanteraTorchProperties index 29c96837..28be4c60 100644 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/constant/CanteraTorchProperties +++ b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/constant/CanteraTorchProperties @@ -7,62 +7,55 @@ \*---------------------------------------------------------------------------*/ FoamFile { - version 2.0; - format ascii; - class dictionary; - location "constant"; - object chemistryProperties; + version 2.0; + format ascii; + class dictionary; + location "constant"; + object chemistryProperties; } +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -chemistry on; +chemistry on; CanteraMechanismFile "ES80_H2-7-16.yaml"; - -transportModel "Mix"; //"UnityLewis"; - +transportModel "Mix";//"UnityLewis"; odeCoeffs { - "relTol" 1e-15; - "absTol" 1e-24; + "relTol" 1e-15; + "absTol" 1e-24; } - -inertSpecie "N2"; +inertSpecie "N2"; zeroDReactor { - constantProperty "pressure"; + constantProperty "pressure";//cvorcp "UV"; } -torch on; -GPU on; -torchModel1 "new_ESH2sub1.pt"; -torchModel2 "new_ESH2sub2.pt"; -torchModel3 "new_ESH2sub3.pt"; +torch on; +GPU on; +torchModel1 "ESH2-sub1.pt"; +torchModel2 "ESH2-sub2.pt"; +torchModel3 "ESH2-sub3.pt"; -torchParameters1 +torchParameters1 { - Tact 700; - Qdotact 3e+07; - coresPerGPU 4; + Tact 700 ; + Qdotact 3e7; + coresPerGPU 4; } - torchParameters2 { - Tact 2000; - Qdotact 3e+07; + Tact 2000; + Qdotact 3e7; } - torchParameters3 { - Tact 2000; - Qdotact 7e+08; + Tact 2000; + Qdotact 7e8; } - loadbalancing { - active false; - //log true; + active false; + //log true; } - - // ************************************************************************* // diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/blockMeshDict b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/blockMeshDict index 35edbf14..b762a930 100644 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/blockMeshDict +++ b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/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/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/controlDict b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/controlDict index a324a3e2..8d64da2b 100644 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/controlDict +++ b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/controlDict @@ -15,7 +15,7 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -application dfLMFoam; +application df0DFoam; startFrom startTime; @@ -23,7 +23,7 @@ startTime 0; stopAt endTime; -endTime 0.001; +endTime 1e-3; deltaT 1e-06; @@ -33,7 +33,7 @@ adjustTimeStep off; writeControl runTime; -writeInterval 10000; +writeInterval 0.01; purgeWrite 0; diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/constant/CanteraTorchProperties b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/decomposeParDict similarity index 64% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/constant/CanteraTorchProperties rename to examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/decomposeParDict index 0f125d43..45c7f859 100644 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/constant/CanteraTorchProperties +++ b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/decomposeParDict @@ -10,32 +10,36 @@ FoamFile version 2.0; format ascii; class dictionary; - location "constant"; - object chemistryProperties; + location "system"; + object decomposeParDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +numberOfSubdomains 4; -chemistry on; -CanteraMechanismFile "drm19.yaml"; -transportModel "Mix"; -odeCoeffs +method scotch; + +simpleCoeffs { - "relTol" 1e-6; - "absTol" 1e-10; + n (4 1 1); + delta 0.001; } -inertSpecie "N2"; -zeroDReactor + +hierarchicalCoeffs { - //cvorcp "UV"; + n (1 1 1); + delta 0.001; + order xyz; } -splittingStrategy off; - -loadbalancing +manualCoeffs { - active true; - //log true; + dataFile ""; } +distributed no; + +roots ( ); + + // ************************************************************************* // diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/probes b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/probes index 2790ce65..e327da35 100644 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/probes +++ b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/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/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/drm19.yaml b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/drm19.yaml deleted file mode 100644 index f4edcc54..00000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/drm19.yaml +++ /dev/null @@ -1,2 +0,0 @@ -../../../../../mechanisms/CH4/drm19.yaml - diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/AR.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/AR.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/AR.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/AR.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/C2H4.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/C2H4.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/C2H4.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/C2H4.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/C2H5.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/C2H5.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/C2H5.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/C2H5.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/C2H6.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/C2H6.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/C2H6.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/C2H6.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/CH2(S).gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH2(S).gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/CH2(S).gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH2(S).gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/CH2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH2.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/CH2.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH2.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/CH2O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH2O.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/CH2O.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH2O.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/CH3.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH3.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/CH3.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH3.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/CH3O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH3O.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/CH3O.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH3O.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/CH4.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH4.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/CH4.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH4.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/CO.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CO.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/CO.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CO.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/CO2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CO2.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/CO2.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CO2.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/H.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/H.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/H.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/H.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/H2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/H2.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/H2.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/H2.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/H2O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/H2O.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/H2O.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/H2O.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/HCO.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/HCO.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/HCO.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/HCO.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/HO2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/HO2.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/HO2.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/HO2.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/N2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/N2.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/N2.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/N2.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/O.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/O.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/O.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/O2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/O2.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/O2.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/O2.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/OH.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/OH.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/OH.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/OH.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/T.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/T.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/T.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/T.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/U.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/U.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/U.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/U.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/p.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/p.gz similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/0/p.gz rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/p.gz diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/Allclean b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/Allclean similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/Allclean rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/Allclean diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/Allrun b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/Allrun similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/Allrun rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/Allrun diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/constant/CanteraTorchProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/constant/CanteraTorchProperties new file mode 100644 index 00000000..16236420 --- /dev/null +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/constant/CanteraTorchProperties @@ -0,0 +1,61 @@ +/*--------------------------------*- 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 chemistryProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +chemistry on; +CanteraMechanismFile "drm19.yml"; +transportModel "Mix";//"UnityLewis"; +odeCoeffs +{ + "relTol" 1e-15; + "absTol" 1e-24; +} +inertSpecie "N2"; + +zeroDReactor +{ + constantProperty "pressure";//cvorcp "UV"; +} + +torch on; +GPU on; +torchModel1 "modeldrm19_0.pt"; +torchModel2 "modeldrm19_1.pt"; +torchModel3 "modeldrm19_2.pt"; + +torchParameters1 +{ + Tact 700 ; + Qdotact 3e7; + coresPerGPU 4; +} +torchParameters2 +{ + Tact 2000; + Qdotact 3e7; +} +torchParameters3 +{ + Tact 2000; + Qdotact 7e8; +} +loadbalancing +{ + active false; + //log true; +} +// ************************************************************************* // diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/constant/combustionProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/constant/combustionProperties similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/constant/combustionProperties rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/constant/combustionProperties diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/constant/thermophysicalProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/constant/thermophysicalProperties similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/constant/thermophysicalProperties rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/constant/thermophysicalProperties diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/constant/turbulenceProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/constant/turbulenceProperties similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/constant/turbulenceProperties rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/constant/turbulenceProperties diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/drm19.yaml b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/drm19.yaml similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/drm19.yaml rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/drm19.yaml diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/system/blockMeshDict b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/blockMeshDict similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/system/blockMeshDict rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/blockMeshDict diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/system/controlDict b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/controlDict similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/system/controlDict rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/controlDict diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/constant/CanteraTorchProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/decomposeParDict similarity index 64% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/constant/CanteraTorchProperties rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/decomposeParDict index cc24cd4f..45c7f859 100644 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/cvodeIntegrator/constant/CanteraTorchProperties +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/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/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/system/fvSchemes b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/fvSchemes similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/system/fvSchemes rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/fvSchemes diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/system/fvSolution b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/fvSolution similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/system/fvSolution rename to examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/fvSolution diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/AR.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/AR.gz deleted file mode 100755 index 39adf801..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/AR.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/C2H4.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/C2H4.gz deleted file mode 100755 index d1aabb1a..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/C2H4.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/C2H5.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/C2H5.gz deleted file mode 100755 index ba4711f8..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/C2H5.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/C2H6.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/C2H6.gz deleted file mode 100755 index 29873bdb..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/C2H6.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CH2(S).gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CH2(S).gz deleted file mode 100755 index e1d2de10..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CH2(S).gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CH2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CH2.gz deleted file mode 100755 index 0ad562ff..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CH2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CH2O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CH2O.gz deleted file mode 100755 index 218a6102..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CH2O.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CH3.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CH3.gz deleted file mode 100755 index 0d4bfdc4..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CH3.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CH3O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CH3O.gz deleted file mode 100755 index 7fa7b69b..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CH3O.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CH4.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CH4.gz deleted file mode 100755 index d1559cce..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CH4.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CO.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CO.gz deleted file mode 100755 index 92b25018..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CO.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CO2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CO2.gz deleted file mode 100755 index ab0b2d5c..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/CO2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/H.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/H.gz deleted file mode 100755 index 41a39ed7..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/H.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/H2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/H2.gz deleted file mode 100755 index b6efee05..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/H2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/H2O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/H2O.gz deleted file mode 100755 index 0963f271..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/H2O.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/HCO.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/HCO.gz deleted file mode 100755 index a93d4f08..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/HCO.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/HO2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/HO2.gz deleted file mode 100755 index 61491707..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/HO2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/N2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/N2.gz deleted file mode 100755 index 49b6beb2..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/N2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/O.gz deleted file mode 100755 index 1dc5916d..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/O.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/O2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/O2.gz deleted file mode 100755 index f1b43da3..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/O2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/OH.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/OH.gz deleted file mode 100755 index eba77fd5..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/OH.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/T.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/T.gz deleted file mode 100755 index 38ad95f2..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/T.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/U.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/U.gz deleted file mode 100755 index c500264a..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/U.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/p.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/p.gz deleted file mode 100755 index ac1af812..00000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/0/p.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/constant/CanteraTorchProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/constant/CanteraTorchProperties deleted file mode 100644 index 76369128..00000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/constant/CanteraTorchProperties +++ /dev/null @@ -1,154 +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 chemistryProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - - -chemistry on; -CanteraMechanismFile "drm19.yaml"; -transportModel "Mix"; -odeCoeffs -{ - "relTol" 1e-6; - "absTol" 1e-10; -} -inertSpecie "N2"; -zeroDReactor -{ - //cvorcp "UV"; -} - -splittingStrategy off; - -torch on; -torchModel "new_modle.pt"; - -torchParameters -{ - Xmu - ( - 2217.681756356299 - 1.2372712155690098 - -6.609314703664828 - -7.199323262359706 - -7.332119442940071 - -5.536742631230836 - -7.141802501972486 - -6.333364316313202 - -8.281175325793479 - -8.060951482192744 - -8.49172604048069 - -7.4362163282010165 - -7.260022789860538 - -5.901163772303269 - -7.06737218812143 - -8.399800896426937 - -7.837104938350125 - -9.101106174651347 - -6.740307445673868 - -8.599370078438403 - -8.527557104158248 - -0.7933260588414361 - -10.0 - ); - - Xstd - ( - 431.02496274992524 - 0.43376378804689036 - 2.250444184227253 - 1.5647416107504606 - 2.0410742923466034 - 2.75788270699218 - 1.7690213388390568 - 2.6060105142365306 - 1.2877128635203885 - 1.5196568528155139 - 1.187695396994965 - 1.8513826185906734 - 2.3900253720056415 - 2.5641309214772487 - 2.2930767685500215 - 1.0796313028856495 - 1.5875358125877437 - 0.7985642336685125 - 2.8916261288345817 - 1.2874033801112403 - 1.5502545098064442 - 1.172788655352323 - 0.0 - ); - - Ymu - ( - 8611599.996488582 - 1.0052402090809686e-13 - 306261.2582791327 - 302952.5661750507 - 246191.97294072132 - 55748.11516946665 - 282740.30622731353 - 338184.77009267046 - 154989.97473252448 - 161933.173349431 - 116333.18977890848 - 223721.37434340312 - 121632.89085603201 - 385655.7343662997 - 236970.81031441092 - 120921.61016921779 - 196030.99284250094 - 10072.793690942817 - 217110.811370787 - 66131.62556631157 - 62348.07619523203 - 1.541860153892557e-08 - 0.0 - ); - - Ystd - ( - 43905478.14125182 - 2.1250436459521883e-10 - 931519.7384718517 - 910510.3349682757 - 974754.1196238518 - 521783.8276859063 - 1007243.1555762171 - 1080286.1639236603 - 750969.551828101 - 813498.3823317331 - 699083.7766516082 - 935639.3875055335 - 700980.8395528512 - 1128324.3659794962 - 787883.0462028814 - 802501.6759949023 - 866138.6664999034 - 570611.085616025 - 911540.1747972643 - 735083.0620995432 - 691625.7072341049 - 3.357557946945996e-05 - 0.0 - ); -} -loadbalancing -{ - active false; - //log true; -} - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/constant/thermophysicalProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/constant/thermophysicalProperties deleted file mode 100644 index 7f207bb7..00000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/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/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/drm19.yaml b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/drm19.yaml deleted file mode 120000 index 6aed11e7..00000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/drm19.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/CH4/drm19.yaml \ No newline at end of file diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/H.gz b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/H.gz new file mode 100644 index 00000000..e0265689 Binary files /dev/null and b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/H.gz differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/H2.gz b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/H2.gz new file mode 100644 index 00000000..4674ce6d Binary files /dev/null and b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/H2.gz differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/H2O.gz b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/H2O.gz new file mode 100644 index 00000000..8fbd42b7 Binary files /dev/null and b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/H2O.gz differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/H2O2.gz b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/H2O2.gz new file mode 100644 index 00000000..ce14de9b Binary files /dev/null and b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/H2O2.gz differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/HO2.gz b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/HO2.gz new file mode 100644 index 00000000..50c50e79 Binary files /dev/null and b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/HO2.gz differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/N2.gz b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/N2.gz new file mode 100644 index 00000000..fae63f29 Binary files /dev/null and b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/N2.gz differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/O.gz b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/O.gz new file mode 100644 index 00000000..1d0aebb3 Binary files /dev/null and b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/O.gz differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/O2.gz b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/O2.gz new file mode 100644 index 00000000..87f403b1 Binary files /dev/null and b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/O2.gz differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/OH.gz b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/OH.gz new file mode 100644 index 00000000..35a199a1 Binary files /dev/null and b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/OH.gz differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/T.gz b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/T.gz new file mode 100644 index 00000000..ef777773 Binary files /dev/null and b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/T.gz differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/U.gz b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/U.gz new file mode 100644 index 00000000..1ceb95c7 Binary files /dev/null and b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/U.gz differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/p.gz b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/p.gz new file mode 100644 index 00000000..6bc27aba Binary files /dev/null and b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/0/p.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/Allclean b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/Allclean similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/Allclean rename to examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/Allclean diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/Allrun b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/Allrun similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/Allrun rename to examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/Allrun diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/constant/CanteraTorchProperties b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/constant/CanteraTorchProperties new file mode 100644 index 00000000..16236420 --- /dev/null +++ b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/constant/CanteraTorchProperties @@ -0,0 +1,61 @@ +/*--------------------------------*- 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 chemistryProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +chemistry on; +CanteraMechanismFile "drm19.yml"; +transportModel "Mix";//"UnityLewis"; +odeCoeffs +{ + "relTol" 1e-15; + "absTol" 1e-24; +} +inertSpecie "N2"; + +zeroDReactor +{ + constantProperty "pressure";//cvorcp "UV"; +} + +torch on; +GPU on; +torchModel1 "modeldrm19_0.pt"; +torchModel2 "modeldrm19_1.pt"; +torchModel3 "modeldrm19_2.pt"; + +torchParameters1 +{ + Tact 700 ; + Qdotact 3e7; + coresPerGPU 4; +} +torchParameters2 +{ + Tact 2000; + Qdotact 3e7; +} +torchParameters3 +{ + Tact 2000; + Qdotact 7e8; +} +loadbalancing +{ + active false; + //log true; +} +// ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/constant/combustionProperties b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/constant/combustionProperties similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/constant/combustionProperties rename to examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/constant/combustionProperties diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/constant/thermophysicalProperties b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/constant/thermophysicalProperties similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/constant/thermophysicalProperties rename to examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/constant/thermophysicalProperties diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/constant/turbulenceProperties b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/constant/turbulenceProperties similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/constant/turbulenceProperties rename to examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/constant/turbulenceProperties diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/drm19.yaml b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/drm19.yaml similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/drm19.yaml rename to examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/drm19.yaml diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/inference.py b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/inference.py new file mode 100644 index 00000000..bf0bd7b7 --- /dev/null +++ b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/inference.py @@ -0,0 +1,173 @@ +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) +print('position 0 in inference.py') +device = torch.device("cuda") +device_ids = range(torch.cuda.device_count()) + + + +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: + #glbal variable will only init once when called interperter + #load parameters from json + setting0 = json2Parser('settingsdrm19_0.json') + setting1 = json2Parser('settingsdrm19_1.json') + setting2 = json2Parser('settingsdrm19_2.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) + print('position 1 in inference.py') + + #load module + model0 = Net() + model1 = Net() + model2 = Net() + check_point0 = torch.load('modeldrm19_0.pt') + check_point1 = torch.load('modeldrm19_1.pt') + check_point2 = torch.load('modeldrm19_2.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) + print('call init') +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)) + + 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/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/system/blockMeshDict b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/system/blockMeshDict similarity index 52% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/system/blockMeshDict rename to examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/system/blockMeshDict index 5ff3488a..e8e079bc 100644 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/system/blockMeshDict +++ b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/system/blockMeshDict @@ -18,19 +18,20 @@ convertToMeters 0.001; vertices ( - (0 1 1) - (60 1 1) - (60 1 0) - (0 1 0) - (0 0 1) - (60 0 1) - (60 0 0) (0 0 0) + (6.283185307179586 0 0) + (6.283185307179586 6.283185307179586 0) + (0 6.283185307179586 0) + (0 0 6.283185307179586) + (6.283185307179586 0 6.283185307179586) + (6.283185307179586 6.283185307179586 6.283185307179586) + (0 6.283185307179586 6.283185307179586) ); + blocks ( - hex (4 5 6 7 0 1 2 3) (4335 1 1) simpleGrading (1 1 1) + hex (0 1 2 3 4 5 6 7) (64 64 64) simpleGrading (1 1 1) ); edges @@ -39,31 +40,58 @@ edges boundary ( - boundary + front { - type empty; + type cyclic; + neighbourPatch back; faces ( - (0 3 2 1) (4 5 6 7) - (0 1 5 4) - (3 2 6 7) ); } - inlet + back { - type patch; + type cyclic; + neighbourPatch front; + faces + ( + (0 3 2 1) + ); + } + left + { + type cyclic; + neighbourPatch right; faces ( (0 4 7 3) ); } - outlet + right + { + type cyclic; + neighbourPatch left; + faces + ( + (2 6 5 1) + ); + } + top + { + type cyclic; + neighbourPatch down; + faces + ( + (3 7 6 2) + ); + } + down { - type patch; + type cyclic; + neighbourPatch top; faces ( - (1 2 6 5) + (1 5 4 0) ); } ); diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/system/controlDict b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/system/controlDict similarity index 98% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/system/controlDict rename to examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/system/controlDict index ede602e9..99fe800c 100644 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/cvodeIntegrator/system/controlDict +++ b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/system/controlDict @@ -33,7 +33,7 @@ adjustTimeStep off; writeControl adjustableRunTime; -writeInterval 0.0001; +writeInterval 5e-6; purgeWrite 0; diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/constant/combustionProperties b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/system/decomposeParDict similarity index 63% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/constant/combustionProperties rename to examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/system/decomposeParDict index 7418500d..45c7f859 100644 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/constant/combustionProperties +++ b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/system/decomposeParDict @@ -10,11 +10,36 @@ FoamFile version 2.0; format ascii; class dictionary; - location "constant"; - object combustionProperties; + location "system"; + object decomposeParDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -combustionModel laminar; +numberOfSubdomains 4; + +method scotch; + +simpleCoeffs +{ + n (4 1 1); + delta 0.001; +} + +hierarchicalCoeffs +{ + n (1 1 1); + delta 0.001; + order xyz; +} + +manualCoeffs +{ + dataFile ""; +} + +distributed no; + +roots ( ); + // ************************************************************************* // diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/constant/turbulenceProperties b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/system/funkySetFieldsDict similarity index 68% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/constant/turbulenceProperties rename to examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/system/funkySetFieldsDict index 1e6753df..4cb58b7f 100644 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/torchIntegrator/constant/turbulenceProperties +++ b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/system/funkySetFieldsDict @@ -10,11 +10,20 @@ FoamFile version 2.0; format ascii; class dictionary; - location "constant"; - object turbulenceProperties; + location "system"; + object funkySetFieldsDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -simulationType laminar; +expressions + ( +TGV_U + { + field U; + expression "vector(4*sin(pos().x/0.001)*cos(pos().y/0.001)*cos(pos().z/0.001),-4*cos(pos().x/0.001)*sin(pos().y/0.001)*cos(pos().z/0.001),0)"; + keepPatches 1; + } + ); + // ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/system/fvSchemes b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/system/fvSchemes similarity index 96% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/system/fvSchemes rename to examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/system/fvSchemes index c841b36e..c5c9136e 100644 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/system/fvSchemes +++ b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/system/fvSchemes @@ -29,7 +29,7 @@ divSchemes { default none; - div(phi,U) Gauss limitedLinearV 1; + div(phi,U) Gauss linear; div(phi,Yi) Gauss limitedLinear01 1; div(phi,h) Gauss limitedLinear 1; div(phi,ha) Gauss limitedLinear 1; diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/system/fvSolution b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/system/fvSolution similarity index 66% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/system/fvSolution rename to examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/system/fvSolution index c13c246b..73baadbf 100644 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/torchIntegrator/system/fvSolution +++ b/examples/dfLowMachFoam/threeD_reactingTGV/CH4/pytorchIntegrator/system/fvSolution @@ -24,29 +24,40 @@ solvers p { - solver PCG; - preconditioner DIC; - tolerance 1e-6; - relTol 0.01; + solver GAMG; + tolerance 1e-7; + relTol 0.01; + smoother GaussSeidel; + cacheAgglomeration true; + nCellsInCoarsestLevel 20; + agglomerator faceAreaPair; + mergeLevels 1; } pFinal { - $p; - relTol 0; + solver GAMG; + tolerance 1e-9; + relTol 0; + smoother GaussSeidel; + cacheAgglomeration true; + nCellsInCoarsestLevel 20; + agglomerator faceAreaPair; + mergeLevels 1; } "(U|ha|k|epsilon)" { solver PBiCGStab; preconditioner DILU; - tolerance 1e-6; - relTol 0.1; + tolerance 1e-7; + relTol 0.01; } "(U|ha|k|epsilon)Final" { $U; + tolerance 1e-9; relTol 0; } @@ -54,14 +65,14 @@ solvers { solver PBiCGStab; preconditioner DILU; - tolerance 1e-6; - relTol 0.1; + tolerance 1e-7; + relTol 0.01; } "YiFinal" { solver PBiCGStab; preconditioner DILU; - tolerance 1e-7; + tolerance 1e-9; relTol 0; } }