Skip to content

Commit

Permalink
Prevent use of FlowReactor sensitivity analysis
Browse files Browse the repository at this point in the history
Some implementation issues are fixed here, but the sensitivities
currently do not match finite difference comparisons.
  • Loading branch information
speth authored and ischoegl committed Jun 14, 2023
1 parent 4cb4e18 commit 1f5a8c7
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
11 changes: 1 addition & 10 deletions include/cantera/zeroD/FlowReactor.h
Expand Up @@ -38,16 +38,7 @@ class FlowReactor : public IdealGasReactor
throw NotImplementedError("FlowReactor::eval");
}

/*!
* Evaluate the reactor governing equations. Called by ReactorNet::eval.
* @param[in] t time.
* @param[in] y solution vector, length neq()
* @param[in] ydot rate of change of solution vector, length neq()
* @param[in] params sensitivity parameter vector, length ReactorNet::nparams()
* @param[out] residual residuals vector, length neq()
*/
void evalDae(double t, double* y, double* ydot, double* params,
double* residual) override;
void evalDae(double t, double* y, double* ydot, double* residual) override;

//! Given a vector of length neq(), mark which variables should be
//! considered algebraic constraints
Expand Down
5 changes: 1 addition & 4 deletions include/cantera/zeroD/Reactor.h
Expand Up @@ -125,12 +125,9 @@ class Reactor : public ReactorBase
* @param[in] t time.
* @param[in] y solution vector, length neq()
* @param[in] ydot rate of change of solution vector, length neq()
* @param[in] params sensitivity parameter vector, length ReactorNet::nparams()
* @param[out] residual residuals vector, length neq()
*/
virtual void evalDae(double t, double* y, double* ydot, double* params,
double* residual)
{
virtual void evalDae(double t, double* y, double* ydot, double* residual) {
throw NotImplementedError("Reactor::evalDae");
}

Expand Down
11 changes: 11 additions & 0 deletions src/numerics/IdasIntegrator.cpp
Expand Up @@ -307,6 +307,17 @@ void IdasIntegrator::initialize(double t0, FuncEval& func)
if (flag != IDA_SUCCESS) {
throw CanteraError("IdasIntegrator::initialize", "IDASetUserData failed.");
}
if (func.nparams() > 0) {
throw CanteraError("IdasIntegrator::initialize", "Sensitivity analysis "
"for DAE systems is not fully implemented");
sensInit(t0, func);
flag = IDASetSensParams(m_ida_mem, func.m_sens_params.data(),
func.m_paramScales.data(), NULL);
if (flag != IDA_SUCCESS) {
throw CanteraError("IdasIntegrator::initialize",
"IDASetSensParams failed.");
}
}
applyOptions();
}

Expand Down
3 changes: 1 addition & 2 deletions src/zeroD/FlowReactor.cpp
Expand Up @@ -237,8 +237,7 @@ void FlowReactor::updateSurfaceState(double* y)
}
}

void FlowReactor::evalDae(double time, double* y, double* ydot, double* params,
double* residual)
void FlowReactor::evalDae(double time, double* y, double* ydot, double* residual)
{
m_thermo->restoreState(m_state);

Expand Down
4 changes: 3 additions & 1 deletion src/zeroD/ReactorNet.cpp
Expand Up @@ -327,7 +327,9 @@ void ReactorNet::evalDae(double t, double* y, double* ydot, double* p, double* r
m_time = t;
updateState(y);
for (size_t n = 0; n < m_reactors.size(); n++) {
m_reactors[n]->evalDae(t, y, ydot, p, residual);
m_reactors[n]->applySensitivity(p);
m_reactors[n]->evalDae(t, y, ydot, residual);
m_reactors[n]->resetSensitivity(p);
}
checkFinite("ydot", ydot, m_nv);
}
Expand Down

0 comments on commit 1f5a8c7

Please sign in to comment.