Skip to content

Commit

Permalink
HA
Browse files Browse the repository at this point in the history
  • Loading branch information
DANA-Laboratory committed Dec 18, 2016
1 parent 8e731a6 commit 3616039
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 29 deletions.
30 changes: 3 additions & 27 deletions test/CoolProp.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module CoolProp
using Compat
export PropsSI, PhaseSI, get_global_param_string, get_parameter_information_string,get_fluid_param_string,set_reference_stateS, get_param_index, get_input_pair_index, set_config, F2K, K2F, HAPropsSI, AbstractState_factory, AbstractState_free, AbstractState_set_fractions, AbstractState_update, AbstractState_specify_phase, AbstractState_unspecify_phase, AbstractState_keyed_output, AbstractState_output, AbstractState_update_and_common_out, AbstractState_update_and_1_out, AbstractState_update_and_5_out, AbstractState_set_binary_interaction_double, AbstractState_set_cubic_alpha_C, AbstractState_set_fluid_parameter_double
export propssi, phasesi, k2f, f2k
export propssi, phasesi, k2f, f2k, hapropssi, cair_sat
errcode = Ref{Clong}(0)

const buffer_length = 20000
Expand Down Expand Up @@ -53,32 +53,7 @@ end
# EXPORT_CODE double CONVENTION saturation_ancillary(const char *fluid_name, const char *output, int Q, const char *input, double value);
###

# ---------------------------------
# Humid Air Properties
# ---------------------------------

"""
HAPropsSI(Output::AbstractString, Name1::AbstractString, Value1::Real, Name2::AbstractString, Value2::Real, Name3::AbstractString, Value3::Real)
DLL wrapper of the HAPropsSI function.
\ref HumidAir::HAPropsSI(const char *OutputName, const char *Input1Name, double Input1, const char *Input2Name, double Input2, const char *Input3Name, double Input3);
\note If there is an error, a huge value will be returned, you can get the error message by doing something like get_global_param_string("errstring",output)
"""
function HAPropsSI(Output::AbstractString, Name1::AbstractString, Value1::Real, Name2::AbstractString, Value2::Real, Name3::AbstractString, Value3::Real)
val = ccall( (:HAPropsSI, "CoolProp"), Cdouble, (Ptr{UInt8},Ptr{UInt8},Float64,Ptr{UInt8},Float64,Ptr{UInt8},Float64), Output,Name1,Value1,Name2,Value2,Name3,Value3)
if val == Inf
error("CoolProp: ", get_global_param_string("errstring"))
end
return val
end

###
# /** \brief DLL wrapper of the cair_sat function
# * \sa \ref HumidAir::cair_sat(double);
# */
# EXPORT_CODE double CONVENTION cair_sat(double T);
###
include("CoolPropHA.jl");

# ---------------------------------
# Low-level access
Expand Down Expand Up @@ -544,4 +519,5 @@ const PropsSI = propssi;
const PhaseSI = phasesi;
const K2F = k2f;
const F2K = f2k;
const HAPropsSI = hapropssi;
end #module
1 change: 0 additions & 1 deletion test/CoolPropConfig.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# ---------------------------------
# Configuration functions
# ---------------------------------
Expand Down
84 changes: 84 additions & 0 deletions test/CoolPropHA.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# ---------------------------------
# Humid Air Properties
# ---------------------------------

"""
hapropssi(output::AbstractString, name1::AbstractString, value1::Real, name2::AbstractString, value2::Real, name3::AbstractString, value3::Real)
DLL wrapper of the HAPropsSI function.
# Arguments
* `output`:
* `name1`, `name2`, `name3`:
Description |Parameter(s) name
:---------------------|:--------------
GIVEN_HUMRAT |Omega HumRat W
GIVEN_PSIW |psi_w Y
Dew point |Tdp T_dp DewPoint D
Wet bulb temperature |Twb T_wb WetBulb B
Enthalpy |Enthalpy H Hda
GIVEN_ENTHALPY_HA |Hha
Internal energy |InternalEnergy U Uda
GIVEN_INTERNAL_ENERGY_HA |Uha
Entropy |Entropy S Sda
GIVEN_ENTROPY_HA |Sha
GIVEN_RH |RH RelHum R
Temperature |Tdb T_db T
Pressure |P
GIVEN_VDA |V Vda
GIVEN_VHA |Vha
Viscosity |mu Visc M
Conductivity |k Conductivity K
GIVEN_CP |C cp
GIVEN_CPHA |Cha cp_ha
GIVEN_CV |CV
GIVEN_CVHA |CVha cv_ha
Partial pressure of water |P_w
GIVEN_ISENTROPIC_EXPONENT |isentropic_exponent
Speed of sound |speed_of_sound
Compressibility factor|Z
# Example
```julia
# Enthalpy (J per kg dry air) as a function of temperature, pressure,
# and relative humidity at STP
julia> h = HAPropsSI("H","T",298.15,"P",101325,"R",0.5)
50423.45039247604
# Temperature of saturated air at the previous enthalpy
julia> T = HAPropsSI("T","P",101325,"H",h,"R",1.0)
290.9620891952412
# Temperature of saturated air - order of inputs doesn't matter
julia> T = HAPropsSI("T","H",h,"R",1.0,"P",101325)
290.9620891952412
```
# Ref
HumidAir::HAPropsSI(const char* OutputName, const char* Input1Name, double Input1, const char* Input2Name, double Input2, const char* Input3Name, double Input3);
"""
function hapropssi(output::AbstractString, name1::AbstractString, value1::Real, name2::AbstractString, value2::Real, name3::AbstractString, value3::Real)
val = ccall( (:HAPropsSI, "CoolProp"), Cdouble, (Ptr{UInt8},Ptr{UInt8},Float64,Ptr{UInt8},Float64,Ptr{UInt8},Float64), output,name1,value1,name2,value2,name3,value3)
if val == Inf
error("CoolProp: ", get_global_param_string("errstring"))
end
return val
end

"""
cair_sat(t::Real)
Air saturation specific heat in [kJ/kg-K] based on a correlation from EES, good from 250K to 300K.
# Arguments
* `t`: Temperature in Kelvin
# Ref
HumidAir::cair_sat(double);
# Note
No error bound checking is carried out
"""
function cair_sat(t::Number)
val = ccall( (:cair_sat, "CoolProp"), Cdouble, (Float64, ), t)
return val;
end
1 change: 0 additions & 1 deletion test/CoolPropHighLevel.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# ---------------------------------
# High-level functions
# ---------------------------------
Expand Down

0 comments on commit 3616039

Please sign in to comment.