yaeos__models_ar_genericcubic Module

Generic cubic equation of state

Description

Base types and the generic implementation of a cubic equation of state. The module defines the abstract AlphaFunction and CubicMixRule types, and the CubicEoS model that combines them. Specific cubic equations are provided in yaeos__models_ar_cubic_implementations. Defines the alpha-function and mixing-rule contracts, evaluates generic cubic Helmholtz expressions, and provides model configuration methods.

Examples

model = PengRobinson76(Tc, Pc, omega)
call model%set_alpha(alpha_function)

Uses

  • module~~yaeos__models_ar_genericcubic~~UsesGraph module~yaeos__models_ar_genericcubic yaeos__models_ar_genericcubic module~yaeos__constants yaeos__constants module~yaeos__models_ar_genericcubic->module~yaeos__constants module~yaeos__models_ar yaeos__models_ar module~yaeos__models_ar_genericcubic->module~yaeos__models_ar module~yaeos__substance yaeos__substance module~yaeos__models_ar_genericcubic->module~yaeos__substance iso_fortran_env iso_fortran_env module~yaeos__constants->iso_fortran_env module~yaeos__models_ar->module~yaeos__constants module~yaeos__models_base yaeos__models_base module~yaeos__models_ar->module~yaeos__models_base module~yaeos__substance->module~yaeos__constants module~yaeos__models_base->module~yaeos__substance

Used by

  • module~~yaeos__models_ar_genericcubic~~UsedByGraph module~yaeos__models_ar_genericcubic yaeos__models_ar_genericcubic module~yaeos__models yaeos__models module~yaeos__models->module~yaeos__models_ar_genericcubic module~yaeos__models_ar_cubic_alphas yaeos__models_ar_cubic_alphas module~yaeos__models->module~yaeos__models_ar_cubic_alphas module~yaeos__models_ar_cubic_cubic_mixing yaeos__models_ar_cubic_cubic_mixing module~yaeos__models->module~yaeos__models_ar_cubic_cubic_mixing module~yaeos__models_ar_cubic_implementations yaeos__models_ar_cubic_implementations module~yaeos__models->module~yaeos__models_ar_cubic_implementations module~yaeos__models_ar_cubic_quadratic_mixing yaeos__models_ar_cubic_quadratic_mixing module~yaeos__models->module~yaeos__models_ar_cubic_quadratic_mixing module~yaeos__models_ar_gerg2008 yaeos__models_ar_gerg2008 module~yaeos__models->module~yaeos__models_ar_gerg2008 module~yaeos__models_cubic_mixing_rules_huron_vidal yaeos__models_cubic_mixing_rules_huron_vidal module~yaeos__models->module~yaeos__models_cubic_mixing_rules_huron_vidal module~yaeos__models_ar_cubic_mixing_sddlc yaeos__models_ar_cubic_mixing_sddlc module~yaeos__models->module~yaeos__models_ar_cubic_mixing_sddlc module~yaeos__models_ar_cubic_alphas->module~yaeos__models_ar_genericcubic module~yaeos__models_ar_cubic_cubic_mixing->module~yaeos__models_ar_genericcubic module~yaeos__models_ar_cubic_implementations->module~yaeos__models_ar_genericcubic module~yaeos__models_ar_cubic_quadratic_mixing->module~yaeos__models_ar_genericcubic module~yaeos__models_ar_gerg2008->module~yaeos__models_ar_genericcubic module~yaeos__models_ar_gerg2008->module~yaeos__models_ar_cubic_implementations module~yaeos__models_cubic_mixing_rules_huron_vidal->module~yaeos__models_ar_genericcubic module~yaeos__models_cubic_mixing_rules_huron_vidal->module~yaeos__models_ar_cubic_quadratic_mixing proc~pengrobinson76 PengRobinson76 proc~pengrobinson76->module~yaeos__models_ar_genericcubic proc~pengrobinson76->module~yaeos__models_ar_cubic_alphas proc~pengrobinson76->module~yaeos__models_ar_cubic_quadratic_mixing proc~pengrobinson78 PengRobinson78 proc~pengrobinson78->module~yaeos__models_ar_genericcubic proc~pengrobinson78->module~yaeos__models_ar_cubic_alphas proc~pengrobinson78->module~yaeos__models_ar_cubic_quadratic_mixing proc~psrk PSRK proc~psrk->module~yaeos__models_ar_genericcubic proc~psrk->module~yaeos__models_ar_cubic_alphas proc~psrk->module~yaeos__models_cubic_mixing_rules_huron_vidal proc~soaveredlichkwong SoaveRedlichKwong proc~soaveredlichkwong->module~yaeos__models_ar_genericcubic proc~soaveredlichkwong->module~yaeos__models_ar_cubic_alphas proc~soaveredlichkwong->module~yaeos__models_ar_cubic_quadratic_mixing module~yaeos yaeos module~yaeos->module~yaeos__models module~yaeos__extra_fluids yaeos__extra_fluids module~yaeos__extra_fluids->module~yaeos__models module~yaeos__models_ar_cubic_mixing_sddlc->module~yaeos__models_ar_cubic_quadratic_mixing proc~co2_h2o_isop co2_h2o_isop proc~co2_h2o_isop->module~yaeos__models proc~refit_rkpr_k refit_rkpr_k proc~refit_rkpr_k->module~yaeos__models_ar_cubic_alphas proc~rkpr RKPR proc~rkpr->module~yaeos__models_ar_cubic_alphas proc~rkpr->module~yaeos__models_ar_cubic_quadratic_mixing

