Skip to content

Commit

Permalink
Merge branch 'main' of github.com:fedebenelli/yaeos into 7-ideal-models
Browse files Browse the repository at this point in the history
  • Loading branch information
fedebenelli committed Feb 5, 2024
2 parents a5445ef + c69cfac commit 32f3c3a
Show file tree
Hide file tree
Showing 20 changed files with 1,457 additions and 875 deletions.
373 changes: 373 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[![GitHub](https://img.shields.io/badge/GitHub-fedebenelli-blue.svg?style=social&logo=github)](https://github.com/fedebenelli) [![Fortran](https://img.shields.io/badge/Fortran-734f96?logo=fortran&style=flat)](https://fortran-lang.org) [![fpm](https://img.shields.io/badge/fpm-Fortran_package_manager-734f96)](https://fpm.fortran-lang.org) [![Documentation](https://img.shields.io/badge/ford-Documentation%20-blueviolet.svg)](https://fedebenelli.github.io/yaeos/) [![License](https://img.shields.io/github/license/fedebenelli/yaeos?color=green)](https://github.com/fedebenelli/yaeos/blob/main/LICENSE) [![CI](https://github.com/fedebenelli/yaeos/actions/workflows/CI.yml/badge.svg)](https://github.com/fedebenelli/yaeos/actions/workflows/CI.yml)
[![GitHub](https://img.shields.io/badge/GitHub-fedebenelli-blue.svg?style=social&logo=github)](https://github.com/fedebenelli)
[![Fortran](https://img.shields.io/badge/Fortran-734f96?logo=fortran&style=flat)](https://fortran-lang.org)
[![fpm](https://img.shields.io/badge/fpm-Fortran_package_manager-734f96)](https://fpm.fortran-lang.org)
[![Documentation](https://img.shields.io/badge/ford-Documentation%20-blueviolet.svg)](https://fedebenelli.github.io/yaeos/)
[![License: MPL 2.0](https://img.shields.io/badge/License-MPL_2.0-brightgreen.svg)](https://github.com/fedebenelli/yaeos/blob/main/LICENSE)
[![CI](https://github.com/fedebenelli/yaeos/actions/workflows/CI.yml/badge.svg)](https://github.com/fedebenelli/yaeos/actions/workflows/CI.yml)

# YA_EoS
There are multiple open source equation of state libraries, like:
Expand Down
6 changes: 3 additions & 3 deletions doc/ford-front-matter.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ display: public
source: false
proc_internals: true
sort: permission-alpha
docmark_alt: -|
docmark: |
docmark_alt: !>
docmark: !
predocmark_alt: *
print_creation_date: true
creation_date: %Y-%m-%d %H:%M %z
md_extensions: markdown.extensions.toc
markdown.extensions.smarty
graph: true
license: MIT
license: MPL
page_dir:pages

{!../README.md!}
3 changes: 0 additions & 3 deletions doc/pages/subdir/index.md

This file was deleted.

4 changes: 2 additions & 2 deletions fpm.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "yaeos"
version = "0.1.0"
license = "BSD"
license = "MPL"
author = "Federico E. Benelli"
maintainer = "[email protected]"
copyright = "Copyright 2023, Federico E. Benelli"
Expand Down Expand Up @@ -28,4 +28,4 @@ main = "demo.f90"
[[example]]
name = "adiff_new_model"
source-dir = "example"
main = "demo.f90"
main = "demo.f90"
8 changes: 4 additions & 4 deletions src/adiff/autodiff.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module yaeos_autodiff
!-| This module holds the diferent ways of automatic differentiation
use hyperdual_mod
implicit none
end module
!! This module holds the diferent ways of automatic differentiation
use hyperdual_mod
implicit none
end module
48 changes: 46 additions & 2 deletions src/adiff/autodiff_api/armodel_adiff_api.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,48 @@
module yaeos_ar_models_hyperdual
!-| Module that contains the automatic differentiation logic for an Ar model
!! 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:
!!
!! ```fortran
!! module newmodel
!! use yaeos_ar_models_hyperdual, 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`
!!
use yaeos_constants, only: pr
use yaeos_models_ar, only: ArModel
use yaeos_autodiff
Expand Down Expand Up @@ -58,6 +101,8 @@ subroutine residual_helmholtz(&
end if
end if

Ar = d_Ar%f0

contains

subroutine get_dardn()
Expand Down Expand Up @@ -163,7 +208,6 @@ subroutine reset_vars()
d_v = v
d_t = t
end subroutine

end subroutine

end module
Loading

0 comments on commit 32f3c3a

Please sign in to comment.