Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HV NRTL model #120

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions src/models/excess_gibbs/nrtl_hv.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
module yaeos__models_ge_nrtl_hv
use yaeos__constants, only: pr, R
use yaeos__models_ge, only: GeModel

type, extends(GeModel) :: NRTLHV
!! NRTL-HV model
!!
!! Huron-Vidal modified NRTL model
!! This model incldues the Cubic EoS repulsive parameters
!! of pure compounds.
!!
!! \[
!! \sum_i n_i
!! \frac
!! {\sum_j n_j b_j exp \left( -\alpha_{ji} \Delta U_{ji}/RT\right)\Delta U_{ji}}
!! {\sum_j n_j b_j exp(-\alpha_{ji} \Delta U_{ji}/RT)}
!! \]
real(pr), allocatable :: aij(:, :) !! \(\alpha_{ij} parameter\)
real(pr), allocatable :: dUij(:, :) !! \(\Delta U_{ji}\)
contains
procedure :: excess_gibbs
end type

contains

subroutine excess_gibbs(self, n, t, Ge, GeT, GeT2, Gen, GeTn, Gen2)
!! Excess Gibbs and derivs procedure
class(NRTLHV), intent(in) :: self !! Model
real(pr), intent(in) ::n(:) !! Moles vector
real(pr), intent(in) :: t !! Temperature [K]
real(pr), optional, intent(out) :: Ge !! Excess Gibbs
real(pr), optional, intent(out) :: GeT !! \(\frac{dG^E}{dT}\)
real(pr), optional, intent(out) :: GeT2 !! \(\frac{d^2G^E}{dT^2}\)
real(pr), optional, intent(out) :: Gen(size(n))
real(pr), optional, intent(out) :: GeTn(size(n))
real(pr), optional, intent(out) :: Gen2(size(n), size(n))

integer :: i, j

real(pr) :: up, down

real(pr) :: b(size(n))
real(pr) :: dU(size(n), size(n))
real(pr) :: alpha(size(n), size(n))
real(pr) :: aux


Ge = 0

b = self%b
dU = self%dUij
alpha = self%aij

do i=1,nc
up = 0
down = 0
do j=1,nc
end do
end do

end subroutine
end module
11 changes: 1 addition & 10 deletions test/test_huron_vidal.f90
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,11 @@ program main
daidt2 = daidt2*model%ac/Tc**2

call model%mixrule%Dmix(n, T, ai, daidt, daidt2, D, dDdT, dDdT2, dDi, dDidT, dDij)
print *, D
print *, dDdT
print *, dDdT2
print *, dDi
print *, dDidT
print *, dDij


if (.not. allclose([D], [test_D], test_tol)) error stop 1
if (.not. allclose([dDdT], [test_dDdT], test_tol)) error stop 1
if (.not. allclose([dDdT2], [test_dDdT2], test_tol)) error stop 1
if (.not. allclose([dDi], [test_dDi], test_tol)) error stop 1
if (.not. allclose([dDidT], [test_dDidT], test_tol)) error stop 1
if (.not. allclose([dDij], [test_dDij], test_tol)) error stop 1



end program main
Loading