diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/CH4.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/CH4.gz deleted file mode 100644 index 92a6f0d98..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/CH4.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/N2.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/N2.gz deleted file mode 100644 index c46b52f66..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/N2.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/O2.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/O2.gz deleted file mode 100644 index d5a3326d6..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/O2.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/T.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/T.gz deleted file mode 100644 index 2664edbf4..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/T.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/U.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/U.gz deleted file mode 100644 index 3126670b9..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/U.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/Ydefault.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/Ydefault.gz deleted file mode 100644 index 355dc649c..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/Ydefault.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/alphat.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/alphat.gz deleted file mode 100644 index 47f73f02b..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/alphat.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/p.gz b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/p.gz deleted file mode 100644 index a187d772b..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/0/p.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/Allclean b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/Allclean deleted file mode 100755 index 656b739c4..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/Allclean +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -echo "Cleaning logfiles*" -rm log.* -echo "Cleaning processor*" -rm -r processor* -echo "Cleaning polyMesh/" -rm -r constant/polyMesh -echo "Cleaning postProcessing/" -rm -r postProcessing diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/Allrun b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/Allrun deleted file mode 100755 index c0cebc861..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/Allrun +++ /dev/null @@ -1,11 +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 decomposePar -runApplication mpirun -np 4 --allow-run-as-root $application -parallel diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/constant/CanteraTorchProperties b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/constant/CanteraTorchProperties deleted file mode 100644 index 13fc340b8..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/constant/CanteraTorchProperties +++ /dev/null @@ -1,56 +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 CanteraTorchProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -chemistry on; - -CanteraMechanismFile "drm19.yaml"; - -transportModel "Mix"; - -odeCoeffs -{ - "relTol" 1e-15; - "absTol" 1e-24; -} - -inertSpecie "N2"; - -zeroDReactor -{ - constantProperty "pressure"; -} - -splittingStrategy off; - -TorchSettings -{ - torch on; - GPU on; - log on; - torchModel ""; - coresPerNode 4; -} - -loadbalancing -{ - active true; - log false; - algorithm allAverage;//headTail; -} - - -// ************************************************************************* // diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/constant/turbulenceProperties b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/constant/turbulenceProperties deleted file mode 100644 index 1e6753dfe..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/constant/turbulenceProperties +++ /dev/null @@ -1,20 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Version: 7 - \\/ M anipulation | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - location "constant"; - object turbulenceProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -simulationType laminar; - -// ************************************************************************* // diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/inference.py b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/inference.py deleted file mode 100644 index 2ceabdf47..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/inference.py +++ /dev/null @@ -1,223 +0,0 @@ -from builtins import Exception, print -from calendar import prcal -import torch -import numpy as np -import math -import time -import json -import os -from easydict import EasyDict as edict -import torch.profiler -import os - - - -torch.set_printoptions(precision=10) - - -class MyGELU(torch.nn.Module): - def __init__(self): - super(MyGELU, self).__init__() - self.torch_PI = 3.1415926536 - - def forward(self, x): - return 0.5 * x * (1 + torch.tanh( - math.sqrt(2 / self.torch_PI) * (x + 0.044715 * torch.pow(x, 3)))) - - -def json2Parser(json_path): - """load json and return parser-like object""" - with open(json_path, 'r') as f: - args = json.load(f) - return edict(args) - - -class Net(torch.nn.Module): - def __init__(self): - super(Net, self).__init__() - neurons = layers - self.depth = len(neurons) - 1 - self.actfun = MyGELU() - self.layers = [] - for i in range(self.depth - 1): - self.layers.append(torch.nn.Linear(neurons[i], neurons[i + 1])) - self.layers.append(self.actfun) - self.layers.append(torch.nn.Linear(neurons[-2], neurons[-1])) # last layer - self.fc = torch.nn.Sequential(*self.layers) - - def forward(self, x): - x = self.fc(x) - return x -try: - #load variables from constant/CanteraTorchProperties - path_r = r"./constant/CanteraTorchProperties" - with open(path_r, "r") as f: - data = f.read() - i = data.index('torchModel') - a = data.index('"',i) - b = data.index('sub',a) - c = data.index('"',b+1) - modelName_split1 = data[a+1:b+3] - modelName_split2 = data[b+3:c] - - modelPath = str(modelName_split1+modelName_split2) - model1Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"1"+modelName_split2+"/checkpoint/") - model2Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"2"+modelName_split2+"/checkpoint/") - model3Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"3"+modelName_split2+"/checkpoint/") - - i = data.index('GPU') - a = data.index(';', i) - b = data.rfind(' ',i+1,a) - switch_GPU = data[b+1:a] - - #load OpenFOAM switch - switch_on = ["true", "True", "on", "yes", "y", "t", "any"] - switch_off = ["false", "False", "off", "no", "n", "f", "none"] - if switch_GPU in switch_on: - device = torch.device("cuda") - device_ids = range(torch.cuda.device_count()) - elif switch_GPU in switch_off: - device = torch.device("cpu") - device_ids = [0] - else: - print("invalid setting!") - os._exit(0) - - - - #glbal variable will only init once when called interperter - #load parameters from json - - norm0 = json2Parser(str(model1Path+"norm.json")) - norm1 = json2Parser(str(model2Path+"norm.json")) - norm2 = json2Parser(str(model3Path+"norm.json")) - setting0 = json2Parser(str(model1Path+"settings.json")) - lamda = setting0.power_transform - delta_t = setting0.delta_t - dim = setting0.dim - layers = setting0.layers - - - Xmu0 = torch.tensor(norm0.input_mean).unsqueeze(0).to(device=device) - Xstd0 = torch.tensor(norm0.input_std).unsqueeze(0).to(device=device) - Ymu0 = torch.tensor(norm0.label_mean).unsqueeze(0).to(device=device) - Ystd0 = torch.tensor(norm0.label_std).unsqueeze(0).to(device=device) - - Xmu1 = torch.tensor(norm1.input_mean).unsqueeze(0).to(device=device) - Xstd1 = torch.tensor(norm1.input_std).unsqueeze(0).to(device=device) - Ymu1 = torch.tensor(norm1.label_mean).unsqueeze(0).to(device=device) - Ystd1 = torch.tensor(norm1.label_std).unsqueeze(0).to(device=device) - - Xmu2 = torch.tensor(norm2.input_mean).unsqueeze(0).to(device=device) - Xstd2 = torch.tensor(norm2.input_std).unsqueeze(0).to(device=device) - Ymu2 = torch.tensor(norm2.label_mean).unsqueeze(0).to(device=device) - Ystd2 = torch.tensor(norm2.label_std).unsqueeze(0).to(device=device) - - #load model - model0 = Net() - model1 = Net() - model2 = Net() - - path_list=os.listdir(model1Path) - for filename in path_list: - if os.path.splitext(filename)[1] == '.pt': - modelname = filename - - - if torch.cuda.is_available()==False: - check_point0 = torch.load(str(model1Path+modelname), map_location='cpu') - check_point1 = torch.load(str(model2Path+modelname), map_location='cpu') - check_point2 = torch.load(str(model3Path+modelname), map_location='cpu') - else: - check_point0 = torch.load(str(model1Path+modelname)) - check_point1 = torch.load(str(model2Path+modelname)) - check_point2 = torch.load(str(model3Path+modelname)) - - model0.load_state_dict(check_point0) - model1.load_state_dict(check_point1) - model2.load_state_dict(check_point2) - model0.to(device=device) - model1.to(device=device) - model2.to(device=device) - - if len(device_ids) > 1: - model0 = torch.nn.DataParallel(model0, device_ids=device_ids) - model1 = torch.nn.DataParallel(model1, device_ids=device_ids) - model2 = torch.nn.DataParallel(model2, device_ids=device_ids) -except Exception as e: - print(e.args) - - -def inference(vec0, vec1, vec2): - ''' - use model to inference - ''' - #args = np.reshape(args, (-1, 9)) #reshape to formed size - #vec0 = np.reshape(vec0, (-1, 24)) - #vec1 = np.reshape(vec1, (-1, 24)) - #vec2 = np.reshape(vec2, (-1, 24)) - vec0 = np.reshape(vec0, (-1, 10)) - vec1 = np.reshape(vec1, (-1, 10)) - vec2 = np.reshape(vec2, (-1, 10)) - - try: - with torch.no_grad(): - input0_ = torch.from_numpy(vec0).double().to(device=device) #cast ndarray to torch tensor - input1_ = torch.from_numpy(vec1).double().to(device=device) #cast ndarray to torch tensor - input2_ = torch.from_numpy(vec2).double().to(device=device) #cast ndarray to torch tensor - - # pre_processing - rho0 = input0_[:, 0].unsqueeze(1) - input0_Y = input0_[:, 3:].clone() - input0_bct = input0_[:, 1:] - input0_bct[:, 2:] = (input0_bct[:, 2:]**(lamda) - 1) / lamda #BCT - input0_normalized = (input0_bct - Xmu0) / Xstd0 - # input0_normalized[:, -1] = 0 #set Y_AR to 0 - input0_normalized = input0_normalized.float() - - rho1 = input1_[:, 0].unsqueeze(1) - input1_Y = input1_[:, 3:].clone() - input1_bct = input1_[:, 1:] - input1_bct[:, 2:] = (input1_bct[:, 2:]**(lamda) - 1) / lamda #BCT - input1_normalized = (input1_bct - Xmu1) / Xstd1 - # input1_normalized[:, -1] = 0 #set Y_AR to 0 - input1_normalized = input1_normalized.float() - - - rho2 = input2_[:, 0].unsqueeze(1) - input2_Y = input2_[:, 3:].clone() - input2_bct = input2_[:, 1:] - input2_bct[:, 2:] = (input2_bct[:, 2:]**(lamda) - 1) / lamda #BCT - input2_normalized = (input2_bct - Xmu2) / Xstd2 - # input2_normalized[:, -1] = 0 #set Y_AR to 0 - input2_normalized = input2_normalized.float() - - #inference - output0_normalized = model0(input0_normalized) - output1_normalized = model1(input1_normalized) - output2_normalized = model2(input2_normalized) - - # post_processing - output0_bct = (output0_normalized * Ystd0 + Ymu0) * delta_t + input0_bct - output0_Y = (lamda * output0_bct[:, 2:] + 1)**(1 / lamda) - output0_Y = output0_Y / torch.sum(input=output0_Y, dim=1, keepdim=True) - output0 = (output0_Y - input0_Y) * rho0 / delta_t - output0 = output0.cpu().numpy() - - output1_bct = (output1_normalized * Ystd1 + Ymu1) * delta_t + input1_bct - output1_Y = (lamda * output1_bct[:, 2:] + 1)**(1 / lamda) - output1_Y = output1_Y / torch.sum(input=output1_Y, dim=1, keepdim=True) - output1 = (output1_Y - input1_Y) * rho1 / delta_t - output1 = output1.cpu().numpy() - - output2_bct = (output2_normalized * Ystd2 + Ymu2) * delta_t + input2_bct - output2_Y = (lamda * output2_bct[:, 2:] + 1)**(1 / lamda) - output2_Y = output2_Y / torch.sum(input=output2_Y, dim=1, keepdim=True) - output2 = (output2_Y - input2_Y) * rho2 / delta_t - output2 = output2.cpu().numpy() - - result = np.append(output0, output1, axis=0) - result = np.append(result, output2, axis=0) - return result - except Exception as e: - print(e.args) diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/blockMeshDict b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/blockMeshDict deleted file mode 100644 index b762a9308..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/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) (10 10 10) 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/pytorchIntegrator/system/controlDict b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/controlDict deleted file mode 100644 index 8d64da2b6..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/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 df0DFoam; - -startFrom startTime; - -startTime 0; - -stopAt endTime; - -endTime 1e-3; - -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/pytorchIntegrator/system/fvSchemes b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/fvSchemes deleted file mode 100644 index 0b7dcc260..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/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/pytorchIntegrator/system/fvSolution b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/fvSolution deleted file mode 100644 index c8b4eb91a..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/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/CH4/pytorchIntegrator/system/probes b/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/probes deleted file mode 100644 index e327da359..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/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 Qdot);// Writes out T -probeLocations -( - (0.0025 0.0025 0.0025) -); - -// ************************************************************************* // diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/inference.py b/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/inference.py deleted file mode 100644 index 9238a55ff..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/cvodeIntegrator/inference.py +++ /dev/null @@ -1,211 +0,0 @@ -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/libtorchIntegrator/0/H2.gz b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/H2.gz deleted file mode 100644 index c6e547fb4..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/H2.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/N2.gz b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/N2.gz deleted file mode 100644 index 2cddaf5ec..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/N2.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/O2.gz b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/O2.gz deleted file mode 100644 index fa18d51a8..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/O2.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/T.gz b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/T.gz deleted file mode 100644 index b2839f7a7..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/T.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/U.gz b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/U.gz deleted file mode 100644 index 3126670b9..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/U.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/Ydefault.gz b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/Ydefault.gz deleted file mode 100644 index 355dc649c..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/Ydefault.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/alphat.gz b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/alphat.gz deleted file mode 100644 index 47f73f02b..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/alphat.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/p.gz b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/p.gz deleted file mode 100644 index 841ae144d..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/0/p.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/Allclean b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/Allclean deleted file mode 100755 index 656b739c4..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/Allclean +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -echo "Cleaning logfiles*" -rm log.* -echo "Cleaning processor*" -rm -r processor* -echo "Cleaning polyMesh/" -rm -r constant/polyMesh -echo "Cleaning postProcessing/" -rm -r postProcessing diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/Allrun b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/Allrun deleted file mode 100755 index c0cebc861..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/Allrun +++ /dev/null @@ -1,11 +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 decomposePar -runApplication mpirun -np 4 --allow-run-as-root $application -parallel diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/ES80_H2-7-16.yaml b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/ES80_H2-7-16.yaml deleted file mode 120000 index 0600efea5..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/ES80_H2-7-16.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/ES80_H2-7-16.yaml \ No newline at end of file diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/constant/CanteraTorchProperties b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/constant/CanteraTorchProperties deleted file mode 100644 index 604b1e925..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/constant/CanteraTorchProperties +++ /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 "constant"; - object CanteraTorchProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -chemistry on; - -CanteraMechanismFile "ES80_H2-7-16.yaml"; - -transportModel "Mix"; - -odeCoeffs -{ - "relTol" 1e-6; - "absTol" 1e-10; -} - -inertSpecie "N2"; - -zeroDReactor -{ - constantProperty "pressure"; -} - -splittingStrategy off; - -TorchSettings -{ - torch on; - GPU on; - log on; - torchModel1 "new_ESH2sub1.pt"; - torchModel2 "new_ESH2sub2.pt"; - torchModel3 "new_ESH2sub3.pt"; - coresPerGPU 4; - GPUsPerNode 4; -} - -loadbalancing -{ - active true; - log false; - algorithm allAverage;//headTail; -} - - -// ************************************************************************* // diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/constant/turbulenceProperties b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/constant/turbulenceProperties deleted file mode 100644 index 1e6753dfe..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/constant/turbulenceProperties +++ /dev/null @@ -1,20 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Version: 7 - \\/ M anipulation | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - location "constant"; - object turbulenceProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -simulationType laminar; - -// ************************************************************************* // diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/new_ESH2sub1.pt b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/new_ESH2sub1.pt deleted file mode 120000 index b672ed90c..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/new_ESH2sub1.pt +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/libtorchDNN/new_ESH2sub1.pt \ No newline at end of file diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/new_ESH2sub2.pt b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/new_ESH2sub2.pt deleted file mode 120000 index 976d5c774..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/new_ESH2sub2.pt +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/libtorchDNN/new_ESH2sub2.pt \ No newline at end of file diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/new_ESH2sub3.pt b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/new_ESH2sub3.pt deleted file mode 120000 index 68906dbcc..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/new_ESH2sub3.pt +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/libtorchDNN/new_ESH2sub3.pt \ No newline at end of file diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/system/blockMeshDict b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/system/blockMeshDict deleted file mode 100644 index b762a9308..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/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) (10 10 10) 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/H2/libtorchIntegrator/system/controlDict b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/system/controlDict deleted file mode 100644 index a324a3e29..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/system/controlDict +++ /dev/null @@ -1,57 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Version: 7 - \\/ M anipulation | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - location "system"; - object controlDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -application dfLMFoam; - -startFrom startTime; - -startTime 0; - -stopAt endTime; - -endTime 0.001; - -deltaT 1e-06; - -maxDeltaT 1e-03; - -adjustTimeStep off; - -writeControl runTime; - -writeInterval 10000; - -purgeWrite 0; - -writeFormat ascii; - -// writePrecision 6; - -writeCompression on; - -timeFormat general; - -timePrecision 6; - -runTimeModifiable true; - -functions -{ - # includeFunc probes -} - -// ************************************************************************* // diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/system/fvSchemes b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/system/fvSchemes deleted file mode 100644 index 0b7dcc260..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/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/H2/libtorchIntegrator/system/fvSolution b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/system/fvSolution deleted file mode 100644 index c8b4eb91a..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/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/libtorchIntegrator/system/probes b/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/system/probes deleted file mode 100644 index 2790ce65b..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/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); -probeLocations -( - (0.0025 0.0025 0.0025) -); - -// ************************************************************************* // diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/H2.gz b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/H2.gz deleted file mode 100644 index c6e547fb4..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/H2.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/N2.gz b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/N2.gz deleted file mode 100644 index 2cddaf5ec..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/N2.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/O2.gz b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/O2.gz deleted file mode 100644 index fa18d51a8..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/O2.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/T.gz b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/T.gz deleted file mode 100644 index b2839f7a7..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/T.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/U.gz b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/U.gz deleted file mode 100644 index 3126670b9..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/U.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/Ydefault.gz b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/Ydefault.gz deleted file mode 100644 index 355dc649c..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/Ydefault.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/alphat.gz b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/alphat.gz deleted file mode 100644 index 47f73f02b..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/alphat.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/p.gz b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/p.gz deleted file mode 100644 index 841ae144d..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/0/p.gz and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/Allclean b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/Allclean deleted file mode 100755 index 656b739c4..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/Allclean +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -echo "Cleaning logfiles*" -rm log.* -echo "Cleaning processor*" -rm -r processor* -echo "Cleaning polyMesh/" -rm -r constant/polyMesh -echo "Cleaning postProcessing/" -rm -r postProcessing diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/Allrun b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/Allrun deleted file mode 100755 index c0cebc861..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/Allrun +++ /dev/null @@ -1,11 +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 decomposePar -runApplication mpirun -np 4 --allow-run-as-root $application -parallel diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/ES80_H2-7-16.yaml b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/ES80_H2-7-16.yaml deleted file mode 120000 index 0600efea5..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/ES80_H2-7-16.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/ES80_H2-7-16.yaml \ No newline at end of file diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/constant/CanteraTorchProperties b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/constant/CanteraTorchProperties deleted file mode 100644 index b7246472f..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/constant/CanteraTorchProperties +++ /dev/null @@ -1,56 +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 CanteraTorchProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -chemistry on; - -CanteraMechanismFile "ES80_H2-7-16.yaml"; - -transportModel "Mix"; - -odeCoeffs -{ - "relTol" 1e-15; - "absTol" 1e-24; -} - -inertSpecie "N2"; - -zeroDReactor -{ - constantProperty "pressure"; -} - -splittingStrategy off; - -TorchSettings -{ - torch on; - GPU off; - log on; - torchModel "HE04_Hydrogen_ESH2_GMS_sub_20221101"; - coresPerNode 4; -} - -loadbalancing -{ - active true; - log false; - algorithm allAverage;//headTail; -} - - -// ************************************************************************* // diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/constant/turbulenceProperties b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/constant/turbulenceProperties deleted file mode 100644 index 1e6753dfe..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/constant/turbulenceProperties +++ /dev/null @@ -1,20 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Version: 7 - \\/ M anipulation | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - location "constant"; - object turbulenceProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -simulationType laminar; - -// ************************************************************************* // diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/data_in_mean.npy b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/data_in_mean.npy deleted file mode 100644 index b4f3bdb81..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/data_in_mean.npy and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/data_in_std.npy b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/data_in_std.npy deleted file mode 100644 index 735bd95c4..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/data_in_std.npy and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/data_target_mean.npy b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/data_target_mean.npy deleted file mode 100644 index 6c3ed5a77..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/data_target_mean.npy and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/data_target_std.npy b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/data_target_std.npy deleted file mode 100644 index 21b8c7ba4..000000000 Binary files a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/data_target_std.npy and /dev/null differ diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/inference.py b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/inference.py deleted file mode 100644 index c49711b81..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/inference.py +++ /dev/null @@ -1,229 +0,0 @@ -from builtins import Exception, print -from calendar import prcal -import torch -import numpy as np -import math -import time -import json -import os -from easydict import EasyDict as edict -import torch.profiler -import os - - -torch.set_printoptions(precision=10) - - -class MyGELU(torch.nn.Module): - def __init__(self): - super(MyGELU, self).__init__() - self.torch_PI = 3.1415926536 - - def forward(self, x): - return 0.5 * x * (1 + torch.tanh( - math.sqrt(2 / self.torch_PI) * (x + 0.044715 * torch.pow(x, 3)))) - - -def json2Parser(json_path): - """load json and return parser-like object""" - with open(json_path, 'r') as f: - args = json.load(f) - return edict(args) - -class NN_MLP(torch.nn.Module): - def __init__(self, layer_info): - super(NN_MLP, self).__init__() - self.net = torch.nn.Sequential() - n = len(layer_info) - 1 - for i in range(n - 1): - self.net.add_module('linear_layer_%d' %(i), torch.nn.Linear(layer_info[i], layer_info[i + 1])) - self.net.add_module('gelu_layer_%d' %(i), torch.nn.GELU()) - if i <= 2: - self.net.add_module('batch_norm_%d' %(i), torch.nn.BatchNorm1d(layer_info[i + 1])) - self.net.add_module('linear_layer_%d' %(n - 1), torch.nn.Linear(layer_info[n - 1], layer_info[n])) - - def forward(self, x): - return self.net(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('torchModel') - a = data.index('"',i) - b = data.index('sub',a) - c = data.index('"',b+1) - modelName_split1 = data[a+1:b+3] - modelName_split2 = data[b+3:c] - - modelPath = str(modelName_split1+modelName_split2) - model1Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"1"+modelName_split2+"/checkpoint/") - model2Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"2"+modelName_split2+"/checkpoint/") - model3Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"3"+modelName_split2+"/checkpoint/") - - i = data.index('GPU') - a = data.index(';', i) - b = data.rfind(' ',i+1,a) - switch_GPU = data[b+1:a] - - #load OpenFOAM switch - switch_on = ["true", "True", "on", "yes", "y", "t", "any"] - switch_off = ["false", "False", "off", "no", "n", "f", "none"] - if switch_GPU in switch_on: - device = torch.device("cuda") - device_ids = range(torch.cuda.device_count()) - elif switch_GPU in switch_off: - device = torch.device("cpu") - device_ids = [0] - else: - print("invalid setting!") - os._exit(0) - - - - #glbal variable will only init once when called interperter - #load parameters from json - - lamda = 0.1 - delta_t = 1e-06 - dim = 9 - #layers = setting0.layers - - - Xmu0 = np.load('data_in_mean.npy') - Xstd0 = np.load('data_in_std.npy') - Ymu0 = np.load('data_target_mean.npy') - Ystd0 = np.load('data_target_std.npy') - - Xmu0 = torch.tensor(Xmu0).unsqueeze(0).to(device=device) - Xstd0 = torch.tensor(Xstd0).unsqueeze(0).to(device=device) - Ymu0 = torch.tensor(Ymu0).unsqueeze(0).to(device=device) - Ystd0 = torch.tensor(Ystd0).unsqueeze(0).to(device=device) - - Xmu1 = Xmu0 - Xstd1 = Xstd0 - Ymu1 = Ymu0 - Ystd1 = Ystd0 - - Xmu2 = Xmu0 - Xstd2 = Xstd0 - Ymu2 = Ymu0 - Ystd2 = Ystd0 - - #load model - layers = [9, 6400, 3200, 1600, 800, 400, 6] - - - model0= NN_MLP(layers) - model1= NN_MLP(layers) - model2= NN_MLP(layers) - if torch.cuda.is_available()==False: - state_dict = (torch.load('Temporary_Chemical.pt',map_location='cpu'))['state_dict'] - else: - state_dict = (torch.load('Temporary_Chemical.pt'))['state_dict'] - - new_state_dict = {} - for k, v in state_dict.items(): - name = k[7:] - new_state_dict[name] = v - model0.load_state_dict(new_state_dict) - #model0.load_state_dict(state_dict) - - model1 = model0 - model2 = model0 - - model0.eval() - model0.to(device=device) - model1.eval() - model1.to(device=device) - model2.eval() - model2.to(device=device) - - if len(device_ids) > 1: - model0 = torch.nn.DataParallel(model0, device_ids=device_ids) - model1 = torch.nn.DataParallel(model1, device_ids=device_ids) - model2 = torch.nn.DataParallel(model2, device_ids=device_ids) -except Exception as e: - print(e.args) - - -def inference(vec0, vec1, vec2): - ''' - use model to inference - ''' - vec0 = np.reshape(vec0, (-1, 10)) # T, P, Yi(7), Rho - vec1 = np.reshape(vec1, (-1, 10)) - vec2 = np.reshape(vec2, (-1, 10)) - vec0[:,1] *= 101325 - vec1[:,1] *= 101325 - vec2[:,1] *= 101325 - - 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_[:, -1].unsqueeze(1) - input0_Y = input0_[:, 2:-1].clone() - input0_bct = input0_[:, 0:-1] - input0_bct[:, 2:] = (input0_bct[:, 2:]**(lamda) - 1) / lamda #BCT - input0_normalized = (input0_bct - Xmu0) / Xstd0 #DimXmu0 = 9, DimXstd0 = 9, input0_bct = - input0_normalized = input0_normalized.float() - - - rho1 = input1_[:, -1].unsqueeze(1) - input1_Y = input1_[:, 2:-1].clone() - input1_bct = input1_[:, 0:-1] - input1_bct[:, 2:] = (input1_bct[:, 2:]**(lamda) - 1) / lamda #BCT - input1_normalized = (input1_bct - Xmu1) / Xstd1 - input1_normalized = input1_normalized.float() - - rho2 = input2_[:, -1].unsqueeze(1) - input2_Y = input2_[:, 2:-1].clone() - input2_bct = input2_[:, 0:-1] - input2_bct[:, 2:] = (input2_bct[:, 2:]**(lamda) - 1) / lamda #BCT - input2_normalized = (input2_bct - Xmu2) / Xstd2 - 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_bct = output0_normalized * Ystd0 + Ymu0 + input0_bct[:, 2:-1] - output0_Y = input0_Y.clone() - output0_Y[:, :-1] = (lamda * output0_bct + 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 + input1_bct[:, 2:-1] - output1_Y = input1_Y.clone() - output1_Y[:, :-1] = (lamda * output1_bct + 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 + input2_bct[:, 2:-1] - output2_Y = input2_Y.clone() - output2_Y[:, :-1] = (lamda * output2_bct + 1)**(1 / lamda) - output2_Y = output2_Y / torch.sum(input=output2_Y, dim=1, keepdim=True) - output2 = output2_Y - output2_Y - 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/pytorchIntegrator/system/blockMeshDict b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/blockMeshDict deleted file mode 100644 index b762a9308..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/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) (10 10 10) 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/H2/pytorchIntegrator/system/controlDict b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/controlDict deleted file mode 100644 index 8d64da2b6..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/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 df0DFoam; - -startFrom startTime; - -startTime 0; - -stopAt endTime; - -endTime 1e-3; - -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/H2/pytorchIntegrator/system/fvSchemes b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/fvSchemes deleted file mode 100644 index 0b7dcc260..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/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/H2/pytorchIntegrator/system/fvSolution b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/fvSolution deleted file mode 100644 index c8b4eb91a..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/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/pytorchIntegrator/system/probes b/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/probes deleted file mode 100644 index e327da359..000000000 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/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 Qdot);// Writes out T -probeLocations -( - (0.0025 0.0025 0.0025) -); - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/C2H2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/C2H2.gz new file mode 100755 index 000000000..047158fa4 Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/C2H2.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/C2H3.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/C2H3.gz new file mode 100755 index 000000000..aba3aec19 Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/C2H3.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/C2H4.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/C2H4.gz new file mode 100755 index 000000000..5722c23f2 Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/C2H4.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/C2H5.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/C2H5.gz new file mode 100755 index 000000000..601cc8f08 Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/C2H5.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CH2CHO.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CH2CHO.gz new file mode 100755 index 000000000..3d5d6fdff Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CH2CHO.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CH2CO.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CH2CO.gz new file mode 100755 index 000000000..0aa1702ad Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CH2CO.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CH2O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CH2O.gz new file mode 100755 index 000000000..ed393d11d Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CH2O.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CH2OH.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CH2OH.gz new file mode 100755 index 000000000..6f546f266 Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CH2OH.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CH3.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CH3.gz new file mode 100755 index 000000000..6a04b1062 Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CH3.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CH4.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CH4.gz new file mode 100755 index 000000000..ef98bec12 Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CH4.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CO.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CO.gz new file mode 100755 index 000000000..7bd0e75a4 Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CO.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CO2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CO2.gz new file mode 100755 index 000000000..d13b9cc62 Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/CO2.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/H.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/H.gz new file mode 100755 index 000000000..83bcd8d0c Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/H.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/H2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/H2.gz new file mode 100755 index 000000000..80f26527b Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/H2.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/H2O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/H2O.gz new file mode 100755 index 000000000..2e2cb0d91 Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/H2O.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/HCCO.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/HCCO.gz new file mode 100755 index 000000000..96d375ef0 Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/HCCO.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/HCO.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/HCO.gz new file mode 100755 index 000000000..79fc4866c Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/HCO.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/HO2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/HO2.gz new file mode 100755 index 000000000..3a2d32e5b Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/HO2.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/N2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/N2.gz new file mode 100755 index 000000000..844c9c0ac Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/N2.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/O.gz new file mode 100755 index 000000000..fcdf12ab2 Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/O.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/O2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/O2.gz new file mode 100755 index 000000000..563bc5192 Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/O2.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/OH.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/OH.gz new file mode 100755 index 000000000..a88b84d2d Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/OH.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/S-CH2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/S-CH2.gz new file mode 100755 index 000000000..272b49fc1 Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/S-CH2.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/T-CH2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/T-CH2.gz new file mode 100755 index 000000000..1971fe964 Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/T-CH2.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/T.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/T.gz new file mode 100755 index 000000000..1dc9948ed Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/T.gz differ diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/funkySetBoundaryDict b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/U old mode 100644 new mode 100755 similarity index 61% rename from examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/funkySetBoundaryDict rename to examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/U index 5ed64c57a..cc3898af6 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/funkySetBoundaryDict +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/U @@ -9,22 +9,32 @@ FoamFile { version 2.0; format ascii; - class dictionary; - location "system"; - object funkySetBoundaryDict; + class volVectorField; + location "0"; + object U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -velocities { - field U; - expressions - ( - { - target value; - patchName fuelInlet; - expression "vector(5,0,0)*1.128*pow(mag(0.004-(mag(pos().y-0.015)))/0.004,1/7)"; - } - ); +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (1.62 0 0); + +boundaryField +{ + boundary + { + type empty; + } + inlet + { + type fixedValue; + value uniform (1.62 0 0); + } + outlet + { + type zeroGradient; + } } + // ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/funkySetBoundaryDict b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/Ydefault old mode 100644 new mode 100755 similarity index 62% rename from examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/funkySetBoundaryDict rename to examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/Ydefault index 5ed64c57a..9920d1092 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/funkySetBoundaryDict +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/Ydefault @@ -9,22 +9,32 @@ FoamFile { version 2.0; format ascii; - class dictionary; - location "system"; - object funkySetBoundaryDict; + class volScalarField; + location "0"; + object Ydefault; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -velocities { - field U; - expressions - ( - { - target value; - patchName fuelInlet; - expression "vector(5,0,0)*1.128*pow(mag(0.004-(mag(pos().y-0.015)))/0.004,1/7)"; - } - ); +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + boundary + { + type empty; + } + inlet + { + type fixedValue; + value uniform 0; + } + outlet + { + type zeroGradient; + } } + // ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/system/decomposeParDict b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/p old mode 100644 new mode 100755 similarity index 60% rename from examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/system/decomposeParDict rename to examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/p index 45c7f859f..06f5c5cac --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/system/decomposeParDict +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/0/p @@ -9,37 +9,33 @@ FoamFile { version 2.0; format ascii; - class dictionary; - location "system"; - object decomposeParDict; + class volScalarField; + location "0"; + object p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -numberOfSubdomains 4; +dimensions [1 -1 -2 0 0 0 0]; -method scotch; +internalField uniform 101325; -simpleCoeffs +boundaryField { - n (4 1 1); - delta 0.001; + boundary + { + type empty; + } + inlet + { + type zeroGradient; + } + outlet + { + type waveTransmissive; + gamma 1.4; + value uniform 101325; + } } -hierarchicalCoeffs -{ - n (1 1 1); - delta 0.001; - order xyz; -} - -manualCoeffs -{ - dataFile ""; -} - -distributed no; - -roots ( ); - // ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/Allclean b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/Allclean similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/Allclean rename to examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/Allclean diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/Allrun b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/Allrun new file mode 100755 index 000000000..732e7a9ba --- /dev/null +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/Allrun @@ -0,0 +1,22 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +if [ -e DNN_model.pt ] +then + echo "DNN_model.pt exists. Make sure correct DNN model has been used!" +else + echo "DNN_model.pt not exist. Downloading ..." + wget https://store.aissquare.com/models/5e1232cd-c23f-489f-9db4-ee09592beeb1/DNN_model.zip + unzip DNN_model.zip + cp ./DNN_model/C2H4/DNN_model.pt . + cp ./DNN_model/C2H4/Wu24sp.yaml . +fi + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +application=dfLowMachFoam + +runApplication blockMesh +runApplication decomposePar +runApplication mpirun -np 4 --allow-run-as-root $application -parallel diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/constant/CanteraTorchProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/constant/CanteraTorchProperties old mode 100644 new mode 100755 similarity index 81% rename from examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/constant/CanteraTorchProperties rename to examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/constant/CanteraTorchProperties index 2b6e27ade..e869f12ec --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/constant/CanteraTorchProperties +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/constant/CanteraTorchProperties @@ -17,7 +17,7 @@ FoamFile chemistry on; -CanteraMechanismFile "ES80_H2-7-16.yaml"; +CanteraMechanismFile "Wu24sp.yaml"; transportModel "Mix"; @@ -33,11 +33,13 @@ splittingStrategy off; TorchSettings { - torch off; - GPU off; - log off; - torchModel "HE04_Hydrogen_ESH2_GMS_sub_20221101"; - coresPerNode 4; + torch on; + GPU on; + log on; + torchModel "DNN_model.pt"; + frozenTemperature 510; + inferenceDeltaTime 1e-7; + coresPerNode 4; } loadbalancing diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/constant/combustionProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/constant/combustionProperties old mode 100644 new mode 100755 similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/constant/combustionProperties rename to examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/constant/combustionProperties diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/constant/thermophysicalProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/constant/thermophysicalProperties old mode 100644 new mode 100755 similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/constant/thermophysicalProperties rename to examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/constant/thermophysicalProperties diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/constant/turbulenceProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/constant/turbulenceProperties old mode 100644 new mode 100755 similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/constant/turbulenceProperties rename to examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/constant/turbulenceProperties diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/inference.py b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/inference.py new file mode 100755 index 000000000..5034809cd --- /dev/null +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/inference.py @@ -0,0 +1,169 @@ +import torch +import numpy as np +import time +import os +import cantera as ct + +device_main = "cuda:0" +device_list = range(torch.cuda.device_count()) + +torch.set_printoptions(precision=10) + +class NN_MLP(torch.nn.Module): + def __init__(self, layer_info): + super(NN_MLP, self).__init__() + self.net = torch.nn.Sequential() + n = len(layer_info) - 1 + for i in range(n - 1): + self.net.add_module('linear_layer_%d' %(i), torch.nn.Linear(layer_info[i], layer_info[i + 1])) + self.net.add_module('gelu_layer_%d' %(i), torch.nn.GELU()) + #if i <= 2: + # self.net.add_module('batch_norm_%d' %(i), torch.nn.BatchNorm1d(layer_info[i + 1])) + self.net.add_module('linear_layer_%d' %(n - 1), torch.nn.Linear(layer_info[n - 1], layer_info[n])) + + def forward(self, x): + return self.net(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('torchModel') + a = data.index('"',i) + b = data.index('"',a+1) + modelName = data[a+1:b] + + i = data.index('frozenTemperature') + a = data.index(';', i) + b = data.rfind(' ',i+1,a) + frozenTemperature = float(data[b+1:a]) + + i = data.index('inferenceDeltaTime') + a = data.index(';', i) + b = data.rfind(' ',i+1,a) + delta_t = float(data[b+1:a]) + + i = data.index('CanteraMechanismFile') + a = data.index('"',i) + b = data.index('"',a+1) + mechanismName = data[a+1:b] + + i = data.index('GPU') + a = data.index(';', i) + b = data.rfind(' ',i+1,a) + switch_GPU = data[b+1:a] + + #read mechanism species number + gas = ct.Solution(mechanismName) + n_species = gas.n_species + #load OpenFOAM switch + switch_on = ["true", "True", "on", "yes", "y", "t", "any"] + switch_off = ["false", "False", "off", "no", "n", "f", "none"] + if switch_GPU in switch_on: + device = torch.device(device_main) + device_ids = device_list + elif switch_GPU in switch_off: + device = torch.device("cpu") + device_ids = [0] + else: + print("invalid setting!") + os._exit(0) + + lamda = 0.1 + dim = 9 + + state_dict = torch.load(modelName,map_location='cpu') + Xmu0 = state_dict['data_in_mean'] + Xstd0 = state_dict['data_in_std'] + Ymu0 = state_dict['data_target_mean'] + Ystd0 = state_dict['data_target_std'] + + + Xmu0 = torch.tensor(Xmu0).unsqueeze(0).to(device=device) + Xstd0 = torch.tensor(Xstd0).unsqueeze(0).to(device=device) + Ymu0 = torch.tensor(Ymu0).unsqueeze(0).to(device=device) + Ystd0 = torch.tensor(Ystd0).unsqueeze(0).to(device=device) + + Xmu1 = Xmu0 + Xstd1 = Xstd0 + Ymu1 = Ymu0 + Ystd1 = Ystd0 + + Xmu2 = Xmu0 + Xstd2 = Xstd0 + Ymu2 = Ymu0 + Ystd2 = Ystd0 + + #load model + layers = [n_species +2, 1600, 800, 400, 1] + + model0list = [] + for i in range(n_species-1): + model0list.append(NN_MLP(layers)) + + for i in range(n_species-1): + model0list[i].load_state_dict(state_dict[f'net{i}']) + + + for i in range(n_species-1): + model0list[i].eval() + model0list[i].to(device=device) + + if len(device_ids) > 1: + for i in range(n_species-1): + model0list[i] = torch.nn.DataParallel(model0list[i], device_ids=device_ids) + +except Exception as e: + print(e.args) + + + + +def inference(vec0): + ''' + use model to inference + ''' + vec0 = np.abs(np.reshape(vec0, (-1, 3+n_species))) # T, P, Yi(7), Rho + vec0[:,1] *= 101325 + mask = vec0[:,0] > frozenTemperature + vec0_input = vec0[mask, :] + print(f'real inference points number: {vec0_input.shape[0]}') + + try: + with torch.no_grad(): + input0_ = torch.from_numpy(vec0_input).double().to(device=device) #cast ndarray to torch tensor + + + # pre_processing + rho0 = input0_[:, -1].unsqueeze(1) + input0_Y = input0_[:, 2:-1].clone() + input0_bct = input0_[:, 0:-1] + input0_bct[:, 2:] = (input0_bct[:, 2:]**(lamda) - 1) / lamda #BCT + input0_normalized = (input0_bct - Xmu0) / Xstd0 #DimXmu0 = 9, DimXstd0 = 9, input0_bct = + # input0_normalized[:, -1] = 0 #set Y_AR to 0 + input0_normalized = input0_normalized.float() + input0_normalized = input0_normalized.to(device=device) + + #inference + + output0_normalized = [] + for i in range(n_species-1): + output0_normalized.append(model0list[i](input0_normalized)) + output0_normalized = torch.cat(output0_normalized, dim=1) + + # post_processing + output0_bct = output0_normalized * Ystd0 + Ymu0 + input0_bct[:, 2:-1] + output0_Y = input0_Y.clone() + output0_Y[:, :-1] = (lamda * output0_bct + 1)**(1 / lamda) + output0_Y[:, :-1] = output0_Y[:, :-1] / torch.sum(input=output0_Y[:, :-1], dim=1, keepdim=True) * (1 - output0_Y[:, -1:]) + output0 = (output0_Y - input0_Y) * rho0 / delta_t + output0 = output0.cpu().numpy() + + + result = np.zeros((vec0.shape[0], n_species)) + result[mask, :] = output0 + return result + except Exception as e: + print(e.args) + diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/system/blockMeshDict b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/system/blockMeshDict old mode 100644 new mode 100755 similarity index 84% rename from examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/system/blockMeshDict rename to examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/system/blockMeshDict index 9bba2c1d0..6ca6fc6c6 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/system/blockMeshDict +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/system/blockMeshDict @@ -19,18 +19,27 @@ convertToMeters 0.001; vertices ( (0 1 1) - (960 1 1) - (960 1 0) + (20 1 1) + (20 1 0) (0 1 0) (0 0 1) - (960 0 1) - (960 0 0) + (20 0 1) + (20 0 0) (0 0 0) ); blocks ( - hex (4 5 6 7 0 1 2 3) (57099 1 1) simpleGrading (1 1 1) + hex (4 5 6 7 0 1 2 3) (880 1 1) + simpleGrading + ( + ( + (0.55 0.625 1) + (0.45 0.375 2) + ) + 1 + 1 + ) ); edges diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/controlDict b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/system/controlDict old mode 100644 new mode 100755 similarity index 94% rename from examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/controlDict rename to examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/system/controlDict index 671552c11..112640927 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/controlDict +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/system/controlDict @@ -23,9 +23,9 @@ startTime 0; stopAt endTime; -endTime 1e-5; +endTime 0.002; -deltaT 1e-6; +deltaT 1e-7; maxDeltaT 1e-04; @@ -49,7 +49,7 @@ timePrecision 6; runTimeModifiable true; -// adjustTimeStep yes; +adjustTimeStep no; // maxCo 0.8; diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/decomposeParDict b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/system/decomposeParDict old mode 100644 new mode 100755 similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/system/decomposeParDict rename to examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/system/decomposeParDict diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/fvSchemes b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/system/fvSchemes old mode 100644 new mode 100755 similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/fvSchemes rename to examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/system/fvSchemes diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/fvSolution b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/system/fvSolution old mode 100644 new mode 100755 similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/fvSolution rename to examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/system/fvSolution diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/system/funkySetFieldsDict b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/system/sample old mode 100644 new mode 100755 similarity index 67% rename from examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/system/funkySetFieldsDict rename to examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/system/sample index 4cb58b7f9..d91b9125f --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/system/funkySetFieldsDict +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/C2H4/pytorchIntegrator/system/sample @@ -7,23 +7,34 @@ \*---------------------------------------------------------------------------*/ FoamFile { - version 2.0; format ascii; class dictionary; location "system"; - object funkySetFieldsDict; + object sample; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -expressions - ( -TGV_U +type sets; +libs ("libsampling.so"); + +interpolationScheme cellPoint; + +setFormat raw; + +sets +( + data { - 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; + type lineUniform; + axis x; + start (0.00103 0 0); + end (0.0014 0 0); + nPoints 15; } - ); +); + +fields ( T OH C2H4 CO2 H2O); // ************************************************************************* // + diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/AR.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/AR.gz deleted file mode 100755 index 39adf801e..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/AR.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/C2H4.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/C2H4.gz deleted file mode 100755 index d1aabb1a6..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/C2H4.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/C2H5.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/C2H5.gz deleted file mode 100755 index ba4711f87..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/C2H5.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/C2H6.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/C2H6.gz deleted file mode 100755 index 29873bdb7..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/C2H6.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH2(S).gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH2(S).gz deleted file mode 100755 index e1d2de10d..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH2(S).gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH2.gz deleted file mode 100755 index 0ad562ff0..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH2O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH2O.gz deleted file mode 100755 index 218a61028..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH2O.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH3.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH3.gz deleted file mode 100755 index 0d4bfdc4d..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH3.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH3O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH3O.gz deleted file mode 100755 index 7fa7b69b9..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH3O.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH4.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH4.gz deleted file mode 100755 index d1559cce1..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CH4.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CO.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CO.gz deleted file mode 100755 index 92b250181..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CO.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CO2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CO2.gz deleted file mode 100755 index ab0b2d5ca..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/CO2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/H.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/H.gz deleted file mode 100755 index 41a39ed70..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/H.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/H2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/H2.gz deleted file mode 100755 index b6efee05f..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/H2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/H2O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/H2O.gz deleted file mode 100755 index 0963f2712..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/H2O.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/HCO.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/HCO.gz deleted file mode 100755 index a93d4f08f..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/HCO.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/HO2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/HO2.gz deleted file mode 100755 index 614917073..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/HO2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/N2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/N2.gz deleted file mode 100755 index 49b6beb2c..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/N2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/O.gz deleted file mode 100755 index 1dc5916dc..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/O.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/O2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/O2.gz deleted file mode 100755 index f1b43da36..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/O2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/OH.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/OH.gz deleted file mode 100755 index eba77fd57..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/OH.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/T.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/T.gz deleted file mode 100755 index 38ad95f26..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/T.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/U.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/U.gz deleted file mode 100755 index c500264a5..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/U.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/p.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/p.gz deleted file mode 100755 index ac1af8120..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/0/p.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/constant/thermophysicalProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/constant/thermophysicalProperties deleted file mode 100644 index 7f207bb77..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/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/pytorchIntegrator/system/blockMeshDict b/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/blockMeshDict deleted file mode 100644 index 5ff3488ae..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/blockMeshDict +++ /dev/null @@ -1,75 +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 1 1) - (60 1 1) - (60 1 0) - (0 1 0) - (0 0 1) - (60 0 1) - (60 0 0) - (0 0 0) -); - -blocks -( - hex (4 5 6 7 0 1 2 3) (4335 1 1) simpleGrading (1 1 1) -); - -edges -( -); - -boundary -( - boundary - { - type empty; - faces - ( - (0 3 2 1) - (4 5 6 7) - (0 1 5 4) - (3 2 6 7) - ); - } - inlet - { - type patch; - faces - ( - (0 4 7 3) - ); - } - outlet - { - type patch; - faces - ( - (1 2 6 5) - ); - } -); - -// mergePatchPairs -// ( -// ); - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/AR.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/AR.gz deleted file mode 100644 index 21b393c37..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/AR.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/H.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/H.gz deleted file mode 100644 index 49eded9d3..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/H.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/H2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/H2.gz deleted file mode 100644 index e1df4b030..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/H2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/H2O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/H2O.gz deleted file mode 100644 index 1c3f50f1e..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/H2O.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/N2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/N2.gz deleted file mode 100644 index 58f7359bf..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/N2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/O.gz deleted file mode 100644 index 6b2cef13a..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/O.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/O2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/O2.gz deleted file mode 100644 index a744e25be..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/O2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/OH.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/OH.gz deleted file mode 100644 index 6142b9614..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/OH.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/T.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/T.gz deleted file mode 100644 index 067eb9fdf..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/T.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/U.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/U.gz deleted file mode 100644 index 202be519e..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/U.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/p.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/p.gz deleted file mode 100644 index 69bf925ad..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/0/p.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/ES80_H2-7-16.yaml b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/ES80_H2-7-16.yaml deleted file mode 120000 index 0600efea5..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/ES80_H2-7-16.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/ES80_H2-7-16.yaml \ No newline at end of file diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/system/controlDict b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/system/controlDict deleted file mode 100644 index 6d959ac39..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/system/controlDict +++ /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 controlDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -application dfLowMachFoam; - -startFrom startTime; - -startTime 0; - -stopAt endTime; - -endTime 1e-5; - -deltaT 1e-6; - -maxDeltaT 1e-04; - -adjustTimeStep off; - -writeControl adjustableRunTime; - -writeInterval 0.001; - -purgeWrite 0; - -writeFormat ascii; - -// writePrecision 6; - -writeCompression on; - -timeFormat general; - -timePrecision 6; - -runTimeModifiable true; - -// adjustTimeStep yes; - -// maxCo 0.8; - -// maxDeltaT 1e-4; - - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/system/fvSchemes b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/system/fvSchemes deleted file mode 100644 index c841b36e1..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/system/fvSchemes +++ /dev/null @@ -1,61 +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,ha) 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(hDiffCorrFlux) Gauss cubic; - div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; -} - -laplacianSchemes -{ - default Gauss linear orthogonal; -} - -interpolationSchemes -{ - default linear; -} - -snGradSchemes -{ - default orthogonal; -} - - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/system/fvSolution b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/system/fvSolution deleted file mode 100644 index c13c246bb..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/system/fvSolution +++ /dev/null @@ -1,78 +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|ha|k|epsilon)" - { - solver PBiCGStab; - preconditioner DILU; - tolerance 1e-6; - relTol 0.1; - } - - "(U|ha|k|epsilon)Final" - { - $U; - relTol 0; - } - - "Yi" - { - solver PBiCGStab; - preconditioner DILU; - tolerance 1e-6; - relTol 0.1; - } - "YiFinal" - { - solver PBiCGStab; - preconditioner DILU; - tolerance 1e-7; - relTol 0; - } -} - -PIMPLE -{ - momentumPredictor yes; - nOuterCorrectors 1; - nCorrectors 2; - nNonOrthogonalCorrectors 0; -} - - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/AR.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/AR.gz deleted file mode 100644 index 21b393c37..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/AR.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/H.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/H.gz deleted file mode 100644 index 49eded9d3..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/H.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/H2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/H2.gz deleted file mode 100644 index e1df4b030..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/H2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/H2O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/H2O.gz deleted file mode 100644 index 1c3f50f1e..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/H2O.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/N2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/N2.gz deleted file mode 100644 index 58f7359bf..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/N2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/O.gz deleted file mode 100644 index 6b2cef13a..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/O.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/O2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/O2.gz deleted file mode 100644 index a744e25be..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/O2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/OH.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/OH.gz deleted file mode 100644 index 6142b9614..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/OH.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/T.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/T.gz deleted file mode 100644 index 067eb9fdf..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/T.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/U.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/U.gz deleted file mode 100644 index 202be519e..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/U.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/p.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/p.gz deleted file mode 100644 index 69bf925ad..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/0/p.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/Allclean b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/Allclean deleted file mode 100755 index 8706a4865..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/Allclean +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -echo "Cleaning log.*" -rm log.* -echo "Cleaning processor*" -rm -r processor* -echo "Cleaning polyMesh/" -rm -r constant/polyMesh - diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/ES80_H2-7-16.yaml b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/ES80_H2-7-16.yaml deleted file mode 120000 index 0600efea5..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/ES80_H2-7-16.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/ES80_H2-7-16.yaml \ No newline at end of file diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/constant/CanteraTorchProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/constant/CanteraTorchProperties deleted file mode 100644 index 604b1e925..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/constant/CanteraTorchProperties +++ /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 "constant"; - object CanteraTorchProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -chemistry on; - -CanteraMechanismFile "ES80_H2-7-16.yaml"; - -transportModel "Mix"; - -odeCoeffs -{ - "relTol" 1e-6; - "absTol" 1e-10; -} - -inertSpecie "N2"; - -zeroDReactor -{ - constantProperty "pressure"; -} - -splittingStrategy off; - -TorchSettings -{ - torch on; - GPU on; - log on; - torchModel1 "new_ESH2sub1.pt"; - torchModel2 "new_ESH2sub2.pt"; - torchModel3 "new_ESH2sub3.pt"; - coresPerGPU 4; - GPUsPerNode 4; -} - -loadbalancing -{ - active true; - log false; - algorithm allAverage;//headTail; -} - - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/constant/thermophysicalProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/constant/thermophysicalProperties deleted file mode 100644 index 7f207bb77..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/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/H2/libtorchIntegrator/new_ESH2sub1.pt b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/new_ESH2sub1.pt deleted file mode 120000 index b672ed90c..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/new_ESH2sub1.pt +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/libtorchDNN/new_ESH2sub1.pt \ No newline at end of file diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/new_ESH2sub2.pt b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/new_ESH2sub2.pt deleted file mode 120000 index 976d5c774..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/new_ESH2sub2.pt +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/libtorchDNN/new_ESH2sub2.pt \ No newline at end of file diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/new_ESH2sub3.pt b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/new_ESH2sub3.pt deleted file mode 120000 index 68906dbcc..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/new_ESH2sub3.pt +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/libtorchDNN/new_ESH2sub3.pt \ No newline at end of file diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/system/blockMeshDict b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/system/blockMeshDict deleted file mode 100644 index 9bba2c1d0..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/system/blockMeshDict +++ /dev/null @@ -1,75 +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 1 1) - (960 1 1) - (960 1 0) - (0 1 0) - (0 0 1) - (960 0 1) - (960 0 0) - (0 0 0) -); - -blocks -( - hex (4 5 6 7 0 1 2 3) (57099 1 1) simpleGrading (1 1 1) -); - -edges -( -); - -boundary -( - boundary - { - type empty; - faces - ( - (0 3 2 1) - (4 5 6 7) - (0 1 5 4) - (3 2 6 7) - ); - } - inlet - { - type patch; - faces - ( - (0 4 7 3) - ); - } - outlet - { - type patch; - faces - ( - (1 2 6 5) - ); - } -); - -// mergePatchPairs -// ( -// ); - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/system/controlDict b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/system/controlDict deleted file mode 100644 index 6d959ac39..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/system/controlDict +++ /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 controlDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -application dfLowMachFoam; - -startFrom startTime; - -startTime 0; - -stopAt endTime; - -endTime 1e-5; - -deltaT 1e-6; - -maxDeltaT 1e-04; - -adjustTimeStep off; - -writeControl adjustableRunTime; - -writeInterval 0.001; - -purgeWrite 0; - -writeFormat ascii; - -// writePrecision 6; - -writeCompression on; - -timeFormat general; - -timePrecision 6; - -runTimeModifiable true; - -// adjustTimeStep yes; - -// maxCo 0.8; - -// maxDeltaT 1e-4; - - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/system/decomposeParDict b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/system/decomposeParDict deleted file mode 100644 index 45c7f859f..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/system/decomposeParDict +++ /dev/null @@ -1,45 +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 decomposeParDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -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/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/system/fvSchemes b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/system/fvSchemes deleted file mode 100644 index c841b36e1..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/system/fvSchemes +++ /dev/null @@ -1,61 +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,ha) 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(hDiffCorrFlux) Gauss cubic; - div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; -} - -laplacianSchemes -{ - default Gauss linear orthogonal; -} - -interpolationSchemes -{ - default linear; -} - -snGradSchemes -{ - default orthogonal; -} - - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/system/fvSolution b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/system/fvSolution deleted file mode 100644 index c13c246bb..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/system/fvSolution +++ /dev/null @@ -1,78 +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|ha|k|epsilon)" - { - solver PBiCGStab; - preconditioner DILU; - tolerance 1e-6; - relTol 0.1; - } - - "(U|ha|k|epsilon)Final" - { - $U; - relTol 0; - } - - "Yi" - { - solver PBiCGStab; - preconditioner DILU; - tolerance 1e-6; - relTol 0.1; - } - "YiFinal" - { - solver PBiCGStab; - preconditioner DILU; - tolerance 1e-7; - relTol 0; - } -} - -PIMPLE -{ - momentumPredictor yes; - nOuterCorrectors 1; - nCorrectors 2; - nNonOrthogonalCorrectors 0; -} - - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/AR.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/AR.gz deleted file mode 100644 index 91311f2dd..000000000 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/AR.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/H.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/H.gz old mode 100644 new mode 100755 index 95206f3a2..d713b87df Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/H.gz and b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/H.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/H2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/H2.gz old mode 100644 new mode 100755 index e0228716f..87d09e26c Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/H2.gz and b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/H2.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/H2O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/H2O.gz old mode 100644 new mode 100755 index e9a755f0b..866d73f7e Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/H2O.gz and b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/H2O.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/H2O2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/H2O2.gz new file mode 100755 index 000000000..3c9aba5fd Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/H2O2.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/HO2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/HO2.gz new file mode 100755 index 000000000..f6dbcc225 Binary files /dev/null and b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/HO2.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/N2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/N2.gz old mode 100644 new mode 100755 index 474b4c317..c33019290 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/N2.gz and b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/N2.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/O.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/O.gz old mode 100644 new mode 100755 index bca3e73fc..06f3e86cc Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/O.gz and b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/O.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/O2.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/O2.gz old mode 100644 new mode 100755 index 63de7efe2..4a19afa76 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/O2.gz and b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/O2.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/OH.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/OH.gz old mode 100644 new mode 100755 index 3f4fe818f..5cbcb0908 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/OH.gz and b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/OH.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/T.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/T.gz old mode 100644 new mode 100755 index 13736182c..d964f9d05 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/T.gz and b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/T.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/U.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/U.gz old mode 100644 new mode 100755 index d1e8512c4..0f8b5ee1d Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/U.gz and b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/U.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/p.gz b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/p.gz old mode 100644 new mode 100755 index 5ebe256bd..c434a5e83 Binary files a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/p.gz and b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/0/p.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/Allrun b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/Allrun index 8cd1cbdd5..c4fa56f05 100755 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/Allrun +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/Allrun @@ -1,6 +1,17 @@ #!/bin/sh cd ${0%/*} || exit 1 # Run from this directory +if [ -e DNN_model.pt ] +then + echo "DNN_model.pt exists. Make sure correct DNN model has been used!" +else + echo "DNN_model.pt not exist. Downloading ..." + wget https://store.aissquare.com/models/5e1232cd-c23f-489f-9db4-ee09592beeb1/DNN_model.zip + unzip DNN_model.zip + cp ./DNN_model/H2/DNN_model.pt . + cp ./DNN_model/H2/Burke2012_s9r23.yaml . +fi + # Source tutorial run functions . $WM_PROJECT_DIR/bin/tools/RunFunctions diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/ES80_H2-7-16.yaml b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/ES80_H2-7-16.yaml deleted file mode 120000 index 0600efea5..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/ES80_H2-7-16.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/ES80_H2-7-16.yaml \ No newline at end of file diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/constant/CanteraTorchProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/constant/CanteraTorchProperties old mode 100644 new mode 100755 index cb52df768..b0a32440e --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/constant/CanteraTorchProperties +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/constant/CanteraTorchProperties @@ -17,7 +17,7 @@ FoamFile chemistry on; -CanteraMechanismFile "ES80_H2-7-16.yaml"; +CanteraMechanismFile "Burke2012_s9r23.yaml"; transportModel "Mix"; @@ -33,11 +33,13 @@ splittingStrategy off; TorchSettings { - torch on; - GPU on; - log on; - torchModel "HE04_Hydrogen_ESH2_GMS_sub_20221101"; - coresPerNode 4; + torch on; + GPU on; + log on; + torchModel "DNN_model.pt"; + frozenTemperature 510; + inferenceDeltaTime 1e-6; + coresPerNode 4; } loadbalancing diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/constant/combustionProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/constant/combustionProperties old mode 100644 new mode 100755 diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/constant/thermophysicalProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/constant/thermophysicalProperties old mode 100644 new mode 100755 diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/constant/turbulenceProperties b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/constant/turbulenceProperties old mode 100644 new mode 100755 diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/inference.py b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/inference.py old mode 100644 new mode 100755 index a4181c1f6..5034809cd --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/inference.py +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/inference.py @@ -1,52 +1,29 @@ -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 +import cantera as ct +device_main = "cuda:0" +device_list = range(torch.cuda.device_count()) torch.set_printoptions(precision=10) - -class MyGELU(torch.nn.Module): - def __init__(self): - super(MyGELU, self).__init__() - self.torch_PI = 3.1415926536 +class NN_MLP(torch.nn.Module): + def __init__(self, layer_info): + super(NN_MLP, self).__init__() + self.net = torch.nn.Sequential() + n = len(layer_info) - 1 + for i in range(n - 1): + self.net.add_module('linear_layer_%d' %(i), torch.nn.Linear(layer_info[i], layer_info[i + 1])) + self.net.add_module('gelu_layer_%d' %(i), torch.nn.GELU()) + #if i <= 2: + # self.net.add_module('batch_norm_%d' %(i), torch.nn.BatchNorm1d(layer_info[i + 1])) + self.net.add_module('linear_layer_%d' %(n - 1), torch.nn.Linear(layer_info[n - 1], layer_info[n])) 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) + return self.net(x) - def forward(self, x): - x = self.fc(x) - return x try: #load variables from constant/CanteraTorchProperties path_r = r"./constant/CanteraTorchProperties" @@ -54,27 +31,38 @@ def forward(self, x): data = f.read() i = data.index('torchModel') a = data.index('"',i) - b = data.index('sub',a) - c = data.index('"',b+1) - modelName_split1 = data[a+1:b+3] - modelName_split2 = data[b+3:c] - - modelPath = str(modelName_split1+modelName_split2) - model1Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"1"+modelName_split2+"/checkpoint/") - model2Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"2"+modelName_split2+"/checkpoint/") - model3Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"3"+modelName_split2+"/checkpoint/") + b = data.index('"',a+1) + modelName = data[a+1:b] + i = data.index('frozenTemperature') + a = data.index(';', i) + b = data.rfind(' ',i+1,a) + frozenTemperature = float(data[b+1:a]) + + i = data.index('inferenceDeltaTime') + a = data.index(';', i) + b = data.rfind(' ',i+1,a) + delta_t = float(data[b+1:a]) + + i = data.index('CanteraMechanismFile') + a = data.index('"',i) + b = data.index('"',a+1) + mechanismName = data[a+1:b] + i = data.index('GPU') a = data.index(';', i) b = data.rfind(' ',i+1,a) switch_GPU = data[b+1:a] + #read mechanism species number + gas = ct.Solution(mechanismName) + n_species = gas.n_species #load OpenFOAM switch switch_on = ["true", "True", "on", "yes", "y", "t", "any"] switch_off = ["false", "False", "off", "no", "n", "f", "none"] if switch_GPU in switch_on: - device = torch.device("cuda") - device_ids = range(torch.cuda.device_count()) + device = torch.device(device_main) + device_ids = device_list elif switch_GPU in switch_off: device = torch.device("cpu") device_ids = [0] @@ -82,140 +70,100 @@ def forward(self, x): print("invalid setting!") os._exit(0) - - - #glbal variable will only init once when called interperter - #load parameters from json - - norm0 = json2Parser(str(model1Path+"norm.json")) - norm1 = json2Parser(str(model2Path+"norm.json")) - norm2 = json2Parser(str(model3Path+"norm.json")) - setting0 = json2Parser(str(model1Path+"settings.json")) - lamda = setting0.power_transform - delta_t = setting0.delta_t - dim = setting0.dim - layers = setting0.layers + lamda = 0.1 + dim = 9 + state_dict = torch.load(modelName,map_location='cpu') + Xmu0 = state_dict['data_in_mean'] + Xstd0 = state_dict['data_in_std'] + Ymu0 = state_dict['data_target_mean'] + Ystd0 = state_dict['data_target_std'] + - Xmu0 = torch.tensor(norm0.input_mean).unsqueeze(0).to(device=device) - Xstd0 = torch.tensor(norm0.input_std).unsqueeze(0).to(device=device) - Ymu0 = torch.tensor(norm0.label_mean).unsqueeze(0).to(device=device) - Ystd0 = torch.tensor(norm0.label_std).unsqueeze(0).to(device=device) + Xmu0 = torch.tensor(Xmu0).unsqueeze(0).to(device=device) + Xstd0 = torch.tensor(Xstd0).unsqueeze(0).to(device=device) + Ymu0 = torch.tensor(Ymu0).unsqueeze(0).to(device=device) + Ystd0 = torch.tensor(Ystd0).unsqueeze(0).to(device=device) - Xmu1 = torch.tensor(norm1.input_mean).unsqueeze(0).to(device=device) - Xstd1 = torch.tensor(norm1.input_std).unsqueeze(0).to(device=device) - Ymu1 = torch.tensor(norm1.label_mean).unsqueeze(0).to(device=device) - Ystd1 = torch.tensor(norm1.label_std).unsqueeze(0).to(device=device) + Xmu1 = Xmu0 + Xstd1 = Xstd0 + Ymu1 = Ymu0 + Ystd1 = Ystd0 - Xmu2 = torch.tensor(norm2.input_mean).unsqueeze(0).to(device=device) - Xstd2 = torch.tensor(norm2.input_std).unsqueeze(0).to(device=device) - Ymu2 = torch.tensor(norm2.label_mean).unsqueeze(0).to(device=device) - Ystd2 = torch.tensor(norm2.label_std).unsqueeze(0).to(device=device) + Xmu2 = Xmu0 + Xstd2 = Xstd0 + Ymu2 = Ymu0 + Ystd2 = Ystd0 #load model - model0 = Net() - model1 = Net() - model2 = Net() - - path_list=os.listdir(model1Path) - for filename in path_list: - if os.path.splitext(filename)[1] == '.pt': - modelname = filename - - - if torch.cuda.is_available()==False: - check_point0 = torch.load(str(model1Path+modelname), map_location='cpu') - check_point1 = torch.load(str(model2Path+modelname), map_location='cpu') - check_point2 = torch.load(str(model3Path+modelname), map_location='cpu') - else: - check_point0 = torch.load(str(model1Path+modelname)) - check_point1 = torch.load(str(model2Path+modelname)) - check_point2 = torch.load(str(model3Path+modelname)) + layers = [n_species +2, 1600, 800, 400, 1] + + model0list = [] + for i in range(n_species-1): + model0list.append(NN_MLP(layers)) - 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) + for i in range(n_species-1): + model0list[i].load_state_dict(state_dict[f'net{i}']) + + + for i in range(n_species-1): + model0list[i].eval() + model0list[i].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) + for i in range(n_species-1): + model0list[i] = torch.nn.DataParallel(model0list[i], device_ids=device_ids) + except Exception as e: print(e.args) + + -def inference(vec0, vec1, vec2): +def inference(vec0): ''' 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)) + vec0 = np.abs(np.reshape(vec0, (-1, 3+n_species))) # T, P, Yi(7), Rho + vec0[:,1] *= 101325 + mask = vec0[:,0] > frozenTemperature + vec0_input = vec0[mask, :] + print(f'real inference points number: {vec0_input.shape[0]}') 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 + input0_ = torch.from_numpy(vec0_input).double().to(device=device) #cast ndarray to torch tensor + # pre_processing rho0 = input0_[:, -1].unsqueeze(1) input0_Y = input0_[:, 2:-1].clone() input0_bct = input0_[:, 0:-1] input0_bct[:, 2:] = (input0_bct[:, 2:]**(lamda) - 1) / lamda #BCT - input0_normalized = (input0_bct - Xmu0) / Xstd0 + input0_normalized = (input0_bct - Xmu0) / Xstd0 #DimXmu0 = 9, DimXstd0 = 9, input0_bct = # input0_normalized[:, -1] = 0 #set Y_AR to 0 input0_normalized = input0_normalized.float() - - rho1 = input1_[:, -1].unsqueeze(1) - input1_Y = input1_[:, 2:-1].clone() - input1_bct = input1_[:, 0:-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_[:, -1].unsqueeze(1) - input2_Y = input2_[:, 2:-1].clone() - input2_bct = input2_[:, 0:-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() + input0_normalized = input0_normalized.to(device=device) #inference - output0_normalized = model0(input0_normalized) - output1_normalized = model1(input1_normalized) - output2_normalized = model2(input2_normalized) - + + output0_normalized = [] + for i in range(n_species-1): + output0_normalized.append(model0list[i](input0_normalized)) + output0_normalized = torch.cat(output0_normalized, dim=1) + # 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_bct = output0_normalized * Ystd0 + Ymu0 + input0_bct[:, 2:-1] + output0_Y = input0_Y.clone() + output0_Y[:, :-1] = (lamda * output0_bct + 1)**(1 / lamda) + output0_Y[:, :-1] = output0_Y[:, :-1] / torch.sum(input=output0_Y[:, :-1], dim=1, keepdim=True) * (1 - output0_Y[:, -1:]) 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) + result = np.zeros((vec0.shape[0], n_species)) + result[mask, :] = output0 return result except Exception as e: print(e.args) + diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/mechanisms b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/mechanisms deleted file mode 120000 index b7afede27..000000000 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/mechanisms +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms \ No newline at end of file diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/system/blockMeshDict b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/system/blockMeshDict old mode 100644 new mode 100755 index 9bba2c1d0..f6299b00b --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/system/blockMeshDict +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/system/blockMeshDict @@ -19,18 +19,27 @@ convertToMeters 0.001; vertices ( (0 1 1) - (960 1 1) - (960 1 0) + (40 1 1) + (40 1 0) (0 1 0) (0 0 1) - (960 0 1) - (960 0 0) + (40 0 1) + (40 0 0) (0 0 0) ); blocks ( - hex (4 5 6 7 0 1 2 3) (57099 1 1) simpleGrading (1 1 1) + hex (4 5 6 7 0 1 2 3) (880 1 1) + simpleGrading + ( + ( + (0.55 0.625 1) + (0.45 0.375 2) + ) + 1 + 1 + ) ); edges diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/system/controlDict b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/system/controlDict old mode 100644 new mode 100755 index 6d959ac39..31e5f977b --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/system/controlDict +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/system/controlDict @@ -23,7 +23,7 @@ startTime 0; stopAt endTime; -endTime 1e-5; +endTime 0.002; deltaT 1e-6; @@ -33,7 +33,7 @@ adjustTimeStep off; writeControl adjustableRunTime; -writeInterval 0.001; +writeInterval 0.0001; purgeWrite 0; diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/system/decomposeParDict b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/system/decomposeParDict old mode 100644 new mode 100755 diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/system/fvSchemes b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/system/fvSchemes old mode 100644 new mode 100755 diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/system/fvSolution b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/system/fvSolution old mode 100644 new mode 100755 diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/system/funkySetFieldsDict b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/system/sample old mode 100644 new mode 100755 similarity index 69% rename from examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/system/funkySetFieldsDict rename to examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/system/sample index 4cb58b7f9..747b58c43 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/system/funkySetFieldsDict +++ b/examples/dfLowMachFoam/oneD_freelyPropagation/H2/pytorchIntegrator/system/sample @@ -7,23 +7,32 @@ \*---------------------------------------------------------------------------*/ FoamFile { - version 2.0; format ascii; class dictionary; location "system"; - object funkySetFieldsDict; + object sample; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -expressions - ( -TGV_U +type sets; +libs ("libsampling.so"); + +interpolationScheme cellPoint; + +setFormat raw; + +sets +( + data { - 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; + type lineUniform; + axis x; + start (0 0 0); + end (0.04 0 0); + nPoints 1000; } - ); +); +fields ( T ); // ************************************************************************* // diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/H.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/H.gz deleted file mode 100644 index 6e7fc10da..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/H.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/H2.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/H2.gz deleted file mode 100644 index 9d0eb9f2e..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/H2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/H2O.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/H2O.gz deleted file mode 100644 index b9414fb13..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/H2O.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/H2O2.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/H2O2.gz deleted file mode 100644 index 3e7d96766..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/H2O2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/HO2.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/HO2.gz deleted file mode 100644 index 947dd8358..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/HO2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/N2.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/N2.gz deleted file mode 100644 index a4a217c68..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/N2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/O.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/O.gz deleted file mode 100644 index 0a2fbdce0..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/O.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/O2.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/O2.gz deleted file mode 100644 index 2a15d74e3..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/O2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/OH.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/OH.gz deleted file mode 100644 index cb2cfb99b..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/OH.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/T.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/T.gz deleted file mode 100644 index 1e8fbb97c..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/T.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/U.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/U.gz deleted file mode 100644 index 334215d06..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/U.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/p.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/p.gz deleted file mode 100644 index b007dbeae..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/0/p.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/Allrun b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/Allrun deleted file mode 100755 index 8cd1cbdd5..000000000 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/Allrun +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions - -application=dfLowMachFoam - -runApplication blockMesh -runApplication decomposePar -runApplication mpirun -np 4 --allow-run-as-root $application -parallel diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/ES80_H2-7-16.yaml b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/ES80_H2-7-16.yaml deleted file mode 120000 index 0600efea5..000000000 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/ES80_H2-7-16.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/ES80_H2-7-16.yaml \ No newline at end of file diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/constant/CanteraTorchProperties b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/constant/CanteraTorchProperties deleted file mode 100644 index 604b1e925..000000000 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/constant/CanteraTorchProperties +++ /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 "constant"; - object CanteraTorchProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -chemistry on; - -CanteraMechanismFile "ES80_H2-7-16.yaml"; - -transportModel "Mix"; - -odeCoeffs -{ - "relTol" 1e-6; - "absTol" 1e-10; -} - -inertSpecie "N2"; - -zeroDReactor -{ - constantProperty "pressure"; -} - -splittingStrategy off; - -TorchSettings -{ - torch on; - GPU on; - log on; - torchModel1 "new_ESH2sub1.pt"; - torchModel2 "new_ESH2sub2.pt"; - torchModel3 "new_ESH2sub3.pt"; - coresPerGPU 4; - GPUsPerNode 4; -} - -loadbalancing -{ - active true; - log false; - algorithm allAverage;//headTail; -} - - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/constant/thermophysicalProperties b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/constant/thermophysicalProperties deleted file mode 100644 index 7f207bb77..000000000 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/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/threeD_reactingTGV/H2/libtorchIntegrator/new_ESH2sub1.pt b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/new_ESH2sub1.pt deleted file mode 120000 index b672ed90c..000000000 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/new_ESH2sub1.pt +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/libtorchDNN/new_ESH2sub1.pt \ No newline at end of file diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/new_ESH2sub2.pt b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/new_ESH2sub2.pt deleted file mode 120000 index 976d5c774..000000000 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/new_ESH2sub2.pt +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/libtorchDNN/new_ESH2sub2.pt \ No newline at end of file diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/new_ESH2sub3.pt b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/new_ESH2sub3.pt deleted file mode 120000 index 68906dbcc..000000000 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/new_ESH2sub3.pt +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/libtorchDNN/new_ESH2sub3.pt \ No newline at end of file diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/system/controlDict b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/system/controlDict deleted file mode 100644 index 99fe800cd..000000000 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/system/controlDict +++ /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 controlDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -application dfLowMachFoam; - -startFrom startTime; - -startTime 0; - -stopAt endTime; - -endTime 1e-5; - -deltaT 1e-6; - -maxDeltaT 1e-04; - -adjustTimeStep off; - -writeControl adjustableRunTime; - -writeInterval 5e-6; - -purgeWrite 0; - -writeFormat ascii; - -// writePrecision 6; - -writeCompression on; - -timeFormat general; - -timePrecision 6; - -runTimeModifiable true; - -// adjustTimeStep yes; - -// maxCo 0.8; - -// maxDeltaT 1e-4; - - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/system/decomposeParDict b/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/system/decomposeParDict deleted file mode 100644 index 45c7f859f..000000000 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/system/decomposeParDict +++ /dev/null @@ -1,45 +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 decomposeParDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -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/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/H.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/H.gz deleted file mode 100644 index e02656898..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/H.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/H2.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/H2.gz deleted file mode 100644 index 4674ce6dd..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/H2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/H2O.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/H2O.gz deleted file mode 100644 index 8fbd42b71..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/H2O.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/H2O2.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/H2O2.gz deleted file mode 100644 index ce14de9bf..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/H2O2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/HO2.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/HO2.gz deleted file mode 100644 index 50c50e79e..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/HO2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/N2.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/N2.gz deleted file mode 100644 index fae63f298..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/N2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/O.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/O.gz deleted file mode 100644 index 1d0aebb35..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/O.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/O2.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/O2.gz deleted file mode 100644 index 87f403b1f..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/O2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/OH.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/OH.gz deleted file mode 100644 index 35a199a1b..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/OH.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/T.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/T.gz deleted file mode 100644 index ef777773e..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/T.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/U.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/U.gz deleted file mode 100644 index 1ceb95c71..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/U.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/p.gz b/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/p.gz deleted file mode 100644 index 6bc27aba4..000000000 Binary files a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/0/p.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/Allrun b/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/Allrun deleted file mode 100755 index 8cd1cbdd5..000000000 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/Allrun +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions - -application=dfLowMachFoam - -runApplication blockMesh -runApplication decomposePar -runApplication mpirun -np 4 --allow-run-as-root $application -parallel diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/ES80_H2-7-16.yaml b/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/ES80_H2-7-16.yaml deleted file mode 120000 index 0600efea5..000000000 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/ES80_H2-7-16.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/ES80_H2-7-16.yaml \ No newline at end of file diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/constant/thermophysicalProperties b/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/constant/thermophysicalProperties deleted file mode 100644 index 7f207bb77..000000000 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/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/threeD_reactingTGV/H2/pytorchIntegrator/inference.py b/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/inference.py deleted file mode 100644 index a4181c1f6..000000000 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/inference.py +++ /dev/null @@ -1,221 +0,0 @@ -from builtins import Exception, print -from calendar import prcal -import torch -import numpy as np -import math -import time -import json -import os -from easydict import EasyDict as edict -import torch.profiler -import os - - -torch.set_printoptions(precision=10) - - -class MyGELU(torch.nn.Module): - def __init__(self): - super(MyGELU, self).__init__() - self.torch_PI = 3.1415926536 - - def forward(self, x): - return 0.5 * x * (1 + torch.tanh( - math.sqrt(2 / self.torch_PI) * (x + 0.044715 * torch.pow(x, 3)))) - - -def json2Parser(json_path): - """load json and return parser-like object""" - with open(json_path, 'r') as f: - args = json.load(f) - return edict(args) - - -class Net(torch.nn.Module): - def __init__(self): - super(Net, self).__init__() - neurons = layers - self.depth = len(neurons) - 1 - self.actfun = MyGELU() - self.layers = [] - for i in range(self.depth - 1): - self.layers.append(torch.nn.Linear(neurons[i], neurons[i + 1])) - self.layers.append(self.actfun) - self.layers.append(torch.nn.Linear(neurons[-2], neurons[-1])) # last layer - self.fc = torch.nn.Sequential(*self.layers) - - def forward(self, x): - x = self.fc(x) - return x -try: - #load variables from constant/CanteraTorchProperties - path_r = r"./constant/CanteraTorchProperties" - with open(path_r, "r") as f: - data = f.read() - i = data.index('torchModel') - a = data.index('"',i) - b = data.index('sub',a) - c = data.index('"',b+1) - modelName_split1 = data[a+1:b+3] - modelName_split2 = data[b+3:c] - - modelPath = str(modelName_split1+modelName_split2) - model1Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"1"+modelName_split2+"/checkpoint/") - model2Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"2"+modelName_split2+"/checkpoint/") - model3Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"3"+modelName_split2+"/checkpoint/") - - i = data.index('GPU') - a = data.index(';', i) - b = data.rfind(' ',i+1,a) - switch_GPU = data[b+1:a] - - #load OpenFOAM switch - switch_on = ["true", "True", "on", "yes", "y", "t", "any"] - switch_off = ["false", "False", "off", "no", "n", "f", "none"] - if switch_GPU in switch_on: - device = torch.device("cuda") - device_ids = range(torch.cuda.device_count()) - elif switch_GPU in switch_off: - device = torch.device("cpu") - device_ids = [0] - else: - print("invalid setting!") - os._exit(0) - - - - #glbal variable will only init once when called interperter - #load parameters from json - - norm0 = json2Parser(str(model1Path+"norm.json")) - norm1 = json2Parser(str(model2Path+"norm.json")) - norm2 = json2Parser(str(model3Path+"norm.json")) - setting0 = json2Parser(str(model1Path+"settings.json")) - lamda = setting0.power_transform - delta_t = setting0.delta_t - dim = setting0.dim - layers = setting0.layers - - - Xmu0 = torch.tensor(norm0.input_mean).unsqueeze(0).to(device=device) - Xstd0 = torch.tensor(norm0.input_std).unsqueeze(0).to(device=device) - Ymu0 = torch.tensor(norm0.label_mean).unsqueeze(0).to(device=device) - Ystd0 = torch.tensor(norm0.label_std).unsqueeze(0).to(device=device) - - Xmu1 = torch.tensor(norm1.input_mean).unsqueeze(0).to(device=device) - Xstd1 = torch.tensor(norm1.input_std).unsqueeze(0).to(device=device) - Ymu1 = torch.tensor(norm1.label_mean).unsqueeze(0).to(device=device) - Ystd1 = torch.tensor(norm1.label_std).unsqueeze(0).to(device=device) - - Xmu2 = torch.tensor(norm2.input_mean).unsqueeze(0).to(device=device) - Xstd2 = torch.tensor(norm2.input_std).unsqueeze(0).to(device=device) - Ymu2 = torch.tensor(norm2.label_mean).unsqueeze(0).to(device=device) - Ystd2 = torch.tensor(norm2.label_std).unsqueeze(0).to(device=device) - - #load model - model0 = Net() - model1 = Net() - model2 = Net() - - path_list=os.listdir(model1Path) - for filename in path_list: - if os.path.splitext(filename)[1] == '.pt': - modelname = filename - - - if torch.cuda.is_available()==False: - check_point0 = torch.load(str(model1Path+modelname), map_location='cpu') - check_point1 = torch.load(str(model2Path+modelname), map_location='cpu') - check_point2 = torch.load(str(model3Path+modelname), map_location='cpu') - else: - check_point0 = torch.load(str(model1Path+modelname)) - check_point1 = torch.load(str(model2Path+modelname)) - check_point2 = torch.load(str(model3Path+modelname)) - - model0.load_state_dict(check_point0) - model1.load_state_dict(check_point1) - model2.load_state_dict(check_point2) - model0.to(device=device) - model1.to(device=device) - model2.to(device=device) - - if len(device_ids) > 1: - model0 = torch.nn.DataParallel(model0, device_ids=device_ids) - model1 = torch.nn.DataParallel(model1, device_ids=device_ids) - model2 = torch.nn.DataParallel(model2, device_ids=device_ids) -except Exception as e: - print(e.args) - - -def inference(vec0, vec1, vec2): - ''' - use model to inference - ''' - #args = np.reshape(args, (-1, 9)) #reshape to formed size - #vec0 = np.reshape(vec0, (-1, 24)) - #vec1 = np.reshape(vec1, (-1, 24)) - #vec2 = np.reshape(vec2, (-1, 24)) - vec0 = np.reshape(vec0, (-1, 10)) - vec1 = np.reshape(vec1, (-1, 10)) - vec2 = np.reshape(vec2, (-1, 10)) - - try: - with torch.no_grad(): - input0_ = torch.from_numpy(vec0).double().to(device=device) #cast ndarray to torch tensor - input1_ = torch.from_numpy(vec1).double().to(device=device) #cast ndarray to torch tensor - input2_ = torch.from_numpy(vec2).double().to(device=device) #cast ndarray to torch tensor - - # pre_processing - rho0 = input0_[:, -1].unsqueeze(1) - input0_Y = input0_[:, 2:-1].clone() - input0_bct = input0_[:, 0:-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_[:, -1].unsqueeze(1) - input1_Y = input1_[:, 2:-1].clone() - input1_bct = input1_[:, 0:-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_[:, -1].unsqueeze(1) - input2_Y = input2_[:, 2:-1].clone() - input2_bct = input2_[:, 0:-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/threeD_reactingTGV/H2/pytorchIntegrator/mechanisms b/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/mechanisms deleted file mode 120000 index b7afede27..000000000 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/mechanisms +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms \ No newline at end of file diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/system/decomposeParDict b/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/system/decomposeParDict deleted file mode 100644 index 45c7f859f..000000000 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/system/decomposeParDict +++ /dev/null @@ -1,45 +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 decomposeParDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -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/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/C2H2.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/C2H2.gz new file mode 100755 index 000000000..4e25f9469 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/C2H2.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/C2H3.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/C2H3.gz new file mode 100755 index 000000000..af77b65ea Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/C2H3.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/C2H4.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/C2H4.gz new file mode 100755 index 000000000..6421149b9 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/C2H4.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/C2H5.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/C2H5.gz new file mode 100755 index 000000000..ba48d2e54 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/C2H5.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CH2CHO.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CH2CHO.gz new file mode 100755 index 000000000..729b558e1 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CH2CHO.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CH2CO.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CH2CO.gz new file mode 100755 index 000000000..21fc7812f Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CH2CO.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CH2O.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CH2O.gz new file mode 100755 index 000000000..e29a4389c Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CH2O.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CH2OH.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CH2OH.gz new file mode 100755 index 000000000..a586f677d Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CH2OH.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CH3.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CH3.gz new file mode 100755 index 000000000..f86abb030 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CH3.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CH4.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CH4.gz new file mode 100755 index 000000000..869d5b8e3 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CH4.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CO.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CO.gz new file mode 100755 index 000000000..5b4755672 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CO.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CO2.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CO2.gz new file mode 100755 index 000000000..a3fd0f773 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/CO2.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/H.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/H.gz new file mode 100755 index 000000000..b03ebe796 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/H.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/H2.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/H2.gz new file mode 100755 index 000000000..f967128ea Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/H2.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/H2O.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/H2O.gz new file mode 100755 index 000000000..22ef19334 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/H2O.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/HCCO.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/HCCO.gz new file mode 100755 index 000000000..43f866c8c Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/HCCO.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/HCO.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/HCO.gz new file mode 100755 index 000000000..389a7b346 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/HCO.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/HO2.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/HO2.gz new file mode 100755 index 000000000..c8e9292ee Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/HO2.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/N2.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/N2.gz new file mode 100755 index 000000000..5b7450c38 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/N2.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/O.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/O.gz new file mode 100755 index 000000000..4da4a62f0 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/O.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/O2.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/O2.gz new file mode 100755 index 000000000..aa4f200ac Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/O2.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/OH.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/OH.gz new file mode 100755 index 000000000..c35862057 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/OH.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/S-CH2.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/S-CH2.gz new file mode 100755 index 000000000..1a5f872c9 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/S-CH2.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/T-CH2.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/T-CH2.gz new file mode 100755 index 000000000..efbe2ac81 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/T-CH2.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/T.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/T.gz new file mode 100755 index 000000000..9a7a825b6 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/T.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/U.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/U.gz new file mode 100755 index 000000000..a5fd9584e Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/U.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/p.gz b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/p.gz new file mode 100755 index 000000000..7bde1e5ad Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/0/p.gz differ diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/Allclean b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/Allclean similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/Allclean rename to examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/Allclean diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/Allrun b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/Allrun new file mode 100755 index 000000000..218486df6 --- /dev/null +++ b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/Allrun @@ -0,0 +1,22 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +if [ -e DNN_model.pt ] +then + echo "DNN_model.pt exists. Make sure correct DNN model has been used!" +else + echo "DNN_model.pt not exist. Downloading ..." + wget https://store.aissquare.com/models/5e1232cd-c23f-489f-9db4-ee09592beeb1/DNN_model.zip + unzip DNN_model.zip + cp ./DNN_model/C2H4/DNN_model.pt . + cp ./DNN_model/C2H4/Wu24sp.yaml . +fi + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +application=dfLowMachFoam + +runApplication blockMesh +runApplication decomposePar +runApplication mpirun -np 8 --allow-run-as-root $application -parallel diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/constant/CanteraTorchProperties b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/constant/CanteraTorchProperties old mode 100644 new mode 100755 similarity index 81% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/constant/CanteraTorchProperties rename to examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/constant/CanteraTorchProperties index 8873b201d..6bac716f7 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/constant/CanteraTorchProperties +++ b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/constant/CanteraTorchProperties @@ -17,7 +17,7 @@ FoamFile chemistry on; -CanteraMechanismFile "drm19.yaml"; +CanteraMechanismFile "Wu24sp.yaml"; transportModel "Mix"; @@ -33,11 +33,13 @@ splittingStrategy off; TorchSettings { - torch on; - GPU on; - log on; - torchModel ""; - coresPerNode 4; + torch on; + GPU on; + log on; + torchModel "DNN_model.pt"; + frozenTemperature 510; + inferenceDeltaTime 1e-7; + coresPerNode 8; } loadbalancing diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/constant/combustionProperties b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/constant/combustionProperties old mode 100644 new mode 100755 similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/constant/combustionProperties rename to examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/constant/combustionProperties diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/constant/thermophysicalProperties b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/constant/thermophysicalProperties old mode 100644 new mode 100755 similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/constant/thermophysicalProperties rename to examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/constant/thermophysicalProperties diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/constant/turbulenceProperties b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/constant/turbulenceProperties old mode 100644 new mode 100755 similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/constant/turbulenceProperties rename to examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/constant/turbulenceProperties diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/inference.py b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/inference.py new file mode 100755 index 000000000..5034809cd --- /dev/null +++ b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/inference.py @@ -0,0 +1,169 @@ +import torch +import numpy as np +import time +import os +import cantera as ct + +device_main = "cuda:0" +device_list = range(torch.cuda.device_count()) + +torch.set_printoptions(precision=10) + +class NN_MLP(torch.nn.Module): + def __init__(self, layer_info): + super(NN_MLP, self).__init__() + self.net = torch.nn.Sequential() + n = len(layer_info) - 1 + for i in range(n - 1): + self.net.add_module('linear_layer_%d' %(i), torch.nn.Linear(layer_info[i], layer_info[i + 1])) + self.net.add_module('gelu_layer_%d' %(i), torch.nn.GELU()) + #if i <= 2: + # self.net.add_module('batch_norm_%d' %(i), torch.nn.BatchNorm1d(layer_info[i + 1])) + self.net.add_module('linear_layer_%d' %(n - 1), torch.nn.Linear(layer_info[n - 1], layer_info[n])) + + def forward(self, x): + return self.net(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('torchModel') + a = data.index('"',i) + b = data.index('"',a+1) + modelName = data[a+1:b] + + i = data.index('frozenTemperature') + a = data.index(';', i) + b = data.rfind(' ',i+1,a) + frozenTemperature = float(data[b+1:a]) + + i = data.index('inferenceDeltaTime') + a = data.index(';', i) + b = data.rfind(' ',i+1,a) + delta_t = float(data[b+1:a]) + + i = data.index('CanteraMechanismFile') + a = data.index('"',i) + b = data.index('"',a+1) + mechanismName = data[a+1:b] + + i = data.index('GPU') + a = data.index(';', i) + b = data.rfind(' ',i+1,a) + switch_GPU = data[b+1:a] + + #read mechanism species number + gas = ct.Solution(mechanismName) + n_species = gas.n_species + #load OpenFOAM switch + switch_on = ["true", "True", "on", "yes", "y", "t", "any"] + switch_off = ["false", "False", "off", "no", "n", "f", "none"] + if switch_GPU in switch_on: + device = torch.device(device_main) + device_ids = device_list + elif switch_GPU in switch_off: + device = torch.device("cpu") + device_ids = [0] + else: + print("invalid setting!") + os._exit(0) + + lamda = 0.1 + dim = 9 + + state_dict = torch.load(modelName,map_location='cpu') + Xmu0 = state_dict['data_in_mean'] + Xstd0 = state_dict['data_in_std'] + Ymu0 = state_dict['data_target_mean'] + Ystd0 = state_dict['data_target_std'] + + + Xmu0 = torch.tensor(Xmu0).unsqueeze(0).to(device=device) + Xstd0 = torch.tensor(Xstd0).unsqueeze(0).to(device=device) + Ymu0 = torch.tensor(Ymu0).unsqueeze(0).to(device=device) + Ystd0 = torch.tensor(Ystd0).unsqueeze(0).to(device=device) + + Xmu1 = Xmu0 + Xstd1 = Xstd0 + Ymu1 = Ymu0 + Ystd1 = Ystd0 + + Xmu2 = Xmu0 + Xstd2 = Xstd0 + Ymu2 = Ymu0 + Ystd2 = Ystd0 + + #load model + layers = [n_species +2, 1600, 800, 400, 1] + + model0list = [] + for i in range(n_species-1): + model0list.append(NN_MLP(layers)) + + for i in range(n_species-1): + model0list[i].load_state_dict(state_dict[f'net{i}']) + + + for i in range(n_species-1): + model0list[i].eval() + model0list[i].to(device=device) + + if len(device_ids) > 1: + for i in range(n_species-1): + model0list[i] = torch.nn.DataParallel(model0list[i], device_ids=device_ids) + +except Exception as e: + print(e.args) + + + + +def inference(vec0): + ''' + use model to inference + ''' + vec0 = np.abs(np.reshape(vec0, (-1, 3+n_species))) # T, P, Yi(7), Rho + vec0[:,1] *= 101325 + mask = vec0[:,0] > frozenTemperature + vec0_input = vec0[mask, :] + print(f'real inference points number: {vec0_input.shape[0]}') + + try: + with torch.no_grad(): + input0_ = torch.from_numpy(vec0_input).double().to(device=device) #cast ndarray to torch tensor + + + # pre_processing + rho0 = input0_[:, -1].unsqueeze(1) + input0_Y = input0_[:, 2:-1].clone() + input0_bct = input0_[:, 0:-1] + input0_bct[:, 2:] = (input0_bct[:, 2:]**(lamda) - 1) / lamda #BCT + input0_normalized = (input0_bct - Xmu0) / Xstd0 #DimXmu0 = 9, DimXstd0 = 9, input0_bct = + # input0_normalized[:, -1] = 0 #set Y_AR to 0 + input0_normalized = input0_normalized.float() + input0_normalized = input0_normalized.to(device=device) + + #inference + + output0_normalized = [] + for i in range(n_species-1): + output0_normalized.append(model0list[i](input0_normalized)) + output0_normalized = torch.cat(output0_normalized, dim=1) + + # post_processing + output0_bct = output0_normalized * Ystd0 + Ymu0 + input0_bct[:, 2:-1] + output0_Y = input0_Y.clone() + output0_Y[:, :-1] = (lamda * output0_bct + 1)**(1 / lamda) + output0_Y[:, :-1] = output0_Y[:, :-1] / torch.sum(input=output0_Y[:, :-1], dim=1, keepdim=True) * (1 - output0_Y[:, -1:]) + output0 = (output0_Y - input0_Y) * rho0 / delta_t + output0 = output0.cpu().numpy() + + + result = np.zeros((vec0.shape[0], n_species)) + result[mask, :] = output0 + return result + except Exception as e: + print(e.args) + diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/system/blockMeshDict b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/system/blockMeshDict old mode 100644 new mode 100755 similarity index 71% rename from examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/system/blockMeshDict rename to examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/system/blockMeshDict index e8e079bc5..2625f1b3f --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/system/blockMeshDict +++ b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/system/blockMeshDict @@ -14,24 +14,24 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -convertToMeters 0.001; +convertToMeters 0.01; vertices ( (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) + (3.1415926 0 0) + (3.1415926 3.1415926 0) + (0 3.1415926 0) + (0 0 3.1415926) + (3.1415926 0 3.1415926) + (3.1415926 3.1415926 3.1415926) + (0 3.1415926 3.1415926) ); blocks ( - hex (0 1 2 3 4 5 6 7) (64 64 64) simpleGrading (1 1 1) + hex (0 1 2 3 4 5 6 7) (1024 1024 1) simpleGrading (1 1 1) ); edges @@ -42,8 +42,7 @@ boundary ( front { - type cyclic; - neighbourPatch back; + type empty; faces ( (4 5 6 7) @@ -51,8 +50,7 @@ boundary } back { - type cyclic; - neighbourPatch front; + type empty; faces ( (0 3 2 1) @@ -60,7 +58,7 @@ boundary } left { - type cyclic; + type patch; neighbourPatch right; faces ( @@ -69,7 +67,7 @@ boundary } right { - type cyclic; + type patch; neighbourPatch left; faces ( @@ -78,7 +76,7 @@ boundary } top { - type cyclic; + type patch; neighbourPatch down; faces ( @@ -87,7 +85,7 @@ boundary } down { - type cyclic; + type patch; neighbourPatch top; faces ( diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/controlDict b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/system/controlDict old mode 100644 new mode 100755 similarity index 93% rename from examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/controlDict rename to examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/system/controlDict index 671552c11..519859b27 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/controlDict +++ b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/system/controlDict @@ -17,15 +17,15 @@ FoamFile application dfLowMachFoam; -startFrom startTime; +startFrom latestTime; startTime 0; stopAt endTime; -endTime 1e-5; +endTime 0.0015; -deltaT 1e-6; +deltaT 1e-7; maxDeltaT 1e-04; diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/decomposeParDict b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/system/decomposeParDict old mode 100644 new mode 100755 similarity index 92% rename from examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/decomposeParDict rename to examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/system/decomposeParDict index 45c7f859f..66e942761 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/system/decomposeParDict +++ b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/system/decomposeParDict @@ -15,13 +15,13 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -numberOfSubdomains 4; +numberOfSubdomains 8; -method scotch; +method simple; simpleCoeffs { - n (4 1 1); + n (4 2 1); delta 0.001; } diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/system/fvSchemes b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/system/fvSchemes old mode 100644 new mode 100755 similarity index 100% rename from examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/system/fvSchemes rename to examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/system/fvSchemes diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/system/fvSolution b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/system/fvSolution old mode 100644 new mode 100755 similarity index 100% rename from examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/system/fvSolution rename to examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/system/fvSolution diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/system/setFieldsDict b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/system/setFieldsDict new file mode 100755 index 000000000..9f57e9ac5 --- /dev/null +++ b/examples/dfLowMachFoam/twoD_HIT_flame/C2H4/pytorchIntegrator/system/setFieldsDict @@ -0,0 +1,60 @@ +/*--------------------------------*- 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 setFieldsDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +defaultFieldValues +( + volScalarFieldValue T 300 + volScalarFieldValue CH4 0.055167 + volScalarFieldValue O2 0.22006 + volScalarFieldValue N2 0.724773 +); + +regions +( + cylinderToCell + { + p1 (0.015707963 0.015707963 0); + p2 (0.015707963 0.015707963 0.031415926); + radius 0.0031415926; + fieldValues + ( + volScalarFieldValue T 2230.9 + volScalarFieldValue H2 0.000255 + volScalarFieldValue H 0.000015 + volScalarFieldValue O 0.000139 + volScalarFieldValue O2 0.006197 + volScalarFieldValue OH 0.001885 + volScalarFieldValue H2 0.120486 + volScalarFieldValue HO 0.000001 + volScalarFieldValue CH 0 + volScalarFieldValue CH2(S) 0 + volScalarFieldValue CH3 0 + volScalarFieldValue CH4 0 + volScalarFieldValue CO 0.008899 + volScalarFieldValue CO2 0.13735 + volScalarFieldValue HCO 0 + volScalarFieldValue CH2O 0 + volScalarFieldValue CH3O 0 + volScalarFieldValue C2H4 0 + volScalarFieldValue C2H5 0 + volScalarFieldValue C2H6 0 + volScalarFieldValue N2 0.724773 + ); + } +); + +// ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/0/CH4.gz b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/0/CH4.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/0/CH4.gz rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/0/CH4.gz diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/0/N2.gz b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/0/N2.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/0/N2.gz rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/0/N2.gz diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/0/O2.gz b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/0/O2.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/0/O2.gz rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/0/O2.gz diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/0/T.gz b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/0/T.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/0/T.gz rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/0/T.gz diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/0/U.gz b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/0/U.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/0/U.gz rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/0/U.gz diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/0/Ydefault.gz b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/0/Ydefault.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/0/Ydefault.gz rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/0/Ydefault.gz diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/0/p.gz b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/0/p.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/0/p.gz rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/0/p.gz diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/Allclean b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/Allclean similarity index 100% rename from examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/Allclean rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/Allclean diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/Allrun b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/Allrun similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/Allrun rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/Allrun diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/constant/CanteraTorchProperties b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/constant/CanteraTorchProperties old mode 100644 new mode 100755 similarity index 93% rename from examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/constant/CanteraTorchProperties rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/constant/CanteraTorchProperties index 8873b201d..bb2b198c3 --- a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/constant/CanteraTorchProperties +++ b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/constant/CanteraTorchProperties @@ -33,9 +33,9 @@ splittingStrategy off; TorchSettings { - torch on; - GPU on; - log on; + torch off; + GPU off; + log off; torchModel ""; coresPerNode 4; } diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/constant/combustionProperties b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/constant/combustionProperties old mode 100644 new mode 100755 similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/constant/combustionProperties rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/constant/combustionProperties diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/constant/thermophysicalProperties b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/constant/thermophysicalProperties old mode 100644 new mode 100755 similarity index 100% rename from examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/constant/thermophysicalProperties rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/constant/thermophysicalProperties diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/constant/turbulenceProperties b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/constant/turbulenceProperties old mode 100644 new mode 100755 similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/constant/turbulenceProperties rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/constant/turbulenceProperties diff --git a/examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/drm19.yaml b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/drm19.yaml similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/CH4/pytorchIntegrator/drm19.yaml rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/drm19.yaml diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/system/blockMeshDict b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/system/blockMeshDict similarity index 100% rename from examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/system/blockMeshDict rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/system/blockMeshDict diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/system/controlDict b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/system/controlDict similarity index 100% rename from examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/system/controlDict rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/system/controlDict diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/system/decomposeParDict b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/system/decomposeParDict similarity index 100% rename from examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/system/decomposeParDict rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/system/decomposeParDict diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/system/fvSchemes b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/system/fvSchemes similarity index 100% rename from examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/system/fvSchemes rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/system/fvSchemes diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/system/fvSolution b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/system/fvSolution similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/system/fvSolution rename to examples/dfLowMachFoam/twoD_HIT_flame/CH4/cvodeIntegrator/system/fvSolution diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/Allrun b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/Allrun deleted file mode 100755 index 8cd1cbdd5..000000000 --- a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/Allrun +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions - -application=dfLowMachFoam - -runApplication blockMesh -runApplication decomposePar -runApplication mpirun -np 4 --allow-run-as-root $application -parallel diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/drm19.yaml b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/drm19.yaml deleted file mode 120000 index 6aed11e7f..000000000 --- a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/drm19.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/CH4/drm19.yaml \ No newline at end of file diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/inference.py b/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/inference.py deleted file mode 100644 index a4181c1f6..000000000 --- a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/inference.py +++ /dev/null @@ -1,221 +0,0 @@ -from builtins import Exception, print -from calendar import prcal -import torch -import numpy as np -import math -import time -import json -import os -from easydict import EasyDict as edict -import torch.profiler -import os - - -torch.set_printoptions(precision=10) - - -class MyGELU(torch.nn.Module): - def __init__(self): - super(MyGELU, self).__init__() - self.torch_PI = 3.1415926536 - - def forward(self, x): - return 0.5 * x * (1 + torch.tanh( - math.sqrt(2 / self.torch_PI) * (x + 0.044715 * torch.pow(x, 3)))) - - -def json2Parser(json_path): - """load json and return parser-like object""" - with open(json_path, 'r') as f: - args = json.load(f) - return edict(args) - - -class Net(torch.nn.Module): - def __init__(self): - super(Net, self).__init__() - neurons = layers - self.depth = len(neurons) - 1 - self.actfun = MyGELU() - self.layers = [] - for i in range(self.depth - 1): - self.layers.append(torch.nn.Linear(neurons[i], neurons[i + 1])) - self.layers.append(self.actfun) - self.layers.append(torch.nn.Linear(neurons[-2], neurons[-1])) # last layer - self.fc = torch.nn.Sequential(*self.layers) - - def forward(self, x): - x = self.fc(x) - return x -try: - #load variables from constant/CanteraTorchProperties - path_r = r"./constant/CanteraTorchProperties" - with open(path_r, "r") as f: - data = f.read() - i = data.index('torchModel') - a = data.index('"',i) - b = data.index('sub',a) - c = data.index('"',b+1) - modelName_split1 = data[a+1:b+3] - modelName_split2 = data[b+3:c] - - modelPath = str(modelName_split1+modelName_split2) - model1Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"1"+modelName_split2+"/checkpoint/") - model2Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"2"+modelName_split2+"/checkpoint/") - model3Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"3"+modelName_split2+"/checkpoint/") - - i = data.index('GPU') - a = data.index(';', i) - b = data.rfind(' ',i+1,a) - switch_GPU = data[b+1:a] - - #load OpenFOAM switch - switch_on = ["true", "True", "on", "yes", "y", "t", "any"] - switch_off = ["false", "False", "off", "no", "n", "f", "none"] - if switch_GPU in switch_on: - device = torch.device("cuda") - device_ids = range(torch.cuda.device_count()) - elif switch_GPU in switch_off: - device = torch.device("cpu") - device_ids = [0] - else: - print("invalid setting!") - os._exit(0) - - - - #glbal variable will only init once when called interperter - #load parameters from json - - norm0 = json2Parser(str(model1Path+"norm.json")) - norm1 = json2Parser(str(model2Path+"norm.json")) - norm2 = json2Parser(str(model3Path+"norm.json")) - setting0 = json2Parser(str(model1Path+"settings.json")) - lamda = setting0.power_transform - delta_t = setting0.delta_t - dim = setting0.dim - layers = setting0.layers - - - Xmu0 = torch.tensor(norm0.input_mean).unsqueeze(0).to(device=device) - Xstd0 = torch.tensor(norm0.input_std).unsqueeze(0).to(device=device) - Ymu0 = torch.tensor(norm0.label_mean).unsqueeze(0).to(device=device) - Ystd0 = torch.tensor(norm0.label_std).unsqueeze(0).to(device=device) - - Xmu1 = torch.tensor(norm1.input_mean).unsqueeze(0).to(device=device) - Xstd1 = torch.tensor(norm1.input_std).unsqueeze(0).to(device=device) - Ymu1 = torch.tensor(norm1.label_mean).unsqueeze(0).to(device=device) - Ystd1 = torch.tensor(norm1.label_std).unsqueeze(0).to(device=device) - - Xmu2 = torch.tensor(norm2.input_mean).unsqueeze(0).to(device=device) - Xstd2 = torch.tensor(norm2.input_std).unsqueeze(0).to(device=device) - Ymu2 = torch.tensor(norm2.label_mean).unsqueeze(0).to(device=device) - Ystd2 = torch.tensor(norm2.label_std).unsqueeze(0).to(device=device) - - #load model - model0 = Net() - model1 = Net() - model2 = Net() - - path_list=os.listdir(model1Path) - for filename in path_list: - if os.path.splitext(filename)[1] == '.pt': - modelname = filename - - - if torch.cuda.is_available()==False: - check_point0 = torch.load(str(model1Path+modelname), map_location='cpu') - check_point1 = torch.load(str(model2Path+modelname), map_location='cpu') - check_point2 = torch.load(str(model3Path+modelname), map_location='cpu') - else: - check_point0 = torch.load(str(model1Path+modelname)) - check_point1 = torch.load(str(model2Path+modelname)) - check_point2 = torch.load(str(model3Path+modelname)) - - model0.load_state_dict(check_point0) - model1.load_state_dict(check_point1) - model2.load_state_dict(check_point2) - model0.to(device=device) - model1.to(device=device) - model2.to(device=device) - - if len(device_ids) > 1: - model0 = torch.nn.DataParallel(model0, device_ids=device_ids) - model1 = torch.nn.DataParallel(model1, device_ids=device_ids) - model2 = torch.nn.DataParallel(model2, device_ids=device_ids) -except Exception as e: - print(e.args) - - -def inference(vec0, vec1, vec2): - ''' - use model to inference - ''' - #args = np.reshape(args, (-1, 9)) #reshape to formed size - #vec0 = np.reshape(vec0, (-1, 24)) - #vec1 = np.reshape(vec1, (-1, 24)) - #vec2 = np.reshape(vec2, (-1, 24)) - vec0 = np.reshape(vec0, (-1, 10)) - vec1 = np.reshape(vec1, (-1, 10)) - vec2 = np.reshape(vec2, (-1, 10)) - - try: - with torch.no_grad(): - input0_ = torch.from_numpy(vec0).double().to(device=device) #cast ndarray to torch tensor - input1_ = torch.from_numpy(vec1).double().to(device=device) #cast ndarray to torch tensor - input2_ = torch.from_numpy(vec2).double().to(device=device) #cast ndarray to torch tensor - - # pre_processing - rho0 = input0_[:, -1].unsqueeze(1) - input0_Y = input0_[:, 2:-1].clone() - input0_bct = input0_[:, 0:-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_[:, -1].unsqueeze(1) - input1_Y = input1_[:, 2:-1].clone() - input1_bct = input1_[:, 0:-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_[:, -1].unsqueeze(1) - input2_Y = input2_[:, 2:-1].clone() - input2_bct = input2_[:, 0:-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/twoD_HIT_flame/H2/pytorchIntegrator/0/H.gz b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/H.gz new file mode 100755 index 000000000..614f4078e Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/H.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/H2.gz b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/H2.gz new file mode 100755 index 000000000..3c82d951d Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/H2.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/H2O.gz b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/H2O.gz new file mode 100755 index 000000000..1be7d2a8f Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/H2O.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/H2O2.gz b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/H2O2.gz new file mode 100755 index 000000000..ddf0a6f1f Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/H2O2.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/HO2.gz b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/HO2.gz new file mode 100755 index 000000000..47767375d Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/HO2.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/N2.gz b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/N2.gz new file mode 100755 index 000000000..22b050aeb Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/N2.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/O.gz b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/O.gz new file mode 100755 index 000000000..fb8f8868d Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/O.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/O2.gz b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/O2.gz new file mode 100755 index 000000000..b2369e2af Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/O2.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/OH.gz b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/OH.gz new file mode 100755 index 000000000..49d4c454d Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/OH.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/T.gz b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/T.gz new file mode 100755 index 000000000..5b3313649 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/T.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/U.gz b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/U.gz new file mode 100755 index 000000000..d8a982d10 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/U.gz differ diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/p.gz b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/p.gz new file mode 100755 index 000000000..c13481107 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/0/p.gz differ diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/Allclean b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/Allclean similarity index 100% rename from examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/Allclean rename to examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/Allclean diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/Allrun b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/Allrun new file mode 100755 index 000000000..de7c5c422 --- /dev/null +++ b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/Allrun @@ -0,0 +1,22 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +if [ -e DNN_model.pt ] +then + echo "DNN_model.pt exists. Make sure correct DNN model has been used!" +else + echo "DNN_model.pt not exist. Downloading ..." + wget https://store.aissquare.com/models/5e1232cd-c23f-489f-9db4-ee09592beeb1/DNN_model.zip + unzip DNN_model.zip + cp ./DNN_model/H2/DNN_model.pt . + cp ./DNN_model/H2/Burke2012_s9r23.yaml . +fi + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +application=dfLowMachFoam + +runApplication blockMesh +runApplication decomposePar +runApplication mpirun -np 8 --allow-run-as-root $application -parallel diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/Burke2012_s9r23.yaml b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/Burke2012_s9r23.yaml new file mode 100755 index 000000000..d77a77bbf --- /dev/null +++ b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/Burke2012_s9r23.yaml @@ -0,0 +1,242 @@ +generator: cti2yaml +cantera-version: 2.5.1 +date: Tue, 24 Oct 2023 17:09:01 +0800 +input-files: [Burke2012_s9s.cti] + +units: {length: cm, quantity: mol, activation-energy: cal/mol} + +phases: +- name: gas + thermo: ideal-gas + elements: [H, O, N] + species: [H, H2, O, OH, H2O, O2, HO2, H2O2, N2] + kinetics: gas + reactions: all + transport: mixture-averaged + state: + T: 300.0 + P: 1.01325e+05 + +species: +- name: H + composition: {H: 1} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 5000.0] + data: + - [2.5, 0.0, 0.0, 0.0, 0.0, 2.547163e+04, -0.4601176] + - [2.5, 0.0, 0.0, 0.0, 0.0, 2.547163e+04, -0.4601176] + transport: + model: gas + geometry: atom + diameter: 2.05 + well-depth: 145.0 + note: '120186' +- name: H2 + composition: {H: 2} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 5000.0] + data: + - [3.298124, 8.249442e-04, -8.143015e-07, -9.475434e-11, 4.134872e-13, + -1012.521, -3.294094] + - [2.991423, 7.000644e-04, -5.633829e-08, -9.231578e-12, 1.582752e-15, + -835.034, -1.35511] + transport: + model: gas + geometry: linear + diameter: 2.92 + well-depth: 38.0 + polarizability: 0.79 + rotational-relaxation: 280.0 + note: '121286' +- name: O + composition: {O: 1} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 5000.0] + data: + - [2.946429, -1.638166e-03, 2.421032e-06, -1.602843e-09, 3.890696e-13, + 2.914764e+04, 2.963995] + - [2.54206, -2.755062e-05, -3.102803e-09, 4.551067e-12, -4.368052e-16, + 2.92308e+04, 4.920308] + transport: + model: gas + geometry: atom + diameter: 2.75 + well-depth: 80.0 + note: '120186' +- name: OH + composition: {H: 1, O: 1} + thermo: + model: NASA7 + temperature-ranges: [200.0, 1000.0, 6000.0] + data: + - [4.12530561, -3.22544939e-03, 6.52764691e-06, -5.79853643e-09, 2.06237379e-12, + 3346.30913, -0.69043296] + - [2.86472886, 1.05650448e-03, -2.59082758e-07, 3.05218674e-11, -1.33195876e-15, + 3683.62875, 5.70164073] + transport: + model: gas + geometry: linear + diameter: 2.75 + well-depth: 80.0 + note: S9/01 +- name: H2O + composition: {H: 2, O: 1} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 5000.0] + data: + - [3.386842, 3.474982e-03, -6.354696e-06, 6.968581e-09, -2.506588e-12, + -3.020811e+04, 2.590233] + - [2.672146, 3.056293e-03, -8.73026e-07, 1.200996e-10, -6.391618e-15, + -2.989921e+04, 6.862817] + transport: + model: gas + geometry: nonlinear + diameter: 2.605 + well-depth: 572.4 + dipole: 1.844 + rotational-relaxation: 4.0 + note: '20387' +- name: O2 + composition: {O: 2} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 5000.0] + data: + - [3.212936, 1.127486e-03, -5.75615e-07, 1.313877e-09, -8.768554e-13, + -1005.249, 6.034738] + - [3.697578, 6.135197e-04, -1.258842e-07, 1.775281e-11, -1.136435e-15, + -1233.93, 3.189166] + transport: + model: gas + geometry: linear + diameter: 3.458 + well-depth: 107.4 + polarizability: 1.6 + rotational-relaxation: 3.8 + note: '121386' +- 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: H2O2 + composition: {H: 2, O: 2} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 5000.0] + data: + - [3.388754, 6.569226e-03, -1.485013e-07, -4.625806e-09, 2.471515e-12, + -1.766315e+04, 6.785363] + - [4.573167, 4.336136e-03, -1.474689e-06, 2.348904e-10, -1.431654e-14, + -1.800696e+04, 0.501137] + transport: + model: gas + geometry: nonlinear + diameter: 3.458 + well-depth: 107.4 + rotational-relaxation: 3.8 + note: '120186' +- name: N2 + composition: {N: 2} + thermo: + model: NASA7 + temperature-ranges: [300.0, 1000.0, 5000.0] + data: + - [3.298677, 1.40824e-03, -3.963222e-06, 5.641515e-09, -2.444855e-12, + -1020.9, 3.950372] + - [2.92664, 1.487977e-03, -5.684761e-07, 1.009704e-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' + +reactions: +- equation: H + O2 <=> O + OH # Reaction 1 + rate-constant: {A: 1.04e+14, b: 0.0, Ea: 1.5286e+04} +- equation: O + H2 <=> H + OH # Reaction 2 + rate-constant: {A: 3.818e+12, b: 0.0, Ea: 7948.0} + duplicate: true +- equation: O + H2 <=> H + OH # Reaction 3 + rate-constant: {A: 8.792e+14, b: 0.0, Ea: 1.917e+04} + duplicate: true +- equation: H2 + OH <=> H2O + H # Reaction 4 + rate-constant: {A: 2.16e+08, b: 1.51, Ea: 3430.0} +- equation: OH + OH <=> O + H2O # Reaction 5 + rate-constant: {A: 3.34e+04, b: 2.42, Ea: -1930.0} +- equation: H2 + M <=> H + H + M # Reaction 6 + type: three-body + rate-constant: {A: 4.577e+19, b: -1.4, Ea: 1.0438e+05} + efficiencies: {H2: 2.5, H2O: 12.0} +- equation: O + O + M <=> O2 + M # Reaction 7 + type: three-body + rate-constant: {A: 6.165e+15, b: -0.5, Ea: 0.0} + efficiencies: {H2: 2.5, H2O: 12.0} +- equation: O + H + M <=> OH + M # Reaction 8 + type: three-body + rate-constant: {A: 4.714e+18, b: -1.0, Ea: 0.0} + efficiencies: {H2: 2.5, H2O: 12.0} +- equation: H2O + M <=> H + OH + M # Reaction 9 + type: three-body + rate-constant: {A: 6.064e+27, b: -3.322, Ea: 1.2079e+05} + efficiencies: {H2: 3.0, H2O: 0.0, N2: 2.0, O2: 1.5} +- equation: H2O + H2O <=> H + OH + H2O # Reaction 10 + rate-constant: {A: 1.006e+26, b: -2.44, Ea: 1.2018e+05} +- equation: H + O2 (+ M) <=> HO2 (+ M) # Reaction 11 + type: falloff + low-P-rate-constant: {A: 6.366e+20, b: -1.72, Ea: 524.8} + high-P-rate-constant: {A: 4.65084e+12, b: 0.44, Ea: 0.0} + Troe: {A: 0.5, T3: 1.0e-30, T1: 1.0e+30} + efficiencies: {H2: 2.0, H2O: 14.0, O2: 0.78} +- equation: HO2 + H <=> H2 + O2 # Reaction 12 + rate-constant: {A: 2.75e+06, b: 2.09, Ea: -1451.0} +- equation: HO2 + H <=> OH + OH # Reaction 13 + rate-constant: {A: 7.079e+13, b: 0.0, Ea: 295.0} +- equation: HO2 + O <=> O2 + OH # Reaction 14 + rate-constant: {A: 2.85e+10, b: 1.0, Ea: -723.93} +- equation: HO2 + OH <=> H2O + O2 # Reaction 15 + rate-constant: {A: 2.89e+13, b: 0.0, Ea: -497.0} +- equation: HO2 + HO2 <=> H2O2 + O2 # Reaction 16 + rate-constant: {A: 4.2e+14, b: 0.0, Ea: 1.1982e+04} + duplicate: true +- equation: HO2 + HO2 <=> H2O2 + O2 # Reaction 17 + rate-constant: {A: 1.3e+11, b: 0.0, Ea: -1629.3} + duplicate: true +- equation: H2O2 (+ M) <=> OH + OH (+ M) # Reaction 18 + type: falloff + low-P-rate-constant: {A: 2.49e+24, b: -2.3, Ea: 4.8749e+04} + high-P-rate-constant: {A: 2.0e+12, b: 0.9, Ea: 4.8749e+04} + Troe: {A: 0.43, T3: 1.0e-30, T1: 1.0e+30} + efficiencies: {H2: 3.7, H2O: 7.5, H2O2: 7.7, N2: 1.5, O2: 1.2} +- equation: H2O2 + H <=> H2O + OH # Reaction 19 + rate-constant: {A: 2.41e+13, b: 0.0, Ea: 3970.0} +- equation: H2O2 + H <=> HO2 + H2 # Reaction 20 + rate-constant: {A: 4.82e+13, b: 0.0, Ea: 7950.0} +- equation: H2O2 + O <=> OH + HO2 # Reaction 21 + rate-constant: {A: 9.55e+06, b: 2.0, Ea: 3970.0} +- equation: H2O2 + OH <=> HO2 + H2O # Reaction 22 + rate-constant: {A: 1.74e+12, b: 0.0, Ea: 318.0} + duplicate: true +- equation: H2O2 + OH <=> HO2 + H2O # Reaction 23 + rate-constant: {A: 7.59e+13, b: 0.0, Ea: 7270.0} + duplicate: true diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/constant/CanteraTorchProperties b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/constant/CanteraTorchProperties new file mode 100755 index 000000000..d0ab70b27 --- /dev/null +++ b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/constant/CanteraTorchProperties @@ -0,0 +1,53 @@ +/*--------------------------------*- 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 CanteraTorchProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +chemistry on; + +CanteraMechanismFile "Burke2012_s9r23.yaml"; + +transportModel "Mix"; + +odeCoeffs +{ + "relTol" 1e-6; + "absTol" 1e-10; +} + +inertSpecie "N2"; + +splittingStrategy off; + +TorchSettings +{ + torch on; + GPU on; + log on; + torchModel "DNN_model.pt"; + frozenTemperature 510; + inferenceDeltaTime 1e-6; + coresPerNode 8; +} + +loadbalancing +{ + active true; + log false; + algorithm allAverage;//headTail; +} + + +// ************************************************************************* // diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/constant/combustionProperties b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/constant/combustionProperties old mode 100644 new mode 100755 similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/constant/combustionProperties rename to examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/constant/combustionProperties diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/constant/thermophysicalProperties b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/constant/thermophysicalProperties old mode 100644 new mode 100755 similarity index 100% rename from examples/df0DFoam/zeroD_cubicReactor/H2/pytorchIntegrator/constant/thermophysicalProperties rename to examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/constant/thermophysicalProperties diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/constant/turbulenceProperties b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/constant/turbulenceProperties old mode 100644 new mode 100755 similarity index 100% rename from examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/constant/turbulenceProperties rename to examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/constant/turbulenceProperties diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/inference.py b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/inference.py new file mode 100755 index 000000000..5034809cd --- /dev/null +++ b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/inference.py @@ -0,0 +1,169 @@ +import torch +import numpy as np +import time +import os +import cantera as ct + +device_main = "cuda:0" +device_list = range(torch.cuda.device_count()) + +torch.set_printoptions(precision=10) + +class NN_MLP(torch.nn.Module): + def __init__(self, layer_info): + super(NN_MLP, self).__init__() + self.net = torch.nn.Sequential() + n = len(layer_info) - 1 + for i in range(n - 1): + self.net.add_module('linear_layer_%d' %(i), torch.nn.Linear(layer_info[i], layer_info[i + 1])) + self.net.add_module('gelu_layer_%d' %(i), torch.nn.GELU()) + #if i <= 2: + # self.net.add_module('batch_norm_%d' %(i), torch.nn.BatchNorm1d(layer_info[i + 1])) + self.net.add_module('linear_layer_%d' %(n - 1), torch.nn.Linear(layer_info[n - 1], layer_info[n])) + + def forward(self, x): + return self.net(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('torchModel') + a = data.index('"',i) + b = data.index('"',a+1) + modelName = data[a+1:b] + + i = data.index('frozenTemperature') + a = data.index(';', i) + b = data.rfind(' ',i+1,a) + frozenTemperature = float(data[b+1:a]) + + i = data.index('inferenceDeltaTime') + a = data.index(';', i) + b = data.rfind(' ',i+1,a) + delta_t = float(data[b+1:a]) + + i = data.index('CanteraMechanismFile') + a = data.index('"',i) + b = data.index('"',a+1) + mechanismName = data[a+1:b] + + i = data.index('GPU') + a = data.index(';', i) + b = data.rfind(' ',i+1,a) + switch_GPU = data[b+1:a] + + #read mechanism species number + gas = ct.Solution(mechanismName) + n_species = gas.n_species + #load OpenFOAM switch + switch_on = ["true", "True", "on", "yes", "y", "t", "any"] + switch_off = ["false", "False", "off", "no", "n", "f", "none"] + if switch_GPU in switch_on: + device = torch.device(device_main) + device_ids = device_list + elif switch_GPU in switch_off: + device = torch.device("cpu") + device_ids = [0] + else: + print("invalid setting!") + os._exit(0) + + lamda = 0.1 + dim = 9 + + state_dict = torch.load(modelName,map_location='cpu') + Xmu0 = state_dict['data_in_mean'] + Xstd0 = state_dict['data_in_std'] + Ymu0 = state_dict['data_target_mean'] + Ystd0 = state_dict['data_target_std'] + + + Xmu0 = torch.tensor(Xmu0).unsqueeze(0).to(device=device) + Xstd0 = torch.tensor(Xstd0).unsqueeze(0).to(device=device) + Ymu0 = torch.tensor(Ymu0).unsqueeze(0).to(device=device) + Ystd0 = torch.tensor(Ystd0).unsqueeze(0).to(device=device) + + Xmu1 = Xmu0 + Xstd1 = Xstd0 + Ymu1 = Ymu0 + Ystd1 = Ystd0 + + Xmu2 = Xmu0 + Xstd2 = Xstd0 + Ymu2 = Ymu0 + Ystd2 = Ystd0 + + #load model + layers = [n_species +2, 1600, 800, 400, 1] + + model0list = [] + for i in range(n_species-1): + model0list.append(NN_MLP(layers)) + + for i in range(n_species-1): + model0list[i].load_state_dict(state_dict[f'net{i}']) + + + for i in range(n_species-1): + model0list[i].eval() + model0list[i].to(device=device) + + if len(device_ids) > 1: + for i in range(n_species-1): + model0list[i] = torch.nn.DataParallel(model0list[i], device_ids=device_ids) + +except Exception as e: + print(e.args) + + + + +def inference(vec0): + ''' + use model to inference + ''' + vec0 = np.abs(np.reshape(vec0, (-1, 3+n_species))) # T, P, Yi(7), Rho + vec0[:,1] *= 101325 + mask = vec0[:,0] > frozenTemperature + vec0_input = vec0[mask, :] + print(f'real inference points number: {vec0_input.shape[0]}') + + try: + with torch.no_grad(): + input0_ = torch.from_numpy(vec0_input).double().to(device=device) #cast ndarray to torch tensor + + + # pre_processing + rho0 = input0_[:, -1].unsqueeze(1) + input0_Y = input0_[:, 2:-1].clone() + input0_bct = input0_[:, 0:-1] + input0_bct[:, 2:] = (input0_bct[:, 2:]**(lamda) - 1) / lamda #BCT + input0_normalized = (input0_bct - Xmu0) / Xstd0 #DimXmu0 = 9, DimXstd0 = 9, input0_bct = + # input0_normalized[:, -1] = 0 #set Y_AR to 0 + input0_normalized = input0_normalized.float() + input0_normalized = input0_normalized.to(device=device) + + #inference + + output0_normalized = [] + for i in range(n_species-1): + output0_normalized.append(model0list[i](input0_normalized)) + output0_normalized = torch.cat(output0_normalized, dim=1) + + # post_processing + output0_bct = output0_normalized * Ystd0 + Ymu0 + input0_bct[:, 2:-1] + output0_Y = input0_Y.clone() + output0_Y[:, :-1] = (lamda * output0_bct + 1)**(1 / lamda) + output0_Y[:, :-1] = output0_Y[:, :-1] / torch.sum(input=output0_Y[:, :-1], dim=1, keepdim=True) * (1 - output0_Y[:, -1:]) + output0 = (output0_Y - input0_Y) * rho0 / delta_t + output0 = output0.cpu().numpy() + + + result = np.zeros((vec0.shape[0], n_species)) + result[mask, :] = output0 + return result + except Exception as e: + print(e.args) + diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/system/blockMeshDict b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/system/blockMeshDict old mode 100644 new mode 100755 similarity index 71% rename from examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/system/blockMeshDict rename to examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/system/blockMeshDict index e8e079bc5..c9bc57caa --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/system/blockMeshDict +++ b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/system/blockMeshDict @@ -14,24 +14,24 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -convertToMeters 0.001; +convertToMeters 0.01; vertices ( (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) + (5.026548245743669 0 0) + (5.026548245743669 5.026548245743669 0) + (0 5.026548245743669 0) + (0 0 5.026548245743669) + (5.026548245743669 0 5.026548245743669) + (5.026548245743669 5.026548245743669 5.026548245743669) + (0 5.026548245743669 5.026548245743669) ); blocks ( - hex (0 1 2 3 4 5 6 7) (64 64 64) simpleGrading (1 1 1) + hex (0 1 2 3 4 5 6 7) (1024 1024 1) simpleGrading (1 1 1) ); edges @@ -42,8 +42,7 @@ boundary ( front { - type cyclic; - neighbourPatch back; + type empty; faces ( (4 5 6 7) @@ -51,8 +50,7 @@ boundary } back { - type cyclic; - neighbourPatch front; + type empty; faces ( (0 3 2 1) @@ -60,7 +58,7 @@ boundary } left { - type cyclic; + type patch; neighbourPatch right; faces ( @@ -69,7 +67,7 @@ boundary } right { - type cyclic; + type patch; neighbourPatch left; faces ( @@ -78,7 +76,7 @@ boundary } top { - type cyclic; + type patch; neighbourPatch down; faces ( @@ -87,7 +85,7 @@ boundary } down { - type cyclic; + type patch; neighbourPatch top; faces ( diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/controlDict b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/system/controlDict old mode 100644 new mode 100755 similarity index 97% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/controlDict rename to examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/system/controlDict index 487a2dfce..6f5f8a7b0 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/controlDict +++ b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/system/controlDict @@ -17,7 +17,7 @@ FoamFile application dfLowMachFoam; -startFrom startTime; +startFrom latestTime; startTime 0; diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/decomposeParDict b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/system/decomposeParDict old mode 100644 new mode 100755 similarity index 92% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/decomposeParDict rename to examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/system/decomposeParDict index 45c7f859f..66e942761 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/system/decomposeParDict +++ b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/system/decomposeParDict @@ -15,13 +15,13 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -numberOfSubdomains 4; +numberOfSubdomains 8; -method scotch; +method simple; simpleCoeffs { - n (4 1 1); + n (4 2 1); delta 0.001; } diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/system/fvSchemes b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/system/fvSchemes old mode 100644 new mode 100755 similarity index 100% rename from examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/system/fvSchemes rename to examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/system/fvSchemes diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/system/fvSolution b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/system/fvSolution old mode 100644 new mode 100755 similarity index 94% rename from examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/system/fvSolution rename to examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/system/fvSolution index 73baadbf7..7ca84e9bd --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/system/fvSolution +++ b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/system/fvSolution @@ -37,8 +37,8 @@ solvers pFinal { solver GAMG; - tolerance 1e-9; - relTol 0; + tolerance 1e-7; + relTol 0.01; smoother GaussSeidel; cacheAgglomeration true; nCellsInCoarsestLevel 20; @@ -57,7 +57,7 @@ solvers "(U|ha|k|epsilon)Final" { $U; - tolerance 1e-9; + tolerance 1e-5; relTol 0; } @@ -72,7 +72,7 @@ solvers { solver PBiCGStab; preconditioner DILU; - tolerance 1e-9; + tolerance 1e-5; relTol 0; } } diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/system/setFieldsDict b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/system/setFieldsDict new file mode 100755 index 000000000..38d0ac653 --- /dev/null +++ b/examples/dfLowMachFoam/twoD_HIT_flame/H2/pytorchIntegrator/system/setFieldsDict @@ -0,0 +1,55 @@ +/*--------------------------------*- 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 setFieldsDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +defaultFieldValues +( + volScalarFieldValue T 500 + volScalarFieldValue H 0.0 + volScalarFieldValue H2 0.028522 + volScalarFieldValue O 0.0 + volScalarFieldValue OH 0.0 + volScalarFieldValue H2O 0.0 + volScalarFieldValue O2 0.226354 + volScalarFieldValue HO2 0.0 + volScalarFieldValue H2O2 0.0 + volScalarFieldValue N2 0.745124 +); + +regions +( + cylinderToCell + { + p1 (0.025132741 0.025132741 0); + p2 (0.025132741 0.025132741 0.050265482); + radius 0.0025132741; + fieldValues + ( + volScalarFieldValue T 2485.8 + volScalarFieldValue H 0.000139 + volScalarFieldValue H2 0.001688 + volScalarFieldValue O 0.000763 + volScalarFieldValue OH 0.008357 + volScalarFieldValue H2O 0.234122 + volScalarFieldValue O2 0.009804 + volScalarFieldValue HO2 0.000003 + volScalarFieldValue H2O2 0 + volScalarFieldValue N2 0.745124 + ); + } +); + +// ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/AR.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/AR.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/AR.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/AR.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/C2H4.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/C2H4.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/C2H4.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/C2H4.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/C2H5.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/C2H5.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/C2H5.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/C2H5.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/C2H6.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/C2H6.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/C2H6.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/C2H6.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/CH2(S).gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/CH2(S).gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/CH2(S).gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/CH2(S).gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/CH2.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/CH2.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/CH2.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/CH2.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/CH2O.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/CH2O.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/CH2O.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/CH2O.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/CH3.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/CH3.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/CH3.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/CH3.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/CH3O.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/CH3O.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/CH3O.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/CH3O.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/CH4.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/CH4.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/CH4.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/CH4.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/CO.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/CO.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/CO.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/CO.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/CO2.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/CO2.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/CO2.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/CO2.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/H.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/H.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/H.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/H.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/H2.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/H2.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/H2.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/H2.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/H2O.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/H2O.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/H2O.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/H2O.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/HCO.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/HCO.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/HCO.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/HCO.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/HO2.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/HO2.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/HO2.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/HO2.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/N2.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/N2.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/N2.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/N2.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/O.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/O.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/O.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/O.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/O2.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/O2.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/O2.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/O2.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/OH.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/OH.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/OH.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/OH.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/T.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/T.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/T.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/T.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/U.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/U.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/U.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/U.gz diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/p.gz b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/p.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/0/p.gz rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/0/p.gz diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/Allclean b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/Allclean similarity index 100% rename from examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/Allclean rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/Allclean diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/Allrun b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/Allrun similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/Allrun rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/Allrun diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/constant/CanteraTorchProperties b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/constant/CanteraTorchProperties similarity index 97% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/constant/CanteraTorchProperties rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/constant/CanteraTorchProperties index 8873b201d..f7e4b92ef 100644 --- a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/constant/CanteraTorchProperties +++ b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/constant/CanteraTorchProperties @@ -33,7 +33,7 @@ splittingStrategy off; TorchSettings { - torch on; + torch off; GPU on; log on; torchModel ""; diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/constant/combustionProperties b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/constant/combustionProperties similarity index 100% rename from examples/dfLowMachFoam/threeD_reactingTGV/H2/libtorchIntegrator/constant/combustionProperties rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/constant/combustionProperties diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/constant/thermophysicalProperties b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/constant/thermophysicalProperties similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/constant/thermophysicalProperties rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/constant/thermophysicalProperties diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/constant/turbulenceProperties b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/constant/turbulenceProperties similarity index 100% rename from examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/constant/turbulenceProperties rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/constant/turbulenceProperties diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/drm19.yaml b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/drm19.yaml similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/CH4/pytorchIntegrator/drm19.yaml rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/drm19.yaml diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/system/blockMeshDict b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/system/blockMeshDict similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/system/blockMeshDict rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/system/blockMeshDict diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/system/controlDict b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/system/controlDict similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/system/controlDict rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/system/controlDict diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/system/decomposeParDict b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/system/decomposeParDict similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/system/decomposeParDict rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/system/decomposeParDict diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/system/funkySetFieldsDict b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/system/funkySetFieldsDict similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/system/funkySetFieldsDict rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/system/funkySetFieldsDict diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/system/fvSchemes b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/system/fvSchemes similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/system/fvSchemes rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/system/fvSchemes diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/system/fvSolution b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/system/fvSolution similarity index 94% rename from examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/system/fvSolution rename to examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/system/fvSolution index 73baadbf7..7ca84e9bd 100644 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/system/fvSolution +++ b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/cvodeIntegrator/system/fvSolution @@ -37,8 +37,8 @@ solvers pFinal { solver GAMG; - tolerance 1e-9; - relTol 0; + tolerance 1e-7; + relTol 0.01; smoother GaussSeidel; cacheAgglomeration true; nCellsInCoarsestLevel 20; @@ -57,7 +57,7 @@ solvers "(U|ha|k|epsilon)Final" { $U; - tolerance 1e-9; + tolerance 1e-5; relTol 0; } @@ -72,7 +72,7 @@ solvers { solver PBiCGStab; preconditioner DILU; - tolerance 1e-9; + tolerance 1e-5; relTol 0; } } diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/Allrun b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/Allrun deleted file mode 100755 index 8cd1cbdd5..000000000 --- a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/Allrun +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions - -application=dfLowMachFoam - -runApplication blockMesh -runApplication decomposePar -runApplication mpirun -np 4 --allow-run-as-root $application -parallel diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/constant/combustionProperties b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/constant/combustionProperties deleted file mode 100644 index 7418500d0..000000000 --- a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/constant/combustionProperties +++ /dev/null @@ -1,20 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Version: 7 - \\/ M anipulation | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - location "constant"; - object combustionProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -combustionModel laminar; - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/drm19.yaml b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/drm19.yaml deleted file mode 120000 index 6aed11e7f..000000000 --- a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/drm19.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/CH4/drm19.yaml \ No newline at end of file diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/inference.py b/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/inference.py deleted file mode 100644 index a4181c1f6..000000000 --- a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/inference.py +++ /dev/null @@ -1,221 +0,0 @@ -from builtins import Exception, print -from calendar import prcal -import torch -import numpy as np -import math -import time -import json -import os -from easydict import EasyDict as edict -import torch.profiler -import os - - -torch.set_printoptions(precision=10) - - -class MyGELU(torch.nn.Module): - def __init__(self): - super(MyGELU, self).__init__() - self.torch_PI = 3.1415926536 - - def forward(self, x): - return 0.5 * x * (1 + torch.tanh( - math.sqrt(2 / self.torch_PI) * (x + 0.044715 * torch.pow(x, 3)))) - - -def json2Parser(json_path): - """load json and return parser-like object""" - with open(json_path, 'r') as f: - args = json.load(f) - return edict(args) - - -class Net(torch.nn.Module): - def __init__(self): - super(Net, self).__init__() - neurons = layers - self.depth = len(neurons) - 1 - self.actfun = MyGELU() - self.layers = [] - for i in range(self.depth - 1): - self.layers.append(torch.nn.Linear(neurons[i], neurons[i + 1])) - self.layers.append(self.actfun) - self.layers.append(torch.nn.Linear(neurons[-2], neurons[-1])) # last layer - self.fc = torch.nn.Sequential(*self.layers) - - def forward(self, x): - x = self.fc(x) - return x -try: - #load variables from constant/CanteraTorchProperties - path_r = r"./constant/CanteraTorchProperties" - with open(path_r, "r") as f: - data = f.read() - i = data.index('torchModel') - a = data.index('"',i) - b = data.index('sub',a) - c = data.index('"',b+1) - modelName_split1 = data[a+1:b+3] - modelName_split2 = data[b+3:c] - - modelPath = str(modelName_split1+modelName_split2) - model1Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"1"+modelName_split2+"/checkpoint/") - model2Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"2"+modelName_split2+"/checkpoint/") - model3Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"3"+modelName_split2+"/checkpoint/") - - i = data.index('GPU') - a = data.index(';', i) - b = data.rfind(' ',i+1,a) - switch_GPU = data[b+1:a] - - #load OpenFOAM switch - switch_on = ["true", "True", "on", "yes", "y", "t", "any"] - switch_off = ["false", "False", "off", "no", "n", "f", "none"] - if switch_GPU in switch_on: - device = torch.device("cuda") - device_ids = range(torch.cuda.device_count()) - elif switch_GPU in switch_off: - device = torch.device("cpu") - device_ids = [0] - else: - print("invalid setting!") - os._exit(0) - - - - #glbal variable will only init once when called interperter - #load parameters from json - - norm0 = json2Parser(str(model1Path+"norm.json")) - norm1 = json2Parser(str(model2Path+"norm.json")) - norm2 = json2Parser(str(model3Path+"norm.json")) - setting0 = json2Parser(str(model1Path+"settings.json")) - lamda = setting0.power_transform - delta_t = setting0.delta_t - dim = setting0.dim - layers = setting0.layers - - - Xmu0 = torch.tensor(norm0.input_mean).unsqueeze(0).to(device=device) - Xstd0 = torch.tensor(norm0.input_std).unsqueeze(0).to(device=device) - Ymu0 = torch.tensor(norm0.label_mean).unsqueeze(0).to(device=device) - Ystd0 = torch.tensor(norm0.label_std).unsqueeze(0).to(device=device) - - Xmu1 = torch.tensor(norm1.input_mean).unsqueeze(0).to(device=device) - Xstd1 = torch.tensor(norm1.input_std).unsqueeze(0).to(device=device) - Ymu1 = torch.tensor(norm1.label_mean).unsqueeze(0).to(device=device) - Ystd1 = torch.tensor(norm1.label_std).unsqueeze(0).to(device=device) - - Xmu2 = torch.tensor(norm2.input_mean).unsqueeze(0).to(device=device) - Xstd2 = torch.tensor(norm2.input_std).unsqueeze(0).to(device=device) - Ymu2 = torch.tensor(norm2.label_mean).unsqueeze(0).to(device=device) - Ystd2 = torch.tensor(norm2.label_std).unsqueeze(0).to(device=device) - - #load model - model0 = Net() - model1 = Net() - model2 = Net() - - path_list=os.listdir(model1Path) - for filename in path_list: - if os.path.splitext(filename)[1] == '.pt': - modelname = filename - - - if torch.cuda.is_available()==False: - check_point0 = torch.load(str(model1Path+modelname), map_location='cpu') - check_point1 = torch.load(str(model2Path+modelname), map_location='cpu') - check_point2 = torch.load(str(model3Path+modelname), map_location='cpu') - else: - check_point0 = torch.load(str(model1Path+modelname)) - check_point1 = torch.load(str(model2Path+modelname)) - check_point2 = torch.load(str(model3Path+modelname)) - - model0.load_state_dict(check_point0) - model1.load_state_dict(check_point1) - model2.load_state_dict(check_point2) - model0.to(device=device) - model1.to(device=device) - model2.to(device=device) - - if len(device_ids) > 1: - model0 = torch.nn.DataParallel(model0, device_ids=device_ids) - model1 = torch.nn.DataParallel(model1, device_ids=device_ids) - model2 = torch.nn.DataParallel(model2, device_ids=device_ids) -except Exception as e: - print(e.args) - - -def inference(vec0, vec1, vec2): - ''' - use model to inference - ''' - #args = np.reshape(args, (-1, 9)) #reshape to formed size - #vec0 = np.reshape(vec0, (-1, 24)) - #vec1 = np.reshape(vec1, (-1, 24)) - #vec2 = np.reshape(vec2, (-1, 24)) - vec0 = np.reshape(vec0, (-1, 10)) - vec1 = np.reshape(vec1, (-1, 10)) - vec2 = np.reshape(vec2, (-1, 10)) - - try: - with torch.no_grad(): - input0_ = torch.from_numpy(vec0).double().to(device=device) #cast ndarray to torch tensor - input1_ = torch.from_numpy(vec1).double().to(device=device) #cast ndarray to torch tensor - input2_ = torch.from_numpy(vec2).double().to(device=device) #cast ndarray to torch tensor - - # pre_processing - rho0 = input0_[:, -1].unsqueeze(1) - input0_Y = input0_[:, 2:-1].clone() - input0_bct = input0_[:, 0:-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_[:, -1].unsqueeze(1) - input1_Y = input1_[:, 2:-1].clone() - input1_bct = input1_[:, 0:-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_[:, -1].unsqueeze(1) - input2_Y = input2_[:, 2:-1].clone() - input2_bct = input2_[:, 0:-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/twoD_temporally_evolving_jet/Allrun b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/Allrun deleted file mode 100755 index 8cd1cbdd5..000000000 --- a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/Allrun +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions - -application=dfLowMachFoam - -runApplication blockMesh -runApplication decomposePar -runApplication mpirun -np 4 --allow-run-as-root $application -parallel diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/C2H2.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/C2H2.gz new file mode 100755 index 000000000..d706b5b72 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/C2H2.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/C2H3.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/C2H3.gz new file mode 100755 index 000000000..2f446a0ca Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/C2H3.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/C2H4.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/C2H4.gz new file mode 100755 index 000000000..fc3b06749 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/C2H4.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/C2H5.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/C2H5.gz new file mode 100755 index 000000000..bcd51c7c3 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/C2H5.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CH2CHO.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CH2CHO.gz new file mode 100755 index 000000000..0be043ec0 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CH2CHO.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CH2CO.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CH2CO.gz new file mode 100755 index 000000000..2d984ffb5 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CH2CO.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CH2O.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CH2O.gz new file mode 100755 index 000000000..a3a05ab56 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CH2O.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CH2OH.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CH2OH.gz new file mode 100755 index 000000000..461fa2233 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CH2OH.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CH3.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CH3.gz new file mode 100755 index 000000000..2284d2771 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CH3.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CH4.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CH4.gz new file mode 100755 index 000000000..85c4ffe80 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CH4.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CO.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CO.gz new file mode 100755 index 000000000..17fbdc6a0 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CO.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CO2.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CO2.gz new file mode 100755 index 000000000..293b718c6 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/CO2.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/H.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/H.gz new file mode 100755 index 000000000..99f51b266 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/H.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/H2.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/H2.gz new file mode 100755 index 000000000..497a9e6d2 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/H2.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/H2O.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/H2O.gz new file mode 100755 index 000000000..4d70b9d03 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/H2O.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/HCCO.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/HCCO.gz new file mode 100755 index 000000000..b927da73e Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/HCCO.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/HCO.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/HCO.gz new file mode 100755 index 000000000..b8c6ed1dd Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/HCO.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/HO2.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/HO2.gz new file mode 100755 index 000000000..c2c6d6216 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/HO2.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/N2.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/N2.gz new file mode 100755 index 000000000..da5a42a10 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/N2.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/O.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/O.gz new file mode 100755 index 000000000..a391115b2 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/O.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/O2.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/O2.gz new file mode 100755 index 000000000..38379dad2 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/O2.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/OH.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/OH.gz new file mode 100755 index 000000000..2dfe5ae63 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/OH.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/S-CH2.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/S-CH2.gz new file mode 100755 index 000000000..13368927d Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/S-CH2.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/T-CH2.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/T-CH2.gz new file mode 100755 index 000000000..bd0f585c9 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/T-CH2.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/T.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/T.gz new file mode 100755 index 000000000..b8a422581 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/T.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/U.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/U.gz new file mode 100755 index 000000000..2d0bb80cb Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/U.gz differ diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/p.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/p.gz new file mode 100755 index 000000000..3b942b940 Binary files /dev/null and b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/0/p.gz differ diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/Allclean b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/Allclean similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/Allclean rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/Allclean diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/Allrun b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/Allrun new file mode 100755 index 000000000..218486df6 --- /dev/null +++ b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/Allrun @@ -0,0 +1,22 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +if [ -e DNN_model.pt ] +then + echo "DNN_model.pt exists. Make sure correct DNN model has been used!" +else + echo "DNN_model.pt not exist. Downloading ..." + wget https://store.aissquare.com/models/5e1232cd-c23f-489f-9db4-ee09592beeb1/DNN_model.zip + unzip DNN_model.zip + cp ./DNN_model/C2H4/DNN_model.pt . + cp ./DNN_model/C2H4/Wu24sp.yaml . +fi + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +application=dfLowMachFoam + +runApplication blockMesh +runApplication decomposePar +runApplication mpirun -np 8 --allow-run-as-root $application -parallel diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/constant/CanteraTorchProperties b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/constant/CanteraTorchProperties old mode 100644 new mode 100755 similarity index 81% rename from examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/constant/CanteraTorchProperties rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/constant/CanteraTorchProperties index cb52df768..6bac716f7 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/constant/CanteraTorchProperties +++ b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/constant/CanteraTorchProperties @@ -17,7 +17,7 @@ FoamFile chemistry on; -CanteraMechanismFile "ES80_H2-7-16.yaml"; +CanteraMechanismFile "Wu24sp.yaml"; transportModel "Mix"; @@ -33,11 +33,13 @@ splittingStrategy off; TorchSettings { - torch on; - GPU on; - log on; - torchModel "HE04_Hydrogen_ESH2_GMS_sub_20221101"; - coresPerNode 4; + torch on; + GPU on; + log on; + torchModel "DNN_model.pt"; + frozenTemperature 510; + inferenceDeltaTime 1e-7; + coresPerNode 8; } loadbalancing diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/constant/combustionProperties b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/constant/combustionProperties old mode 100644 new mode 100755 similarity index 100% rename from examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/constant/combustionProperties rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/constant/combustionProperties diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/constant/thermophysicalProperties b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/constant/thermophysicalProperties similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/constant/thermophysicalProperties rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/constant/thermophysicalProperties diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/constant/turbulenceProperties b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/constant/turbulenceProperties old mode 100644 new mode 100755 similarity index 100% rename from examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/constant/turbulenceProperties rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/constant/turbulenceProperties diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/inference.py b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/inference.py new file mode 100755 index 000000000..5034809cd --- /dev/null +++ b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/inference.py @@ -0,0 +1,169 @@ +import torch +import numpy as np +import time +import os +import cantera as ct + +device_main = "cuda:0" +device_list = range(torch.cuda.device_count()) + +torch.set_printoptions(precision=10) + +class NN_MLP(torch.nn.Module): + def __init__(self, layer_info): + super(NN_MLP, self).__init__() + self.net = torch.nn.Sequential() + n = len(layer_info) - 1 + for i in range(n - 1): + self.net.add_module('linear_layer_%d' %(i), torch.nn.Linear(layer_info[i], layer_info[i + 1])) + self.net.add_module('gelu_layer_%d' %(i), torch.nn.GELU()) + #if i <= 2: + # self.net.add_module('batch_norm_%d' %(i), torch.nn.BatchNorm1d(layer_info[i + 1])) + self.net.add_module('linear_layer_%d' %(n - 1), torch.nn.Linear(layer_info[n - 1], layer_info[n])) + + def forward(self, x): + return self.net(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('torchModel') + a = data.index('"',i) + b = data.index('"',a+1) + modelName = data[a+1:b] + + i = data.index('frozenTemperature') + a = data.index(';', i) + b = data.rfind(' ',i+1,a) + frozenTemperature = float(data[b+1:a]) + + i = data.index('inferenceDeltaTime') + a = data.index(';', i) + b = data.rfind(' ',i+1,a) + delta_t = float(data[b+1:a]) + + i = data.index('CanteraMechanismFile') + a = data.index('"',i) + b = data.index('"',a+1) + mechanismName = data[a+1:b] + + i = data.index('GPU') + a = data.index(';', i) + b = data.rfind(' ',i+1,a) + switch_GPU = data[b+1:a] + + #read mechanism species number + gas = ct.Solution(mechanismName) + n_species = gas.n_species + #load OpenFOAM switch + switch_on = ["true", "True", "on", "yes", "y", "t", "any"] + switch_off = ["false", "False", "off", "no", "n", "f", "none"] + if switch_GPU in switch_on: + device = torch.device(device_main) + device_ids = device_list + elif switch_GPU in switch_off: + device = torch.device("cpu") + device_ids = [0] + else: + print("invalid setting!") + os._exit(0) + + lamda = 0.1 + dim = 9 + + state_dict = torch.load(modelName,map_location='cpu') + Xmu0 = state_dict['data_in_mean'] + Xstd0 = state_dict['data_in_std'] + Ymu0 = state_dict['data_target_mean'] + Ystd0 = state_dict['data_target_std'] + + + Xmu0 = torch.tensor(Xmu0).unsqueeze(0).to(device=device) + Xstd0 = torch.tensor(Xstd0).unsqueeze(0).to(device=device) + Ymu0 = torch.tensor(Ymu0).unsqueeze(0).to(device=device) + Ystd0 = torch.tensor(Ystd0).unsqueeze(0).to(device=device) + + Xmu1 = Xmu0 + Xstd1 = Xstd0 + Ymu1 = Ymu0 + Ystd1 = Ystd0 + + Xmu2 = Xmu0 + Xstd2 = Xstd0 + Ymu2 = Ymu0 + Ystd2 = Ystd0 + + #load model + layers = [n_species +2, 1600, 800, 400, 1] + + model0list = [] + for i in range(n_species-1): + model0list.append(NN_MLP(layers)) + + for i in range(n_species-1): + model0list[i].load_state_dict(state_dict[f'net{i}']) + + + for i in range(n_species-1): + model0list[i].eval() + model0list[i].to(device=device) + + if len(device_ids) > 1: + for i in range(n_species-1): + model0list[i] = torch.nn.DataParallel(model0list[i], device_ids=device_ids) + +except Exception as e: + print(e.args) + + + + +def inference(vec0): + ''' + use model to inference + ''' + vec0 = np.abs(np.reshape(vec0, (-1, 3+n_species))) # T, P, Yi(7), Rho + vec0[:,1] *= 101325 + mask = vec0[:,0] > frozenTemperature + vec0_input = vec0[mask, :] + print(f'real inference points number: {vec0_input.shape[0]}') + + try: + with torch.no_grad(): + input0_ = torch.from_numpy(vec0_input).double().to(device=device) #cast ndarray to torch tensor + + + # pre_processing + rho0 = input0_[:, -1].unsqueeze(1) + input0_Y = input0_[:, 2:-1].clone() + input0_bct = input0_[:, 0:-1] + input0_bct[:, 2:] = (input0_bct[:, 2:]**(lamda) - 1) / lamda #BCT + input0_normalized = (input0_bct - Xmu0) / Xstd0 #DimXmu0 = 9, DimXstd0 = 9, input0_bct = + # input0_normalized[:, -1] = 0 #set Y_AR to 0 + input0_normalized = input0_normalized.float() + input0_normalized = input0_normalized.to(device=device) + + #inference + + output0_normalized = [] + for i in range(n_species-1): + output0_normalized.append(model0list[i](input0_normalized)) + output0_normalized = torch.cat(output0_normalized, dim=1) + + # post_processing + output0_bct = output0_normalized * Ystd0 + Ymu0 + input0_bct[:, 2:-1] + output0_Y = input0_Y.clone() + output0_Y[:, :-1] = (lamda * output0_bct + 1)**(1 / lamda) + output0_Y[:, :-1] = output0_Y[:, :-1] / torch.sum(input=output0_Y[:, :-1], dim=1, keepdim=True) * (1 - output0_Y[:, -1:]) + output0 = (output0_Y - input0_Y) * rho0 / delta_t + output0 = output0.cpu().numpy() + + + result = np.zeros((vec0.shape[0], n_species)) + result[mask, :] = output0 + return result + except Exception as e: + print(e.args) + diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/system/blockMeshDict b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/system/blockMeshDict similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/system/blockMeshDict rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/system/blockMeshDict diff --git a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/system/controlDict b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/system/controlDict old mode 100644 new mode 100755 similarity index 83% rename from examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/system/controlDict rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/system/controlDict index 99fe800cd..6e20a7723 --- a/examples/dfLowMachFoam/threeD_reactingTGV/H2/pytorchIntegrator/system/controlDict +++ b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/system/controlDict @@ -17,23 +17,19 @@ FoamFile application dfLowMachFoam; -startFrom startTime; +startFrom latestTime; startTime 0; stopAt endTime; -endTime 1e-5; +endTime 1.6e-4; -deltaT 1e-6; - -maxDeltaT 1e-04; - -adjustTimeStep off; +deltaT 1e-7; writeControl adjustableRunTime; -writeInterval 5e-6; +writeInterval 1e-5; purgeWrite 0; @@ -49,11 +45,11 @@ timePrecision 6; runTimeModifiable true; -// adjustTimeStep yes; +adjustTimeStep no; -// maxCo 0.8; +maxCo 0.6; -// maxDeltaT 1e-4; +maxDeltaT 1e-4; // ************************************************************************* // diff --git a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/system/decomposeParDict b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/system/decomposeParDict old mode 100644 new mode 100755 similarity index 92% rename from examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/system/decomposeParDict rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/system/decomposeParDict index 45c7f859f..66e942761 --- a/examples/df0DFoam/zeroD_cubicReactor/H2/libtorchIntegrator/system/decomposeParDict +++ b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/system/decomposeParDict @@ -15,13 +15,13 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -numberOfSubdomains 4; +numberOfSubdomains 8; -method scotch; +method simple; simpleCoeffs { - n (4 1 1); + n (4 2 1); delta 0.001; } diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/system/fvSchemes b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/system/fvSchemes similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/system/fvSchemes rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/system/fvSchemes diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/system/fvSolution b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/system/fvSolution similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/system/fvSolution rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/system/fvSolution diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/system/setFieldsDict b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/system/setFieldsDict new file mode 100755 index 000000000..cd6f8efe2 --- /dev/null +++ b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/C2H4/pytorchIntegrator/system/setFieldsDict @@ -0,0 +1,84 @@ +/*--------------------------------*- 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 setFieldsDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +defaultFieldValues +( + volScalarFieldValue T 2458.6 + volScalarFieldValue H 0.000053 + volScalarFieldValue O2 0.01511 + volScalarFieldValue OH 0.004558 + volScalarFieldValue O 0.00077 + volScalarFieldValue H2 0.000356 + volScalarFieldValue H2O 0.075807 + volScalarFieldValue HO2 0.000002 + volScalarFieldValue CO 0.025874 + volScalarFieldValue CO2 0.159367 + volScalarFieldValue HCO 0.0 + volScalarFieldValue CH3 0.0 + volScalarFieldValue CH4 0.0 + volScalarFieldValue CH2O 0.0 + volScalarFieldValue T-CH2 0.0 + volScalarFieldValue S-CH2 0.0 + volScalarFieldValue C2H4 0.0 + volScalarFieldValue C2H5 0.0 + volScalarFieldValue C2H2 0.0 + volScalarFieldValue C2H3 0.0 + volScalarFieldValue CH2CHO 0.0 + volScalarFieldValue HCCO 0.0 + volScalarFieldValue CH2CO 0.0 + volScalarFieldValue CH2OH 0.0 + volScalarFieldValue N2 0.718103 +); + +regions +( + boxToCell + { + box (0 0.0075 -0.0005) (0.016 0.0085 0.0005); + fieldValues + ( + volScalarFieldValue T 500 + volScalarFieldValue H 0.0 + volScalarFieldValue O2 0.218145 + volScalarFieldValue OH 0.0 + volScalarFieldValue O 0.0 + volScalarFieldValue H2 0.0 + volScalarFieldValue H2O 0.0 + volScalarFieldValue HO2 0.0 + volScalarFieldValue CO 0.0 + volScalarFieldValue CO2 0.0 + volScalarFieldValue HCO 0.0 + volScalarFieldValue CH3 0.0 + volScalarFieldValue CH4 0.0 + volScalarFieldValue CH2O 0.0 + volScalarFieldValue T-CH2 0.0 + volScalarFieldValue S-CH2 0.0 + volScalarFieldValue C2H4 0.063752 + volScalarFieldValue C2H5 0.0 + volScalarFieldValue C2H2 0.0 + volScalarFieldValue C2H3 0.0 + volScalarFieldValue CH2CHO 0.0 + volScalarFieldValue HCCO 0.0 + volScalarFieldValue CH2CO 0.0 + volScalarFieldValue CH2OH 0.0 + volScalarFieldValue N2 0.718103 + + ); + } +); +// ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/CH4.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/CH4.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/CH4.gz rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/CH4.gz diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/CO2.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/CO2.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/CO2.gz rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/CO2.gz diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/H2O.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/H2O.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/H2O.gz rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/H2O.gz diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/N2.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/N2.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/N2.gz rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/N2.gz diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/O2.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/O2.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/O2.gz rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/O2.gz diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/T.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/T.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/T.gz rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/T.gz diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/U.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/U.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/U.gz rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/U.gz diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/Ydefault.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/Ydefault.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/Ydefault.gz rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/Ydefault.gz diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/alphat.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/alphat.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/alphat.gz rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/alphat.gz diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/nut.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/nut.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/nut.gz rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/nut.gz diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/p.gz b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/p.gz similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/0/p.gz rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/0/p.gz diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/Allclean b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/Allclean similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/Allclean rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/Allclean diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/Allrun b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/Allrun similarity index 100% rename from examples/dfLowMachFoam/oneD_freelyPropagation/H2/libtorchIntegrator/Allrun rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/Allrun diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/constant/CanteraTorchProperties b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/constant/CanteraTorchProperties similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/constant/CanteraTorchProperties rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/constant/CanteraTorchProperties diff --git a/examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/constant/combustionProperties b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/constant/combustionProperties old mode 100644 new mode 100755 similarity index 100% rename from examples/dfLowMachFoam/twoD_HIT_flame/CH4/pytorchIntegrator/constant/combustionProperties rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/constant/combustionProperties diff --git a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/constant/thermophysicalProperties b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/constant/thermophysicalProperties old mode 100644 new mode 100755 similarity index 54% rename from examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/constant/thermophysicalProperties rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/constant/thermophysicalProperties index 7f207bb77..f82ee9785 --- a/examples/dfLowMachFoam/oneD_freelyPropagation/H2/cvodeIntegrator/constant/thermophysicalProperties +++ b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/constant/thermophysicalProperties @@ -1,9 +1,9 @@ /*--------------------------------*- C++ -*----------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Version: 7 - \\/ M anipulation | +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 2.4.0 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { diff --git a/examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/constant/turbulenceProperties b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/constant/turbulenceProperties old mode 100644 new mode 100755 similarity index 100% rename from examples/dfLowMachFoam/twoD_reactingTGV/CH4/pytorchIntegrator/constant/turbulenceProperties rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/constant/turbulenceProperties diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/drm19.yaml b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/drm19.yaml new file mode 100755 index 000000000..f278b6b84 --- /dev/null +++ b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/drm19.yaml @@ -0,0 +1,608 @@ +description: |- + !<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> 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/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/blockMeshDict b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/system/blockMeshDict old mode 100644 new mode 100755 similarity index 62% rename from examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/blockMeshDict rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/system/blockMeshDict index e45a31901..38710de65 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/blockMeshDict +++ b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/system/blockMeshDict @@ -27,13 +27,13 @@ vertices #codeStream #{ pointField points(8); points[0] = point(0, 0, -0.5); - points[1] = point(50, 0, -0.5); - points[2] = point(50, 11, -0.5); - points[3] = point(0, 11, -0.5); - points[4] = point(0, 19, -0.5); - points[5] = point(50, 19, -0.5); - points[6] = point(50, 30, -0.5); - points[7] = point(0, 30, -0.5); + points[1] = point(16, 0, -0.5); + points[2] = point(16, 7.5, -0.5); + points[3] = point(0, 7.5, -0.5); + points[4] = point(0, 8.5, -0.5); + points[5] = point(16, 8.5, -0.5); + points[6] = point(16, 16, -0.5); + points[7] = point(0, 16, -0.5); // Duplicate z points label sz = points.size(); @@ -50,9 +50,27 @@ vertices #codeStream blocks ( - hex (0 1 2 3 8 9 10 11) (500 110 1) simpleGrading (1 1 1) - hex (3 2 5 4 11 10 13 12) (500 80 1) simpleGrading (1 1 1) - hex (4 5 6 7 12 13 14 15) (500 110 1) simpleGrading (1 1 1) + hex (0 1 2 3 8 9 10 11) (800 250 1) + simpleGrading + ( + 1 + ( + (0.6 0.4 0.25) + (0.4 0.6 1) + ) + 1 + ) + hex (3 2 5 4 11 10 13 12) (800 50 1) simpleGrading (1 1 1) + hex (4 5 6 7 12 13 14 15) (800 250 1) + simpleGrading + ( + 1 + ( + (0.4 0.6 1) + (0.6 0.4 4) + ) + 1 + ) ); edges @@ -61,50 +79,42 @@ edges boundary ( - fuelInlet + left { - type patch; + type cyclic; + neighbourPatch right; faces ( - (3 4 11 12) + (0 3 11 8) + (3 4 12 11) + (4 7 15 12) ); } - airInlet + right { - type patch; + type cyclic; + neighbourPatch left; faces ( - (0 3 8 11) - (4 7 12 15) + (1 2 10 9) + (2 5 13 10) + (5 6 14 13) ); } - outlet + top { type patch; faces ( - // (1 6 9 14) - (1 2 9 10) - (2 5 10 13) - (5 6 13 14) - ); - } - up - { - type cyclic; - neighbourPatch down; - faces - ( - (7 6 15 14) + (7 6 14 15) ); } down { - type cyclic; - neighbourPatch up; + type patch; faces ( - (0 1 8 9) + (0 1 9 8) ); } ); diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/system/controlDict b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/system/controlDict similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/system/controlDict rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/system/controlDict diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/system/decomposeParDict b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/system/decomposeParDict similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/system/decomposeParDict rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/system/decomposeParDict diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/fvSchemes b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/system/fvSchemes old mode 100644 new mode 100755 similarity index 98% rename from examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/fvSchemes rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/system/fvSchemes index 8d11e7ed3..2f2cf3dd9 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/fvSchemes +++ b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/system/fvSchemes @@ -17,7 +17,7 @@ FoamFile ddtSchemes { - default Euler; + default Euler; } gradSchemes @@ -57,5 +57,4 @@ snGradSchemes default orthogonal; } - // ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/fvSolution b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/system/fvSolution old mode 100644 new mode 100755 similarity index 86% rename from examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/fvSolution rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/system/fvSolution index 7b498dbd5..2ff9eac58 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/fvSolution +++ b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/system/fvSolution @@ -25,7 +25,7 @@ solvers p { solver GAMG; - tolerance 1e-8; + tolerance 1e-7; relTol 0.01; smoother GaussSeidel; cacheAgglomeration true; @@ -37,8 +37,8 @@ solvers pFinal { solver GAMG; - tolerance 1e-10; - relTol 0; + tolerance 1e-7; + relTol 0.01; smoother GaussSeidel; cacheAgglomeration true; nCellsInCoarsestLevel 20; @@ -50,30 +50,30 @@ solvers { solver PBiCGStab; preconditioner DILU; - tolerance 1e-8; + tolerance 1e-7; relTol 0.01; } "(U|ha|k|epsilon)Final" { $U; - tolerance 1e-10; - relTol 0; + tolerance 1e-7; + relTol 0.01; } "Yi" { solver PBiCGStab; preconditioner DILU; - tolerance 1e-8; + tolerance 1e-7; relTol 0.01; } "YiFinal" { solver PBiCGStab; preconditioner DILU; - tolerance 1e-10; - relTol 0; + tolerance 1e-7; + relTol 0.01; } } diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/system/setFieldsDict b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/system/setFieldsDict similarity index 100% rename from examples/dfLowMachFoam/twoD_temporally_evolving_jet/system/setFieldsDict rename to examples/dfLowMachFoam/twoD_temporally_evolving_jet/CH4/cvodeIntegrator/system/setFieldsDict diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/constant/combustionProperties b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/constant/combustionProperties deleted file mode 100755 index 7418500d0..000000000 --- a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/constant/combustionProperties +++ /dev/null @@ -1,20 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Version: 7 - \\/ M anipulation | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - location "constant"; - object combustionProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -combustionModel laminar; - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/constant/turbulenceProperties b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/constant/turbulenceProperties deleted file mode 100755 index ab70e94d3..000000000 --- a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/constant/turbulenceProperties +++ /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 | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - location "constant"; - object turbulenceProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -simulationType laminar; - - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/drm19.yaml b/examples/dfLowMachFoam/twoD_temporally_evolving_jet/drm19.yaml deleted file mode 120000 index 6aed11e7f..000000000 --- a/examples/dfLowMachFoam/twoD_temporally_evolving_jet/drm19.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/CH4/drm19.yaml \ No newline at end of file diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/H2.gz b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/H2.gz deleted file mode 100644 index 9b065c773..000000000 Binary files a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/H2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/N2.gz b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/N2.gz deleted file mode 100644 index 5d5e0548d..000000000 Binary files a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/N2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/O2.gz b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/O2.gz deleted file mode 100644 index f70ecbb7f..000000000 Binary files a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/O2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/T.gz b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/T.gz deleted file mode 100644 index 4e34a558a..000000000 Binary files a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/T.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/U.gz b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/U.gz deleted file mode 100644 index c3f7dd773..000000000 Binary files a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/U.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/Ydefault.gz b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/Ydefault.gz deleted file mode 100644 index 5c46219f4..000000000 Binary files a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/Ydefault.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/p.gz b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/p.gz deleted file mode 100644 index 10ab290a2..000000000 Binary files a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/0/p.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/Allclean b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/Allclean deleted file mode 100755 index bb60ecd5e..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/Allclean +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -echo "Cleaning log.*" -rm log.* -echo "Cleaning processor*" -rm -r processor* -echo "Cleaning polyMesh/" -rm -r constant/polyMesh -echo "Cleaning dynamicCode/" -rm -r dynamicCode diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/Allrun b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/Allrun deleted file mode 100755 index 8cd1cbdd5..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/Allrun +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions - -application=dfLowMachFoam - -runApplication blockMesh -runApplication decomposePar -runApplication mpirun -np 4 --allow-run-as-root $application -parallel diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/ES80_H2-7-16.yaml b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/ES80_H2-7-16.yaml deleted file mode 120000 index 0600efea5..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/ES80_H2-7-16.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/ES80_H2-7-16.yaml \ No newline at end of file diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/constant/CanteraTorchProperties b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/constant/CanteraTorchProperties deleted file mode 100644 index 604b1e925..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/constant/CanteraTorchProperties +++ /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 "constant"; - object CanteraTorchProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -chemistry on; - -CanteraMechanismFile "ES80_H2-7-16.yaml"; - -transportModel "Mix"; - -odeCoeffs -{ - "relTol" 1e-6; - "absTol" 1e-10; -} - -inertSpecie "N2"; - -zeroDReactor -{ - constantProperty "pressure"; -} - -splittingStrategy off; - -TorchSettings -{ - torch on; - GPU on; - log on; - torchModel1 "new_ESH2sub1.pt"; - torchModel2 "new_ESH2sub2.pt"; - torchModel3 "new_ESH2sub3.pt"; - coresPerGPU 4; - GPUsPerNode 4; -} - -loadbalancing -{ - active true; - log false; - algorithm allAverage;//headTail; -} - - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/constant/combustionProperties b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/constant/combustionProperties deleted file mode 100644 index 7418500d0..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/constant/combustionProperties +++ /dev/null @@ -1,20 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Version: 7 - \\/ M anipulation | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - location "constant"; - object combustionProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -combustionModel laminar; - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/constant/thermophysicalProperties b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/constant/thermophysicalProperties deleted file mode 100644 index 7f207bb77..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/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/twoD_tripleFlame/H2/libtorchIntegrator/constant/turbulenceProperties b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/constant/turbulenceProperties deleted file mode 100644 index ab70e94d3..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/constant/turbulenceProperties +++ /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 | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - location "constant"; - object turbulenceProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -simulationType laminar; - - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/new_ESH2sub1.pt b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/new_ESH2sub1.pt deleted file mode 120000 index b672ed90c..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/new_ESH2sub1.pt +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/libtorchDNN/new_ESH2sub1.pt \ No newline at end of file diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/new_ESH2sub2.pt b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/new_ESH2sub2.pt deleted file mode 120000 index 976d5c774..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/new_ESH2sub2.pt +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/libtorchDNN/new_ESH2sub2.pt \ No newline at end of file diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/new_ESH2sub3.pt b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/new_ESH2sub3.pt deleted file mode 120000 index 68906dbcc..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/new_ESH2sub3.pt +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/libtorchDNN/new_ESH2sub3.pt \ No newline at end of file diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/decomposeParDict b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/decomposeParDict deleted file mode 100644 index 45c7f859f..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/decomposeParDict +++ /dev/null @@ -1,45 +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 decomposeParDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -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/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/funkySetFieldsDict b/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/funkySetFieldsDict deleted file mode 100644 index 4e9802435..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/libtorchIntegrator/system/funkySetFieldsDict +++ /dev/null @@ -1,86 +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 funkySetFieldsDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -expressions - ( -U1 - { - field U; - expression "vector(3,0,0)*0.5*(1+erf(1-pos().x/0.016))"; - condition "(pos().x>0) && (pos().y>=0.019) || (pos().y<=0.011)"; - keepPatches 1; - } -U2 - { - field U; - expression "vector(5,0,0)*1.128*pow(mag(0.004-(mag(pos().y-0.015)))/0.004,1/7)*0.5*(1+erf(1-pos().x/0.016))"; - condition "(pos().x>0) && (pos().y<0.019) && (pos().y>0.011)"; - keepPatches 1; - } -h2_1 - { - field H2; - expression "0.176470588235294*0.5*(1+erf(1-pos().x/0.016))"; - condition "(pos().x>0) && (pos().y<0.019) && (pos().y>0.011)"; - keepPatches 1; - } -h2_2 - { - field H2; - expression "0"; - condition "(pos().x>0) && (pos().y>=0.019) || (pos().y<=0.011)"; - keepPatches 1; - } -n2_1 - { - field N2; - expression "0.766899766899767+0.5*(1+erf(1-pos().x/0.016))*(0.823529411764706-0.766899766899767)"; - condition "(pos().x>0) && (pos().y<0.019) && (pos().y>0.011)"; - keepPatches 1; - } -n2_2 - { - field N2; - expression "0.766899766899767"; - condition "(pos().x>0) && (pos().y>=0.019) || (pos().y<=0.011)"; - keepPatches 1; - } -o2_1 - { - field O2; - expression "0.5*0.233100233100233*(1-erf(1-pos().x/0.016))"; - condition "(pos().x>0) && (pos().y<=0.019) && (pos().y>=0.011)"; - keepPatches 1; - } -o2_2 - { - field O2; - expression "0.233100233100233"; - condition "(pos().x>0) && (pos().y>0.019) || (pos().y<0.011)"; - keepPatches 1; - } -T1 - { - field T; - expression "1200"; - condition "(mag(pos().y-0.015)<=0.004) && (pos().x>0.016) && (pos().x<0.02)"; - keepPatches 1; - } - ); - - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/H2.gz b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/H2.gz deleted file mode 100644 index 3c0fc5cba..000000000 Binary files a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/H2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/N2.gz b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/N2.gz deleted file mode 100644 index 2e864a3e8..000000000 Binary files a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/N2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/O2.gz b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/O2.gz deleted file mode 100644 index ef5ac1835..000000000 Binary files a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/O2.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/T.gz b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/T.gz deleted file mode 100644 index c22b2200f..000000000 Binary files a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/T.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/U.gz b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/U.gz deleted file mode 100644 index 7c286a13a..000000000 Binary files a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/U.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/Ydefault.gz b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/Ydefault.gz deleted file mode 100644 index 9a96439ab..000000000 Binary files a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/Ydefault.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/p.gz b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/p.gz deleted file mode 100644 index 4c2a5651f..000000000 Binary files a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/0/p.gz and /dev/null differ diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/Allclean b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/Allclean deleted file mode 100755 index bb60ecd5e..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/Allclean +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -echo "Cleaning log.*" -rm log.* -echo "Cleaning processor*" -rm -r processor* -echo "Cleaning polyMesh/" -rm -r constant/polyMesh -echo "Cleaning dynamicCode/" -rm -r dynamicCode diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/Allrun b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/Allrun deleted file mode 100755 index 8cd1cbdd5..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/Allrun +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory - -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions - -application=dfLowMachFoam - -runApplication blockMesh -runApplication decomposePar -runApplication mpirun -np 4 --allow-run-as-root $application -parallel diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/ES80_H2-7-16.yaml b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/ES80_H2-7-16.yaml deleted file mode 120000 index 0600efea5..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/ES80_H2-7-16.yaml +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms/H2/ES80_H2-7-16.yaml \ No newline at end of file diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/constant/CanteraTorchProperties b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/constant/CanteraTorchProperties deleted file mode 100644 index cb52df768..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/constant/CanteraTorchProperties +++ /dev/null @@ -1,51 +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 CanteraTorchProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -chemistry on; - -CanteraMechanismFile "ES80_H2-7-16.yaml"; - -transportModel "Mix"; - -odeCoeffs -{ - "relTol" 1e-6; - "absTol" 1e-10; -} - -inertSpecie "N2"; - -splittingStrategy off; - -TorchSettings -{ - torch on; - GPU on; - log on; - torchModel "HE04_Hydrogen_ESH2_GMS_sub_20221101"; - coresPerNode 4; -} - -loadbalancing -{ - active true; - log false; - algorithm allAverage;//headTail; -} - - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/constant/combustionProperties b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/constant/combustionProperties deleted file mode 100644 index 7418500d0..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/constant/combustionProperties +++ /dev/null @@ -1,20 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Version: 7 - \\/ M anipulation | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - location "constant"; - object combustionProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -combustionModel laminar; - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/constant/thermophysicalProperties b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/constant/thermophysicalProperties deleted file mode 100644 index 7f207bb77..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/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/twoD_tripleFlame/H2/pytorchIntegrator/constant/turbulenceProperties b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/constant/turbulenceProperties deleted file mode 100644 index ab70e94d3..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/constant/turbulenceProperties +++ /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 | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - location "constant"; - object turbulenceProperties; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -simulationType laminar; - - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/inference.py b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/inference.py deleted file mode 100644 index a4181c1f6..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/inference.py +++ /dev/null @@ -1,221 +0,0 @@ -from builtins import Exception, print -from calendar import prcal -import torch -import numpy as np -import math -import time -import json -import os -from easydict import EasyDict as edict -import torch.profiler -import os - - -torch.set_printoptions(precision=10) - - -class MyGELU(torch.nn.Module): - def __init__(self): - super(MyGELU, self).__init__() - self.torch_PI = 3.1415926536 - - def forward(self, x): - return 0.5 * x * (1 + torch.tanh( - math.sqrt(2 / self.torch_PI) * (x + 0.044715 * torch.pow(x, 3)))) - - -def json2Parser(json_path): - """load json and return parser-like object""" - with open(json_path, 'r') as f: - args = json.load(f) - return edict(args) - - -class Net(torch.nn.Module): - def __init__(self): - super(Net, self).__init__() - neurons = layers - self.depth = len(neurons) - 1 - self.actfun = MyGELU() - self.layers = [] - for i in range(self.depth - 1): - self.layers.append(torch.nn.Linear(neurons[i], neurons[i + 1])) - self.layers.append(self.actfun) - self.layers.append(torch.nn.Linear(neurons[-2], neurons[-1])) # last layer - self.fc = torch.nn.Sequential(*self.layers) - - def forward(self, x): - x = self.fc(x) - return x -try: - #load variables from constant/CanteraTorchProperties - path_r = r"./constant/CanteraTorchProperties" - with open(path_r, "r") as f: - data = f.read() - i = data.index('torchModel') - a = data.index('"',i) - b = data.index('sub',a) - c = data.index('"',b+1) - modelName_split1 = data[a+1:b+3] - modelName_split2 = data[b+3:c] - - modelPath = str(modelName_split1+modelName_split2) - model1Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"1"+modelName_split2+"/checkpoint/") - model2Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"2"+modelName_split2+"/checkpoint/") - model3Path = str("mechanisms/"+modelPath+"/"+modelName_split1+"3"+modelName_split2+"/checkpoint/") - - i = data.index('GPU') - a = data.index(';', i) - b = data.rfind(' ',i+1,a) - switch_GPU = data[b+1:a] - - #load OpenFOAM switch - switch_on = ["true", "True", "on", "yes", "y", "t", "any"] - switch_off = ["false", "False", "off", "no", "n", "f", "none"] - if switch_GPU in switch_on: - device = torch.device("cuda") - device_ids = range(torch.cuda.device_count()) - elif switch_GPU in switch_off: - device = torch.device("cpu") - device_ids = [0] - else: - print("invalid setting!") - os._exit(0) - - - - #glbal variable will only init once when called interperter - #load parameters from json - - norm0 = json2Parser(str(model1Path+"norm.json")) - norm1 = json2Parser(str(model2Path+"norm.json")) - norm2 = json2Parser(str(model3Path+"norm.json")) - setting0 = json2Parser(str(model1Path+"settings.json")) - lamda = setting0.power_transform - delta_t = setting0.delta_t - dim = setting0.dim - layers = setting0.layers - - - Xmu0 = torch.tensor(norm0.input_mean).unsqueeze(0).to(device=device) - Xstd0 = torch.tensor(norm0.input_std).unsqueeze(0).to(device=device) - Ymu0 = torch.tensor(norm0.label_mean).unsqueeze(0).to(device=device) - Ystd0 = torch.tensor(norm0.label_std).unsqueeze(0).to(device=device) - - Xmu1 = torch.tensor(norm1.input_mean).unsqueeze(0).to(device=device) - Xstd1 = torch.tensor(norm1.input_std).unsqueeze(0).to(device=device) - Ymu1 = torch.tensor(norm1.label_mean).unsqueeze(0).to(device=device) - Ystd1 = torch.tensor(norm1.label_std).unsqueeze(0).to(device=device) - - Xmu2 = torch.tensor(norm2.input_mean).unsqueeze(0).to(device=device) - Xstd2 = torch.tensor(norm2.input_std).unsqueeze(0).to(device=device) - Ymu2 = torch.tensor(norm2.label_mean).unsqueeze(0).to(device=device) - Ystd2 = torch.tensor(norm2.label_std).unsqueeze(0).to(device=device) - - #load model - model0 = Net() - model1 = Net() - model2 = Net() - - path_list=os.listdir(model1Path) - for filename in path_list: - if os.path.splitext(filename)[1] == '.pt': - modelname = filename - - - if torch.cuda.is_available()==False: - check_point0 = torch.load(str(model1Path+modelname), map_location='cpu') - check_point1 = torch.load(str(model2Path+modelname), map_location='cpu') - check_point2 = torch.load(str(model3Path+modelname), map_location='cpu') - else: - check_point0 = torch.load(str(model1Path+modelname)) - check_point1 = torch.load(str(model2Path+modelname)) - check_point2 = torch.load(str(model3Path+modelname)) - - model0.load_state_dict(check_point0) - model1.load_state_dict(check_point1) - model2.load_state_dict(check_point2) - model0.to(device=device) - model1.to(device=device) - model2.to(device=device) - - if len(device_ids) > 1: - model0 = torch.nn.DataParallel(model0, device_ids=device_ids) - model1 = torch.nn.DataParallel(model1, device_ids=device_ids) - model2 = torch.nn.DataParallel(model2, device_ids=device_ids) -except Exception as e: - print(e.args) - - -def inference(vec0, vec1, vec2): - ''' - use model to inference - ''' - #args = np.reshape(args, (-1, 9)) #reshape to formed size - #vec0 = np.reshape(vec0, (-1, 24)) - #vec1 = np.reshape(vec1, (-1, 24)) - #vec2 = np.reshape(vec2, (-1, 24)) - vec0 = np.reshape(vec0, (-1, 10)) - vec1 = np.reshape(vec1, (-1, 10)) - vec2 = np.reshape(vec2, (-1, 10)) - - try: - with torch.no_grad(): - input0_ = torch.from_numpy(vec0).double().to(device=device) #cast ndarray to torch tensor - input1_ = torch.from_numpy(vec1).double().to(device=device) #cast ndarray to torch tensor - input2_ = torch.from_numpy(vec2).double().to(device=device) #cast ndarray to torch tensor - - # pre_processing - rho0 = input0_[:, -1].unsqueeze(1) - input0_Y = input0_[:, 2:-1].clone() - input0_bct = input0_[:, 0:-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_[:, -1].unsqueeze(1) - input1_Y = input1_[:, 2:-1].clone() - input1_bct = input1_[:, 0:-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_[:, -1].unsqueeze(1) - input2_Y = input2_[:, 2:-1].clone() - input2_bct = input2_[:, 0:-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/twoD_tripleFlame/H2/pytorchIntegrator/mechanisms b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/mechanisms deleted file mode 120000 index b7afede27..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/mechanisms +++ /dev/null @@ -1 +0,0 @@ -../../../../../mechanisms \ No newline at end of file diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/blockMeshDict b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/blockMeshDict deleted file mode 100644 index e45a31901..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/blockMeshDict +++ /dev/null @@ -1,116 +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 #codeStream -{ - codeInclude - #{ - #include "pointField.H" - #}; - - code - #{ - pointField points(8); - points[0] = point(0, 0, -0.5); - points[1] = point(50, 0, -0.5); - points[2] = point(50, 11, -0.5); - points[3] = point(0, 11, -0.5); - points[4] = point(0, 19, -0.5); - points[5] = point(50, 19, -0.5); - points[6] = point(50, 30, -0.5); - points[7] = point(0, 30, -0.5); - - // Duplicate z points - label sz = points.size(); - points.setSize(2*sz); - for (label i = 0; i < sz; i++) - { - const point& pt = points[i]; - points[i+sz] = point(pt.x(), pt.y(), -pt.z()); - } - - os << points; - #}; -}; - -blocks -( - hex (0 1 2 3 8 9 10 11) (500 110 1) simpleGrading (1 1 1) - hex (3 2 5 4 11 10 13 12) (500 80 1) simpleGrading (1 1 1) - hex (4 5 6 7 12 13 14 15) (500 110 1) simpleGrading (1 1 1) -); - -edges -( -); - -boundary -( - fuelInlet - { - type patch; - faces - ( - (3 4 11 12) - ); - } - airInlet - { - type patch; - faces - ( - (0 3 8 11) - (4 7 12 15) - ); - } - outlet - { - type patch; - faces - ( - // (1 6 9 14) - (1 2 9 10) - (2 5 10 13) - (5 6 13 14) - ); - } - up - { - type cyclic; - neighbourPatch down; - faces - ( - (7 6 15 14) - ); - } - down - { - type cyclic; - neighbourPatch up; - faces - ( - (0 1 8 9) - ); - } -); - -// mergePatchPairs -// ( -// ); - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/decomposeParDict b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/decomposeParDict deleted file mode 100644 index 45c7f859f..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/decomposeParDict +++ /dev/null @@ -1,45 +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 decomposeParDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -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/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/funkySetFieldsDict b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/funkySetFieldsDict deleted file mode 100644 index 4e9802435..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/funkySetFieldsDict +++ /dev/null @@ -1,86 +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 funkySetFieldsDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -expressions - ( -U1 - { - field U; - expression "vector(3,0,0)*0.5*(1+erf(1-pos().x/0.016))"; - condition "(pos().x>0) && (pos().y>=0.019) || (pos().y<=0.011)"; - keepPatches 1; - } -U2 - { - field U; - expression "vector(5,0,0)*1.128*pow(mag(0.004-(mag(pos().y-0.015)))/0.004,1/7)*0.5*(1+erf(1-pos().x/0.016))"; - condition "(pos().x>0) && (pos().y<0.019) && (pos().y>0.011)"; - keepPatches 1; - } -h2_1 - { - field H2; - expression "0.176470588235294*0.5*(1+erf(1-pos().x/0.016))"; - condition "(pos().x>0) && (pos().y<0.019) && (pos().y>0.011)"; - keepPatches 1; - } -h2_2 - { - field H2; - expression "0"; - condition "(pos().x>0) && (pos().y>=0.019) || (pos().y<=0.011)"; - keepPatches 1; - } -n2_1 - { - field N2; - expression "0.766899766899767+0.5*(1+erf(1-pos().x/0.016))*(0.823529411764706-0.766899766899767)"; - condition "(pos().x>0) && (pos().y<0.019) && (pos().y>0.011)"; - keepPatches 1; - } -n2_2 - { - field N2; - expression "0.766899766899767"; - condition "(pos().x>0) && (pos().y>=0.019) || (pos().y<=0.011)"; - keepPatches 1; - } -o2_1 - { - field O2; - expression "0.5*0.233100233100233*(1-erf(1-pos().x/0.016))"; - condition "(pos().x>0) && (pos().y<=0.019) && (pos().y>=0.011)"; - keepPatches 1; - } -o2_2 - { - field O2; - expression "0.233100233100233"; - condition "(pos().x>0) && (pos().y>0.019) || (pos().y<0.011)"; - keepPatches 1; - } -T1 - { - field T; - expression "1200"; - condition "(mag(pos().y-0.015)<=0.004) && (pos().x>0.016) && (pos().x<0.02)"; - keepPatches 1; - } - ); - - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/fvSchemes b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/fvSchemes deleted file mode 100644 index 8d11e7ed3..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/fvSchemes +++ /dev/null @@ -1,61 +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 linear; - div(phi,Yi) Gauss limitedLinear01 1; - div(phi,h) Gauss limitedLinear 1; - div(phi,ha) 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(hDiffCorrFlux) Gauss cubic; - div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; -} - -laplacianSchemes -{ - default Gauss linear orthogonal; -} - -interpolationSchemes -{ - default linear; -} - -snGradSchemes -{ - default orthogonal; -} - - -// ************************************************************************* // diff --git a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/fvSolution b/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/fvSolution deleted file mode 100644 index 7b498dbd5..000000000 --- a/examples/dfLowMachFoam/twoD_tripleFlame/H2/pytorchIntegrator/system/fvSolution +++ /dev/null @@ -1,89 +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 GAMG; - tolerance 1e-8; - relTol 0.01; - smoother GaussSeidel; - cacheAgglomeration true; - nCellsInCoarsestLevel 20; - agglomerator faceAreaPair; - mergeLevels 1; - } - - pFinal - { - solver GAMG; - tolerance 1e-10; - relTol 0; - smoother GaussSeidel; - cacheAgglomeration true; - nCellsInCoarsestLevel 20; - agglomerator faceAreaPair; - mergeLevels 1; - } - - "(U|ha|k|epsilon)" - { - solver PBiCGStab; - preconditioner DILU; - tolerance 1e-8; - relTol 0.01; - } - - "(U|ha|k|epsilon)Final" - { - $U; - tolerance 1e-10; - relTol 0; - } - - "Yi" - { - solver PBiCGStab; - preconditioner DILU; - tolerance 1e-8; - relTol 0.01; - } - "YiFinal" - { - solver PBiCGStab; - preconditioner DILU; - tolerance 1e-10; - relTol 0; - } -} - -PIMPLE -{ - momentumPredictor yes; - nOuterCorrectors 1; - nCorrectors 2; - nNonOrthogonalCorrectors 0; -} - - -// ************************************************************************* //