Abstract Interfaces

abstract interface

  • public subroutine abs_Bmix(self, n, bi, B, dBi, dBij)

    abs_Bmix

    Description

    Evaluate the repulsive mixture parameter and its composition derivatives.

    Arguments

    Type IntentOptional Attributes Name
    class(CubicMixRule), intent(in) :: self

    Mixing-rule implementation.

    real(kind=pr), intent(in) :: n(:)

    Component mole amounts [mol].

    real(kind=pr), intent(in) :: bi(:)

    Pure-component covolumes.

    real(kind=pr), intent(out) :: B

    Mixture covolume [L].

    real(kind=pr), intent(out) :: dBi(:)

    Mole-number gradient of the mixture covolume.

    real(kind=pr), intent(out) :: dBij(:,:)

    Mole-number Hessian of the mixture covolume.

abstract interface

  • public subroutine abs_D1mix(self, n, d1i, D1, dD1i, dD1ij)

    abs_D1mix

    Description

    Evaluate the first denominator parameter and its composition derivatives.

    Arguments

    Type IntentOptional Attributes Name
    class(CubicMixRule), intent(in) :: self

    Mixing-rule implementation.

    real(kind=pr), intent(in) :: n(:)

    Component mole amounts [mol].

    real(kind=pr), intent(in) :: d1i(:)

    Pure-component values.

    real(kind=pr), intent(out) :: D1

    Mixture parameter.

    real(kind=pr), intent(out) :: dD1i(:)

    Gradient of D1 with respect to mole amounts.

    real(kind=pr), intent(out) :: dD1ij(:,:)

    Hessian of D1 with respect to mole amounts.

abstract interface

  • public subroutine abs_Dmix(self, n, V, T, ai, daidt, daidt2, D, dDdV, dDdT, dDdV2, dDdT2, dDi, dDdTV, dDidV, dDidT, dDij)

    abs_Dmix

    Description

    Evaluate the attractive mixture parameter and its state/composition derivatives for a cubic mixing rule.

    Arguments

    Type IntentOptional Attributes Name
    class(CubicMixRule), intent(in) :: self

    Mixing-rule implementation.

    real(kind=pr), intent(in) :: n(:)

    Component mole amounts [mol].

    real(kind=pr), intent(in) :: V

    Total volume [L].

    real(kind=pr), intent(in) :: T

    Temperature [K].

    real(kind=pr), intent(in) :: ai(:)

    Pure-component attractive parameters.

    real(kind=pr), intent(in) :: daidt(:)

    Temperature derivatives of pure-component attractive parameters.

    real(kind=pr), intent(in) :: daidt2(:)

    Second temperature derivatives of pure-component attractive parameters.

    real(kind=pr), intent(out) :: D

    Attractive mixture parameter.

    real(kind=pr), intent(out) :: dDdV

    Volume derivative of the attractive mixture parameter.

    real(kind=pr), intent(out) :: dDdT

    Temperature derivative of the attractive mixture parameter.

    real(kind=pr), intent(out) :: dDdV2

    Second volume derivative of the attractive mixture parameter.

    real(kind=pr), intent(out) :: dDdT2

    Second temperature derivative of the attractive mixture parameter.

    real(kind=pr), intent(out) :: dDi(:)

    Mole-number gradient of the attractive mixture parameter.

    real(kind=pr), intent(out) :: dDdTV

    Mixed temperature/volume derivative of the attractive mixture parameter.

    real(kind=pr), intent(out) :: dDidV(:)

    Volume derivative of the attractive mole-number gradient.

    real(kind=pr), intent(out) :: dDidT(:)

    Temperature derivative of the attractive mole-number gradient.

    real(kind=pr), intent(out) :: dDij(:,:)

    Mole-number Hessian of the attractive mixture parameter.

abstract interface

  • public subroutine abs_alpha(self, Tr, a, dadt, dadt2)

    abs_alpha

    Description

    Evaluate a cubic alpha function and its reduced-temperature derivatives.

    Arguments

    Type IntentOptional Attributes Name
    class(AlphaFunction), intent(in) :: self

    Alpha-function implementation.

    real(kind=pr), intent(in) :: Tr(:)

    Reduced temperatures, one per component.

    real(kind=pr), intent(out) :: a(:)

    Alpha-function values.

    real(kind=pr), intent(out) :: dadt(:)

    First reduced-temperature derivative of alpha.

    real(kind=pr), intent(out) :: dadt2(:)

    Second reduced-temperature derivative of alpha.


Derived Types

type, public, abstract ::  AlphaFunction

Abstract contract for temperature corrections to cubic attraction.

Read more…

Type-Bound Procedures

procedure(abs_alpha), public, deferred :: alpha

type, public, extends(ArModel) ::  CubicEoS

Generic cubic equation of state with configurable alpha and mixing rules.

Read more…

Components

Type Visibility Attributes Name Initial
real(kind=pr), public, allocatable :: ac(:)

Pure-component attractive parameters at , [bar L^2/mol^2]

class(AlphaFunction), public, allocatable :: alpha

Uses the abstract derived type AlphaFunction to define the Alpha function that the CubicEoS will use. The Alpha function receives the reduced temperature and returns the values of alpha and its derivatives, named a, dadt and dadt2 respectively.

Read more…
real(kind=pr), public, allocatable :: b(:)

Pure-component covolumes [L/mol]

type(Substances), public :: components

Pure-component properties for the model’s component order.

real(kind=pr), public, allocatable :: del1(:)

parameter

real(kind=pr), public, allocatable :: del2(:)

parameter

class(CubicMixRule), public, allocatable :: mixrule

Uses the abstract derived type CubicMixRule to define the mixing rule that the CubicEoS will use. It includes internally three methods to calculate the corresponding parameters for the Cubic EoS: Dmix, Bmix and D1mix.

Read more…
character(len=:), public, allocatable :: name

Name of the model

Type-Bound Procedures

procedure, public :: Cp_residual_pt
procedure, public :: Cp_residual_vt
procedure, public :: Cv_residual_pt
procedure, public :: Cv_residual_vt
procedure, public :: Psat_pure
procedure, public :: calculate_attractive_parameters
procedure, public :: enthalpy_excess
procedure, public :: enthalpy_residual_pt
procedure, public :: enthalpy_residual_vt
procedure, public :: entropy_excess
procedure, public :: entropy_residual_pt
procedure, public :: entropy_residual_vt
procedure, public :: get_v0 => v0
procedure, public :: gibbs_excess
procedure, public :: gibbs_residual_pt
procedure, public :: gibbs_residual_vt
procedure, public :: helmholtz_excess
procedure, public :: helmholtz_residual_pt
procedure, public :: internal_energy_excess
procedure, public :: internal_energy_residual_pt
procedure, public :: internal_energy_residual_vt
procedure, public :: ln_activity_coefficient
procedure, public :: lnfug_vt
procedure, public :: lnphi_pt
procedure, public :: lnphi_vt
procedure, public :: pressure
procedure, public :: residual_helmholtz => GenericCubic_Ar
procedure, public :: set_alpha
procedure, public :: set_delta1
procedure, public :: set_mixrule
procedure, public :: volume
procedure, public :: volume_excess

type, public, abstract ::  CubicMixRule

Abstract contract for cubic-EOS mixture parameter calculations.

Read more…

Components

