'===========================================================================
' Subject: PROPERTIES OF MOIST AIR            Date: 11-12-98 (23:32)       
'  Author: Antoni Gual                        Code: QB, QBasic, PDS        
'  Origin: agual@eic.ictnet.es              Packet: ALGOR.ABC
'===========================================================================
DECLARE SUB Explanation ()
DECLARE FUNCTION Dewpoint! (pp!)
DECLARE FUNCTION SpecificVolume! (temp!, pp!, atmp!)
DECLARE FUNCTION PartialPresureSat! (temp!)
DECLARE FUNCTION AbsoluteHumidity! (pp!, atmp!)
DECLARE FUNCTION Enthalpy! (temp!, absh!)
'psychro.bas"
'calculates properties of moist air from the temperaure and relative humidity"
'useful for air conditioning calculations"
'uses metric units


CONST molwghtair = 28.9645
CONST molwghtwater = 18.01534
CONST specheatair = 1.01         'Kj/Kg/§K
CONST specheatwater = 1.86       'Kj/Kg/§K
CONST r = .287                   'Kj/Kg/§K
CONST Kelvinator = 273.15        'convert Centigrades to Kelvin
CONST AtmPresure = 101.32        'KPa :Could be made a variable and be asked to user


Explanation
DO
    CLS
    DO
    INPUT "Centigrade Temperature 0 to 70 "; temp
    LOOP UNTIL temp > 0 AND temp <= 70
    DO
    INPUT "Relative Humidity     0 to 100 "; rh
    LOOP UNTIL rh >= 0 AND rh <= 100

    ppsat = PartialPresureSat(temp)
    PRINT "Partial Presure of water at Saturation: ", ppsat; " KPa"
    ppreal = ppsat * rh / 100
    PRINT "Partial Presure of water at actual r.h.", ppreal; " KPa"
    absh = AbsoluteHumidity(ppreal, AtmPresure)
    PRINT "Absolute Humidity", , absh * 100; " gr water/Kg Air"
    enthy = Enthalpy(temp, absh)
    PRINT "Enthalpy", , , enthy; " Kj/Kg"
    svol = SpecificVolume(temp, ppreal, AtmPresure)
    PRINT "Specific Volume", , svol; " m3/Kg"
    dpoint = Dewpoint(ppreal)
    PRINT "Dewpoint ", , , dpoint; " Centigrades"
    PRINT "More Calculations? (y/n)"
    a$ = INPUT$(1)

LOOP UNTIL UCASE$(a$) = "N"


FUNCTION AbsoluteHumidity (pp, atmp)
'output: amount of water vapour in moist air (Kg water/Kg air)
'input : partial presure of water vapour (Kpa), atmospherir presure (KPa)

AbsoluteHumidity = molwghtwater / molwghtair * (pp / (atmp - pp))
END FUNCTION

FUNCTION Dewpoint (pp)
'Output: Dewpoint of moist air (Centigrade)
'Input : Partial presure of water vapour (KPa)  

'Dewpoint is the temperature at which the air is unable to retain his moist
'contents and starts to produce dew.(Water condensating in surfaces around)

CONST a1 = 6.851372998#
CONST a2 = .1050822#
CONST a3 = 14.441426#
CONST a4 = .87490778#
lnpp = LOG(pp)
Dewpoint = a1 + a2 * pp + a3 * lnpp + a4 * lnpp * lnpp
END FUNCTION

FUNCTION Enthalpy (temp, absh)
'Output : Enthalpy in Kj/Kg
'Input  : Temperature (Centigrade), Absolute Humidity (Kg/Kg)

'The enthalpy is a measure of the energy contained in moist air
'Its components are the energy needed to evaporate the water contained
'in the air plus the energies needed to put air and water to the actual
'temperature

Enthalpy = (specheatair * temp) + absh * (2501.6 + specheatwater * temp)
END FUNCTION

SUB Explanation
CLS
PRINT "PSYCHROMETRY"
PRINT "This program calculates properties of moist air from the temperature and "
PRINT "relative humidity. These properties are important in the design of air condi-"
PRINT "tioning systems. "
PRINT
PRINT "Air can absorb a different amount of moisture depending of the temperature"
PRINT "All properties of moist air are affected by the moisture contents in a non- "
PRINT "linear way. All relations are found in the ASHRAE psychrometric diagram"
PRINT
PRINT "I've checked some results with the ASHRAE diagram and are reasonabily OK"
PRINT "Use at your own risk.The program uses metric units"
PRINT ""
PRINT "Bibliography :"
PRINT "ASHRAE Fundamentals 1985 (not all true, some formulae in the metric spanish"
PRINT "   version does'nt work, so i had to recalculate them.Probably the fault is"
PRINT "   in the trnslation )"
PRINT "D.H. Bacon BASIC THERMODINAMIC & HEAT TRANSFER    1983 Butterworth&Co London"
PRINT "I found myself the  Covariant Coeficients in the partial presure and Dewpoint"
PRINT "functions, using a steam properties table and the MS Excel Data Analysis Tools"
PRINT
PRINT "I can be contacted at agual@eic.ictnet.es"
PRINT "PRESS ANY KEY"
a$ = INPUT$(1)
END SUB

FUNCTION PartialPresureSat (temp)

'output: partial presure of steam in saturated air (KPa)
'input:  air temperatura (Centrigrade)

'From kynethic Theory of gases, the presure in a mix of gases is the result
'of the partial presures of the different components.
'The saturated air is the air that can't retain more moisture, it's relative
'humidity is 100%.
'The partial presure has no use in the air conditioning calculations, but is
'an intermediary step to find the useful values.

CONST a1 = -488426.18#
CONST a2 = -343.1069237#
CONST a3 = .2068381#
CONST a4 = 8844918.75#
CONST a5 = 95246.14629999999#
t = temp + Kelvinator
PartialPresureSat = a1 + (a2 * t) + (a3 * t * t) + (a4 / t) + (a5 * LOG(t))
END FUNCTION

FUNCTION SpecificVolume (temp, pp, atmp)
'Output : SpecificVolume in m3/Kg
'Input  : Temperature (Centigrade), partial presure of vapour,(KPa)
'       : Atmospheric Presure (KPa)
'
     SpecificVolume = r * (temp + Kelvinator) / (atmp - pp)
END FUNCTION
