yaeos__adiff_hyperdual_ar_api Module

Module that contains the automatic differentiation logic for an Ar model.

All that is needed to define an Ar model that uses automatic differentiation with hyperdual numbers is to define a new derived type that overloads the method to the Ar function that you want to use. A minimal example follows:

module newmodel
use yaeos__adiff_hyperdual_ar_api, only: ArModelAdiff

type, extends(ArModelAdiff) :: YourNewModel
      type(Substances) :: composition
      real(8) :: parameters(:)
    contains
      procedure :: Ar => arfun
      procedure :: get_v0 => v0
end type
contains
subroutine arfun(self, n, v, t, Ar)
   class(YourNewModel), intent(in) :: self
   type(hyperdual), intent(in) :: n(:) ! Number of moles
   type(hyperdual), intent(in) :: v ! Volume [L]
   type(hyperdual), intent(in) :: t ! Temperature [K]
   type(hyperdual), intent(out) :: ar_value ! Residual Helmholtz Energy

   ! A very complicated residual helmholtz function of a mixture
   Ar = sum(n) * v * t
end subroutine

function v0(self, n, p, t)
   class(YourNewModel), intent(in) :: self
   real(pr), intent(in) :: n(:) ! Number of moles
   real(pr), intent(in) :: p ! Pressure [bar]
   real(pr), intent(in) :: t ! Temperature [K]
   real(pr) :: v0

   v0 = self%parameters(3)
end function

A complete implementation of the PR76 Equation of State can me found in example/adiff/adiff_pr76.f90


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_ar_saft_pcsaft yaeos__models_ar_saft_pcsaft module~yaeos__models_ar_saft_pcsaft->module~yaeos__adiff_hyperdual_ar_api module~yaeos__models yaeos__models module~yaeos__models->module~yaeos__models_ar_gerg2008 module~yaeos__models->module~yaeos__models_ar_saft_pcsaft 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__models_cubic_mixing_rules_huron_vidal->module~yaeos__models_ge_nrtlhv module~yaeos__models_ge_implementations->module~yaeos__models_ge_nrtlhv 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)

    Arguments

    Type IntentOptional Attributes Name
    class(ArModelAdiff) :: self
    type(hyperdual), intent(in) :: n(:)
    type(hyperdual), intent(in) :: v
    type(hyperdual), intent(in) :: t

    Return Value type(hyperdual)


Derived Types

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

Components

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

Substances contained in the module

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

Name of the model

Type-Bound Procedures

procedure(hyperdual_Ar), public, deferred :: Ar
procedure, public :: Cp_residual_vt
procedure, public :: Cv_residual_vt
procedure, public :: Psat_pure
procedure, public :: enthalpy_residual_vt
procedure, public :: entropy_residual_vt
procedure(abs_volume_initializer), public, deferred :: get_v0
procedure, public :: gibbs_residual_vt
procedure, public :: internal_energy_residual_vt
procedure, public :: lnfug_vt
procedure, public :: lnphi_pt
procedure, public :: lnphi_vt
procedure, public :: pressure
procedure, public :: residual_helmholtz
procedure, public :: volume

Subroutines

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

Arguments

Type IntentOptional Attributes Name
class(ArModelAdiff), intent(in) :: self
real(kind=pr), intent(in) :: n(:)
real(kind=pr), intent(in) :: v
real(kind=pr), intent(in) :: t
real(kind=pr), intent(out), optional :: Ar
real(kind=pr), intent(out), optional :: ArV
real(kind=pr), intent(out), optional :: ArT
real(kind=pr), intent(out), optional :: ArTV
real(kind=pr), intent(out), optional :: ArV2
real(kind=pr), intent(out), optional :: ArT2
real(kind=pr), intent(out), optional, dimension(size(n)) :: Arn
real(kind=pr), intent(out), optional, dimension(size(n)) :: ArVn
real(kind=pr), intent(out), optional, dimension(size(n)) :: ArTn
real(kind=pr), intent(out), optional :: Arn2(size(n),size(n))