@@ -246,44 +246,44 @@ namespace model
246
246
};
247
247
}
248
248
249
- int GeneralRateParticle::residual (double t, unsigned int secIdx, double const * yPar, double const * yBulk, double const * yDotPar, double * resPar, columnPackingParameters packing, linalg::BandedEigenSparseRowIterator& jacIt, LinearBufferAllocator tlmAlloc, WithoutParamSensitivity)
249
+ int GeneralRateParticle::residual (double t, unsigned int secIdx, double const * yPar, double const * yBulk, double const * yDotPar, double * resPar, double * resBulk, columnPackingParameters packing, linalg::BandedEigenSparseRowIterator& jacIt, LinearBufferAllocator tlmAlloc, WithoutParamSensitivity)
250
250
{
251
251
if (resPar)
252
252
{
253
253
if (jacIt.data ())
254
- return residualImpl<double , double , double , true , true >(t, secIdx, yPar, yBulk, yDotPar, resPar, packing, jacIt, tlmAlloc);
254
+ return residualImpl<double , double , double , true , true >(t, secIdx, yPar, yBulk, yDotPar, resPar, resBulk, packing, jacIt, tlmAlloc);
255
255
else
256
- return residualImpl<double , double , double , false , true >(t, secIdx, yPar, yBulk, yDotPar, resPar, packing, jacIt, tlmAlloc);
256
+ return residualImpl<double , double , double , false , true >(t, secIdx, yPar, yBulk, yDotPar, resPar, resBulk, packing, jacIt, tlmAlloc);
257
257
}
258
258
else if (jacIt.data ())
259
- return residualImpl<double , double , double , true , false >(t, secIdx, yPar, yBulk, yDotPar, resPar, packing, jacIt, tlmAlloc);
259
+ return residualImpl<double , double , double , true , false >(t, secIdx, yPar, yBulk, yDotPar, resPar, resBulk, packing, jacIt, tlmAlloc);
260
260
else
261
261
return -1 ;
262
262
}
263
- int GeneralRateParticle::residual (double t, unsigned int secIdx, double const * yPar, double const * yBulk, double const * yDotPar, active* resPar, columnPackingParameters packing, linalg::BandedEigenSparseRowIterator& jacIt, LinearBufferAllocator tlmAlloc, WithParamSensitivity)
263
+ int GeneralRateParticle::residual (double t, unsigned int secIdx, double const * yPar, double const * yBulk, double const * yDotPar, active* resPar, active* resBulk, columnPackingParameters packing, linalg::BandedEigenSparseRowIterator& jacIt, LinearBufferAllocator tlmAlloc, WithParamSensitivity)
264
264
{
265
265
if (jacIt.data ())
266
- return residualImpl<double , active, active, true , true >(t, secIdx, yPar, yBulk, yDotPar, resPar, packing, jacIt, tlmAlloc);
266
+ return residualImpl<double , active, active, true , true >(t, secIdx, yPar, yBulk, yDotPar, resPar, resBulk, packing, jacIt, tlmAlloc);
267
267
else
268
- return residualImpl<double , active, active, false , true >(t, secIdx, yPar, yBulk, yDotPar, resPar, packing, jacIt, tlmAlloc);
268
+ return residualImpl<double , active, active, false , true >(t, secIdx, yPar, yBulk, yDotPar, resPar, resBulk, packing, jacIt, tlmAlloc);
269
269
}
270
- int GeneralRateParticle::residual (double t, unsigned int secIdx, active const * yPar, active const * yBulk, double const * yDotPar, active* resPar, columnPackingParameters packing, linalg::BandedEigenSparseRowIterator& jacIt, LinearBufferAllocator tlmAlloc, WithoutParamSensitivity)
270
+ int GeneralRateParticle::residual (double t, unsigned int secIdx, active const * yPar, active const * yBulk, double const * yDotPar, active* resPar, active* resBulk, columnPackingParameters packing, linalg::BandedEigenSparseRowIterator& jacIt, LinearBufferAllocator tlmAlloc, WithoutParamSensitivity)
271
271
{
272
272
if (jacIt.data ())
273
- return residualImpl<active, active, double , true , true >(t, secIdx, yPar, yBulk, yDotPar, resPar, packing, jacIt, tlmAlloc);
273
+ return residualImpl<active, active, double , true , true >(t, secIdx, yPar, yBulk, yDotPar, resPar, resBulk, packing, jacIt, tlmAlloc);
274
274
else
275
- return residualImpl<active, active, double , false , true >(t, secIdx, yPar, yBulk, yDotPar, resPar, packing, jacIt, tlmAlloc);
275
+ return residualImpl<active, active, double , false , true >(t, secIdx, yPar, yBulk, yDotPar, resPar, resBulk, packing, jacIt, tlmAlloc);
276
276
}
277
- int GeneralRateParticle::residual (double t, unsigned int secIdx, active const * yPar, active const * yBulk, double const * yDotPar, active* resPar, columnPackingParameters packing, linalg::BandedEigenSparseRowIterator& jacIt, LinearBufferAllocator tlmAlloc, WithParamSensitivity)
277
+ int GeneralRateParticle::residual (double t, unsigned int secIdx, active const * yPar, active const * yBulk, double const * yDotPar, active* resPar, active* resBulk, columnPackingParameters packing, linalg::BandedEigenSparseRowIterator& jacIt, LinearBufferAllocator tlmAlloc, WithParamSensitivity)
278
278
{
279
279
if (jacIt.data ())
280
- return residualImpl<active, active, active, true , true >(t, secIdx, yPar, yBulk, yDotPar, resPar, packing, jacIt, tlmAlloc);
280
+ return residualImpl<active, active, active, true , true >(t, secIdx, yPar, yBulk, yDotPar, resPar, resBulk, packing, jacIt, tlmAlloc);
281
281
else
282
- return residualImpl<active, active, active, false , true >(t, secIdx, yPar, yBulk, yDotPar, resPar, packing, jacIt, tlmAlloc);
282
+ return residualImpl<active, active, active, false , true >(t, secIdx, yPar, yBulk, yDotPar, resPar, resBulk, packing, jacIt, tlmAlloc);
283
283
}
284
284
285
285
template <typename StateType, typename ResidualType, typename ParamType, bool wantNonLinJac, bool wantRes>
286
- int GeneralRateParticle::residualImpl (double t, unsigned int secIdx, StateType const * yPar, StateType const * yBulk, double const * yDotPar, ResidualType* resPar, columnPackingParameters packing, linalg::BandedEigenSparseRowIterator& jacIt, LinearBufferAllocator tlmAlloc)
286
+ int GeneralRateParticle::residualImpl (double t, unsigned int secIdx, StateType const * yPar, StateType const * yBulk, double const * yDotPar, ResidualType* resPar, ResidualType* resBulk, columnPackingParameters packing, linalg::BandedEigenSparseRowIterator& jacIt, LinearBufferAllocator tlmAlloc)
287
287
{
288
288
int const * const qsBinding = _binding->reactionQuasiStationarity ();
289
289
const parts::cell::CellParameters cellResParams = makeCellResidualParams (qsBinding, _parDiffOp->nBound ());
@@ -315,9 +315,25 @@ namespace model
315
315
jacIt += stridePoint ();
316
316
}
317
317
318
+ // particle diffusion, including film diffusion boundary condition
318
319
ResidualType* wantResPtr = wantRes ? resPar : nullptr ;
319
320
linalg::BandedEigenSparseRowIterator jacSafe = wantNonLinJac ? jacBase : linalg::BandedEigenSparseRowIterator{};
320
- return _parDiffOp->residual (t, secIdx, yPar, yBulk, yDotPar, wantResPtr, jacSafe, typename ParamSens<ParamType>::enabled ());
321
+ _parDiffOp->residual (t, secIdx, yPar, yBulk, yDotPar, wantResPtr, jacSafe, typename ParamSens<ParamType>::enabled ());
322
+
323
+ // film diffusion bulk eq. term
324
+ active const * const filmDiff = _parDiffOp->getFilmDiffusion (secIdx);
325
+ const ParamType invBetaC = 1.0 / static_cast <ParamType>(packing.colPorosity ) - 1.0 ;
326
+ const ParamType jacCF_val = invBetaC * static_cast <ParamType>(surfaceToVolumeRatio ());
327
+ const ParamType jacPF_val = -1.0 / static_cast <ParamType>(getPorosity ());
328
+
329
+ // Add flux to column void / bulk volume
330
+ for (unsigned int comp = 0 ; comp < _nComp; ++comp)
331
+ {
332
+ // + 1/Beta_c * (surfaceToVolumeRatio_{p,j}) * d_j * (k_f * [c_l - c_p])
333
+ resBulk[0 ] += static_cast <ParamType>(filmDiff[comp]) * jacCF_val * static_cast <ParamType>(packing.parTypeVolFrac [0 ]) * (yBulk[0 ] - yPar[(nDiscPoints () - 1 ) * stridePoint () + comp]);
334
+ }
335
+
336
+ return 0 ;
321
337
}
322
338
323
339
unsigned int GeneralRateParticle::jacobianNNZperParticle () const
0 commit comments