Classic liquid-vapor UNIFAC model implementation module.
Classic liquid-vapor UNIFAC model implementation module. The implementation is based on the Thermopack library (SINTEF) implementation.
! Instantiate an UNIFAC model with ethanol-water mix and calculate gammas
use yaeos, only: pr, Groups, setup_unifac, UNIFAC
type(UNIFAC) :: model
type(Groups) :: molecules(2)
real(pr) :: ln_gammas(2)
! Ethanol definition [CH3, CH2, OH]
molecules(1)%groups_ids = [1, 2, 14] ! Subgroups ids
molecules(1)%number_of_groups = [1, 1, 1] ! Subgroups occurrences
! Water definition [H2O]
molecules(2)%groups_ids = [16]
molecules(2)%number_of_groups = [1]
! Model setup
model = setup_unifac(molecules)
! Calculate ln_gammas
call model%ln_activity_coefficient([0.5_pr, 0.5_pr], 298.0_pr, ln_gammas)
print *, ln_gammas ! result: 0.18534142000449058 0.40331395945417559
Classic liquid-vapor UNIFAC model derived type
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(Substances), | public | :: | components |
Substances contained in the module |
|||
real(kind=pr), | public, | allocatable | :: | group_area(:) |
Group areas |
||
real(kind=pr), | public, | allocatable | :: | group_volume(:) |
Group volumes |
||
type(Groups), | public | :: | groups_stew |
All the groups present in the system |
|||
type(Groups), | public, | allocatable | :: | molecules(:) |
Substances present in the system |
||
integer, | public | :: | ngroups |
Total number of individual groups in the mixture |
|||
integer, | public | :: | nmolecules |
Total number of molecules in the mixture |
|||
class(PsiFunction), | public, | allocatable | :: | psi_function |
Temperature dependance function of the model |
||
real(kind=pr), | public, | allocatable | :: | qk(:) |
Area of each group k |
||
real(kind=pr), | public, | allocatable | :: | thetas_ij(:,:) |
Area fractions of the groups j on molecules i |
||
real(kind=pr), | public, | allocatable | :: | vij(:,:) |
Ocurrences of each group j on each molecule i |
||
real(kind=pr), | public | :: | z | = | 10 |
Model constant |
procedure, public :: excess_gibbs | |
procedure, public :: ln_activity_coefficient |
Instantiate a UNIFAC model
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(Groups), | intent(in) | :: | molecules(:) |
Molecules (Group type) objects |
||
type(GeGCModelParameters), | intent(in), | optional | :: | parameters |
UNIFAC parameters |
Calculate the area fraciton of each froup on each molecule.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | nm |
Number of molecules |
||
integer, | intent(in) | :: | ng |
Number of groups |
||
type(GeGCModelParameters), | intent(in) | :: | parameters |
UNIFAC parameters |
||
type(Groups), | intent(in) | :: | stew |
All the groups present in the system |
||
type(Groups), | intent(in) | :: | molecules(:) |
Molecules |
Group j area fraction on molecule i
Calculate the UNIFAC combinatorial term of Gibbs excess energy
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(UNIFAC) | :: | self | ||||
real(kind=pr), | intent(in) | :: | n(self%nmolecules) |
Moles vector [mol] |
||
real(kind=pr), | intent(in) | :: | T |
Temperature [K] |
||
real(kind=pr), | intent(out), | optional | :: | Ge |
Combinatorial Gibbs excess energy |
|
real(kind=pr), | intent(out), | optional | :: | dGe_dn(self%nmolecules) |
|
|
real(kind=pr), | intent(out), | optional | :: | dGe_dn2(self%nmolecules,self%nmolecules) |
|
Evaluate the UNIFAC residual therm
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(UNIFAC) | :: | self | ||||
real(kind=pr), | intent(in) | :: | n(self%nmolecules) |
Moles vector |
||
real(kind=pr), | intent(in) | :: | T |
Temperature [K] |
||
real(kind=pr), | intent(out), | optional | :: | Ge |
Residual Gibbs excess energy |
|
real(kind=pr), | intent(out), | optional | :: | dGe_dn(self%nmolecules) |
|
|
real(kind=pr), | intent(out), | optional | :: | dGe_dn2(self%nmolecules,self%nmolecules) |
|
|
real(kind=pr), | intent(out), | optional | :: | dGe_dT |
|
|
real(kind=pr), | intent(out), | optional | :: | dGe_dT2 |
|
|
real(kind=pr), | intent(out), | optional | :: | dGe_dTn(self%nmolecules) |
|
Calculate the Gibbs excess energy of the UNIFAC model
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(UNIFAC), | intent(in) | :: | self |
UNIFAC model |
||
real(kind=pr), | intent(in) | :: | n(:) |
Moles vector [mol] |
||
real(kind=pr), | intent(in) | :: | T |
Temperature [K] |
||
real(kind=pr), | intent(out), | optional | :: | Ge |
Excess Gibbs energy |
|
real(kind=pr), | intent(out), | optional | :: | GeT |
|
|
real(kind=pr), | intent(out), | optional | :: | GeT2 |
|
|
real(kind=pr), | intent(out), | optional | :: | Gen(size(n)) |
|
|
real(kind=pr), | intent(out), | optional | :: | GeTn(size(n)) |
|
|
real(kind=pr), | intent(out), | optional | :: | Gen2(size(n),size(n)) |
|