yaeos__adiff_hyperdual_ar_api Module

Hyperdual residual Helmholtz models

Base type and derivative adapter for models defined with hyperdual numbers.

Description

Extend ArModelAdiff, implement its hyperdual Ar function and the inherited volume initializer, and the adapter extracts the first and second derivatives required by the standard ArModel interface. This is the intended user entry point for operator-overloaded AD; the adapter routines are its implementation details.

Examples

All that is needed is a derived type extending ArModelAdiff, a hyperdual-valued Ar function, and the inherited volume initializer.

module newmodel
use yaeos__adiff_hyperdual_ar_api, only: ArModelAdiff
use yaeos__constants, only: pr
use hyperdual_mod, only: hyperdual
implicit none

type, extends(ArModelAdiff) :: YourNewModel
   real(pr) :: a = 1.0_pr
contains
   procedure :: Ar => arfun
   procedure :: get_v0 => v0
end type
contains
type(hyperdual) function arfun(self, n, v, t) result(arval)
   class(YourNewModel) :: self
   type(hyperdual), intent(in) :: n(:), v, t

   arval = sum(n) * t + self%a * v
end function arfun

function v0(self, n, p, t) result(vol)
   class(YourNewModel), intent(in) :: self
   real(pr), intent(in) :: n(:), p, t
   real(pr) :: vol

   vol = self%a * sum(n)
end function v0
end module newmodel

References

See example/extra/adiff_pr76.f90 and the user guide’s automatic- differentiation page for a complete implementation.


Uses

  • module~~yaeos__adiff_hyperdual_ar_api~~UsesGraph module~yaeos__adiff_hyperdual_ar_api yaeos__adiff_hyperdual_ar_api module~hyperdual_mod hyperdual_mod module~yaeos__adiff_hyperdual_ar_api->module~hyperdual_mod module~yaeos__constants yaeos__constants module~yaeos__adiff_hyperdual_ar_api->module~yaeos__constants module~yaeos__models_ar yaeos__models_ar module~yaeos__adiff_hyperdual_ar_api->module~yaeos__models_ar module~hyperdual_mod->module~yaeos__constants 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 yaeos__substance module~yaeos__models_base->module~yaeos__substance module~yaeos__substance->module~yaeos__constants

Used by

  • module~~yaeos__adiff_hyperdual_ar_api~~UsedByGraph module~yaeos__adiff_hyperdual_ar_api yaeos__adiff_hyperdual_ar_api module~yaeos__autodiff yaeos__autodiff module~yaeos__autodiff->module~yaeos__adiff_hyperdual_ar_api module~yaeos__models_ar_gerg2008 yaeos__models_ar_gerg2008 module~yaeos__models_ar_gerg2008->module~yaeos__adiff_hyperdual_ar_api module~yaeos__models yaeos__models 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_ge_implementations yaeos__models_ge_implementations module~yaeos__models->module~yaeos__models_ge_implementations module~yaeos__models_ge_nrtlhv yaeos__models_ge_nrtlhv module~yaeos__models_ge_nrtlhv->module~yaeos__autodiff 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_cubic_mixing_rules_huron_vidal->module~yaeos__models_ge_nrtlhv module~yaeos__models_ge_implementations->module~yaeos__models_ge_nrtlhv proc~co2_h2o_isop co2_h2o_isop proc~co2_h2o_isop->module~yaeos__models proc~dmixhvnrtl HV_NRTL%DmixHVNRTL proc~dmixhvnrtl->module~yaeos__models_ge_nrtlhv proc~init_hvnrtl init_hvnrtl proc~init_hvnrtl->module~yaeos__models_ge_nrtlhv proc~psrk PSRK proc~psrk->module~yaeos__models_cubic_mixing_rules_huron_vidal proc~psrk->module~yaeos__models_ge_implementations

Abstract Interfaces

abstract interface

  • public function hyperdual_Ar(self, n, v, t)

    Evaluate the model’s residual Helmholtz energy [bar L] in hyperdual arithmetic.

    Arguments

    Type IntentOptional Attributes Name
    class(ArModelAdiff) :: self

    Concrete EOS model; passed-object dummy.

    type(hyperdual), intent(in) :: n(:)

    Component mole amounts as hyperdual values.

    type(hyperdual), intent(in) :: v

    Total volume as a hyperdual value.

    type(hyperdual), intent(in) :: t

    Temperature as a hyperdual value.

    Return Value type(hyperdual)


Derived Types

type, public, abstract, extends(ArModel) ::  ArModelAdiff

Base type for residual Helmholtz models defined with hyperdual arithmetic.

Read more…

Components

Type Visibility Attributes Name Initial
type(Substances), public :: components

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

character(len=:), public, allocatable :: name

Name of the model

Type-Bound Procedures

procedure(hyperdual_Ar), public, deferred :: Ar
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 :: 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(abs_volume_initializer), public, deferred :: get_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
procedure, public :: volume
procedure, public :: volume_excess

Subroutines

public subroutine residual_helmholtz(self, n, v, t, Ar, ArV, ArT, ArTV, ArV2, ArT2, Arn, ArVn, ArTn, Arn2)

Evaluate residual Helmholtz energy and requested derivatives by AD.

Read more…

Arguments

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

Model instance.

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(out), optional :: Ar

Residual Helmholtz energy [bar L].

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

[bar].

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

[bar L/K].

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

[bar/K].

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

[bar/L].

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

[bar L/K^2].

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

[bar L/mol].

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

[bar/mol].

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

[bar L/(K mol)].

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

[bar L/mol^2].