Skip to content

Instantly share code, notes, and snippets.

@FedericoTartarini
Last active May 18, 2024 03:12
Show Gist options
  • Save FedericoTartarini/d435cdfc86c631d8b5ab70a5d94fec45 to your computer and use it in GitHub Desktop.
Save FedericoTartarini/d435cdfc86c631d8b5ab70a5d94fec45 to your computer and use it in GitHub Desktop.
\begin{verbatim}
from pythermalcomfort.models import pmv_ppd
from pythermalcomfort.psychrometrics import v_relative
from pythermalcomfort.utilities import met_typical_tasks
from pythermalcomfort.utilities import clo_individual_garments
# input variables
tdb = 27 # dry-bulb air temperature, [$^{\circ}$C]
tr = 25 # mean radiant temperature, [$^{\circ}$C]
v = 0.1 # average air velocity, [m/s]
rh = 50 # relative humidity, [%]
activity = "Typing" # partcipant's activity description
garments = ["Sweatpants", "T-shirt", "Shoes or sandals"]
met = met_typical_tasks[activity] # activity met, [met]
icl = sum([clo_individual_garments[item] for item in garments]) # calculate total clothing insulation
\end{verbatim}
=====
\usepackage{listings}
=====
\begin{lstlisting}
from pythermalcomfort.models import pmv_ppd
tdb = 27 # dry-bulb air temperature, [$^{\circ}$C]
# calculate PMV in accordance with the ASHRAE 55 2017
results = pmv_ppd(tdb=tdb, tr=27, vr=0.1, rh=50, met=1.0, clo=0.5, standard="ASHRAE")
# print the results
print(results)
# {"pmv": -0.11, "ppd": 5.2}
\end{lstlisting}
=====
\begin{lstlisting}[language=Python, caption={Calculate PMV with pythermalcomfort.},label={lst:code}, mathescape=true, breaklines=true]
=====
\renewcommand\lstlistingname{Source Code}
\renewcommand\lstlistlistingname{Source Code}
\usepackage{xcolor}
\definecolor{codegreen}{rgb}{0,0.6,0}
\definecolor{codegray}{rgb}{0.5,0.5,0.5}
\definecolor{codeorange}{rgb}{1,0.49,0}
\definecolor{backcolour}{rgb}{0.95,0.95,0.96}
\lstdefinestyle{mystyle}{
backgroundcolor=\color{backcolour},
commentstyle=\color{codegray},
keywordstyle=\color{codeorange},
numberstyle=\tiny\color{codegray},
stringstyle=\color{codegreen},
basicstyle=\ttfamily\footnotesize,
breakatwhitespace=false,
breaklines=true,
captionpos=b,
keepspaces=true,
numbers=left,
numbersep=5pt,
showspaces=false,
showstringspaces=false,
showtabs=false,
tabsize=2,
xleftmargin=10pt,
}
\lstset{style=mystyle}
=====
\lstinputlisting[language=Python, caption={Calculate PMV with pythermalcomfort.},label={lst:pmv_example}, mathescape=true, firstline=12]{code.py}
=====
\lstlistoflistings
@commandercoo
Copy link

Thank you for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment