Skip to content

Commit

Permalink
change jacobian impl
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoniaBerger committed Dec 18, 2024
1 parent e21fb9a commit 1765bfd
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/libcadet/model/StirredTankModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1329,31 +1329,45 @@ int CSTRModel::residualImpl(double t, unsigned int secIdx, StateType const* cons
{
resCMoities[comp] = _MconvMoityBulk.row(MoityIdx) * resC[comp];
MoityIdx++;

if (wantJac)
_jac.native(comp, _nComp + _totalBound) = 0; // dF_{Vliquid}/dci = 0

}
else if (comp < _nComp - nmoities)
{
resCMoities[comp] += v * flux[comp];

if (wantJac)
_jac.native(comp, _nComp + _totalBound) = static_cast<double>(flux[comp]); // dF/dci = v_liquid

}

else if(comp > _nComp - nmoities)
{
resCMoities[comp] = v * flux[comp];

if (wantJac)
_dynReactionBulk->analyticJacobianLiquidAdd(t, secIdx, colPos, reinterpret_cast<double const*>(c), -static_cast<double>(v), _jac.row(0), subAlloc);
}
}

Eigen::Map<Vector<ResidualType, Dynamic>> mapResC(resC, _nComp);
mapResC = resCMoities;

}
else
{
for (unsigned int comp = 0; comp < _nComp; ++comp)
resC[comp] += v * flux[comp];
}

if (wantJac)
{
for (unsigned int comp = 0; comp < _nComp; ++comp)
_jac.native(comp, _nComp + _totalBound) += static_cast<double>(flux[comp]); // dF/dvliquid = flux

if (wantJac)
{
for (unsigned int comp = 0; comp < _nComp; ++comp)
_jac.native(comp, _nComp + _totalBound) += static_cast<double>(flux[comp]); // dF/dvliquid = flux

_dynReactionBulk->analyticJacobianLiquidAdd(t, secIdx, colPos, reinterpret_cast<double const*>(c), -static_cast<double>(v), _jac.row(0), subAlloc);
_dynReactionBulk->analyticJacobianLiquidAdd(t, secIdx, colPos, reinterpret_cast<double const*>(c), -static_cast<double>(v), _jac.row(0), subAlloc);
}
}
}

Expand Down

0 comments on commit 1765bfd

Please sign in to comment.