diff --git a/docs/source/qs/install.rst b/docs/source/qs/install.rst index e4d8c37e..ba473032 100644 --- a/docs/source/qs/install.rst +++ b/docs/source/qs/install.rst @@ -39,6 +39,15 @@ Alternatively, one can `compile OpenFOAM-7 from source code `_. If your platform is compatible, run the following command to install the dependencies. +.. code-block:: bash + + conda create -n deepflame python=3.8 + conda activate deepflame + 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 + .. Note:: Please go to `the official website of PyTorch `_ to check your system compatibility and choose the installation command line that is suitable for your platform. .. code-block:: bash @@ -123,8 +132,15 @@ 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 cd ~/miniconda3/envs/deepflame/lib @@ -144,7 +160,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. @@ -164,7 +180,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: 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 = "<