Skip to content

Commit

Permalink
Fix nBin check
Browse files Browse the repository at this point in the history
  • Loading branch information
jbreue16 committed Dec 19, 2024
1 parent 1d6bfd9 commit dedd7d3
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/libcadet/model/reaction/CrystallizationReaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,16 +470,9 @@ class CrystallizationReaction : public IDynamicReactionModel
{
readScalarParameterOrArray(_bins, paramProvider, "CRY_BINS", 1);

if (_usePBM)
{
if (_bins.size() != _nBins + 2)
throw InvalidParameterException("Expected CRY_BINS to have " + std::to_string(_nBins + 2) + " elements (got " + std::to_string(_bins.size()) + ")");
}
else
{

if (_bins.size() != _nBins + 1)
throw InvalidParameterException("Expected CRY_BINS to have " + std::to_string(_nBins + 1) + " elements (got " + std::to_string(_bins.size()) + ")");
}

registerParam1DArray(_parameters, _bins, [=](bool multi, unsigned int idx) { return makeParamId(hashString("CRY_BINS"), unitOpIdx, CompIndep, ParTypeIndep, BoundStateIndep, idx, SectionIndep); });

Expand Down Expand Up @@ -992,9 +985,8 @@ class CrystallizationReaction : public IDynamicReactionModel

const StateType sParam = (cadet_likely(y[0] / y[_nComp - 1] - 1.0 > 0)) ? y[0] / y[_nComp - 1] - 1.0 : 0.0; // s = (c_0 - c_eq) / c_eq = c_0 / c_eq - 1, rewrite it to zero if s drops below 0
const ParamType massDensityShapeFactor = static_cast<ParamType>(_nucleiMassDensity) * static_cast<ParamType>(_volShapeFactor);
const ResidualType k_g_times_s_g = static_cast<ParamType>(_growthRateConstant) * pow(sParam, static_cast<ParamType>(_g));
k_g_times_s_g = static_cast<ParamType>(_growthRateConstant) * pow(sParam, static_cast<ParamType>(_g));

ResidualType MParam = 0.0;
ResidualType substrateConversion = 0.0;

for (int i = 0; i < _nBins; ++i)
Expand All @@ -1012,7 +1004,6 @@ class CrystallizationReaction : public IDynamicReactionModel
// mass balance
res[0] -= factor * massDensityShapeFactor * (B_0 * x_c_3 + substrateConversion);

ResidualType v_g = 0.0;

// growth flux reconstruction
switch (_growthSchemeOrder)
Expand Down Expand Up @@ -1065,6 +1056,11 @@ class CrystallizationReaction : public IDynamicReactionModel
StateType const* const yCrystal = y;
ResidualType* const resCrystal = res;

// define and initialize mass balance and its discretization related parameters
ResidualType MParam = 0.0;
ResidualType v_g = 0.0;
ResidualType k_g_times_s_g = 0.0;

// define aggregation/fragmentation related local parameters
ResidualType source = 0.0;
ResidualType sink = 0.0;
Expand Down

0 comments on commit dedd7d3

Please sign in to comment.