yaeos__tapenade_ar_api Module

Tapenade residual Helmholtz API

Abstract interface and adapter for source-to-source differentiated EOS models.

Description

ArModelTapenade requires primal, forward, reverse, mixed, and second directional derivative routines. Its implementation of residual_helmholtz dispatches to those routines to populate requested derivative outputs.

Examples

See PCSAFT in src/models/residual_helmholtz/saft/pc_saft.f90 for a production implementation and tools/tapenade_diff/ for the generator.

References

Tapenade documentation: https://tapenade.gitlabpages.inria.fr/


Uses

  • module~~yaeos__tapenade_ar_api~~UsesGraph module~yaeos__tapenade_ar_api yaeos__tapenade_ar_api module~yaeos__constants yaeos__constants module~yaeos__tapenade_ar_api->module~yaeos__constants module~yaeos__models_ar yaeos__models_ar module~yaeos__tapenade_ar_api->module~yaeos__models_ar 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__tapenade_ar_api~~UsedByGraph module~yaeos__tapenade_ar_api yaeos__tapenade_ar_api module~yaeos__models_ar_saft_pcsaft YAEOS__MODELS_AR_SAFT_PCSAFT module~yaeos__models_ar_saft_pcsaft->module~yaeos__tapenade_ar_api module~yaeos__models yaeos__models module~yaeos__models->module~yaeos__models_ar_saft_pcsaft module~yaeos yaeos module~yaeos->module~yaeos__models module~yaeos__extra_fluids yaeos__extra_fluids module~yaeos__extra_fluids->module~yaeos__models proc~co2_h2o_isop co2_h2o_isop proc~co2_h2o_isop->module~yaeos__models

Abstract Interfaces

abstract interface

  • private subroutine tapenade_ar(model, n, v, t, arval)

    tapenade_ar

    Primal residual Helmholtz callback required by ArModelTapenade.

    Arguments

    Type IntentOptional Attributes Name
    class(ArModelTapenade), intent(in) :: model

    Model parameters.

    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) :: arval

    Residual Helmholtz energy.

abstract interface

  • private subroutine tapenade_ar_b(model, n, nb, v, vb, t, tb, arval, arvalb)

    tapenade_ar_b

    Reverse-mode adjoint callback for the residual Helmholtz energy.

    Arguments

    Type IntentOptional Attributes Name
    class(ArModelTapenade), intent(in) :: model

    Model parameters.

    real(kind=pr), intent(in) :: n(:)

    Component mole amounts [mol].

    real(kind=pr) :: nb(:)

    Adjoint value for component mole amounts.

    real(kind=pr), intent(in) :: v

    Total volume [L].

    real(kind=pr) :: vb

    Adjoint value for volume.

    real(kind=pr), intent(in) :: t

    Temperature [K].

    real(kind=pr) :: tb

    Adjoint value for temperature.

    real(kind=pr) :: arval

    Primal energy value.

    real(kind=pr) :: arvalb

    Incoming adjoint seed on the energy.

abstract interface

  • private subroutine tapenade_ar_d(model, n, nd, v, vd, t, td, arval, arvald)

    tapenade_ar_d

    Forward directional derivative callback for the residual Helmholtz energy.

    Arguments

    Type IntentOptional Attributes Name
    class(ArModelTapenade), intent(in) :: model

    Model parameters.

    real(kind=pr), intent(in) :: n(:)

    Component mole amounts [mol].

    real(kind=pr), intent(in) :: nd(:)

    Tangent seed for component mole amounts (nd).

    real(kind=pr), intent(in) :: v

    Total volume [L].

    real(kind=pr), intent(in) :: vd

    Tangent seed for volume (vd).

    real(kind=pr), intent(in) :: t

    Temperature [K].

    real(kind=pr), intent(in) :: td

    Tangent seed for temperature (td).

    real(kind=pr), intent(out) :: arval

    Primal residual Helmholtz energy.

    real(kind=pr), intent(out) :: arvald

    Forward directional derivative of residual Helmholtz energy.

