diff --git a/src/CoolProp.jl b/src/CoolProp.jl index 2418248..0d8d29b 100644 --- a/src/CoolProp.jl +++ b/src/CoolProp.jl @@ -90,6 +90,7 @@ const _ha_units = Dict( "Tdb" => Unitful.u"K", "Twb" => Unitful.u"K", "Tdp" => Unitful.u"K", + "D" => Unitful.u"K", "H" => Unitful.u"J/kg", "Hha" => Unitful.u"J/kg", "U" => Unitful.u"J/kg", @@ -104,9 +105,9 @@ const _ha_units = Dict( "P_w" => Unitful.u"Pa", ) -function _get_unit(param::AbstractString) +function _get_unit(param::AbstractString, is_ha::Bool) # First check if it's a humid air parameter - if haskey(_ha_units, param) + if is_ha && haskey(_ha_units, param) return _ha_units[param] end # Otherwise use the normal parameter info @@ -135,9 +136,9 @@ end _si_value(unit, value) = Unitful.ustrip(Unitful.uconvert(unit, value)) function PropsSI(output::AbstractString, name1::AbstractString, value1::Union{Unitful.Quantity,Real}, name2::AbstractString, value2::Union{Unitful.Quantity,Real}, fluid::AbstractString) - unit1 = _get_unit(name1) - unit2 = _get_unit(name2) - outunit = _get_unit(output) + unit1 = _get_unit(name1,false) + unit2 = _get_unit(name2,false) + outunit = _get_unit(output,false) return PropsSI(output, name1, _si_value(unit1,value1), name2, _si_value(unit2,value2), fluid)*outunit end @@ -713,10 +714,10 @@ function HAPropsSI(output::AbstractString, name1::AbstractString, value1::Real, end function HAPropsSI(output::AbstractString, name1::AbstractString, value1::Union{Unitful.Quantity,Real}, name2::AbstractString, value2::Union{Unitful.Quantity,Real}, name3::AbstractString, value3::Union{Unitful.Quantity,Real}) - unit1 = _get_unit(name1) - unit2 = _get_unit(name2) - unit3 = _get_unit(name3) - outunit = _get_unit(output) + unit1 = _get_unit(name1,true) + unit2 = _get_unit(name2,true) + unit3 = _get_unit(name3,true) + outunit = _get_unit(output,true) return HAPropsSI(output, name1, _si_value(unit1,value1), name2, _si_value(unit2,value2), name3, _si_value(unit3,value3))*outunit end diff --git a/test/testunits.jl b/test/testunits.jl index 1b9c347..df4a46d 100644 --- a/test/testunits.jl +++ b/test/testunits.jl @@ -9,11 +9,13 @@ let fluid="air" # Test that all parameters return a unit for param in split(get_global_param_string("parameter_list"),',') - @test CoolProp._get_unit(param) isa FreeUnits + @test CoolProp._get_unit(param,false) isa FreeUnits end end let p=1atm, Tdb = 20°C, φ = 0.6 x = HAPropsSI("HumRat", "Tdb", Tdb, "RH", φ, "P", p) |> g/kg @test round(g/kg, x; digits=2) == 8.77g/kg + Tdp = HAPropsSI("D", "T", 300K, "P", 101325Pa, "W", 0.01) + @test round(K,Tdp) == 287K end \ No newline at end of file