You're reading the documentation for a development version. For the latest stable documentation, please have a look at v5.1.X.

Particle models#

A particle model describes the pore liquid and the solid phase of one particle type and hosts its binding and reaction models. Column models and the stirred tank hold one cadet::model::IParticleModel per particle type. The transport inside the particle is delegated to a particle diffusion operator, which combines the diffusion model with its spatial discretization.

Interface#

class IParticleModel#
[source]

Implements the particle model interface.

Subclassed by cadet::model::GeneralRateParticle, cadet::model::HomogeneousParticle, cadet::model::LiquidEquilibriumParticle

Public Functions

inline IParticleModel()#
[source]
inline virtual ~IParticleModel() noexcept#
[source]
virtual bool configureModelDiscretization(IParameterProvider &paramProvider, const IConfigHelper &helper, const int nComp, const int parTypeIdx, const int nParType, const int strideBulkComp) = 0#
[source]
virtual bool configure(UnitOpIdx unitOpIdx, IParameterProvider &paramProvider, std::unordered_map<ParameterId, active*> &parameters, const int nParType, const unsigned int *nBoundBeforeType, const int nTotalBound, bool uoImplementsReqReactions) = 0#
[source]

Configures the particle model.

Parameters:

uoImplementsReqReactions – [in] Whether the owning unit operation implements rapid-equilibrium reactions in the particle liquid phase. A particle model is shared between unit operations, so only its owner can answer this.

virtual void updateRadialDisc() = 0#
[source]
virtual parts::cell::CellParameters makeCellResidualParams(int const *qsReaction, unsigned int const *nBound) const = 0#
[source]
virtual bool notifyDiscontinuousSectionTransition(double t, unsigned int secIdx) = 0#
[source]

Notifies the operator that a discontinuous section transition is in progress.

Parameters:
  • t – [in] Current time point

  • secIdx – [in] Index of the new section that is about to be integrated

Returns:

true if flow direction has changed, otherwise false

virtual int 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) = 0#
[source]

Computes the residual of the particle equations and updates nonlinear Jacobian entries.

Parameters:
  • t – [in] Current time point

  • secIdx – [in] Index of the current section

  • yPar – [in] Pointer to particle phase entry in unit state vector

  • yBulk – [in] Pointer to corresponding bulk phase entry in unit state vector

  • yDotPar – [in] Pointer to particle phase derivative entry in unit state vector

  • resPar – [out] Pointer Pointer to particle phase entry in unit residual vector, nullptr if no residual shall be computed

  • packing – [out] column packing parameters

  • jacIt – [in] Row iterator pointing to the particle phase entry in the unit Jacobian, uninitialized if no Jacobian shall be computed, otherwise only non-linear Jacobian entries will be added

  • tlmAlloc – [in] memory allocator

Returns:

0 on success, -1 on non-recoverable error, and +1 on recoverable error

virtual int 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) = 0#
[source]
virtual int 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) = 0#
[source]
virtual int 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) = 0#
[source]
virtual double relativeCoordinate(const unsigned int nodeIdx) const noexcept = 0#
[source]
virtual active surfaceToVolumeRatio() const noexcept = 0#
[source]
inline IBindingModel *getBinding() const noexcept#
[source]
inline bool bindingParDep() const noexcept#
[source]
inline const ReactionSystem *getReaction() const noexcept#
[source]
inline bool reactionParDep() const noexcept#
[source]
inline virtual const active &getPorosity() const noexcept = 0#
[source]
inline virtual const active *getPoreAccessFactor() const noexcept = 0#
[source]
inline virtual const active *getFilmDiffusion(const unsigned int secIdx) const noexcept = 0#
[source]
inline virtual int nDiscPoints() const noexcept = 0#
[source]

total number discrete points per particle

inline virtual int strideParBlock() const noexcept = 0#
[source]

stride over one particle

virtual int writeParticleCoordinates(double *coords) const = 0#
[source]

computes the physical particle coordinates for every spatial point

virtual void setParJacPattern(std::vector<Eigen::Triplet<double>> &tripletList, const unsigned int offsetPar, const unsigned int offsetBulk, unsigned int colNode, unsigned int secIdx, const bulkFilmTransfer &bulkFilm) const = 0#
[source]

sets the particle sparsity pattern wrt the global Jacobian

virtual unsigned int jacobianNNZperParticle() const = 0#
[source]
virtual int calcParticleDiffJacobian(const int secIdx, const int colNode, const int offsetLocalCp, Eigen::SparseMatrix<double, Eigen::RowMajor> &globalJac) = 0#
[source]

analytically calculates the static (per section) particle diffusion Jacobian

Returns:

1 if jacobain calculation fits the predefined pattern of the jacobian, 0 if not.

virtual int calcFilmDiffJacobian(unsigned int secIdx, const int offsetCp, const int offsetC, const int nBulkPoints, const int nParType, const bulkFilmTransfer &bulkFilm, const active *const parTypeVolFrac, const active *const pointVelocity, Eigen::SparseMatrix<double, Eigen::RowMajor> &globalJac, bool crossDepsOnly = false) = 0#
[source]

calculates the film diffusion Jacobian

Parameters:
  • bulkFilm – [in] bulk side operator of the film transfer term

  • parTypeVolFrac – [in] pointer to the particle type volume fractions in column-position-major order

  • pointVelocity – [in] pointer to the interstitial velocity at each bulk point (size nBulkPoints), used to evaluate FILM_DIFFUSION_DEP

Returns:

1 if jacobain calculation fits the predefined pattern of the jacobian, 0 if not

virtual void bulkFilmTransferCoefficients(unsigned int secIdx, active const *const pointVelocity, const int nBulkPoints, active *filmDiffusion) const = 0#
[source]

Film transfer coefficient of the bulk side flux at each discrete bulk point.

Returns the factor that multiplies \( c^{\mathrm{b}} - c^{\mathrm{p}} \) in the bulk side film transfer flux, i.e. FILM_DIFFUSION including its velocity dependence and, where the particle discretization calls for it, its discretized counterpart. The bulk transport operator needs it to assemble the bulk side operator of the term, see bulkFilmTransfer.

Parameters:
  • pointVelocity – [in] Interstitial velocity at each bulk point (size nBulkPoints)

  • filmDiffusion – [out] nBulkPoints * nComp coefficients, bulk point major

virtual bool setParameter(const ParameterId &pId, double value) = 0#
[source]
virtual bool setParameter(const ParameterId &pId, int value) = 0#
[source]
virtual bool setParameter(const ParameterId &pId, bool value) = 0#
[source]
virtual bool setSensitiveParameter(std::unordered_set<active*> &sensParams, const ParameterId &pId, unsigned int adDirection, double adValue) = 0#
[source]
virtual bool setSensitiveParameterValue(const std::unordered_set<active*> &sensParams, const ParameterId &pId, double value) = 0#
[source]
virtual bool hasParameter(const ParameterId &pId) const = 0#
[source]
virtual double getParameterDouble(const ParameterId &pId) const = 0#
[source]
virtual std::unordered_map<ParameterId, double> getAllParameterValues(std::unordered_map<ParameterId, double> &data) const = 0#
[source]
inline virtual void setBulkRowOffset(int offset) noexcept#
[source]

Sets the distance from the bound states of this particle type back to the liquid phase they bind to.

Only a particle in rapid equilibrium binds to a liquid phase that is not adjacent to its bound states in the state vector. Every other particle model has its own particle liquid phase directly in front of its bound states and ignores this.

virtual bool leanConsistentInitialStateValidity() const = 0#
[source]
virtual bool leanConsistentInitialTimeDerivativeValidity() const = 0#
[source]
inline unsigned int *nBound() noexcept#
[source]
virtual bool isParticleLumped() const noexcept = 0#
[source]

Particle diffusion operators#

class ParticleDiffusionOperatorBase#
[source]

Subclassed by cadet::model::parts::ParticleDiffusionOperatorDG, cadet::model::parts::ParticleDiffusionOperatorFV

Public Functions

virtual bool configureModelDiscretization(IParameterProvider &paramProvider, const IConfigHelper &helper, const int nComp, const int parTypeIdx, const int nParType, const int strideBulkComp) = 0#
[source]

Sets fixed parameters of the particle diffusion operator (e.g., the number of discretization points, components, bound states).

This function is called prior to configure() by the underlying model. It can only be called once. Whereas non-structural model parameters (e.g., rate constants) are configured by configure(), this function sets structural parameters (e.g., number of components and bound states).

Parameters:
  • paramProvider – [in] Parameter provider

  • helper – [in] Configuration helper

  • nComp – [in] Number of components

  • parTypeIdx – [in] particle type index of this operator in the unit operation that owns it

  • nParType – [in] Number of particle types in unit operation that owns this operator

  • strideBulkComp – [in] Stride of bulk components in the unit state vector

virtual bool configure(UnitOpIdx unitOpIdx, IParameterProvider &paramProvider, std::unordered_map<ParameterId, active*> &parameters, const int nParType, const unsigned int *nBoundBeforeType, const int nTotalBound, const int *reqBinding) = 0#
[source]

Configures the model by extracting all non-structural parameters (e.g., model parameters) from the given paramProvider.

The scope of the cadet::IParameterProvider is left unchanged on return.

     The structure of the model is left unchanged, that is, the number of degrees of
     freedom stays the same (e.g., number of bound states is left unchanged). Only
     true (non-structural) model parameters are read and changed.

     This function may only be called if configureModelDiscretization() has been called
     in the past. Contrary to configureModelDiscretization(), it can be called multiple
     times.

Parameters:

paramProvider – [in] Parameter provider

Returns:

true if the configuration was successful, otherwise false

virtual void updateRadialDisc() = 0#
[source]

updates radial discretization operators based on configured parameters

virtual bool notifyDiscontinuousSectionTransition(double t, unsigned int secIdx) = 0#
[source]

Notifies the operator that a discontinuous section transition is in progress.

Parameters:
  • t – [in] Current time point

  • secIdx – [in] Index of the new section that is about to be integrated

Returns:

true if flow direction has changed, otherwise false

virtual int residual(double t, unsigned int secIdx, double const *yPar, double const *yBulk, double const *yDotPar, double *resPar, const ColumnPosition &colPos, const active &velocity, linalg::BandedEigenSparseRowIterator &jacIt, WithoutParamSensitivity) = 0#
[source]

Computes the residual of the transport equations.

Parameters:
  • t – [in] Current time point

  • secIdx – [in] Index of the current section

  • yPar – [in] Pointer to particle phase entry in unit state vector

  • yBulk – [in] Pointer to corresponding bulk phase entry in unit state vector

  • yDotPar – [in] Pointer to particle phase derivative entry in unit state vector

  • resPar – [out] Pointer Pointer to particle phase entry in unit residual vector, nullptr if no residual shall be computed

  • colPos – [in] Column position of this particle, needed to evaluate FILM_DIFFUSION_DEP

  • velocity – [in] Interstitial velocity at colPos, needed to evaluate FILM_DIFFUSION_DEP

  • jacIt – [in] Row iterator pointing to the particle phase entry in the unit Jacobian, uninitialized if no Jacobian shall be computed

Returns:

0 on success, -1 on non-recoverable error, and +1 on recoverable error

virtual void setParticleJacobianPattern(std::vector<Eigen::Triplet<double>> &tripletList, unsigned int offsetPar, unsigned int offsetBulk, unsigned int colNode, unsigned int secIdx, const bulkFilmTransfer &bulkFilm) = 0#
[source]

adds the solid time derivative and binding pattern to the list

virtual int writeParticleCoordinates(double *coords) const = 0#
[source]

calculates and returns the physical particle coordinates according to the discretization

virtual double relativeCoordinate(const unsigned int nodeIdx) const = 0#
[source]

calculates and returns the relative particle coordinate in [0, 1] for the given node index

virtual unsigned int jacobianNNZperParticle() const = 0#
[source]

Number of non-zero Jacobian entries occuring from a single particle of this type.

includes intra-particle entries and film diffusion entries

inline std::shared_ptr<unsigned int[]> nBound() noexcept#
[source]

array with number of bound states for each component

inline unsigned int *offsetBoundComp() const noexcept#
[source]

array with offsets to the first bound state of each component in the solid phase

inline unsigned int offsetBoundComp(ComponentIndex comp) const noexcept#
[source]

offset to the first bound state

inline unsigned int strideBound() const noexcept#
[source]

total number of bound states

inline int nDiscPoints() const noexcept#
[source]

total number discrete points per particle

template<typename ParamType>
inline active modifiedFilmDiffusion(unsigned int secIdx, unsigned int comp, const ColumnPosition &colPos, const ParamType &velocity) const#

Returns the film diffusion coefficient for a given component, position, and (velocity-dependent) parameter dependence.

Evaluates FILM_DIFFUSION_DEP (defaults to CONSTANT_ONE, i.e. no dependence) pointwise at the given normalized column position and interstitial velocity, mirroring how COL_DISPERSION_DEP is evaluated pointwise in the bulk operator (see ConvectionDispersionOperator{FV,DG}). The caller (unit operation) is responsible for supplying the local velocity, since only it has access to the bulk operator.

inline virtual active discretizedFilmDiffusionFactor(const unsigned int secIdx, const int comp, const ColumnPosition &colPos, const active &velocity) const noexcept#
[source]

Returns the discretization dependent correction factor of the film diffusion coefficient.

The bulk phase film diffusion flux is computed as factor * modifiedFilmDiffusion() * (c^b - c^p). The factor must be evaluated with the same (section and FILM_DIFFUSION_DEP dependent) coefficients that the particle side boundary condition uses, otherwise both sides of the flux disagree.