Skip to content

Commit

Permalink
Fix CSTR time derivative Jacobian (#310)
Browse files Browse the repository at this point in the history
Co-authored-by: Jan Breuer <[email protected]>
  • Loading branch information
AntoniaBerger and jbreue16 authored Nov 12, 2024
1 parent d34b5d7 commit 941bb69
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/libcadet/model/StirredTankModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1824,8 +1824,8 @@ void CSTRModel::addTimeDerivativeJacobian(double t, double alpha, const ConstSim
double const* const c = simState.vecStateY + _nComp;
double const* const q = simState.vecStateY + 2 * _nComp;
const double v = simState.vecStateY[2 * _nComp + _totalBound];
const double vsolid = static_cast<double>(_constSolidVolume);
const double timeV = v * alpha;
const double timeVSolid = static_cast<double>(_constSolidVolume) * alpha;

// Assemble Jacobian: dRes / dyDot

Expand All @@ -1839,7 +1839,7 @@ void CSTRModel::addTimeDerivativeJacobian(double t, double alpha, const ConstSim
{
double const* const qi = q + _offsetParType[type] + _boundOffset[type * _nComp + i];
const unsigned int localOffset = _nComp + _offsetParType[type] + _boundOffset[type * _nComp + i];
const double vSolidParVolFrac = vsolid * static_cast<double>(_parTypeVolFrac[type]);
const double vSolidParVolFrac = timeVSolid * static_cast<double>(_parTypeVolFrac[type]);
for (unsigned int j = 0; j < _nBound[type * _nComp + i]; ++j)
{
mat.native(i, localOffset + j) += vSolidParVolFrac; // dRes / dqDot
Expand All @@ -1851,7 +1851,7 @@ void CSTRModel::addTimeDerivativeJacobian(double t, double alpha, const ConstSim
}
}

mat.native(i, _nComp + _totalBound) += alpha * c[i]; // dRes / dV
mat.native(i, _nComp + _totalBound) += alpha * c[i]; // dRes / dVlDot
}

// Bound states
Expand Down

0 comments on commit 941bb69

Please sign in to comment.