-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathBasicIdeal.jl
executable file
·47 lines (39 loc) · 1.18 KB
/
BasicIdeal.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
abstract type BasicIdealModel <: IdealModel end
@newmodelsingleton BasicIdeal BasicIdealModel
"""
BasicIdeal <: IdealModel
BasicIdeal(components;
userlocations = String[],
reference_state = nothing,
verbose = false)
## Input parameters
None
## Description
Default Ideal Model. Constant specific heat capacity equal to `5R/2`. it's Helmholtz energy is equal to:
```
a₀ = A₀/nRT = ∑(xᵢlog(nxᵢ/V)) - 1 - 1.5log(T)
```
## Model Construction Examples
```
# Because this model does not have parameters, all those constructors are equivalent:
idealmodel = BasicIdeal()
idealmodel = BasicIdeal("water")
idealmodel = BasicIdeal(["water","carbon dioxide"])
```
"""
BasicIdeal
export BasicIdeal
function a_ideal(model::BasicIdeal, V, T, z)
N = sum(z)
res = sum(Base.Fix2(xlogx,1/V),z)
res /= N
res -= 1.5*log(T)
res -= one(res)
# ∑(x .* log.(z/V)) - 1 original formulation, prone no NaN when passing pure Fractions
return res
end
check_arraysize(::BasicIdealModel,x::AbstractVector) = nothing
check_arraysize(::BasicIdealModel,x::AbstractMatrix) = nothing
function ∂²f∂T²(model::BasicIdealModel,V,T,z)
return -1.5*sum(z)*Rgas(model)/T
end