legacy_ar_models Module

Legacy cubic EOS procedures

Compatibility layer for older applications that use global EOS state and procedure pointers.

Description

This module stores model configuration, component data, and mixing parameters in module variables, then dispatches properties through the ar_fun and vinit pointers from ar_interface. It is retained for compatibility only: it is not reentrant or thread-safe, and new code should use the object-oriented model types exported by yaeos.

Examples

call setup(nc, nmodel, ntdep, ncomb)
call PR78_factory(z, ac, b, Tc, Pc, omega, k)

Uses

  • module~~legacy_ar_models~~UsesGraph module~legacy_ar_models legacy_ar_models module~ar_interface ar_interface module~legacy_ar_models->module~ar_interface module~yaeos__constants yaeos__constants module~legacy_ar_models->module~yaeos__constants module~ar_interface->module~yaeos__constants iso_fortran_env iso_fortran_env module~ar_interface->iso_fortran_env module~yaeos__constants->iso_fortran_env

Used by

  • module~~legacy_ar_models~~UsedByGraph module~legacy_ar_models legacy_ar_models module~legacy_thermo_properties legacy_thermo_properties module~legacy_thermo_properties->module~legacy_ar_models

Variables

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

Critical attractive parameter [bar (L/mol)^2]

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

repulsive parameter [L]

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

Pair covolume matrix used by quadratic mixing.

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

Critical density [mol/L]

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

parameter

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

Attractive parameter constant

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

Attractive BIP

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

Low-temperature binary interaction coefficients.

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

Asymptotic binary interaction coefficients.

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

Repulsive BIP

integer, public :: mixing_rule

Legacy integer selector for the mixing rule.

integer, public :: nc

Number of active components.

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

Critical pressure [bar]

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

Critical temperature [K]

integer, public :: tdep

Legacy selector for temperature-dependent binary interactions.

integer, public :: thermo_model

Legacy integer selector for the cubic EOS alpha/covolume formulation.

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

Reference temperatures for the binary interaction law.

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

Acentric factor

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

Mole fractions vector


Functions

public function cubic_v0(z, p, t)

Return a cubic-EOS liquid-volume initial estimate for legacy solvers.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=pr) :: z(:)

Feed or overall composition.

real(kind=pr) :: p
real(kind=pr) :: t

Return Value real(kind=pr)


Subroutines

public subroutine ArVnder(nc, nder, ntemp, z, V, T, ar, arv, artv, arv2, Arn, ArVn, ArTn, Arn2)

Dispatch the configured legacy residual Helmholtz implementation.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nc

Number of active components.

integer, intent(in) :: nder

Get compositional derivatives

integer, intent(in) :: ntemp

Get temperature derivatives

real(kind=pr), intent(in) :: z(nc)

Component mole amounts/composition vector.

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

Total volume [L].

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

Temperature [K].

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

Residual Helmholtz energy.

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

First volume derivative of residual Helmholtz energy.

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

Mixed volume-temperature derivative of residual Helmholtz energy.

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

Second volume derivative of residual Helmholtz energy.

real(kind=pr), intent(out), dimension(size(z)) :: Arn

Composition gradient of residual Helmholtz energy.

real(kind=pr), intent(out), dimension(size(z)) :: ArVn

Mixed volume-composition derivatives.

real(kind=pr), intent(out), dimension(size(z)) :: ArTn

Mixed temperature-composition derivatives.

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

Composition Hessian of residual Helmholtz energy.

public subroutine Bnder(nc, rn, Bmix, dBi, dBij)

Evaluate the legacy quadratic-mixture covolume and derivatives.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nc

Number of active components.

real(kind=pr), intent(in) :: rn(nc)

Component mole amounts used in mixture rules.

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

Mixture covolume.

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

Mole-number gradient of the mixture covolume.

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

Mole-number Hessian of the mixture covolume.

public subroutine DELTAnder(nc, rn, D1m, dD1i, dD1ij)

Evaluate the mole-averaged cubic denominator parameter and derivatives.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nc

Number of active components.

real(kind=pr), intent(in) :: rn(nc)

Component mole amounts used in mixture rules.

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

Mixture cubic denominator parameter.

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

