Evaluate the Helmholtz derivatives with central finite difference.
Tool to facilitate the development of new ArModel by testing the implementation of analytic derivatives.
use yaeos, only: pr, SoaveRedlichKwong, ArModel
use yaeos__consistency_armodel, only: numeric_ar_derivatives
class(ArModel), allocatable :: model
real(pr) :: tc(4), pc(4), w(4)
real(pr) :: n(4), T, V
real(pr) :: Ar_num, ArV_num, ArT_num, Arn_num(size(n)), ArV2_num, ArT2_num
real(pr) :: ArTV_num, ArVn_num(size(n)), ArTn_num(size(n))
real(pr) :: Arn2_num(size(n), size(n))
n = [1.5, 0.2, 0.7, 2.3]
tc = [190.564, 425.12, 300.11, 320.25]
pc = [45.99, 37.96, 39.23, 40.21]
w = [0.0115478, 0.200164, 0.3624, 0.298]
T = 600_pr
V = 0.5_pr
model = SoaveRedlichKwong(tc, pc, w)
call numeric_ar_derivatives(&
model, n, V, T, d_n = 0.0001_pr, d_v = 0.0001_pr, d_t = 0.01_pr, &
Ar=Ar_num, ArV=ArV_num, ArT=ArT_num, ArTV=ArTV_num, ArV2=ArV2_num, &
ArT2=ArT2_num, Arn=Arn_num, ArVn=ArVn_num, ArTn=ArTn_num, &
Arn2=Arn2_num &
)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(ArModel), | intent(in) | :: | eos |
Equation of state |
||
real(kind=pr), | intent(in) | :: | n(:) |
Moles number vector |
||
real(kind=pr), | intent(in) | :: | V |
Volume [L] |
||
real(kind=pr), | intent(in) | :: | T |
Temperature [K] |
||
real(kind=pr), | intent(in) | :: | d_n |
Moles finite difference step |
||
real(kind=pr), | intent(in) | :: | d_v |
Volume finite difference step |
||
real(kind=pr), | intent(in) | :: | d_t |
Temperature finite difference step |
||
real(kind=pr), | intent(out) | :: | Ar |
Residual Helmoltz energy |
||
real(kind=pr), | intent(out), | optional | :: | ArV |
|
|
real(kind=pr), | intent(out), | optional | :: | ArT |
|
|
real(kind=pr), | intent(out), | optional | :: | Arn(size(n)) |
|
|
real(kind=pr), | intent(out), | optional | :: | ArV2 |
|
|
real(kind=pr), | intent(out), | optional | :: | ArT2 |
|
|
real(kind=pr), | intent(out), | optional | :: | ArTV |
|
|
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)) |
|
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
real(kind=pr), | public | :: | Ar_aux1 | ||||
real(kind=pr), | public | :: | Ar_aux2 | ||||
real(kind=pr), | public | :: | Ar_aux3 | ||||
real(kind=pr), | public | :: | Ar_aux4 | ||||
real(kind=pr), | public | :: | dn_aux1(size(n)) | ||||
real(kind=pr), | public | :: | dn_aux2(size(n)) | ||||
integer, | public | :: | i | ||||
integer, | public | :: | j |