You are on page 1of 1

# Plot a simple psychrometric chart

import psychrolib
import matplotlib.pyplot as plt
import numpy as np

psychrolib.SetUnitSystem(psychrolib.SI)

# Constants
atmospheric_pressure = 101325

# Defining range of values to use/calculate/plot


temperature_range = np.arange(0, 50.1, 0.1)
relative_humidity_range = np.arange(0, 1.1, 0.1)
enthalpy_values = np.arange(0, 150000, 5000)
humidity_ratio_lines = np.arange(0.005, 0.05, 0.005)
wet_bulb_temperature_range = np.arange(-10, 50, 5)

figure, axes = plt.subplots()

# Plot constant relative humidity lines


for rh in relative_humidity_range:
humidity_ratio_from_RelHum = list()
for temperature in temperature_range:

humidity_ratio_from_RelHum.append(psychrolib.GetHumRatioFromRelHum(temperature, rh,
atmospheric_pressure))
humidity_ratio_max = np.max(humidity_ratio_from_RelHum)
axes.plot(temperature_range, humidity_ratio_from_RelHum, 'k')

for wet_bulb_temperature in wet_bulb_temperature_range:


humidity_ratio_from_TWet = list()
temperature_to_plot = list()
for temperature in temperature_range:
if wet_bulb_temperature <= temperature:

humidity_ratio_from_TWet.append(psychrolib.GetHumRatioFromTWetBulb(temperature,
wet_bulb_temperature, atmospheric_pressure))
temperature_to_plot.append(temperature)
humidity_ratio_max = np.max(humidity_ratio_from_TWet)
axes.plot(temperature_to_plot, humidity_ratio_from_TWet, 'b')

axes.set(ylim=(0, 0.03), xlim=(temperature_range[0], temperature_range[-1]),


ylabel=r"Humidity Ratio [$kg_{water}/kg_{dry air}$]", xlabel="Dry-bulb Temperature
[°C]")
axes.yaxis.tick_right()
axes.yaxis.set_label_position("right")
plt.tight_layout()
plt.show()

You might also like