Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Preconditioning for multicomponent flows #2426

Open
wants to merge 25 commits into
base: develop
Choose a base branch
from

Conversation

Cristopher-Morales
Copy link
Contributor

@Cristopher-Morales Cristopher-Morales commented Jan 18, 2025

Proposed Changes

This pull request aims to extend the preconditioning for incompressible multicomponent flows, specifically when FLUID_MIXTURE model is used and energy equation is solved. Changes introduced in this pull request aim to solve directly for the sensible enthalpy instead of temperature. Specifically, the energy equation that is going to be solved for multicomponent flows is given as follows:

image

and the sensible enthalpy is:
image

Currently $C_{p}$ does not depend on temperature for FLUID_MIXTURE, but it depends on the mixture composition. So the sensible enthalpy simplifies to $C_{p}*(T-T_{0})$. For problems where $C_{p}$ strongly depends on the temperature, Cantera library will be coupled to SU2. After this pull request is completed, a pull request with a fluid model using Cantera will be done where an energy equation for the total enthalpy will be solved.
A pdf document will be attached in the coming days for giving more details about this pull request.

Related Work

Currently fluid mixture does not work correctly when the energy equation is on, this is mainly due to the fact that the energy equation that must be solved for multicomponent flows is the one mentioned above for the sensible enthalpy and not the energy equation for a perfect gas that is currently solved in SU2.

PR Checklist

  • 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.

@Cristopher-Morales Cristopher-Morales changed the title [WIP] Preconditioning fro multicomponent flows [WIP] Preconditioning for multicomponent flows Jan 18, 2025
Comment on lines +1335 to +1336
lim_i = 1.0; // nodes->GetLimiter_Primitive(iPoint, iVar);
lim_j = 1.0; // nodes->GetLimiter_Primitive(jPoint, iVar);

Check notice

Code scanning / CodeQL

Commented-out code Note

This comment appears to contain commented-out code.
SU2_CFD/src/solvers/CIncNSSolver.cpp Fixed Show fixed Hide fixed
Comment on lines +358 to +363
/*!
* \brief Virtual member.
* \param[in] val_enthalpy - Enthalpy value at the point.
*/
virtual void ComputeTempFromEnthalpy(su2double val_enthalpy, su2double* val_temperature,
const su2double* val_scalars = nullptr) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems inconsistent with the SetTDState_* functions.
Should this be SetTDState_h and then you use GetTemperature to get the temperature?

Copy link
Contributor Author

@Cristopher-Morales Cristopher-Morales Jan 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the pull request made by evert regarding preferential diffusion, he also used the same function for the flamelet solver. The only difference is that that function is in the CSpeciesFlameletSolver.cpp and I cannot access to that function when I set the primitives in SetPrimVar in CIncNSVariable.cpp

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is again to keep an abstract interface.
Evert's function is a private function of a specific solver which is perfectly fine, and it uses the fluid model... If you need a similar function, move it somewhere higher up in the hierarchy to make it accessible. For example the scalar solver. Or even the fluid model but implemented in a way that keeps it useful for all fluids.

Comment on lines +94 to +97
/*!
* \brief Compute Enthalpy given the temperature and scalars.
*/
su2double ComputeEnthalpyFromT(const su2double val_temperature, const su2double* val_scalars);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't this use TDState_T

Copy link
Contributor Author

@Cristopher-Morales Cristopher-Morales Jan 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We compute the enthalpy from the temperature and the species mass fractions. That function is used for setting the enthalpy at the inlets.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And why don't you compute the enthalpy in that function too instead of adding another function?
The idea with generic classes like CFluidModel is to have a concise abstract interface. Having specific functions that only a few subclasses implement defeats the purpose of a generic interface.

@@ -434,7 +434,7 @@ void CFVMFlowSolverBase<V, R>::Viscous_Residual_impl(unsigned long iEdge, CGeome
const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
const bool tkeNeeded = (config->GetKind_Turb_Model() == TURB_MODEL::SST);

CVariable* turbNodes = nullptr;
CVariable* turbNodes = nullptr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please setup your IDE to remove trailing spaces.

@@ -212,13 +212,43 @@ su2double CFluidScalar::ComputeMeanSpecificHeatCp(const su2double* val_scalars)
return mean_cp;
}

su2double CFluidScalar::ComputeEnthalpyFromT(const su2double val_temperature, const su2double* val_scalars){
su2double val_Enthalpy = Cp * (val_temperature - 298.15);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't T0 a config option? It is bad practice to hard code constants like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://ansyshelp.ansys.com/public/account/secured?returnurl=////Views/Secured/corp/v242/en/flu_th/flu_th_sec_hxfer_theory.html this is the theory related to the enthalpy equation for multicomponent gases. T_ref is always 298.15 K for this equation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then make it a constant, not a hard-coded value everywhere.

Comment on lines +283 to +287
val_Proj_Jac_Tensor[3][0] = val_scale * ((*val_temperature) * proj_vel / (*val_betainc2));
val_Proj_Jac_Tensor[3][1] = val_scale * ((*val_temperature) * val_normal[0] * (*val_density));
val_Proj_Jac_Tensor[3][2] = val_scale * ((*val_temperature) * val_normal[1] * (*val_density));
val_Proj_Jac_Tensor[3][3] =
val_scale * ((*val_temperature) * (*val_dRhodT) + (*val_density)) * proj_vel;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is happening here? Is temperature being used for enthalpy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the energy can be $C_{p}T$ or enthalpy. The enthalpy is used not the temperature.

Copy link
Member

@pcarruscag pcarruscag Jan 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then some renaming is in order and you need to come up with a better solution to switch between formulations than to have an if statement everytime Cp is used (for example making Cp=1, or encapsulating the computation of enthalpy in a function).

SU2_CFD/src/numerics/flow/convection/fds.cpp Show resolved Hide resolved
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.

2 participants