/*---------------------------------------------------------------------------*\
  ==  == ====== ====   ====    |
                    \\     ||  | Multiphase Code Repository by HZDR
  ======   //   ||  || ===//   | Website: https://doi.org/10.14278/rodare.767
  ||  ||  //    ||  // || \\   | License: GPL-3.0-or-later
  ==  == ====== ====   ==  ==  |
-------------------------------------------------------------------------------
License
    This file is part of the Multiphase Code Repository by HZDR.

    Copyright (C) 2025 by Helmholtz-Zentrum Dresden-Rossendorf e.V. (HZDR),
    Website: https://hzdr.de

    Multiphase Code Repository by HZDR is based on the free software for
    computational fluid dynamics (CFD) from the OpenFOAM Foundation.
    Copyright (C) 2025 by OpenFOAM Foundation, Website: https://openfoam.org

    If you are interested in which files are original OpenFOAM Foundation
    files, which OpenFOAM Foundation files were modified, and which files were
    newly created, see FILES.md.

    Multiphase Code Repository by HZDR is free software: you can redistribute
    it and/or modify it under the terms of the GNU General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or (at your option) any later version.

    Multiphase Code Repository by HZDR is distributed in the hope that it will
    be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
    Public License for more details.

    You should have received a copy of the GNU General Public License along
    with the Multiphase Code Repository by HZDR. If not, see
    <http://www.gnu.org/licenses/>.

Class
    Foam::fv::BhutaniBritoParada

Description
    Bhutani and Brito-Parada (2020) model for bubble-particle attachment.

    This model determines the net attachment/detachment rate based on the
    flotation kinetics:

    1- Collision frequency \f$Z\f$ is dependent on the bubble and particle
    sizes. If both are larger than their corresponding critical sizes, then the
    bubble and particle velocities are considered uncorrelated and the
    relationship proposed by Abrahamson (1975) (Eq. 15) is used. Otherwise, the
    velocities are correlated and the relationship proposed by Saffman and
    Turner (1956) (Eq. 1) is used.

    2- Detachment frequency \f$Z^{'}\f$ is modelled according to Bloom and
    Heindel (2002) (Eq. 38).

    3- Collision probability \f$P_{C}\f$ is modelled according to Yoon and
    Luttrell (1989) for intermediate Reynolds number flow (Eq. 19).

    4- Adhesion probability \f$P_{A}\f$ is modelled according to Yoon and
    Luttrell (1989) for Stokes flow (Eq. 28) based on the induction time, which
    is estimated from the induction angle.

    5- Stabilisation probability \f$P_{S}\f$ is modelled according to Schulze
    (1993) (Eq. 93) using a modified Bond number \f$Bo\f$. Bloom and Heindel
    (2003) (Eq. 33) suggested an empirical constant \f$A_{S}\f$ to correct the
    correlation, which is also included here.

    Physically, attachment occurs only if the capacity of the surface allows.
    The maximum surface loading is controlled by the parameter "maxLoading", and
    the number density of available carrier species.

    For numerical stability and accuracy, attachment occurs only when three
    conditions are fulfilled:

    1- if the volume fraction of the detached phase is larger than
    residualAlpha of the detached phase

    2- if mass of the detached phase is larger than or equals to
    the mass being transferred

    3- if the volume fraction of the aggregate phase is 10 times larger than
    its residualAlpha

    Note: the model can only be applied for the attachment of a single species.
    Therefore, the list of species consists of a single phase only. Please note,
    that the following interface is required:
    <detachedPhase>_dispersedIn_<aggregatePhase> .

Usage
    \table
        Property       | Description                    | Required | Default
        species        | Name of species changing phase | yes      | -
        carrierSpecie | Name of carrier specie         | yes      | -
        maxLoading     | The maximum surface loading    | no       | 1
        stability      | Include the stability factor   | no       | yes
        detachment     | Include the detachemnt rate    | no       | yes
        theta          | Induction angle in degrees     | no       | 75
        B              | Empirical parameter            | no       | 0.6
        C              | Empirical parameter            | no       | 2
        As             | Empirical parameter            | no       | 1
        residualAlpha  | Residual for aggregate phase   | no      | 10*res.Alpha
    \endtable

    Reference:
    \verbatim
        Bhutani, G., & Brito-Parada, R. P. (2020).
        A framework for polydisperse pulp phase modelling in flotation.
        Separation and Purification Technology, 236, 116252.
    \endverbatim

SourceFiles
    BhutaniBritoParada.C

\*---------------------------------------------------------------------------*/

