HumidAir.jl

License: MIT

Installing and Loading HumidAir

HumidAir.jl on Gitlab is the replacement of deprecated Psychrometrics.jl on Github (lastest released version in 1.1.1)

HumidAir can be installed and loaded either from the JuliaHub repository (last released version) or from the maintainer's repository.

Last Released Version

The last version of HumidAir can be installed from JuliaHub repository:

using Pkg
Pkg.add("HumidAir")
using HumidAir

If HumidAir is already installed, it can be updated:

using Pkg
Pkg.update("HumidAir")
using HumidAir

Pre-Release (Under Construction) Version

The pre-release (under construction) version of HumidAir can be installed from the maintainer's repository.

using Pkg
Pkg.add(path="https://gitlab.com/aumpierre/HumidAir.jl.git")
using HumidAir

Citation of HumidAir

For citation of the last released version of HumidAir, please check CITATION file at the maintainer's repository.

The HumidAir Module for Julia

HumidAir provides a set of functions to compute the various variables related to water vapor humid air, providing the following functions:

moistAir

moistAir computes

given any two of the following parameters:

except for the combination of humidity and dew point temperature, which are not mutually independent.

If a different number of parameters is given, execution will be aborted.

If fig=true is given a schematic psychrometric chart is plotted as a graphical representation of the solution.

If back=:transparent is given plot background is set transparent (default is back=:white).

If unit=:°C is given both input and output temperatures are given in °C and temperature units in plot is set to °C (default is unit=:K).

Syntax:

moistAir(;
    Tdry::Number=NaN, # dry bulb temperature
    Twet::Number=NaN,  # wet bulb temperature
    Tdew::Number=NaN, # dew bulb temperature
    W::Number=NaN, # absolute humidity
    φ::Number=NaN, # relative humidity
    h::Number=NaN, # specific enthalpy
    v::Number=NaN, # specific volume
    fig::Bool=false, # show/omit chart
    back::Symbol=:white, # plot background color (:white (default) or :transparent)
    unit::Symbol=:K # units for temperature (:K (default) or :°C)
    )

Examples:

Compute the dry bulb temperature, the wet bulb temperature, the dew point temperature, the adiabatic saturation temperature, the humidity, the saturation humidity, the saturation humidity at wet bulb temperature, the adiabatic saturation humidity, the relative humidity, the specific enthalpy, the specific volume, the density, the water vapor pressure, the saturation pressure, the saturation pressure at wet bulb temperature given the dew point temperature is 22 °C and the relative humidity is 29 %.

moistAir = moistAir( # all results ordered in one tuple
    Tdew=22 + 273.15, # dew temperature in K
    φ=0.29, # relative humidity
    fig=true # show plot
    )
moistAir.φ # relative humidity
moistAir.Tdry # dry bulb temperature
moistAir.Twet # wet bulb temperature

Compute the dry bulb temperature, the wet bulb temperature, the dew point temperature, the adiabatic saturation temperature, the humidity, the saturation humidity, the saturation humidity at wet bulb temperature, the adiabatic saturation humidity, the relative humidity, the specific enthalpy, the specific volume, the density, the water vapor pressure, the saturation pressure, the saturation pressure at wet bulb temperature given the specific enthalpy is 79.5 kJ/kg and the relative humidity is 0.29 and plot a graphical representation of the answer in a schematic psychrometric chart.

moistAir(
    h=79.5e3, # specific enthalpy in kJ/kg of dry air
    φ=0.29, # relative humidity
    fig=true, # show plot
    back=:transparent, # plot background transparent
    unit=:°C # temperature in °C
    )

8.5 cubic meters of humid air at dry bulb temperature of 293 K and wet bulb temperature of 288 K is subjected to two cycles of heating to 323 and adiabatic saturation. Compute the energy and water vapor demands. Assume the amount of dry air is constant.

states::Vector{}=[]

push!(states, moistAir( # initial parameters
    Tdry=293,
    Twet=288,
    fig=true
    ));
sleep(1)

push!(states, moistAir( # parameters after the first heating
    Tdry=323,
    W=states[end].W,
    fig=true
    ));
sleep(1)

push!(states, moistAir( # parameters the after first adiabatic saturation
    h=states[end].h,
    φ=1,
    fig=true
    ));
sleep(1)

push!(states, moistAir( # parameters after the second heating
    Tdry=323,
    W=states[end].W,
    fig=true
    ));
sleep(1)

push!(states, moistAir( # parameters the after second adiabatic saturation
    h=states[end].h,
    φ=1,
    fig=true
    ));
sleep(1)

begin # water vapor
    local V = 8.5; # initial volume of humid air
    (states[end].W - states[1].W) * (V / states[1].v)
end

begin # energy demand
    local V = 8.5; # initial volume of humid air
    (states[end].h - states[1].h) * (V / states[1].v)
end

begin
    using Plots
    buildBasicChart()
    local T = [state.Tdry for state in states]
    local W = [state.W for state in states]
    plot!(T, W, seriestype=:path, linewidth=2, color=:red)
    plot!(T, W, seriestype=:scatter, markersize=5, markerstrokecolor=:red, color=:red)
end

try # please notice that PrettyTables is not automatically loaded with HumidAir!
    using PrettyTables
    local mytable = [name for name in fieldnames(HumidAir.HumidAirProps)]
    for state in states
        mytable = [mytable [getfield(state, field) for field in 1:nfields(state)]]
    end
    local myheader = ["Parameter"]
    for (i, val) in enumerate(states)
        text = "State " * string(i)
        push!(myheader, text)
    end
    print(
        "\nSummary of process evolution:\n"
        )
    pretty_table(mytable, column_labels=myheader)
catch
end

adiabSat

adiabSat computes the dry bulb temperature and the humidity given the specific enthalpy (in J/kg of dry air).

Syntax:

adiabSat( # adiabatic saturation temperature in K
    h::Number
    )

Examples:

Compute the adiabatic saturation temperature given the specific enthalpy is 82.4 kJ/kg of dry air and plot a graphical representation of the answer in a schematic psychrometric chart.

adiabSat(
    82.4e3
    )

humidity

humidity computes the humidity (in kg/kg of dry air) of humid air given the water vapor pressure (in Pa) and the total pressure (in Pa).

By default, total pressure is assumed to be the atmospheric pressure at sea level (101325 Pa).

Syntax:

humidity( # humidity in kg/kg of dry air
    pw::Number, # water vapor pressure in Pa
    p::Number=101325 # total pressure in Pa
    )

Examples:

Compute the humidity of humid air at atmospheric pressure given water vapor pressure is 1 kPa at 1 atm total pressure.

humidity( # humidity in kg/kg of dry air
    1e3 # water vapor pressure in Pa
    )

Compute the humidity of humid air at atmospheric pressure given dry bulb temperature is 305 K and relative humidiy is 50 % at 101325 Pa total pressure.

state = moistAir(
    Tdry=305., # dry bulb temperature
    φ=0.50 # relative humidity
    );
state.W # absolute humidity calculated by moistAir
pw = state.φ * state.psat # water vapor pressure, by definition
W = humidity(pw) # absolute humidity calculated by humidity
W = 0.621945 * pw / (101325 - pw) # absolute humidity, by definition

Compute the humidity of humid air at atmospheric pressure given the water vapor pressure 1 kPa and the total pressure 101325 Pa.

humidity( # humidity in kg/kg of dry air
       1e3, # water vapor pressure in Pa
       101325 # total pressure in Pa
       )

Compute the humidity of humid air at atmospheric pressure given the dry bulb temperature 300 K and the wet bulb temperature 290 K.

humidity( # humidity in kg/kg of dry air
       300, # dry bulb temperature in K
       290 # wet bulb temperature in K
       )

satPress

satPress computes the saturation pressure (in Pa) of humid air given the dry bulb temperature (in K).

Syntax:

satPress( # saturation pressure in Pa
    Tdry::Number # dry bulb temperature in K
    )

Examples:

Compute the saturation pressure given the dry bulb temperature is 25 °C.

satPress( # saturation pressure in Pa
    25 + 273.15; # dry bulb temperature in K
    )

enthalpy

enthalpy computes the specific enthalpy (in J/kg of dry air) of humid air given the dry bulb temperature (in K) and the humidity (in kg/kg of dry air).

Syntax:

enthalpy( # specific enthalpy in kJ/kg of dry air
    Tdry::Number, # dry bulb temperature in K
    W::Number # humidity in kg/kg of dry air
    )

Examples:

Compute the specific enthalpy given the dry bulb temperature is 25 °C and the humidity is 7 g/kg of dry air.

enthalpy( # specific enthalpy in J/kg of dry air
    25 + 273.15, # dry bulb temperature in K
    7e-3 # humidity in kg/kg of dry air
    )

volume

volume computes the specific volume (in cu. m/kg of dry air) of humid air given the dry bulb temperature (in K), the humidity (in kg/kg of dry air) and the total pressure p (in Pa).

By default, total pressure is assumed to be the atmospheric pressure at sea level (101325 Pa).

Syntax:

volume( # specific enthalpy in J/kg of dry air
    Tdry::Number, # dry bulb temperature in K
    W::Number, # humidity in kg/kg of dry air
    p::Number=101325 # total pressure in Pa
    )

Examples:

Compute the specific volume given the dry bulb temperature is 25 °C and the humidity is 7 g/kg of dry air at 1 atm total pressure.

volume( # specific volume in cu. m/kg of dry air
    25 + 273.15, # dry bulb temperature in K 
    7e-3 # humidity in kg/kg of dry air
    )

dewTemp

dewTemp computes the dew point temperature (in K) of humid air given the water vapor pressure (in Pa).

Syntax:

dewTemp( # dew point temperature in K
    pw::Number # water vapor pressure in Pa
    )

Examples:

Compute the dew temperature of humid air given the water vapor pressure is 1 kPa.

dewTemp( # dew temperature in K
    1e3 # water vapor pressure in Pa
    )

buildBasicChart

buildBasicChart plots a schematic psychrometric chart.

If back=:transparent is given plot background is set transparent (default is back=:white).

If unit=:°C is given temperature units in plot is set to °C (default is unit=:K).

Syntax:

buildBasicChart(;
    back::Symbol=:white,
    unit::Symbol=:K
    )

Examples:

Build a schematic psychrometric chart with temperature in °C with transparent background and save figure as psychrometricChart_transparent.svg.

buildBasicChart(
    back=:transparent, # plot background transparent
    unit=:°C # temperature in °C
    )

Reference

The theory and the adjusted equations used in HumidAir.jl package were taken from the first chapter of the 2017 ASHRAE Handbook Fundamentals Systems - International Metric System, published by the American Society of Heating, Refrigerating and Air-Conditioning Engineers.

Acknowledgements

The author of HumidAir.jl package acknowledges Professor Brent Stephens, Ph.D. from the Illinois Institute of Technology for kindly suggesting the source reference for equations used in this package.

Copyright © 2022 2023 2024 2025 2026 Alexandre Umpierre

email: aumpierre@gmail.com