Skip to content

Commit

Permalink
Merge pull request #100 from CenterForTheBuiltEnvironment/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
FedericoTartarini authored Feb 22, 2024
2 parents 0db6287 + cfb8133 commit 84b23f5
Show file tree
Hide file tree
Showing 25 changed files with 454 additions and 233 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 2.9.1
current_version = 2.9.2
commit = True
tag = True

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
year = "2019"
author = "Federico Tartarini"
copyright = "{0}, {1}".format(year, author)
version = release = "2.9.1"
version = release = "2.9.2"

pygments_style = "trac"
templates_path = ["."]
Expand Down
2 changes: 1 addition & 1 deletion pythermalcomfort/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "__version__ = '2.9.1'"
__version__ = "__version__ = '2.9.2'"

from pythermalcomfort.models import *
57 changes: 41 additions & 16 deletions pythermalcomfort/models/a_pmv.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
from typing import Union, List

import numpy as np

from pythermalcomfort.models import pmv


def a_pmv(tdb, tr, vr, rh, met, clo, a_coefficient, wme=0, **kwargs):
def a_pmv(
tdb: Union[float, int, np.ndarray, List[float], List[int]],
tr: Union[float, int, np.ndarray, List[float], List[int]],
vr: Union[float, int, np.ndarray, List[float], List[int]],
rh: Union[float, int, np.ndarray, List[float], List[int]],
met: Union[float, int, np.ndarray, List[float], List[int]],
clo: Union[float, int, np.ndarray, List[float], List[int]],
a_coefficient: float,
wme: Union[float, int, np.ndarray, List[float], List[int]] = 0,
units="SI",
limit_inputs=True,
):
"""Returns Adaptive Predicted Mean Vote (aPMV) [25]_. This index was
developed by Yao, R. et al. (2009). The model takes into account factors
such as culture, climate, social, psychological and behavioural
Expand All @@ -13,11 +26,11 @@ def a_pmv(tdb, tr, vr, rh, met, clo, a_coefficient, wme=0, **kwargs):
Parameters
----------
tdb : float or array-like
tdb : float, int, or array-like
dry bulb air temperature, default in [°C] in [°F] if `units` = 'IP'
tr : float or array-like
tr : float, int, or array-like
mean radiant temperature, default in [°C] in [°F] if `units` = 'IP'
vr : float or array-like
vr : float, int, or array-like
relative air speed, default in [m/s] in [fps] if `units` = 'IP'
Note: vr is the relative air speed caused by body movement and not the air
Expand All @@ -26,11 +39,11 @@ def a_pmv(tdb, tr, vr, rh, met, clo, a_coefficient, wme=0, **kwargs):
(Vag). Where Vag is the activity-generated air speed caused by motion of
individual body parts. vr can be calculated using the function
:py:meth:`pythermalcomfort.utilities.v_relative`.
rh : float or array-like
rh : float, int, or array-like
relative humidity, [%]
met : float or array-like
met : float, int, or array-like
metabolic rate, [met]
clo : float or array-like
clo : float, int, or array-like
clothing insulation, [clo]
Note: The activity as well as the air speed modify the insulation characteristics
Expand All @@ -42,13 +55,11 @@ def a_pmv(tdb, tr, vr, rh, met, clo, a_coefficient, wme=0, **kwargs):
:py:meth:`pythermalcomfort.utilities.clo_dynamic`.
a_coefficient : float
adaptive coefficient
wme : float or array-like
wme : float, int, or array-like
external work, [met] default 0
Other Parameters
----------------
units : {'SI', 'IP'}
units : str, optional
select the SI (International System of Units) or the IP (Imperial Units) system.
Supported values are 'SI' and 'IP'. Defaults to 'SI'.
limit_inputs : boolean default True
By default, if the inputs are outsude the standard applicability limits the
function returns nan. If False returns pmv and ppd values even if input values are
Expand All @@ -59,7 +70,7 @@ def a_pmv(tdb, tr, vr, rh, met, clo, a_coefficient, wme=0, **kwargs):
Returns
-------
pmv : float or array-like
pmv : float, int, or array-like
Predicted Mean Vote
Examples
Expand All @@ -79,9 +90,23 @@ def a_pmv(tdb, tr, vr, rh, met, clo, a_coefficient, wme=0, **kwargs):
>>> print(results)
0.74
"""
default_kwargs = {"units": "SI", "limit_inputs": True}
kwargs = {**default_kwargs, **kwargs}

_pmv = pmv(tdb, tr, vr, rh, met, clo, wme, "ISO", **kwargs)
# Validate units string
valid_units: List[str] = ["SI", "IP"]
if units.upper() not in valid_units:
raise ValueError(f"Invalid unit: {units}. Supported units are {valid_units}.")

_pmv = pmv(
tdb,
tr,
vr,
rh,
met,
clo,
wme,
standard="ISO",
units=units,
limit_inputs=limit_inputs,
)

return np.around(_pmv / (1 + a_coefficient * _pmv), 2)
51 changes: 32 additions & 19 deletions pythermalcomfort/models/adaptive_ashrae.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import numpy as np
from dataclasses import dataclass
from typing import Union, List

import numpy as np

from pythermalcomfort.psychrometrics import t_o
from pythermalcomfort.shared_functions import valid_range
Expand All @@ -11,20 +13,25 @@

@dataclass
class AdaptiveASHRAE:
tmp_cmf: float
tmp_cmf_80_low: float
tmp_cmf_80_up: float
tmp_cmf_90_low: float
tmp_cmf_90_up: float
acceptability_80: np.array
acceptability_90: np.array
tmp_cmf: Union[float, int, np.ndarray, List[float], List[int]]
tmp_cmf_80_low: Union[float, int, np.ndarray, List[float], List[int]]
tmp_cmf_80_up: Union[float, int, np.ndarray, List[float], List[int]]
tmp_cmf_90_low: Union[float, int, np.ndarray, List[float], List[int]]
tmp_cmf_90_up: Union[float, int, np.ndarray, List[float], List[int]]
acceptability_80: Union[float, int, np.ndarray, List[float], List[int]]
acceptability_90: Union[float, int, np.ndarray, List[float], List[int]]

def __getitem__(self, item):
return getattr(self, item)


def adaptive_ashrae(
tdb, tr, t_running_mean, v, units="SI", limit_inputs=True
tdb: Union[float, int, np.ndarray, List[float], List[int]],
tr: Union[float, int, np.ndarray, List[float], List[int]],
t_running_mean: Union[float, int, np.ndarray, List[float], List[int]],
v: Union[float, int, np.ndarray, List[float], List[int]],
units: str = "SI",
limit_inputs: bool = True,
) -> AdaptiveASHRAE:
"""Determines the adaptive thermal comfort based on ASHRAE 55. The adaptive
model relates indoor design temperatures or acceptable temperature ranges
Expand All @@ -39,19 +46,20 @@ def adaptive_ashrae(
Parameters
----------
tdb : float or array-like
tdb : float, int, or array-like
dry bulb air temperature, default in [°C] in [°F] if `units` = 'IP'
tr : float or array-like
tr : float, int, or array-like
mean radiant temperature, default in [°C] in [°F] if `units` = 'IP'
t_running_mean: float or array-like
t_running_mean: float, int, or array-like
running mean temperature, default in [°C] in [°C] in [°F] if `units` = 'IP'
The running mean temperature can be calculated using the function
:py:meth:`pythermalcomfort.utilities.running_mean_outdoor_temperature`.
v : float or array-like
v : float, int, or array-like
air speed, default in [m/s] in [fps] if `units` = 'IP'
units : {'SI', 'IP'}
units : str, optional
select the SI (International System of Units) or the IP (Imperial Units) system.
Supported values are 'SI' and 'IP'. Defaults to 'SI'.
limit_inputs : boolean default True
By default, if the inputs are outsude the standard applicability limits the
function returns nan. If False returns pmv and ppd values even if input values are
Expand All @@ -62,16 +70,16 @@ def adaptive_ashrae(
Returns
-------
tmp_cmf : float or array-like
tmp_cmf : float, int, or array-like
Comfort temperature a that specific running mean temperature, default in [°C]
or in [°F]
tmp_cmf_80_low : float or array-like
tmp_cmf_80_low : float, int, or array-like
Lower acceptable comfort temperature for 80% occupants, default in [°C] or in [°F]
tmp_cmf_80_up : float or array-like
tmp_cmf_80_up : float, int, or array-like
Upper acceptable comfort temperature for 80% occupants, default in [°C] or in [°F]
tmp_cmf_90_low : float or array-like
tmp_cmf_90_low : float, int, or array-like
Lower acceptable comfort temperature for 90% occupants, default in [°C] or in [°F]
tmp_cmf_90_up : float or array-like
tmp_cmf_90_up : float, int, or array-like
Upper acceptable comfort temperature for 90% occupants, default in [°C] or in [°F]
acceptability_80 : bol or array-like
Acceptability for 80% occupants
Expand Down Expand Up @@ -126,6 +134,11 @@ def adaptive_ashrae(
v = np.array(v)
standard = "ashrae"

# Validate units string
valid_units: List[str] = ["SI", "IP"]
if units.upper() not in valid_units:
raise ValueError(f"Invalid unit: {units}. Supported units are {valid_units}.")

if units.lower() == "ip":
tdb, tr, t_running_mean, v = units_converter(
tdb=tdb, tr=tr, tmp_running_mean=t_running_mean, v=v
Expand Down
31 changes: 20 additions & 11 deletions pythermalcomfort/models/adaptive_en.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Union, List

import numpy as np

from pythermalcomfort.psychrometrics import t_o
Expand All @@ -7,21 +9,28 @@
)


def adaptive_en(tdb, tr, t_running_mean, v, units="SI", limit_inputs=True):
def adaptive_en(
tdb: Union[float, int, np.ndarray, List[float], List[int]],
tr: Union[float, int, np.ndarray, List[float], List[int]],
t_running_mean: Union[float, int, np.ndarray, List[float], List[int]],
v: Union[float, int, np.ndarray, List[float], List[int]],
units: str = "SI",
limit_inputs: bool = True,
):
"""Determines the adaptive thermal comfort based on EN 16798-1 2019 [3]_
Parameters
----------
tdb : float or array-like
tdb : float, int, or array-like
dry bulb air temperature, default in [°C] in [°F] if `units` = 'IP'
tr : float or array-like
tr : float, int, or array-like
mean radiant temperature, default in [°C] in [°F] if `units` = 'IP'
t_running_mean: float or array-like
t_running_mean: float, int, or array-like
running mean temperature, default in [°C] in [°C] in [°F] if `units` = 'IP'
The running mean temperature can be calculated using the function
:py:meth:`pythermalcomfort.utilities.running_mean_outdoor_temperature`.
v : float or array-like
v : float, int, or array-like
air speed, default in [m/s] in [fps] if `units` = 'IP'
Note: Indoor operative temperature correction is applicable for buildings equipped
Expand All @@ -39,7 +48,7 @@ def adaptive_en(tdb, tr, t_running_mean, v, units="SI", limit_inputs=True):
Returns
-------
tmp_cmf : float or array-like
tmp_cmf : float, int, or array-like
Comfort temperature at that specific running mean temperature, default in [°C]
or in [°F]
acceptability_cat_i : bol or array-like
Expand All @@ -48,15 +57,15 @@ def adaptive_en(tdb, tr, t_running_mean, v, units="SI", limit_inputs=True):
If the indoor conditions comply with comfort category II
acceptability_cat_iii : bol or array-like
If the indoor conditions comply with comfort category III
tmp_cmf_cat_i_up : float or array-like
tmp_cmf_cat_i_up : float, int, or array-like
Upper acceptable comfort temperature for category I, default in [°C] or in [°F]
tmp_cmf_cat_ii_up : float or array-like
tmp_cmf_cat_ii_up : float, int, or array-like
Upper acceptable comfort temperature for category II, default in [°C] or in [°F]
tmp_cmf_cat_iii_up : float or array-like
tmp_cmf_cat_iii_up : float, int, or array-like
Upper acceptable comfort temperature for category III, default in [°C] or in [°F]
tmp_cmf_cat_i_low : float or array-like
tmp_cmf_cat_i_low : float, int, or array-like
Lower acceptable comfort temperature for category I, default in [°C] or in [°F]
tmp_cmf_cat_ii_low : float or array-like
tmp_cmf_cat_ii_low : float, int, or array-like
Lower acceptable comfort temperature for category II, default in [°C] or in [°F]
tmp_cmf_cat_iii_low : float or array-like
Lower acceptable comfort temperature for category III, default in [°C] or in [°F]
Expand Down
2 changes: 1 addition & 1 deletion pythermalcomfort/models/ankle_draft.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
)


def ankle_draft(tdb, tr, vr, rh, met, clo, v_ankle, units="SI"):
def ankle_draft(tdb, tr, vr, rh, met, clo, v_ankle, units: str = "SI"):
"""
Calculates the percentage of thermally dissatisfied people with the ankle draft (
0.1 m) above floor level [23]_.
Expand Down
2 changes: 1 addition & 1 deletion pythermalcomfort/models/at.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def at(tdb, rh, v, q=None, **kwargs):
kwargs = {**default_kwargs, **kwargs}

# dividing it by 100 since the at eq. requires p_vap to be in hPa
p_vap = psy_ta_rh(tdb, rh)["p_vap"] / 100
p_vap = psy_ta_rh(tdb, rh).p_vap / 100

# equation sources [16] and http://www.bom.gov.au/info/thermal_stress/#apparent
if q:
Expand Down
12 changes: 6 additions & 6 deletions pythermalcomfort/models/atcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ def __init__(self, *args, **kwargs):
Attributes
----------
tdb : float or array-like
tdb : float, int, or array-like
Dry bulb air temperature [°C].
tr : float or array-like
tr : float, int, or array-like
Mean radiant temperature [°C].
to : float or array-like
to : float, int, or array-like
Operative temperature [°C].
v : float or array-like
v : float, int, or array-like
Air speed [m/s].
rh : float or array-like
rh : float, int, or array-like
Relative humidity [%].
clo : float or array-like
clo : float, int, or array-like
Clothing insulation [clo].
Note: If you want to input clothing insulation to each body part,
it can be input using the dictionaly in "utilities.py" in "jos3_function" folder.
Expand Down
10 changes: 5 additions & 5 deletions pythermalcomfort/models/athb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ def athb(tdb, tr, vr, rh, met, t_running_mean):
Parameters
----------
tdb : float or array-like
tdb : float, int, or array-like
dry bulb air temperature, in [°C]
tr : float or array-like
tr : float, int, or array-like
mean radiant temperature, in [°C]
vr : float or array-like
vr : float, int, or array-like
relative air speed, in [m/s]
Note: vr is the relative air speed caused by body movement and not the air
Expand All @@ -27,9 +27,9 @@ def athb(tdb, tr, vr, rh, met, t_running_mean):
(Vag). Where Vag is the activity-generated air speed caused by motion of
individual body parts. vr can be calculated using the function
:py:meth:`pythermalcomfort.utilities.v_relative`.
rh : float or array-like
rh : float, int, or array-like
relative humidity, [%]
met : float or array-like
met : float, int, or array-like
metabolic rate, [met]
t_running_mean: float or array-like
running mean temperature, in [°C]
Expand Down
Loading

0 comments on commit 84b23f5

Please sign in to comment.