#ifndef BhutaniBritoParada_H
#define BhutaniBritoParada_H

#include "attachmentModel.H"
#include "phaseCompressibleMomentumTransportModel.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

namespace fv
{

/*---------------------------------------------------------------------------*\
                     Class BhutaniBritoParada Declaration
\*---------------------------------------------------------------------------*/

class BhutaniBritoParada
:
    public attachmentModel
{
private:

    // Private Data

        //- Const reference to the continuous phase
        const phaseModel& continuousPhase_;

        //- Continuous phase momentum transport model
        const phaseCompressible::momentumTransportModel& continuousTurbulence_;

        //- Whether stability probability is included in attachment
        const Switch stability_;

        //- Whether detachment is activated
        const Switch detachment_;

        //- Contact angle in degrees
        const scalar theta_;

        //- Empirical parameter for induction time
        const scalar B_;

        //- Empirical parameter for detachment frequency
        const scalar C_;

        //- Empirical parameter for stabilisation probability
        const scalar As_;

        //- Attachment mass rate
        mutable volScalarField Psi_;

        //- Collision rate
        mutable volScalarField Z_;

        //- Detachment frequency
        mutable volScalarField ZPrime_;

        //- Collision probability
        mutable volScalarField Pc_;

        //- Adhesion probability
        mutable volScalarField Pa_;

        //- Stability probability
        mutable volScalarField Ps_;


    // Private Member Functions

        //- Critical diameter of bubble/particle
        inline tmp<volScalarField> dCrit
        (
            const volScalarField& nu,
            const volScalarField& k,
            const volScalarField& eps,
            const volScalarField& rhoC,
            const volScalarField& rhoD
        ) const;

        //- Fluctuating velocity of bubble/particle
        inline tmp<volScalarField> uPrime
        (
            const volScalarField& d,
            const volScalarField& nu,
            const volScalarField& eps,
            const volScalarField& rhoC,
            const volScalarField& rhoD
        ) const;

        //- Number density of a species
        inline tmp<volScalarField> nD
        (
            const volScalarField& d,
            const volScalarField& alpha,
            const volScalarField& rhoA,
            const volScalarField& rhoD,
            const volScalarField& Y
        ) const;

        //- Bubble Reynolds number based on fluctuating velocity
        inline tmp<volScalarField> Re
        (
            const volScalarField& d,
            const volScalarField& u,
            const volScalarField& nu
        ) const;

        //- Modified Bond number of the aggregate phase
        inline tmp<volScalarField> BoM
        (
            const volScalarField& dP,
            const volScalarField& dB,
            const volScalarField& rhoP,
            const volScalarField& rhoL,
            const volScalarField& eps,
            const volScalarField& sigma
        ) const;

        //- Induction time
        inline tmp<volScalarField> tInduction(const volScalarField& d) const;

        //- Z
        void correctZ
        (
            const volScalarField& dP,
            const volScalarField& dB,
            const volScalarField& rhoP,
            const volScalarField& rhoB,
            const volScalarField& rhoL,
            const volScalarField& kL,
            const volScalarField& epsilonL,
            const volScalarField& nuL,
            const volScalarField& uPrimeB
        ) const;

        //- ZPrime
        void correctZPrime
        (
            const volScalarField& dP,
            const volScalarField& dB,
            const volScalarField& epsilonL
        ) const;

        //- Pc
        void correctPc
        (
            const volScalarField& dP,
            const volScalarField& dB,
            const volScalarField& RePrime
        ) const;

        //- Pa
        void correctPa
        (
            const volScalarField& dP,
            const volScalarField& dB,
            const volScalarField& uPrimeB,
            const volScalarField& RePrime
        ) const;

        //- Ps
        void correctPs
        (
            const volScalarField& dP,
            const volScalarField& dB,
            const volScalarField& rhoP,
            const volScalarField& rhoL,
            const volScalarField& epsilonL
        ) const;


protected:

        //- Attachment rate
        virtual tmp<volScalarField> rate() const;


public:

    //- Runtime type information
    TypeName("BhutaniBritoParada");


    // Constructors

        //- Construct from components
        BhutaniBritoParada
        (
            const dictionary& dict,
            const dispersedPhaseInterface& interface,
            const hashedWordList& species
        );


    //- Destructor
    virtual ~BhutaniBritoParada();
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

} // End namespace fv
} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //
