From 84cc6e4cb58979dacda46f582a7d613cf7d0810f Mon Sep 17 00:00:00 2001 From: minzhang0929 <78373564+minzhang0929@users.noreply.github.com> Date: Sat, 4 Nov 2023 22:41:40 +0800 Subject: [PATCH 1/3] Update torchFunctions to correct number of species for inference(#383) * Update pytorchFunctions.H * Update torchFunctions.H --- src/dfChemistryModel/pytorchFunctions.H | 8 ++++---- src/dfChemistryModel/torchFunctions.H | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/dfChemistryModel/pytorchFunctions.H b/src/dfChemistryModel/pytorchFunctions.H index 535a7418..af2c224d 100644 --- a/src/dfChemistryModel/pytorchFunctions.H +++ b/src/dfChemistryModel/pytorchFunctions.H @@ -275,9 +275,9 @@ Foam::scalar Foam::dfChemistryModel::solve_DNN(const DeltaTType &del pybind11::module_ call_torch = pybind11::module_::import("inference"); // import python file pybind11::object result = call_torch.attr("inference")(vec0, vec1, vec2); // call python function const double* star = result.cast>().data(); - std::vector outputsVec0(star, star+outputLength[0] * 7); //the float number is sample_length*sample_number - std::vector outputsVec1(star+outputLength[0] * 7, star+outputLength[1] * 7); - std::vector outputsVec2(star+outputLength[1] * 7, star+outputLength[2] * 7); + std::vector outputsVec0(star, star+outputLength[0] * mixture_.nSpecies()); //the float number is sample_length*sample_number + std::vector outputsVec1(star+outputLength[0] * mixture_.nSpecies(), star+outputLength[1] * mixture_.nSpecies()); + std::vector outputsVec2(star+outputLength[1] * mixture_.nSpecies(), star+outputLength[2] * mixture_.nSpecies()); std::vector> results = {outputsVec0, outputsVec1, outputsVec2}; updateSolutionBuffer(solutionBuffer, results, cellIDBuffer, problemCounter); DynamicList finalList; @@ -301,4 +301,4 @@ Foam::scalar Foam::dfChemistryModel::solve_DNN(const DeltaTType &del time_allsolve_ += processingTime.count(); return deltaTMin; -} \ No newline at end of file +} diff --git a/src/dfChemistryModel/torchFunctions.H b/src/dfChemistryModel/torchFunctions.H index 1639d287..f7d9a83c 100644 --- a/src/dfChemistryModel/torchFunctions.H +++ b/src/dfChemistryModel/torchFunctions.H @@ -149,9 +149,9 @@ void Foam::dfChemistryModel::getDNNinputs if (gpulog_) { - std::cout<<"inputsDNN0 = "< Date: Mon, 20 Nov 2023 15:34:36 +0800 Subject: [PATCH 2/3] Update install.rst conda install -c conda-forge libcantera-devel --- docs/source/qs/install.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/source/qs/install.rst b/docs/source/qs/install.rst index 7e25ce35..c9e256d7 100644 --- a/docs/source/qs/install.rst +++ b/docs/source/qs/install.rst @@ -26,7 +26,7 @@ OpenFOAM-7 and ParaView-5.6.0 will be installed in the ``/opt`` directory. conda create -n deepflame python=3.8 conda activate deepflame - conda install -c cantera libcantera-devel + conda install -c conda-forge libcantera-devel conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia conda install pybind11 conda install -c conda-forge easydict @@ -129,7 +129,7 @@ DeepFlame also provides users with LibTorch and CVODE (no DNN version) options. conda create -n df-libtorch python=3.8 conda activate df-libtorch - conda install -c cantera libcantera-devel + conda install -c conda-forge libcantera-devel Then you can pass your own libtorch path to DeepFlame. @@ -149,7 +149,7 @@ Then you can pass your own libtorch path to DeepFlame. conda create -n df-notorch python=3.8 conda activate df-notorch - conda install -c cantera libcantera-devel + conda install -c conda-forge libcantera-devel If the conda env ``df-notorch`` is activated, install DeepFlame by running: From 77c4611fcafa1b8ae3d9061ddd5a56a3cedbc400 Mon Sep 17 00:00:00 2001 From: Zhi Chen Date: Mon, 20 Nov 2023 15:41:02 +0800 Subject: [PATCH 3/3] Update install.rst --- docs/source/qs/install.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/source/qs/install.rst b/docs/source/qs/install.rst index c9e256d7..458f1950 100644 --- a/docs/source/qs/install.rst +++ b/docs/source/qs/install.rst @@ -108,7 +108,14 @@ Finally you can build and install DeepFlame: . install.sh -.. Note:: You may come accross an error regarding shared library ``libmkl_rt.so.2`` when libcantera is installed through cantera channel. If so, go to your conda environment and check the existance of ``libmkl_rt.so.2`` and ``libmkl_rt.so.1``, and then link ``libmkl_rt.so.2`` to ``libmkl_rt.so.1``. +.. Note:: You may see an error ``fmt`` or ``eigen`` files cannot be found. If so, go to your conda environment and install the packages as follows. + +.. code-block:: bash + + conda install fmt + conda install eigen + +.. Note:: You may also come accross an error regarding shared library ``libmkl_rt.so.2`` when libcantera is installed through cantera channel. If so, go to your conda environment and check the existance of ``libmkl_rt.so.2`` and ``libmkl_rt.so.1``, and then link ``libmkl_rt.so.2`` to ``libmkl_rt.so.1``. .. code-block:: bash