Mole-number gradient of the cubic denominator parameter.

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

Mole-number Hessian of the cubic denominator parameter.

public subroutine DandTnder(ntd, nc, T, rn, D, dDi, dDiT, dDij, dDdT, dDdT2)

Evaluate the legacy mixture attractive parameter and derivatives.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ntd

Flag selecting temperature-dependent derivative calculations.

integer, intent(in) :: nc

Number of active components.

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

Temperature [K].

real(kind=pr), intent(in) :: rn(nc)

Component mole amounts used in mixture rules.

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

Mixture attractive parameter.

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

.

real(kind=pr), intent(out) :: dDiT(nc)

.

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

.

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

.

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

.

public subroutine HelmRKPR(nco, NDE, NTD, rn, V, T, Ar, ArV, ArTV, ArV2, Arn, ArVn, ArTn, Arn2)

Calculate the reduced residual Helmholtz Energy and it’s derivatives with the RKPR EOS

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nco

Number of components in the mixture.

integer, intent(in) :: NDE

Compositional derivative order; 2 also computes Arn2.

integer, intent(in) :: NTD

Flag selecting temperature-dependent derivative calculations.

real(kind=pr), intent(in) :: rn(nco)

Component mole amounts used in mixture rules.

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

Total volume [L].

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

Temperature [K].

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

Residual Helmholtz energy.

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

First volume derivative of residual Helmholtz energy.

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

Mixed volume-temperature derivative of residual Helmholtz energy.

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

Second volume derivative of residual Helmholtz energy.

real(kind=pr), intent(out) :: Arn(nco)

Mole-number gradient of residual Helmholtz energy.

real(kind=pr), intent(out) :: ArVn(nco)

Mixed volume/mole-number derivative of residual Helmholtz energy.

real(kind=pr), intent(out) :: ArTn(nco)

Mixed temperature/mole-number derivative of residual Helmholtz energy.

real(kind=pr), intent(out) :: Arn2(nco,nco)

Mole-number Hessian of residual Helmholtz energy.

public subroutine HelmSRKPR(nc, nd, nt, rn, v, t, ar, arv, artv, arv2, Arn, ArVn, ArTn, Arn2)

Evaluate the SRK/PR-family residual Helmholtz expression and derivatives.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: nc

Number of components

integer, intent(in) :: nd

Compositional derivatives

integer, intent(in) :: nt

Temperature derivatives

real(kind=pr), intent(in) :: rn(nc)

Number of moles

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

Volume [L]

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

Temperature [K]

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

Residual Helmholtz

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

dAr/dV

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

dAr2/dTV

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

dAr2/dV2

real(kind=pr), intent(out) :: Arn(nc)

dAr/dn

real(kind=pr), intent(out) :: ArVn(nc)

dAr2/dVn

real(kind=pr), intent(out) :: ArTn(nc)

dAr2/dTn

real(kind=pr), intent(out) :: Arn2(nc,nc)

dAr2/dn2

public subroutine PR76_factory(moles_in, ac_in, b_in, tc_in, pc_in, w_in, k_in)

PengRobinson 76 factory

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=pr), intent(in) :: moles_in(nc)

Component mole amounts or feed composition used to initialize the legacy model.

real(kind=pr), intent(in), optional :: ac_in(nc)

Optional precomputed critical attractive parameters.

real(kind=pr), intent(in), optional :: b_in(nc)

Optional precomputed covolumes.

real(kind=pr), intent(in), optional :: tc_in(nc)

Optional critical temperatures [K].

real(kind=pr), intent(in), optional :: pc_in(nc)

Optional critical pressures [bar].

real(kind=pr), intent(in), optional :: w_in(nc)

Optional acentric factors.

real(kind=pr), intent(in), optional :: k_in(nc)

Optional alpha-function parameters.

public subroutine PR78_factory(moles_in, ac_in, b_in, tc_in, pc_in, w_in, k_in)

PengRobinson 78 factory

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=pr), intent(in) :: moles_in(nc)

Component mole amounts or feed composition used to initialize the legacy model.

real(kind=pr), intent(in), optional :: ac_in(nc)

Optional precomputed critical attractive parameters.

