def test_check_standard_compliance(): with pytest.warns( UserWarning, match= "ISO 7933:2004 air temperature applicability limits between 15 and 50 °C", ): warnings.warn( phs(tdb=70, tr=40, rh=33.85, v=0.3, met=150, clo=0.5, posture=2), UserWarning, ) with pytest.warns( UserWarning, match= "ISO 7933:2004 t_r - t_db applicability limits between 0 and 60 °C", ): warnings.warn( phs(tdb=20, tr=0, rh=33.85, v=0.3, met=150, clo=0.5, posture=2), UserWarning, ) with pytest.warns( UserWarning, match= "ISO 7933:2004 air speed applicability limits between 0 and 3 m/s", ): warnings.warn( phs(tdb=40, tr=40, rh=33.85, v=5, met=150, clo=0.5, posture=2), UserWarning, ) with pytest.warns( UserWarning, match= "ISO 7933:2004 met applicability limits between 100 and 450 met", ): warnings.warn( phs(tdb=40, tr=40, rh=33.85, v=2, met=1, clo=0.5, posture=2), UserWarning, ) with pytest.warns( UserWarning, match= "ISO 7933:2004 clo applicability limits between 0.1 and 1 clo", ): warnings.warn( phs(tdb=40, tr=40, rh=33.85, v=2, met=150, clo=2, posture=2), UserWarning, ) with pytest.warns( UserWarning, match="ISO 7933:2004 t_r - t_db applicability limits between 0 and", ): warnings.warn( phs(tdb=40, tr=40, rh=61, v=2, met=150, clo=2, posture=2), UserWarning, )
def test_phs(): assert phs(tdb=40, tr=40, rh=33.85, v=0.3, met=150, clo=0.5, posture=2) == { "d_lim_loss_50": 440, "d_lim_loss_95": 298, "d_lim_t_re": 480, "water_loss": 6166.0, "t_re": 37.5, } assert phs(tdb=35, tr=35, rh=71, v=0.3, met=150, clo=0.5, posture=2) == { "d_lim_loss_50": 385, "d_lim_loss_95": 256, "d_lim_t_re": 75, "water_loss": 6935.0, "t_re": 39.8, } assert phs(tdb=30, tr=50, posture=2, rh=70.65, v=0.3, met=150, clo=0.5) == { "t_re": 37.7, "water_loss": 7166.0, # in the standard is 6935 "d_lim_t_re": 480, "d_lim_loss_50": 380, "d_lim_loss_95": 258, } assert phs(tdb=28, tr=58, acclimatized=0, posture=2, rh=79.31, v=0.3, met=150, clo=0.5) == { "t_re": 41.2, "water_loss": 5807, "d_lim_t_re": 57, "d_lim_loss_50": 466, "d_lim_loss_95": 314, } assert phs(tdb=35, tr=35, acclimatized=0, posture=1, rh=53.3, v=1, met=150, clo=0.5) == { "t_re": 37.6, "water_loss": 3892.0, "d_lim_t_re": 480, "d_lim_loss_50": 480, "d_lim_loss_95": 463, } assert phs(tdb=43, tr=43, posture=1, rh=34.7, v=0.3, met=103, clo=0.5) == { "t_re": 37.3, "water_loss": 6765.0, "d_lim_t_re": 480, "d_lim_loss_50": 401, "d_lim_loss_95": 271, } assert phs(tdb=35, tr=35, acclimatized=0, posture=2, rh=53.3, v=0.3, met=206, clo=0.5) == { "t_re": 39.2, "water_loss": 7236.0, "d_lim_t_re": 70, "d_lim_loss_50": 372, "d_lim_loss_95": 247, } # assert phs(tdb=34, tr=34, rh=56.3, v=0.3, met=150, clo=1, posture=2) == { # "t_re": 41.0, # "water_loss": 5548, # "d_lim_t_re": 67, # "d_lim_loss_50": 480, # "d_lim_loss_95": 318, # } assert phs(tdb=40, tr=40, rh=40.63, v=0.3, met=150, clo=0.4, posture=2) == { "t_re": 37.5, "water_loss": 6683.0, "d_lim_t_re": 480, "d_lim_loss_50": 407, "d_lim_loss_95": 276, } assert phs( tdb=40, tr=40, rh=40.63, v=0.3, met=150, clo=0.4, posture=2, theta=90, walk_sp=1, ) == { "t_re": 37.6, "water_loss": 5379.0, "d_lim_t_re": 480, "d_lim_loss_50": 480, "d_lim_loss_95": 339, }
from pythermalcomfort.models import phs import pandas as pd import seaborn as sns plt.close("all") for v in [0.2, 0.8]: results = [] for tdb in range(30, 52, 1): for rh in range(0, 100, 1): result = phs(tdb=tdb, tr=tdb, rh=rh, v=v, met=55, clo=0.5, posture=2) result["tdb"] = tdb result["rh"] = rh results.append(result) df = pd.DataFrame.from_dict(results) plt.figure() pivot = df.pivot("tdb", "rh", "t_re") pivot = pivot.sort_index(ascending=False) ax = sns.heatmap(pivot) plt.title(f"velocity {v}") plt.tight_layout()