Skip to content

[WIP] Adding Cantera fluid model for incompressible reacting flows - #2713

Open
Cristopher-Morales wants to merge 289 commits into
developfrom
feature_CANTERA_PR
Open

[WIP] Adding Cantera fluid model for incompressible reacting flows#2713
Cristopher-Morales wants to merge 289 commits into
developfrom
feature_CANTERA_PR

Conversation

@Cristopher-Morales

@Cristopher-Morales Cristopher-Morales commented Jan 19, 2026

Copy link
Copy Markdown
Contributor

Proposed Changes

This pull request aims to add a fluid model called FLUID_CANTERA for coupling Cantera library with SU2. Cantera library is an open-source library for problems involving chemical kinetics, thermodynamics, and transport processes. This is needed for combustion problems using the incompressible solver.

[UPDATE] adding the cantera option to meson is now sufficient to get cantera coupled to su2.

SU2 can be built with Cantera as follows (for example):

    ./meson.py build -Dwarning_level=2 -Denable-autodiff=false -Denable-directdiff=false -Dwith-mpi=enabled -Denable-cgns=true -Denable-tecio=false -Denable-cantera=true --prefix=/path_to_SU2_directory/SU2

• -Denable-tests=true can be used for testing if Cantera is correctly compiled with SU2, running one of the Cantera fluid unit test cases.

Work in progress:

• Improve cantera coupling, only compile the functionalities needed for SU2. Currently, when cantera is compiled, whole functionalities are compiled. Most of the cantera implementations are not needed for incompressible reacting flows.
• Compile cantera with the AD options. For this purpose, a different repository must be cloned and compiled, where the AD implementation of cantera is located.
• Add regression and unit test cases in the SU2 workflow.

Regarding the coupling between SU2 and Cantera, any advice/suggestion how to improve it would be really appreciated.

Thanks in advance!!

Related Work

Related to pull request #2426

PR Checklist

Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
  • My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
  • I used the pre-commit hook to prevent dirty commits and used pre-commit run --all to format old commits.
  • I have added a test case that demonstrates my contribution, if necessary.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.

* \brief Get High temperature applied during spark ignition.
* \return Spark Temperature.
*/
const su2double GetSpark_Temperature(void) const {

Check warning

Code scanning / CodeQL

Constant return type on member Warning

The 'const' modifier has no effect on return types. The 'const' modifying the return type can be removed.

Copilot Autofix

AI 3 days ago

The fix is to remove only the superfluous top-level const from the return type of GetSpark_Temperature, while preserving the method’s trailing const qualifier.

In Common/include/CConfig.hpp, at the getter near line 4102, change:

  • const su2double GetSpark_Temperature(void) const

to:

  • su2double GetSpark_Temperature(void) const

No other code, imports, or definitions are required. This keeps behavior identical and resolves the CodeQL warning.

Suggested changeset 1
Common/include/CConfig.hpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp
--- a/Common/include/CConfig.hpp
+++ b/Common/include/CConfig.hpp
@@ -4099,7 +4099,7 @@
    * \brief Get High temperature applied during spark ignition.
    * \return Spark Temperature.
    */
-  const su2double GetSpark_Temperature(void) const {
+  su2double GetSpark_Temperature(void) const {
     return Spark_Temperature;
   }
 
EOF
@@ -4099,7 +4099,7 @@
* \brief Get High temperature applied during spark ignition.
* \return Spark Temperature.
*/
const su2double GetSpark_Temperature(void) const {
su2double GetSpark_Temperature(void) const {
return Spark_Temperature;
}

Copilot is powered by AI and may make mistakes. Always verify output.

#include <cmath>

// #include <numeric>

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.

Copilot Autofix

AI 7 months ago

In general, to fix commented-out code, either remove it entirely if it is no longer needed, or reinstate it as active code if it is required for functionality. If the intent is to document an example snippet, it should be reformatted to avoid looking like disabled code (for example, quoting it or explaining it in prose).

For this specific case, the best fix with no functional change is to remove the commented-out include directive // #include <numeric> from SU2_CFD/src/fluid/CFluidCantera.cpp. There is no indication in the shown code that <numeric> is needed (no calls to std::accumulate or similar), so uncommenting it would introduce an unused include, while leaving it as a comment keeps triggering the static analysis warning. Removing that single line resolves the CodeQL issue cleanly without affecting behavior. No additional methods, imports, or definitions are needed.

Suggested changeset 1
SU2_CFD/src/fluid/CFluidCantera.cpp

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/SU2_CFD/src/fluid/CFluidCantera.cpp b/SU2_CFD/src/fluid/CFluidCantera.cpp
--- a/SU2_CFD/src/fluid/CFluidCantera.cpp
+++ b/SU2_CFD/src/fluid/CFluidCantera.cpp
@@ -29,7 +29,6 @@
 
 #include <cmath>
 
-// #include <numeric>
 #ifdef USE_CANTERA
 #include <cantera/core.h>
 #include <cantera/kinetics/Reaction.h>
EOF
@@ -29,7 +29,6 @@

#include <cmath>

// #include <numeric>
#ifdef USE_CANTERA
#include <cantera/core.h>
#include <cantera/kinetics/Reaction.h>
Copilot is powered by AI and may make mistakes. Always verify output.
@Hanquist

Hanquist commented Feb 1, 2026

Copy link
Copy Markdown

How difficult would it be to extend this to the compressible solver?

@bigfooted

Copy link
Copy Markdown
Contributor

How difficult would it be to extend this to the compressible solver?

Have a look at all the changed files that have "INC" in the name :-)
Cristopher can give a more detailed answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants