I have not yet got the overall architecture right, but the functions are

beginning to work.
This commit is contained in:
Simon Brooke 2026-08-09 13:32:32 +01:00
parent 691852d830
commit 3874a37a86
13 changed files with 291 additions and 0 deletions

View file

@ -0,0 +1,49 @@
# I'm guessing this is Python
# Saturated water vapor pressure in hPa, Magnus Formula
# Parameters from Sonntag1990, for 45 °C ≤ T ≤ 60 °C (error ±0.35 °C).
def saturatedVaporPressureMagnusSonntag1990(temperatureCelsius):
a = 6.112
b = 17.62
c = 243.12
saturatedVaporPressure = a * math.exp((b * temperatureCelsius) / (c + temperatureCelsius))
return saturatedVaporPressure
# Saturated water vapor pressure in hPa, Tetens Formula
def saturatedVaporPressureTetens(temperatureCelsius):
a = 6.1078
b = 17.27
c = 237.3
saturatedVaporPressure = a * math.exp((b * temperatureCelsius) / (c + temperatureCelsius))
return saturatedVaporPressure
# Saturated water vapor pressure in hPa, Buck 1996 Formula
def saturatedVaporPressureBuck1996(temperatureCelsius):
if temperatureCelsius < 0:
return 6.1115 * math.exp(
(23.06 - temperatureCelsius / 333.7) * (temperatureCelsius / (279.82 + temperatureCelsius)))
else:
return 6.1121 * math.exp(
(18.678 - temperatureCelsius / 234.5) * (temperatureCelsius / (257.14 + temperatureCelsius)))
# Actual water vapor pressure in hPa
def vaporPressure(relativeHumidity, temperatureCelsius):
vaporPressure = relativeHumidity / 100.0 * saturatedVaporPressureBuck1996(temperatureCelsius)
return vaporPressure
# Absolute humidity in g/m³
def absoluteHumidity(relativeHumidity, temperatureCelsius):
molarMassOfWaterVapor = 18.01528
universalGasConstant = 8314.46261815324
zeroCelsiusInKelvin = 273.15
absoluteHumidity = 10 ** 5 * molarMassOfWaterVapor / universalGasConstant * vaporPressure(relativeHumidity,
temperatureCelsius) / (
temperatureCelsius + zeroCelsiusInKelvin)
return absoluteHumidity