real(kind=pr), intent(in), optional :: b_in(nc)

Optional precomputed covolumes.

real(kind=pr), intent(in), optional :: tc_in(nc)

Optional critical temperatures [K].

real(kind=pr), intent(in), optional :: pc_in(nc)

Optional critical pressures [bar].

real(kind=pr), intent(in), optional :: w_in(nc)

Optional acentric factors.

real(kind=pr), intent(in), optional :: k_in(nc)

Optional alpha-function parameters.

public subroutine SRK_factory(moles_in, ac_in, b_in, tc_in, pc_in, w_in, k_in)

SoaveRedlichKwong factory

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=pr), intent(in) :: moles_in(nc)

Component mole amounts or feed composition used to initialize the legacy model.

real(kind=pr), intent(in), optional :: ac_in(nc)

Optional precomputed critical attractive parameters.

real(kind=pr), intent(in), optional :: b_in(nc)

Optional precomputed covolumes.

real(kind=pr), intent(in), optional :: tc_in(nc)

Optional critical temperatures [K].

real(kind=pr), intent(in), optional :: pc_in(nc)

Optional critical pressures [bar].

real(kind=pr), intent(in), optional :: w_in(nc)

Optional acentric factors.

real(kind=pr), intent(in), optional :: k_in(nc)

Optional alpha-function parameters.

public subroutine aTder(ac, Tc, k, T, a, dadT, dadT2)

Evaluate the configured cubic alpha correction and its temperature derivatives.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=pr), intent(in) :: ac

Pure-component critical attractive parameter.

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

Pure-component critical temperature [K].

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

Alpha-function parameter.

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

Temperature [K].

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

Attractive parameter at the state.

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

First temperature derivative of the attractive parameter.

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

Second temperature derivative of the attractive parameter.

public subroutine aijTder(ntd, nc, T, aij, daijdT, daijdT2)

Build pair attractive parameters and their temperature derivatives.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: ntd

Flag selecting temperature-dependent derivative calculations.

integer, intent(in) :: nc

Number of active components.

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

Temperature [K].

real(kind=pr), intent(out) :: aij(nc,nc)

Pair attractive-parameter matrix.

real(kind=pr), intent(out) :: daijdT(nc,nc)

Temperature derivative of the pair attractive parameters.

real(kind=pr), intent(out) :: daijdT2(nc,nc)

Second temperature derivative of the pair attractive parameters.

public subroutine ar_rkpr(z, v, t, ar, arv, artv, arv2, Arn, ArVn, ArTn, Arn2)

Evaluate residual Helmholtz derivatives for the legacy RKPR model.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=pr), intent(in) :: z(:)

Number of moles

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

Volume [L]

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

Temperature [K]

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

Residual Helmholtz

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

dAr/dV

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

dAr2/dTV

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

dAr2/dV2

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

dAr/dn

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

dAr2/dVn

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

dAr2/dTn

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

dAr2/dn2

public subroutine ar_srkpr(z, v, t, ar, arv, artv, arv2, Arn, ArVn, ArTn, Arn2)

Wrapper subroutine to the SRK/PR Residula Helmholtz function to use the general interface

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=pr), intent(in) :: z(:)

Number of moles

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

Volume [L]

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

Temperature [K]

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

Residual Helmholtz

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

dAr/dV

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

dAr2/dTV

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

dAr2/dV2

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

dAr/dn

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

dAr2/dVn

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

dAr2/dTn

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

dAr2/dn2

public subroutine get_Zc_OMa_OMb(del1, Zc, OMa, OMb)

Calculate Zc, OMa and OMb from the delta_1 parameter.

Read more…

Arguments

Type IntentOptional Attributes Name
real(kind=pr), intent(in) :: del1(:)

delta_1 parameter

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

Critical compressibility factor

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

OMa

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

OMb

public subroutine setup(n, nmodel, ntdep, ncomb)

Initialize the global configuration and allocate legacy model arrays.

Read more…

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n

Number of components

integer, intent(in) :: nmodel

Number of model

integer, intent(in) :: ntdep

Kij dependant of temperature

integer, intent(in) :: ncomb

Combining rule