-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #952 from AlbertoCuadra/develop
Add: include routine to compute specific humidity of air
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
function value = humidity_specific(T, p, humidity_relative) | ||
% Get the specific humidity of air [kg_w/kg_da] at a given temperature and pressure | ||
% | ||
% Args: | ||
% T (float): Temperature [K] | ||
% p (float): Pressure [bar] | ||
% humidity_relative (float): Relative humidity [%] | ||
% | ||
% Returns: | ||
% value (float): Specific humidity of air [kg_w/kg_da] at a given temperature and pressure | ||
|
||
% Constants | ||
A = [-5.8002206e3, 1.3914993e0, -4.8640239e-2, 4.1764768e-5, -1.4452093e-8, 6.5459673e0]; | ||
|
||
% Change pressure from [bar] to [Pa] | ||
p = p * 1e5; | ||
|
||
% Saturated vapor pressure [Pa] | ||
p_ws = exp( A(1)./T + A(2) + A(3) * T + A(4) * T.^2 + A(5) * T.^3 + A(6) * log(T) ); % Temperature in [K] | ||
|
||
% Vapor pressure [Pa] | ||
p_w = humidity_relative * p_ws * 1e-2; | ||
|
||
% Specific humidity [kg_w/kg_da] | ||
value = 0.622 * p_w ./ (p - p_w); | ||
end |