Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions SU2_CFD/include/variables/CSpeciesFlameletVariable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class CSpeciesFlameletVariable final : public CSpeciesVariable {
MatrixType lookup_scalar; /*!< \brief Vector of the source terms from the lookup table for each scalar equation */
su2vector<unsigned short> table_misses; /*!< \brief Vector of lookup table misses. */
MatrixType source_cons_jac; /*!< \brief Consumption-rate Jacobian dS_aux_i/dY_aux_i = source_cons_i, one column per user scalar. */
VectorType source_pv_jac; /*!< \brief Derivative of the progress variable source with respect to the progress variable. */

public:
/*!
Expand Down Expand Up @@ -102,4 +103,14 @@ class CSpeciesFlameletVariable final : public CSpeciesVariable {
inline su2double GetAuxSourceCons(unsigned long iPoint, unsigned long i_aux) const {
return source_cons_jac(iPoint, i_aux);
}

/*!
* \brief Store the derivative of the progress variable source with respect to the progress variable.
*/
inline void SetSourceJacobianPV(unsigned long iPoint, su2double val) { source_pv_jac(iPoint) = val; }

/*!
* \brief Get the derivative of the progress variable source with respect to the progress variable.
*/
inline su2double GetSourceJacobianPV(unsigned long iPoint) const { return source_pv_jac(iPoint); }
};
17 changes: 16 additions & 1 deletion SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,12 @@ void CSpeciesFlameletSolver::Source_Residual(CGeometry* geometry, CSolver** solv
/*--- Implicit: analytic Jacobian for auxiliary species from the split source form.
* S_aux_i = source_prod_i + source_cons_i * Y_aux_i
* dS_aux_i/dY_aux_i = source_cons_i
* J_ii += -source_cons_i * V ---*/
* J_ii += -source_cons_i * V
* The progress variable gets the decreasing part of its source, per unit of rho*PV. ---*/
if (implicit) {
const su2double density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(i_point);
const su2double dsource_dpv = fn->GetSourceJacobianPV(i_point);
Jacobian.AddVal2Diag(i_point, I_PROGVAR, fmax(0.0, -dsource_dpv) / density * volume);
for (auto i_aux = 0u; i_aux < n_aux; i_aux++) {
Jacobian.AddVal2Diag(i_point, n_CV + i_aux, -fn->GetAuxSourceCons(i_point, i_aux) * volume);
}
Expand Down Expand Up @@ -649,6 +653,17 @@ unsigned long CSpeciesFlameletSolver::SetScalarSources(const CConfig* config, CF
vector<su2double> source_scalar(flamelet_config_options.n_scalars);
for (auto iCV = 0u; iCV < flamelet_config_options.n_control_vars; iCV++) source_scalar[iCV] = table_sources[iCV];

/*--- Forward difference of the progress variable source, used only by the implicit Jacobian. ---*/
if ((config->GetKind_TimeIntScheme() == EULER_IMPLICIT) && !AD::TapeActive()) {
const su2double delta = 1e-6;
vector<su2double> scalars_pert = scalars;
scalars_pert[I_PROGVAR] += delta;
vector<su2double> sources_pert(table_sources.size());
fluid_model_local->EvaluateDataSet(scalars_pert, FLAMELET_LOOKUP_OPS::SOURCES, sources_pert);
const su2double dsource = (fmax(0, sources_pert[I_PROGVAR]) - table_sources[I_PROGVAR]) / delta;
Comment on lines +658 to +663

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Calculating the Jacobian of thermochemical variables should be done in the FlameletFluidModel class. When using MLP for example, the Jacobian can be calculated analytically.

static_cast<CSpeciesFlameletVariable*>(nodes)->SetSourceJacobianPV(iPoint, F * dsource);
}

/*--- Source term for the auxiliary species transport equations. ---*/
for (size_t i_aux = 0; i_aux < flamelet_config_options.n_user_scalars; i_aux++) {
/*--- The source term for the auxiliary equations consists of a production term and a consumption term:
Expand Down
1 change: 1 addition & 0 deletions SU2_CFD/src/variables/CSpeciesFlameletVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ CSpeciesFlameletVariable::CSpeciesFlameletVariable(const su2double* species_inf,
lookup_scalar.resize(nPoint, flamelet_config_options.n_lookups) = su2double(0.0);
table_misses.resize(nPoint) = 0;
source_cons_jac.resize(nPoint, flamelet_config_options.n_user_scalars) = su2double(0.0);
source_pv_jac.resize(nPoint) = su2double(0.0);

if (flamelet_config_options.preferential_diffusion) {
nAuxVar = FLAMELET_PREF_DIFF_SCALARS::N_BETA_TERMS;
Expand Down
2 changes: 1 addition & 1 deletion SU2_PY/SU2_MON
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
cd "$(dirname "$(readlink -f "$0")")" && python monitor.py "$@"
exec python "$(dirname "$(readlink -f "$0")")/monitor.py" "$@"
Loading
Loading