-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Put module types first in load order
- Loading branch information
Showing
9 changed files
with
275 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
abstract type AbstractEOS end | ||
abstract type AbstractCubicEOS <: AbstractEOS end | ||
|
||
""" | ||
GenericCubicEOS is an implementation of generalized cubic equations of state. | ||
Many popular cubic equations can be written in a single form with a few changes in | ||
definitions for the terms (they are, after all, all cubic in form). References: | ||
1. [Cubic Equations of State-Which? by J.J. Martin](https://doi.org/10.1021/i160070a001) | ||
2. [Simulation of Gas Condensate Reservoir Performance by K.H. Coats](https://doi.org/10.2118/10512-PA) | ||
""" | ||
struct GenericCubicEOS{T, R, N, V} <: AbstractCubicEOS | ||
type::T | ||
mixture::MultiComponentMixture{R, N} | ||
m_1::R | ||
m_2::R | ||
ω_a::R | ||
ω_b::R | ||
volume_shift::V | ||
end | ||
|
||
""" | ||
Abstract base type for generalized cubics. | ||
Any subtype may override the any of following internal functions to alter the EOS: | ||
* static_coefficients | ||
* weight_ai | ||
* weight_bi | ||
In addition, the GenericCubicEOS is parametric on the specific cubic type for further | ||
dispatch modifications. | ||
""" | ||
abstract type AbstractGeneralizedCubic end | ||
|
||
|
||
abstract type AbstractPengRobinson <: AbstractGeneralizedCubic end | ||
|
||
""" | ||
Specializes the GenericCubicEOS to the Peng-Robinson cubic equation of state. | ||
""" | ||
struct PengRobinson <: AbstractPengRobinson end | ||
|
||
|
||
""" | ||
Specializes the GenericCubicEOS to Peng-Robinson modified for large acentric factors | ||
""" | ||
|
||
struct PengRobinsonCorrected <: AbstractPengRobinson end | ||
""" | ||
Specializes the GenericCubicEOS to the Zudkevitch-Joffe cubic equation of state. | ||
The Zudkevitch-Joffe equations of state allows for per-component functions of | ||
temperature that modify the `weight_ai` and `weight_bi` functions. These additional | ||
fitting parameters allows for more flexibility when matching complex mixtures. | ||
""" | ||
struct ZudkevitchJoffe <: AbstractGeneralizedCubic | ||
F_a | ||
F_b | ||
function ZudkevitchJoffe(; F_a = (T, c_i) -> 1.0, F_b = (T, c_i) -> 1.0) | ||
new(F_a, F_b) | ||
end | ||
end | ||
|
||
""" | ||
Specializes the GenericCubicEOS to the Soave-Redlich-Kwong cubic equation of state. | ||
""" | ||
struct SoaveRedlichKwong <: AbstractGeneralizedCubic end | ||
""" | ||
Specializes the GenericCubicEOS to the Redlich-Kwong cubic equation of state. | ||
""" | ||
struct RedlichKwong <: AbstractGeneralizedCubic end | ||
|
||
""" | ||
GenericCubicEOS(mixture, [type = PengRobinson()]) | ||
Instantiate a generic cubic equation-of-state for a `MultiComponentMixture` and | ||
a specified EOS. | ||
Currently supported choices for type: | ||
1. `PengRobinson` (default) | ||
2. `ZudkevitchJoffe` | ||
3. `RedlichKwong` | ||
4. `SoaveRedlichKwong` | ||
""" | ||
function GenericCubicEOS(mixture, type = PengRobinson(); kwarg...) | ||
ω_a, ω_b, m_1, m_2 = static_coefficients(type) | ||
setup = (ω_a = ω_a, ω_b = ω_b, m_1 = m_1, m_2 = m_2, type = type) | ||
return GenericCubicEOS(setup, mixture; kwarg...) | ||
end | ||
|
||
function GenericCubicEOS(setup::NamedTuple, mixture; volume_shift = nothing) | ||
if !isnothing(volume_shift) | ||
@assert length(volume_shift) == number_of_components(mixture) "Volume shift must have one value per component." | ||
end | ||
return GenericCubicEOS(setup.type, mixture, setup.m_1, setup.m_2, setup.ω_a, setup.ω_b, volume_shift) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"Abstract type for all flash types" | ||
abstract type AbstractFlash end | ||
"Abstract type for all flash types that use Newton in some form" | ||
abstract type AbstractNewtonFlash <: AbstractFlash end | ||
|
||
""" | ||
Flash method that uses successive subtition. | ||
Unconditionally convergent, does not require derivatives, but is very slow around critical regions. | ||
See also: [`flash_2ph!`](@ref), [`NewtonFlash`](@ref) [`SSINewtonFlash`](@ref) | ||
""" | ||
struct SSIFlash <: AbstractFlash end | ||
|
||
""" | ||
NewtonFlash([dMax = 0.2]) | ||
Flash using Newton's method for zero solve. | ||
Only conditionally convergent, but has better convergence rate than SSI. | ||
# Arguments | ||
- `dMax`: dampening factor for the newton iteration | ||
See also: [`flash_2ph!`](@ref), [`SSIFlash`](@ref) [`SSINewtonFlash`](@ref) | ||
""" | ||
@Base.kwdef struct NewtonFlash <: AbstractNewtonFlash | ||
dMax::Float64 = 0.2 | ||
end | ||
|
||
""" | ||
SSINewtonFlash([swap_iter = 5,dMax = 0.2]) | ||
Perform a number of SSI iterations, followed by Newton until convergence. | ||
See also: [`flash_2ph!`](@ref), [`SSIFlash`](@ref) [`NewtonFlash`](@ref) | ||
""" | ||
@Base.kwdef struct SSINewtonFlash <: AbstractNewtonFlash | ||
swap_iter::Int = 5 | ||
dMax::Float64 = 0.2 | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.