Skip to content

Commit

Permalink
Merge pull request #94 from ipqa-research/dev
Browse files Browse the repository at this point in the history
Renamed EquilbriaState to EquilibriumState
  • Loading branch information
fedebenelli authored Jul 18, 2024
2 parents ca09eab + fb10c5d commit e3981c2
Show file tree
Hide file tree
Showing 25 changed files with 90 additions and 88 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
fort.*
.stuff
build
.vscode
tools/Makefile
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ call model%pressure(z, V, T, P)
print *, P
! Obtain derivatives adding them as optional arguments!
call pressure(model, z, V, T, P, dPdN=dPdN)
call model%pressure(model, z, V, T, P, dPdN=dPdN)
print *, dPdN
```

Expand Down
8 changes: 4 additions & 4 deletions app/fit.f90
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
program main
!! Binary system parameter optimization
use yaeos, only: EquilibriaState, pr, ArModel, SoaveRedlichKwong, CubicEoS, saturation_pressure
use yaeos, only: EquilibriumState, pr, ArModel, SoaveRedlichKwong, CubicEoS, saturation_pressure
use yaeos, only: MHV
use forsus, only: Substance, forsus_dir
use yaeos__fitting, only: FittingProblem, fobj, optimize
use yaeos__fitting_fit_nrtl_mhv, only: FitMHVNRTL
integer, parameter :: nc = 2, np=7
integer :: i, infile, iostat

type(EquilibriaState), allocatable :: exp_points(:)
type(EquilibriaState) :: point
type(EquilibriumState), allocatable :: exp_points(:)
type(EquilibriumState) :: point

type(FitMHVNRTL) :: prob
type(Substance) :: sus(2)
Expand All @@ -33,7 +33,7 @@ program main
if (iostat /= 0) exit
select case (kind)
case ("bubble", "dew", "liquid-liquid")
point = EquilibriaState( &
point = EquilibriumState( &
kind=kind, T=T, P=P, x=[x1, 1 - x1], y=[y1, 1 - y1], &
Vx=0._pr, Vy=0._pr, iters=0, beta=0._pr &
)
Expand Down
4 changes: 2 additions & 2 deletions app/flash.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ program flasher
!! EoS model.

! Import the relevant
use yaeos, only: pr, EquilibriaState, flash, PengRobinson76, ArModel
use yaeos, only: pr, EquilibriumState, flash, PengRobinson76, ArModel
implicit none

! Variables definition:
class(ArModel), allocatable :: model !! Model to use
type(EquilibriaState) :: flash_result !! Result of Flash calculation
type(EquilibriumState) :: flash_result !! Result of Flash calculation

real(pr) :: tc(2), pc(2), w(2)
real(pr) :: n(2), t, p, k0(2)
Expand Down
4 changes: 2 additions & 2 deletions app/phase_diagram.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ program phase_diagram
use forsus, only: Substance, forsus_dir, forsus_default_dir
use yaeos, only: pr, &
SoaveRedlichKwong, PengRobinson76, PengRobinson78, RKPR, &
EquilibriaState, ArModel, PTEnvel2, &
EquilibriumState, ArModel, PTEnvel2, &
pt_envelope_2ph, saturation_pressure, saturation_temperature
use yaeos__phase_equilibria_auxiliar, only: k_wilson
implicit none
Expand All @@ -13,7 +13,7 @@ program phase_diagram
! ---------------------------------------------------------------------------
integer, parameter :: nc=2
class(ArModel), allocatable :: model ! Thermodynamic model to be used
type(EquilibriaState) :: sat_point ! Init
type(EquilibriumState) :: sat_point ! Init
type(PTEnvel2) :: envelope ! PT Phase envelope
real(pr) :: tc(nc), pc(nc), w(nc) ! Component's critical constants
real(pr) :: n(nc) ! Termodynamic variables
Expand Down
2 changes: 1 addition & 1 deletion app/saturation.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ program main
real(pr), dimension(nc) :: tc, pc, w
type(MHV) :: mixrule
type(CubicEOS) :: eos
type(EquilibriaState) :: eq
type(EquilibriumState) :: eq
real(pr) :: n(nc)

integer :: i
Expand Down
2 changes: 1 addition & 1 deletion doc/page/usage/eos/cubics/alpha.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
title: alpha functions
title: Alpha functions
---
2 changes: 1 addition & 1 deletion doc/page/usage/eos/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ title: Equations of State
ordered_subpage: cubics
---

Explain ArModels thermoprops here
`yaeos` is a library based on Equation-of-State calculations.
4 changes: 2 additions & 2 deletions example/extra/flash.f90
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module flashing
use yaeos, only: pr, EquilibriaState, flash, PengRobinson76, ArModel
use yaeos, only: pr, EquilibriumState, flash, PengRobinson76, ArModel
implicit none

contains

subroutine main()
class(ArModel), allocatable :: model
type(EquilibriaState) :: flash_result
type(EquilibriumState) :: flash_result

real(pr) :: tc(2), pc(2), w(2)

Expand Down
2 changes: 1 addition & 1 deletion example/extra/hard_spheres_mixing.f90
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ subroutine main
type(hPR76) :: hdpr76
type(HardSpheresCubicEoS) :: hspr76

type(EquilibriaState) :: eq
type(EquilibriumState) :: eq
type(PTEnvel2) :: env

real(pr) :: Ar, ArT, ArV, ArTV, ArT2, ArV2, Arn(nc), Artn(nc), ArVn(nc), arn2(nc,nc)
Expand Down
8 changes: 4 additions & 4 deletions example/tutorials/huron_vidal.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ program main
use forsus, only: Substance, forsus_dir
use yaeos, only: &
pr, SoaveRedlichKwong, CubicEoS, NRTL, saturation_pressure, &
pt_envelope_2ph, EquilibriaState, PTEnvel2, UNIFAC, setup_unifac, Groups
pt_envelope_2ph, EquilibriumState, PTEnvel2, UNIFAC, setup_unifac, Groups
use yaeos__models_cubic_mixing_rules_huron_vidal, only: MHV

implicit none
Expand All @@ -21,7 +21,7 @@ program main
type(MHV) :: mixrule
type(Groups) :: molecules(nc)

type(EquilibriaState) :: sat
type(EquilibriumState) :: sat

type(Substance) :: sus(nc)

Expand Down Expand Up @@ -75,9 +75,9 @@ program main
contains

subroutine phase_envel(fu)
use yaeos, only: EquilibriaState, PTEnvel2, pt_envelope_2ph, saturation_temperature
use yaeos, only: EquilibriumState, PTEnvel2, pt_envelope_2ph, saturation_temperature
integer :: fu
type(EquilibriaState) :: sat
type(EquilibriumState) :: sat
type(PTEnvel2) :: env

sat = saturation_pressure(model, n, T=300._pr, kind="bubble")
Expand Down
2 changes: 1 addition & 1 deletion example/tutorials/phase_envelope.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ program phase_envelope
implicit none

class(ArModel), allocatable :: model ! model
type(EquilibriaState) :: bubble !
type(EquilibriumState) :: bubble !
type(PTEnvel2) :: envelope

integer, parameter :: nc=2
Expand Down
4 changes: 2 additions & 2 deletions example/tutorials/saturation_points.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
! - saturation_pressure
! - saturation_temperature
!
! All the outputs of this functions use the `EquilibriaState` type
! All the outputs of this functions use the `EquilibriumState` type
program saturation
use yaeos
use yaeos__example_tools, only: methane_butane_pr76

class(ArModel), allocatable :: model
type(EquilibriaState) :: sat_point
type(EquilibriumState) :: sat_point

real(pr) :: n(2), T

Expand Down
16 changes: 8 additions & 8 deletions python/yaeos/fortran_wrap/yaeos_c.f90
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ end subroutine fug_vt
! Phase equilibria
! --------------------------------------------------------------------------
subroutine equilibria_state_to_arrays(eq_state, x, y, P, T, Vx, Vy, beta)
use yaeos, only: EquilibriaState
type(EquilibriaState) :: eq_state
use yaeos, only: EquilibriumState
type(EquilibriumState) :: eq_state
real(c_double), intent(out) :: x(:)
real(c_double), intent(out) :: y(:)
real(c_double), intent(out) :: P
Expand All @@ -266,7 +266,7 @@ subroutine equilibria_state_to_arrays(eq_state, x, y, P, T, Vx, Vy, beta)
end subroutine equilibria_state_to_arrays

subroutine flash(id, z, T, P, x, y, k0, Pout, Tout, Vx, Vy, beta)
use yaeos, only: EquilibriaState, fflash => flash
use yaeos, only: EquilibriumState, fflash => flash
integer(c_int), intent(in) :: id
real(c_double), intent(in) :: z(:)
real(c_double), intent(in) :: T
Expand All @@ -280,7 +280,7 @@ subroutine flash(id, z, T, P, x, y, k0, Pout, Tout, Vx, Vy, beta)
real(c_double), intent(out) :: Vy
real(c_double), intent(out) :: beta

type(EquilibriaState) :: result
type(EquilibriumState) :: result
integer :: iters

result = fflash(ar_models(id)%model, z, t, p_spec=p, iters=iters)
Expand All @@ -299,7 +299,7 @@ subroutine flash(id, z, T, P, x, y, k0, Pout, Tout, Vx, Vy, beta)
end subroutine flash

subroutine saturation_pressure(id, z, T, kind, P, x, y, Vx, Vy, beta)
use yaeos, only: EquilibriaState, fsaturation_pressure => saturation_pressure
use yaeos, only: EquilibriumState, fsaturation_pressure => saturation_pressure
integer(c_int), intent(in) :: id
real(c_double), intent(in) :: z(:)
real(c_double), intent(in) :: T
Expand All @@ -312,7 +312,7 @@ subroutine saturation_pressure(id, z, T, kind, P, x, y, Vx, Vy, beta)

real(c_double) :: aux

type(EquilibriaState) :: sat
type(EquilibriumState) :: sat

sat = fsaturation_pressure(ar_models(id)%model, z, T, kind)
call equilibria_state_to_arrays(sat, x, y, P, aux, Vx, Vy, beta)
Expand All @@ -321,7 +321,7 @@ end subroutine saturation_pressure
subroutine pt2_phase_envelope(id, z, kind, Ts, Ps, tcs, pcs, T0, P0)
use yaeos, only: &
saturation_pressure, saturation_temperature, pt_envelope_2ph, &
EquilibriaState, PTEnvel2
EquilibriumState, PTEnvel2
integer(c_int), intent(in) :: id
real(c_double), intent(in) :: z(:)
character(len=15), intent(in) :: kind
Expand All @@ -331,7 +331,7 @@ subroutine pt2_phase_envelope(id, z, kind, Ts, Ps, tcs, pcs, T0, P0)
real(c_double), optional, intent(in) :: T0, P0

real(8) :: makenan, nan
type(EquilibriaState) :: sat
type(EquilibriumState) :: sat
type(PTEnvel2) :: env

integer :: i, neval=0
Expand Down
2 changes: 1 addition & 1 deletion src/fitting/fit_kij_lij.f90
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module yaeos__fitting_fit_kij_lij
!! ```fortran
!! type(CubicEoS) :: model ! Model to fit
!! type(FitKijLij) :: fitting_problem ! Fitting problem specification
!! type(EquilibriaState) :: exp_data(3)
!! type(EquilibriumState) :: exp_data(3)
!! real(pr) :: X(2) ! parameter variables
!! real(pr) :: error
!!
Expand Down
8 changes: 4 additions & 4 deletions src/fitting/fitting.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module yaeos__fitting
use yaeos__constants, only: pr
use yaeos__models, only: ArModel, CubicEoS
use yaeos__equilibria, only: &
EquilibriaState, saturation_pressure, saturation_temperature, flash
EquilibriumState, saturation_pressure, saturation_temperature, flash
use forbear, only: bar_object
implicit none

Expand All @@ -19,7 +19,7 @@ module yaeos__fitting

class(ArModel), allocatable :: model

type(EquilibriaState), allocatable :: experimental_points(:)
type(EquilibriumState), allocatable :: experimental_points(:)
logical :: verbose = .false.
contains
procedure(model_from_X), deferred :: get_model_from_X
Expand Down Expand Up @@ -132,8 +132,8 @@ real(pr) function error_function(X, func_data) result(fobj)
real(pr), intent(in) :: X(:)
class(FittingProblem) :: func_data

type(EquilibriaState) :: model_point !! Each solved point
type(EquilibriaState) :: exp_point
type(EquilibriumState) :: model_point !! Each solved point
type(EquilibriumState) :: exp_point

integer :: i

Expand Down
10 changes: 5 additions & 5 deletions src/phase_equilibria/boundaries/phase_envelopes_pt.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module yaeos__phase_equilibria_boundaries_phase_envelopes_pt
!! Phase boundaries line on the \(PT\) plane calculation procedures.
use yaeos__constants, only: pr
use yaeos__models, only: ArModel
use yaeos__equilibria_equilibria_state, only: EquilibriaState
use yaeos__equilibria_equilibria_state, only: EquilibriumState
use yaeos__math_continuation, only: &
continuation, continuation_solver, continuation_stopper
implicit none
Expand All @@ -16,7 +16,7 @@ module yaeos__phase_equilibria_boundaries_phase_envelopes_pt
type :: PTEnvel2
!! Two-phase isopleth.
!! Phase boundary line of a fluid at constant composition.
type(EquilibriaState), allocatable :: points(:)
type(EquilibriumState), allocatable :: points(:)
!! Each point through the line.
type(CriticalPoint), allocatable :: cps(:)
!! Critical points found along the line.
Expand Down Expand Up @@ -44,7 +44,7 @@ function pt_envelope_2ph(&
!! Thermodyanmic model
real(pr), intent(in) :: z(:)
!! Vector of molar fractions
type(EquilibriaState) :: first_point
type(EquilibriumState) :: first_point
integer, optional, intent(in) :: points
!! Maxmimum number of points, defaults to 500
integer, optional, intent(in) :: iterations
Expand Down Expand Up @@ -238,14 +238,14 @@ subroutine save_point(X, iters)
!! Save the converged point
real(pr), intent(in) :: X(:)
integer, intent(in) :: iters
type(EquilibriaState) :: point
type(EquilibriumState) :: point

real(pr) :: y(nc), T, P

T = exp(X(nc+1))
P = exp(X(nc+2))
y = exp(X(:nc))*z
point = EquilibriaState(&
point = EquilibriumState(&
kind=kind, x=z, Vx=0._pr, y=y, Vy=0._pr, &
T=T, P=P, beta=0._pr, iters=iters &
)
Expand Down
12 changes: 6 additions & 6 deletions src/phase_equilibria/equilibria_state.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module yaeos__equilibria_equilibria_state
use yaeos__constants, only: pr
implicit none

type :: EquilibriaState
type :: EquilibriumState
!! Description of a two-phase equilibria state.
!!
!! Contains the relevant information of an equilibrium point obtained
Expand All @@ -27,14 +27,14 @@ module yaeos__equilibria_equilibria_state
!! Mole fraction of light-phase
contains
private
procedure, pass :: write => write_EquilibriaState
procedure, pass :: write => write_EquilibriumState
generic, public :: write (FORMATTED) => write
end type EquilibriaState
end type EquilibriumState

contains

subroutine write_EquilibriaState(eq, unit, iotype, v_list, iostat, iomsg)
class(EquilibriaState), intent(in) :: eq
subroutine write_EquilibriumState(eq, unit, iotype, v_list, iostat, iomsg)
class(EquilibriumState), intent(in) :: eq
integer, intent(in) :: unit
character(*), intent(in) :: iotype
integer, intent(in) :: v_list(:)
Expand All @@ -45,5 +45,5 @@ subroutine write_EquilibriaState(eq, unit, iotype, v_list, iostat, iomsg)

write(unit, *) eq%kind, eq%T, eq%P, eq%beta, eq%x, eq%y

end subroutine write_EquilibriaState
end subroutine write_EquilibriumState
end module yaeos__equilibria_equilibria_state
4 changes: 2 additions & 2 deletions src/phase_equilibria/flash.f90
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
module yaeos__equilibria_flash
use yaeos__constants, only: pr
use yaeos__models, only: ArModel
use yaeos__equilibria_equilibria_state, only: EquilibriaState
use yaeos__equilibria_equilibria_state, only: EquilibriumState
use yaeos__phase_equilibria_rachford_rice, only: betato01, betalimits, rachford_rice, solve_rr
use yaeos__phase_equilibria_auxiliar, only: k_wilson
implicit none

contains

type(EquilibriaState) function flash(model, z, t, v_spec, p_spec, k0, iters)
type(EquilibriumState) function flash(model, z, t, v_spec, p_spec, k0, iters)
!! Flash algorithm using sucessive substitutions.
!!
!! Available specifications:
Expand Down
2 changes: 1 addition & 1 deletion src/phase_equilibria/phase_equilibria.f90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module yaeos__equilibria
use yaeos__equilibria_equilibria_state, only: EquilibriaState
use yaeos__equilibria_equilibria_state, only: EquilibriumState
use yaeos__equilibria_flash, only: flash
use yaeos__equilibria_saturation_points, only:&
saturation_pressure, saturation_temperature
Expand Down
Loading

0 comments on commit e3981c2

Please sign in to comment.