-
Notifications
You must be signed in to change notification settings - Fork 23
/
SatVaporPressure.c
executable file
·121 lines (90 loc) · 3.55 KB
/
SatVaporPressure.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
* SUMMARY: SatVaporPressure.c - Calculate saturated vapor pressure
* USAGE: Part of DHSVM
*
* AUTHOR: Bart Nijssen
* ORG: University of Washington, Department of Civil Engineering
* E-MAIL: [email protected]
* ORIG-DATE: 4-Oct-1996 at 09:34:43
* DESCRIPTION: Calculates the saturated vapor pressure in Pa for a certain
* temperature
* DESCRIP-END.
* FUNCTIONS: SatVaporPressure()
* COMMENTS:
* $Id: SatVaporPressure.c,v 1.4 2003/07/01 21:26:23 olivier Exp $
*/
#include <stdlib.h>
#include <math.h>
#include "lookuptable.h"
float CalcVaporPressure(float T);
static FLOATTABLE svp; /* Table that contains saturated vapor
pressures as a function of temperature
in degrees C */
/*****************************************************************************
Function name: InitSatVaporTable()
Purpose : Initialize lookup table for saturated vapor pressure as a
function of temperature in degrees C.
Required : void
Returns : void
Modifies : none
Comments : Table runs from -100 C to 100 C with an interval of 0.02 C
*****************************************************************************/
void InitSatVaporTable(void)
{
InitFloatTable(10000L, -100., .02, CalcVaporPressure, &svp);
}
/*****************************************************************************
Function name: CalcVaporPressure()
Purpose : Calculates the saturated vapor pressure in Pa for a certain
temperature in degrees C
Required :
float T - Temperature (C)
Returns :
float - Saturated vapor pressure (Pa)
Modifies : none
Comments :
References: Shuttleworth, W.J., Evaporation, In: Maidment, D. R. (ed.),
Handbook of hydrology, 1993, McGraw-Hill, New York, etc..
Bras, R. A., Hydrology, an introduction to hydrologic
science, Addisson Wesley, Inc., Reading, etc., 1990.
*****************************************************************************/
float CalcVaporPressure(float T)
{
float Pressure;
Pressure = 610.78 * exp((double) ((17.269 * T) / (237.3 + T)));
/* Calculate the saturated vapor pressure in the snow pack,
(Equation 3.32, Bras 1990) */
if (T < 0.0)
Pressure *= 1.0 + .00972 * T + .000042 * T * T;
return Pressure;
}
/*****************************************************************************
Function name: SatVaporPressure() - new version, using a lookup table
Purpose : Looks up the saturated vapor pressure in Pa for a certain
temperature in a table
Required :
float T - Temperature (C)
Returns :
float - Saturated vapor pressure (Pa)
Modifies : none
Comments : Uses lookup table
*****************************************************************************/
float SatVaporPressure(float T)
{
return FloatLookup(T, &svp);
}
/*****************************************************************************
Function name: SatVaporPressure() - old version, pre lookup table
Purpose : Calculates the saturated vapor pressure in Pa for a certain
temperature
Required :
float T - Temperature (C)
Returns :
float - Saturated vapor pressure (Pa)
Modifies : none
Comments : No longer used
*****************************************************************************/
/* float SatVaporPressure(float T) */
/* { */
/* return CalcVaporPressure(T); */
/* } */