Created
September 18, 2023 15:33
-
-
Save sciunto/d10077a3f5d89428afcfeb44e0ef330e to your computer and use it in GitHub Desktop.
Wood humidity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
import numpy as np | |
from scipy import constants, optimize | |
import matplotlib.pyplot as plt | |
plt.rcParams.update({'figure.autolayout': True}) | |
def switch_mpl_style(latex=True): | |
import matplotlib | |
if latex: | |
plt.rcParams['figure.figsize'] = (7 * 1.61, 7) | |
matplotlib.rcParams['text.usetex'] = True | |
plt.rc('axes', labelsize=22) # fontsize of the x and y labels | |
plt.rc('xtick', labelsize=20) # fontsize of the tick labels | |
plt.rc('ytick', labelsize=20) # fontsize of the tick labels | |
plt.rc('legend', fontsize=15) # legend fontsize | |
else: | |
matplotlib.rcParams['text.usetex'] = False | |
plt.rc('axes', labelsize=10) # fontsize of the x and y labels | |
plt.rc('xtick', labelsize=10) # fontsize of the tick labels | |
plt.rc('ytick', labelsize=10) # fontsize of the tick labels | |
plt.rc('legend', fontsize=10) # legend fontsize | |
switch_mpl_style() | |
# $$ w_{eq} = \frac{1800}{W} ( \frac{K H}{1 - KH} + \frac{K_1 K H + 2 K_1K_2K^2 H^2}{1 + K_1 K H + K_1K_2K^2H^2} ) $$ | |
# | |
# | |
# * $w_{eq}$ teneur en eau % | |
# * $H$ : humidité relative de l'air | |
# * T : temperature en °C | |
# * $W = 349 + 1.29T + 0.0135T^2$ | |
# * $K = 0.805 + 0.000736T - 0.00000273T^2$ | |
# * $K_1 = 6.27 - 0.00938 T - 0.000303 T^2$ | |
# * $K_2 = 1.91 + 0.0407 T - 0.000293 T^2$ | |
def get_weq(T, humidity): | |
Tf = constants.convert_temperature(T, 'C', 'F') | |
W = 330 + 0.452 * Tf + 0.00415 * Tf**2 | |
K = 0.791 + 0.000463 * Tf - 0.000000844 * Tf**2 | |
K_1 = 6.34 + 0.000775 * Tf - 0.0000935 * Tf**2 | |
K_2 = 1.09 + 0.0284 * Tf - 0.0000904 * Tf**2 | |
term_1 = K * humidity / (1 - K * humidity) | |
term_2 = K_1 * K * humidity + 2 * K_1 * K_2 * K**2 * humidity**2 | |
term_2 /= 1 + K_1 * K * humidity + K_1 * K_2 * K**2 * humidity**2 | |
weq = 1800 * (term_1 + term_2) / W | |
return weq | |
RH = np.linspace(0, 100, 100) | |
temperatures = np.linspace(-10, 40, 3) | |
for T in temperatures: | |
weq = get_weq(T, RH/100) | |
plt.plot(RH, weq, label=f'$T={T}' + r'~^\circ {\rm C}$') | |
plt.xlabel(r'${\cal R}_{\rm H}~(\%)$') | |
plt.ylabel(r'$w_{\rm eq}~(\%)$') | |
plt.grid() | |
plt.legend() | |
plt.tight_layout() | |
plt.savefig('RH-0-100.pdf') | |
RH = np.linspace(30, 70, 100) | |
temperatures = np.linspace(10, 30, 3) | |
for T in temperatures: | |
weq = get_weq(T, RH/100) | |
plt.plot(RH, weq, label=f'$T={T}' + r'~^\circ {\rm C}$') | |
plt.xlabel(r'${\cal R}_{\rm H}~(\%)$') | |
plt.ylabel(r'$w_{\rm eq}~(\%)$') | |
plt.grid() | |
plt.legend() | |
plt.tight_layout() | |
plt.savefig('RH-30-70.pdf') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment