Reaction integration related questions in PeleLMeX #422
-
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 44 replies
-
In PelePhysics, the state vector that is given to CVode or the other chemical integrators is the species and temperature (rather than enthalpy), which simplifies the Jacobian. See here: https://amrex-combustion.github.io/PelePhysics/CvodeInPP.html#the-different-reactors (although don't read too far because some of that documentation has fallen very out of date). The bits of code you've called out ensure that the initial temperature for chemistry integration is consistent with the initial enthalpy and that the enthalpy gets updated properly at the end of chemistry integration. |
Beta Was this translation helpful? Give feedback.
-
Okay. To replace the reaction integration in PeleLMeX (currently done using CVODE) with the DeepONet, I have an intermediate C++ file (with one of the headers being #include <Python.h> ) that calls the necessary functions from the DeepONet code (in python) and returns the required outputs, i.e., species MF and temperature. I have added this function in the ReactorCvode.cpp file (in the CPU region, after the box_flatten, and before the box_unflatten) and included the intermediate C++ file in the header accordingly. Even though I have added the header files and libraries in the Cmake file. I added in BuildPelePhysicsLib.cmake Can you please help with this? Thanks for your time. |
Beta Was this translation helpful? Give feedback.
-
As a general word of advice, I would recommend adding a new I haven't previously written software that calls python functions from C++ code (the reverse is more common) so I can't provide useful advice on how to approach that or get things to compile properly. Also, it seems likely to me that this strategy will not end up being computationally efficient. If you are training your models using pytorch or tensorflow in python, it isn't that difficult to link Pele to C++ versions of these libraries and execute a network that was exported from your python training scripts. There are some very basic examples of doing that here: https://github.nrel.gov/bperry/ML-Models-CPP, and we have previously integrated both tensorflow and pytorch models into Pele in this manner. I could provide further pointers if you're interested in this strategy. A final option would be to take advantage of the home-rolled neural network evaluator that is now in PelePhysics (https://github.com/AMReX-Combustion/PelePhysics/blob/development/Source/Utility/BlackBoxFunction/NeuralNetHomerolled.H), although this implementation is very specific and would have to be adapted for your use case. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your advice. I will try to implement them in my work. I tried compiling the Python code and the intermediate C++ file (that calls the python functions) with PeleLMeX. It is compiling now, but there is some issue while linking Python, and that's why the executable is not created. I have added this to the "Make.PeleLMeX" file in the "Exec" folder:
I have added the Python files and the intermediate C++ in the folder of the case that I am running (Exec/RegTests/EB_BackwardStepFlame) and in the Submodules/PelePhysics/Source/Reactions directory. This is the error that I get on the terminal:
I will highly appreciate any help from your side in my work. If you have any idea how to resolve this, please let me know. Thank you so much. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
That initial condition looks reasonable to me. From that output, it looks like the linear solvers are converging, although not quite to the default criterion. You can adjust the tolerances as documented here: https://amrex-combustion.github.io/PeleLMeX/manual/html/LMeXControls.html#linear-solvers I'd recommend something around 1e-9 for rtol and 1e-10 for atoll for both mac and nodal projections. |
Beta Was this translation helpful? Give feedback.
-
I did that, and now the linear solver is converging, but it said in the command window that dt is too small and the simulation will stop. So I added Now, the simulation is running without issues, but when i try to visualize any plotfile except the initial one, it looks like this: Every other variable contour looks exactly like the above one. When I look at the values of variables using spreadsheet view, I see a lot of zeros and NaNs. Any idea why this is happening? |
Beta Was this translation helpful? Give feedback.
-
Okay. Running the code with debug mode gave me something like this
|
Beta Was this translation helpful? Give feedback.
-
Can you add divu to the plot file and look to see if there is something unexpected in that field? |
Beta Was this translation helpful? Give feedback.
-
Very glad to hear about your success, and your ability to sort through the very subtle issues! |
Beta Was this translation helpful? Give feedback.
-
Hi. I am trying to run the backward-step flame problem (with Cvode as the chemical integrator) on my university's HPC cluster with GPUs. I am working on a node, which is equipped with an NVIDIA RTX A4000 GPU, and I have compiled PeleLMeX with CUDA and MPI support using the recommended CMake flags.
This is how I run the simulation, and the initial output that I see related to MPI and GPU.
Is there anything that I am doing wrong? Please let me know. Also, I could not find any tutorial that explains how to compile and run a problem with MPI and CUDA support, so I am not sure if I am doing it correctly. Thanks for your time. |
Beta Was this translation helpful? Give feedback.
Not all of this is in the PeleLMeX docs, but if you look at the PeleLM docs there's some more details on the temporal integration approach, which is mostly the same between the two codes: https://amrex-combustion.github.io/PeleLM/manual/html/Model.html#the-pelelm-temporal-integration
In CVODE, we integrate the system$\frac{d\xi}{dt} = \dot{\omega}_{\xi}(T) + F$ from $t$ to $t+ \Delta t$ . That means the state after CVODE integration includes the effects of reaction, diffusion, and advection, so F_AD does not need to be added separately for the updated state. In fact, to compute I_R, the forcing just due to reactions, we have to subtract F_AD from the update. The density can change during …