Skip to content

Commit

Permalink
,
Browse files Browse the repository at this point in the history
  • Loading branch information
DANA-Laboratory committed Jan 5, 2017
1 parent 12805ec commit 36a360d
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 147 deletions.
2 changes: 1 addition & 1 deletion test/CoolProp.jl
@@ -1,6 +1,6 @@
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, 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, hapropssi, cair_sat, set_reference_state
export abstractstate_factory, abstractstate_free, abstractstate_set_fractions, abstractstate_update, abstractstate_keyed_output, abstractstate_specify_phase, abstractstate_unspecify_phase, abstractstate_update_and_common_out!, abstractstate_update_and_5_out!, abstractstate_update_and_1_out!, abstractstate_set_binary_interaction_double, abstractstate_set_cubic_alpha_c, abstractstate_set_fluid_parameter_double
errcode = Ref{Clong}(0)
Expand Down
2 changes: 1 addition & 1 deletion test/CoolPropConfig.jl
Expand Up @@ -19,7 +19,7 @@ ALTERNATIVE_REFPROP_HMX_BNC_PATH | "" | An alternative path to the HMX.BNC file.
VTPR_UNIFAQ_PATH | "" | The path to the directory containing the UNIFAQ JSON files. Should be slash terminated
"""
function set_config(key::AbstractString, val::AbstractString)
ccall( (:set_config_string, "CoolProp"), Void, (Cstring, Cstring), key,val)
ccall( (:set_config_string, "CoolProp"), Void, (Cstring, Cstring), key, val)
return get_global_param_string("errstring")
end

Expand Down
8 changes: 4 additions & 4 deletions test/CoolPropHA.jl
Expand Up @@ -46,21 +46,21 @@ Z |Compressibility factor | |`
```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)
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)
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)
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, (Cstring, Cstring, Cdouble, Cstring, Cdouble, Cstring, Cdouble), output,name1,value1,name2,value2,name3,value3)
val = ccall( (:HAPropsSI, "CoolProp"), Cdouble, (Cstring, Cstring, Cdouble, Cstring, Cdouble, Cstring, Cdouble), output, name1, value1, name2, value2, name3, value3)
if val == Inf
error("CoolProp: ", get_global_param_string("errstring"))
end
Expand Down
52 changes: 26 additions & 26 deletions test/CoolPropHighLevel.jl
Expand Up @@ -13,7 +13,7 @@ Return a value that does not depend on the thermodynamic state - this is a conve
# Example
```julia
julia> propssi("n-Butane","rhomolar_critical")
julia> propssi("n-Butane", "rhomolar_critical")
3922.769612987809
```
Expand All @@ -32,7 +32,7 @@ end
propssi(output::AbstractString, name1::AbstractString, value1::Real, name2::AbstractString, value2::Real, fluid::AbstractString)
Return a value that depends on the thermodynamic state.
> For pure and pseudo-pure fluids, two state points are required to fix the state. The equations of state are based on T and ρ as state variables, so T,ρ will always be the fastest inputs. P,T will be a bit slower (3-10 times), and then comes inputs where neither T nor ρ are given, like p,h. They will be much slower. If speed is an issue, you can look into table-based interpolation methods using TTSE or bicubic interpolation.
> For pure and pseudo-pure fluids, two state points are required to fix the state. The equations of state are based on T and ρ as state variables, so T, ρ will always be the fastest inputs. P, T will be a bit slower (3-10 times), and then comes inputs where neither T nor ρ are given, like p, h. They will be much slower. If speed is an issue, you can look into table-based interpolation methods using TTSE or bicubic interpolation.
# Arguments
* `fluid::AbstractString`: The name of the fluid that is part of CoolProp, for instance "n-Propane", to get a list of different passible fulid types call `get_global_param_string(key)` with `key` one of the following: `["FluidsList", "incompressible_list_pure", "incompressible_list_solution", "mixture_binary_pairs_list", "predefined_mixtures"]`, also there is a list in CoolProp online documentation [List of Fluids](http://www.coolprop.org/fluid_properties/PurePseudoPure.html#list-of-fluids)
Expand All @@ -44,19 +44,19 @@ Return a value that depends on the thermodynamic state.
# Example
```julia
julia> propssi("D","T",300,"P",101325,"n-Butane")
julia> propssi("D", "T", 300, "P", 101325, "n-Butane")
2.4325863624814326
julia> propssi("D","T",300,"P",101325,"INCOMP::DEB") # incompressible pure
julia> propssi("D", "T", 300, "P", 101325, "INCOMP::DEB") # incompressible pure
857.1454
julia> propssi("D","T",300,"P",101325,"INCOMP::LiBr[0.23]") # incompressible mass-based binary mixture
julia> propssi("D", "T", 300, "P", 101325, "INCOMP::LiBr[0.23]") # incompressible mass-based binary mixture
1187.5438243617214
julia> propssi("D","T",300,"P",101325,"INCOMP::ZM[0.23]") # incompressible volume-based binary mixtures
julia> propssi("D", "T", 300, "P", 101325, "INCOMP::ZM[0.23]") # incompressible volume-based binary mixtures
1028.7273860290911
julia> propssi("Dmass","T",300,"P",101325,"R125[0.5]&R32[0.5]")
julia> propssi("Dmass", "T", 300, "P", 101325, "R125[0.5]&R32[0.5]")
3.5413381483914512
julia> split(get_global_param_string("mixture_binary_pairs_list"),',')[1] # a random binary pair
julia> split(get_global_param_string("mixture_binary_pairs_list"), ', ')[1] # a random binary pair
"100-41-4&106-42-3"
julia> propssi("Dmass","T",300,"P",101325,"100-41-4[0.5]&106-42-3[0.5]") # ethylbenzene[0.5]&p-Xylene[0.5]
julia> propssi("Dmass", "T", 300, "P", 101325, "100-41-4[0.5]&106-42-3[0.5]") # ethylbenzene[0.5]&p-Xylene[0.5]
857.7381127561846
```
Expand Down Expand Up @@ -85,24 +85,24 @@ Return a string representation of the phase. Valid states are: "liquid", "superc
# Example
```julia
julia> phasesi("T",propssi("TCRIT", "Water"),"P",propssi("PCRIT", "Water"),"Water")
julia> phasesi("T", propssi("TCRIT", "Water"), "P", propssi("PCRIT", "Water"), "Water")
"critical_point"
julia> phasesi("T",300,"Q",1,"Water")
julia> phasesi("T", 300, "Q", 1, "Water")
"twophase"
julia> propssi("P","T",300,"Q",1,"Water")
julia> propssi("P", "T", 300, "Q", 1, "Water")
3536.806750422325
julia> phasesi("T",300,"P",3531,"Water")
julia> phasesi("T", 300, "P", 3531, "Water")
"gas"
julia> phasesi("T",300,"P",3541,"Water")
julia> phasesi("T", 300, "P", 3541, "Water")
"liquid"
```
# Ref
CoolProp::PhaseSI(const std::string &, double, const std::string &, double, const std::string&)
"""
function phasesi(name1::AbstractString, value1::Real, name2::AbstractString, value2::Real, fluid::AbstractString)
val = ccall( (:PhaseSI, "CoolProp"), Int32, (Cstring, Cdouble, Cstring, Cdouble, Cstring, Ptr{UInt8}, Int), name1, value1, name2, value2, fluid, message_buffer::Array{UInt8,1}, buffer_length)
val = unsafe_string(convert(Ptr{UInt8}, pointer(message_buffer::Array{UInt8,1})))
val = ccall( (:PhaseSI, "CoolProp"), Int32, (Cstring, Cdouble, Cstring, Cdouble, Cstring, Ptr{UInt8}, Int), name1, value1, name2, value2, fluid, message_buffer::Array{UInt8, 1}, buffer_length)
val = unsafe_string(convert(Ptr{UInt8}, pointer(message_buffer::Array{UInt8, 1})))
if val == ""
error("CoolProp: ", get_global_param_string("errstring"))
end
Expand All @@ -125,7 +125,7 @@ end
###

"""
set_reference_state(ref::AbstractString,reference_state::AbstractString)
set_reference_state(ref::AbstractString, reference_state::AbstractString)
Set the reference state based on a string representation.
Expand All @@ -147,7 +147,7 @@ julia> h0=-15870000.0; # J/kg
julia> s0= 3887.0; #J/kg
julia> rho0=997.1;
julia> T0=298.15;
julia> M = PropsSI("molemass","Water");
julia> M = PropsSI("molemass", "Water");
julia> set_reference_stateS("Water", T0, rho0/M, h0*M, s0*M);
julia> PropsSI("H", "T", T0, "P", 101325, "Water")
-1.5870107493843542e7
Expand All @@ -157,21 +157,21 @@ julia> PropsSI("H", "T", T0, "P", 101325, "Water")
```
#Ref
set_reference_stateS(const std::string& FluidName,const std::string& reference_state)
set_reference_stateS(const std::string& FluidName, const std::string& reference_state)
#Note
The changing of the reference state should be part of the initialization of your program, and it is not recommended to change the reference state during the course of making calculations
"""
function set_reference_state(fluid::AbstractString,reference_state::AbstractString)
val = ccall( (:set_reference_stateS,"CoolProp"),Cint,(Cstring,Cstring),fluid,reference_state)
function set_reference_state(fluid::AbstractString, reference_state::AbstractString)
val = ccall( (:set_reference_stateS, "CoolProp"), Cint, (Cstring, Cstring), fluid, reference_state)
if val == 0
error("CoolProp: ", get_global_param_string("errstring"))
end
return val
end

"""
set_reference_state(fluid::AbstractString,temp::Real,rhomolar::Real,hmolar0::Real,smolar0::Real)
set_reference_state(fluid::AbstractString, temp::Real, rhomolar::Real, hmolar0::Real, smolar0::Real)
Set the reference state based on a thermodynamic state point specified by temperature and molar density.
Expand All @@ -183,10 +183,10 @@ Set the reference state based on a thermodynamic state point specified by temper
* `smolar0::Real` Molar entropy at reference state [J/mol/K]
#Ref
set_reference_stateD(const char* Ref,double T,double rhomolar,double hmolar0,double smolar0)
set_reference_stateD(const char* Ref, double T, double rhomolar, double hmolar0, double smolar0)
"""
function set_reference_state(fluid::AbstractString,temp::Real,rhomolar::Real,hmolar0::Real,smolar0::Real)
val = ccall( (:set_reference_stateD,"CoolProp"),Cint,(Cstring,Cdouble,Cdouble,Cdouble,Cdouble),fluid,temp,rhomolar,hmolar0,smolar0)
function set_reference_state(fluid::AbstractString, temp::Real, rhomolar::Real, hmolar0::Real, smolar0::Real)
val = ccall( (:set_reference_stateD, "CoolProp"), Cint, (Cstring, Cdouble, Cdouble, Cdouble, Cdouble), fluid, temp, rhomolar, hmolar0, smolar0)
if val == 0
error("CoolProp: ", get_global_param_string("errstring"))
end
Expand All @@ -203,7 +203,7 @@ end
# * \overload
# * \sa \ref CoolProp::PropsSI(const std::string &, const std::string &, double, const std::string &, double, const std::string&)
# *
# * \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)
# * \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)
# */
# EXPORT_CODE void CONVENTION propssi_(const char *Output, const char *Name1, const double *Prop1, const char *Name2, const double *Prop2, const char * Ref, double *output);
###
22 changes: 11 additions & 11 deletions test/CoolPropInformation.jl
Expand Up @@ -30,15 +30,15 @@ ref CoolProp::get_global_param_string
* `key`: A string represents parameter name, could be one of $inputs_to_get_global_param_string
"""
function get_global_param_string(key::AbstractString)
val = ccall( (:get_global_param_string, "CoolProp"), Clong, (Cstring, Ptr{UInt8},Int), key, message_buffer::Array{UInt8,1}, buffer_length)
val = ccall( (:get_global_param_string, "CoolProp"), Clong, (Cstring, Ptr{UInt8}, Int), key, message_buffer::Array{UInt8, 1}, buffer_length)
if val == 0
error("CoolProp: ", get_global_param_string("errstring"))
end
return unsafe_string(convert(Ptr{UInt8}, pointer(message_buffer::Array{UInt8,1})))
return unsafe_string(convert(Ptr{UInt8}, pointer(message_buffer::Array{UInt8, 1})))
end

"""
get_parameter_information_string(key::AbstractString,outtype::AbstractString)
get_parameter_information_string(key::AbstractString, outtype::AbstractString)
get_parameter_information_string(key::AbstractString)
Get information for a parameter.
Expand All @@ -60,19 +60,19 @@ A tabular output for this function is available with `?parameters` or `parameter
"""
function get_parameter_information_string(key::AbstractString, outtype::AbstractString)
message_buffer[1:length(outtype)+1] = [outtype.data; 0x00]
val = ccall( (:get_parameter_information_string, "CoolProp"), Clong, (Cstring,Ptr{UInt8},Int), key,message_buffer::Array{UInt8,1},buffer_length)
val = ccall( (:get_parameter_information_string, "CoolProp"), Clong, (Cstring, Ptr{UInt8}, Int), key, message_buffer::Array{UInt8, 1}, buffer_length)
if val == 0
error("CoolProp: ", get_global_param_string("errstring"))
end
return unsafe_string(convert(Ptr{UInt8}, pointer(message_buffer::Array{UInt8,1})))
return unsafe_string(convert(Ptr{UInt8}, pointer(message_buffer::Array{UInt8, 1})))
end

function get_parameter_information_string(key::AbstractString)
return get_parameter_information_string(key, "long")
end

"""
get_fluid_param_string(fluid::AbstractString,param::AbstractString)
get_fluid_param_string(fluid::AbstractString, param::AbstractString)
Get a string for a value from a fluid (numerical values for the fluid can be obtained from Props1SI function).
Expand All @@ -81,24 +81,24 @@ Get a string for a value from a fluid (numerical values for the fluid can be obt
* `param`: A string, can be in one of the terms described in the following table
ParamName | Description
:------------------------- |:----------------------------------------
:----------------------------|:----------------------------------------
"aliases" | A comma separated list of aliases for the fluid
"CAS", "CAS_number" | The CAS number
"ASHRAE34" | The ASHRAE standard 34 safety rating
"REFPROPName","REFPROP_name" | The name of the fluid used in REFPROP
"REFPROPName", "REFPROP_name"| The name of the fluid used in REFPROP
"Bibtex-XXX" | A BibTeX key, where XXX is one of the bibtex keys used in get_BibTeXKey
"pure" | "true" if the fluid is pure, "false" otherwise
"formula" | The chemical formula of the fluid in LaTeX form if available, "" otherwise
# Note
A tabular output for this function is available with `?fluids` or `fluids=fluids()`
"""
function get_fluid_param_string(fluid::AbstractString,param::AbstractString)
val = ccall( (:get_fluid_param_string, "CoolProp"), Clong, (Cstring,Cstring,Ptr{UInt8},Int), fluid,param,message_buffer::Array{UInt8,1},buffer_length)
function get_fluid_param_string(fluid::AbstractString, param::AbstractString)
val = ccall( (:get_fluid_param_string, "CoolProp"), Clong, (Cstring, Cstring, Ptr{UInt8}, Int), fluid, param, message_buffer::Array{UInt8, 1}, buffer_length)
if val == 0
error("CoolProp: ", get_global_param_string("errstring"))
end
return unsafe_string(convert(Ptr{UInt8}, pointer(message_buffer::Array{UInt8,1})))
return unsafe_string(convert(Ptr{UInt8}, pointer(message_buffer::Array{UInt8, 1})))
end

"""
Expand Down

0 comments on commit 36a360d

Please sign in to comment.