abstract interface

  • private subroutine tapenade_ar_d_b(model, n, nb, nd, ndb, v, vb, vd, vdb, t, tb, td, tdb, arval, arvalb, arvald, arvaldb)

    tapenade_ar_d_b

    Mixed forward/reverse callback used for Hessian and mixed derivatives.

    Arguments

    Type IntentOptional Attributes Name
    class(ArModelTapenade), intent(in) :: model

    Model parameters.

    real(kind=pr), intent(in) :: n(:)

    Component mole amounts [mol].

    real(kind=pr) :: nb(:)

    Adjoint value for component mole amounts.

    real(kind=pr), intent(in) :: nd(:)

    Forward tangent seed for the mole amounts.

    real(kind=pr) :: ndb(:)

    Mixed tangent-adjoint value for component mole amounts.

    real(kind=pr), intent(in) :: v

    Total volume [L].

    real(kind=pr) :: vb

    Adjoint value for volume.

    real(kind=pr), intent(in) :: vd

    Forward tangent seed for the volume.

    real(kind=pr) :: vdb

    Mixed tangent-adjoint value for volume.

    real(kind=pr), intent(in) :: t

    Temperature [K].

    real(kind=pr) :: tb

    Adjoint value for temperature.

    real(kind=pr), intent(in) :: td

    Forward tangent seed for the temperature.

    real(kind=pr) :: tdb

    Mixed tangent-adjoint value for temperature.

    real(kind=pr) :: arval

    Primal energy value.

    real(kind=pr) :: arvalb

    Adjoint seed for the primal energy output.

    real(kind=pr) :: arvald

    Forward directional energy derivative.

    real(kind=pr) :: arvaldb

    Mixed tangent-adjoint energy output.

abstract interface

  • private subroutine tapenade_ar_d_d(model, n, nd, v, vd0, vd, t, td0, td, arval, arvald0, arvald, arvaldd)

    tapenade_ar_d_d

    Nested forward-mode callback for second directional derivatives.

    Arguments

    Type IntentOptional Attributes Name
    class(ArModelTapenade), intent(in) :: model

    Model parameters.

    real(kind=pr), intent(in) :: n(:)

    Component mole amounts [mol].

    real(kind=pr), intent(in) :: nd(:)

    Tangent seed for component mole amounts (nd).

    real(kind=pr), intent(in) :: v

    Total volume [L].

    real(kind=pr), intent(in) :: vd0

    Tangent seed for volume (vd0).

    real(kind=pr), intent(in) :: vd

    Tangent seed for volume (vd).

    real(kind=pr), intent(in) :: t

    Temperature [K].

    real(kind=pr), intent(in) :: td0

    Tangent seed for temperature (td0).

    real(kind=pr), intent(in) :: td

    Tangent seed for temperature (td).

    real(kind=pr), intent(out) :: arval

    Primal residual Helmholtz energy.

    real(kind=pr), intent(out) :: arvald0

    First nested tangent of residual Helmholtz energy.

    real(kind=pr), intent(out) :: arvald

    Forward directional derivative of residual Helmholtz energy.

    real(kind=pr), intent(out) :: arvaldd

    Mixed second tangent of residual Helmholtz energy.


Derived Types

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

Base class for EOS models with Tapenade-generated derivatives.

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, public :: Cp_residual_pt
procedure, public :: Cp_residual_vt
procedure, public :: Cv_residual_pt
procedure, public :: Cv_residual_vt
procedure, public :: Psat_pure
procedure(tapenade_ar), public, deferred :: ar
procedure(tapenade_ar_b), public, deferred :: ar_b
procedure(tapenade_ar_d), public, deferred :: ar_d
procedure(tapenade_ar_d_b), public, deferred :: ar_d_b
procedure(tapenade_ar_d_d), public, deferred :: ar_d_d
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

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

Residual Helmholtz model generic interface

Arguments

Type IntentOptional Attributes Name
class(ArModelTapenade), 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].