Type Visibility Attributes Name Initial
logical, public :: dn2 = .false.

Calculate second-order mole-number derivatives

logical, public :: is_D_ddlc = .false.

Mixing rule D parameter depends on volume (density)

Type-Bound Procedures

procedure(abs_Bmix), public, deferred :: Bmix
procedure(abs_D1mix), public, deferred :: D1mix
procedure(abs_Dmix), public, deferred :: Dmix

Functions

public function v0(self, n, p, t)

Cubic EoS volume initializer. For a Cubic Equation of State, the covolume calculated with the mixing rule is a good estimate for the initial volume solver on the liquid region.

Arguments

Type IntentOptional Attributes Name
class(CubicEoS), intent(in) :: self

Cubic model with component covolumes and mixing rule.

real(kind=pr), intent(in) :: n(:)

Component mole amounts [mol].

real(kind=pr), intent(in) :: p

Pressure [bar].

real(kind=pr), intent(in) :: t

Temperature [K].

Return Value real(kind=pr)


Subroutines

public subroutine GenericCubic_Ar(self, n, v, t, ar, arv, ArT, artv, arv2, ArT2, Arn, ArVn, ArTn, Arn2)

Residual Helmholtz Energy for a generic Cubic Equation of State.

Read more…

Arguments

Type IntentOptional Attributes Name
class(CubicEoS), intent(in) :: self

Cubic model containing parameters and mixing-rule state.

real(kind=pr), intent(in) :: n(:)

Number of moles

real(kind=pr), intent(in) :: v

Volume [L]

real(kind=pr), intent(in) :: t

Temperature [K]

real(kind=pr), intent(out), optional :: ar

Residual Helmholtz

real(kind=pr), intent(out), optional :: arv

real(kind=pr), intent(out), optional :: ArT

real(kind=pr), intent(out), optional :: artv

real(kind=pr), intent(out), optional :: arv2

real(kind=pr), intent(out), optional :: ArT2

real(kind=pr), intent(out), optional :: Arn(size(n))

real(kind=pr), intent(out), optional :: ArVn(size(n))

real(kind=pr), intent(out), optional :: ArTn(size(n))

real(kind=pr), intent(out), optional :: Arn2(size(n),size(n))

public subroutine calculate_attractive_parameters(self, T, a, dadt, dadt2)

Pure-component attractive parameters and their temperature derivatives.

Read more…

Arguments

Type IntentOptional Attributes Name
class(CubicEoS), intent(inout) :: self

Model

real(kind=pr), intent(in) :: T

Temperature [K]

real(kind=pr), intent(out) :: a(:)

Attractive parameters [bar L^2/mol^2]

real(kind=pr), intent(out) :: dadt(:)

[bar L^2/(mol^2 K)]

real(kind=pr), intent(out) :: dadt2(:)

[bar L^2/(mol^2 K^2)]

public subroutine set_alpha(self, alpha)

Set the alpha function used to calculate the attractive parameter.

Read more…

Arguments

Type IntentOptional Attributes Name
class(CubicEoS), intent(inout) :: self

Model whose alpha function is replaced.

class(AlphaFunction), intent(in) :: alpha

Alpha function

public subroutine set_delta1(self, delta1)

Set the parameter of the cubic equation.

Read more…

Arguments

Type IntentOptional Attributes Name
class(CubicEoS) :: self
real(kind=pr), intent(in) :: delta1(:)

values

public subroutine set_mixrule(self, mixrule)

Set the mixing rule used to calculate mixture attractive parameters.

Read more…

Arguments

Type IntentOptional Attributes Name
class(CubicEoS), intent(inout) :: self

Model whose mixing rule is replaced.

class(CubicMixRule), intent(in) :: mixrule

Mixing rule

public subroutine volume(eos, n, P, T, V, root_type)

Volume solver optimized for Cubic Equations of State.

Read more…

Arguments

Type IntentOptional Attributes Name
class(CubicEoS), intent(in) :: eos

Cubic EOS and mixing-rule parameters.

real(kind=pr), intent(in) :: n(:)

Component mole amounts [mol].

real(kind=pr), intent(in) :: P

Pressure [bar].

real(kind=pr), intent(in) :: T

Temperature [K].

real(kind=pr), intent(out) :: V

Selected total volume [L].

character(len=*), intent(in) :: root_type

Requested liquid, vapor, or stable root.