Abstract interface and adapter for source-to-source differentiated EOS models.
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.
See PCSAFT in src/models/residual_helmholtz/saft/pc_saft.f90 for a
production implementation and tools/tapenade_diff/ for the generator.
Tapenade documentation: https://tapenade.gitlabpages.inria.fr/
Primal residual Helmholtz callback required by ArModelTapenade.
| Type | Intent | Optional | 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. |
Reverse-mode adjoint callback for the residual Helmholtz energy.
| Type | Intent | Optional | 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. |
Forward directional derivative callback for the residual Helmholtz energy.
| Type | Intent | Optional | 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. |
Mixed forward/reverse callback used for Hessian and mixed derivatives.
| Type | Intent | Optional | 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. |
Nested forward-mode callback for second directional derivatives.
| Type | Intent | Optional | 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. |
Base class for EOS models with Tapenade-generated derivatives.
| 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 |
| 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 |
Residual Helmholtz model generic interface
| Type | Intent | Optional | 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]. |