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
//! Crate providing formulae for air thermodynamic calculations.
//!
//! # How to use
//!
//! To use this crate simply import it with `use` statement and then use desired function from chosen module.
//!
//! ```
//! use floccus::vapour_pressure;
//! # use float_cmp::assert_approx_eq;
//!
//! //Set temperature and pressure in SI units
//! let temperature = 300.0; //in K
//! let pressure = 101325.0; //in Pa
//!
//! //Compute vapour pressure using Buck (1981) formula
//! let vapour_pressure = vapour_pressure::buck1(temperature, pressure).unwrap();
//! println!("{}", vapour_pressure); // 3550.662 (f32) or 3550.6603579471303 (f64)
//! ```
//!
//! # Naming of modules and functions
//!
//! Because some thermodynamic formulae are empirical there are several ways to compute a value of given quantity.
//! Therefore there are multiple functions available to compute the same parameter, which are grouped into modules.
//!
//! The naming of modules and functions follows this convention:
//!
//! ```
//! # use floccus::vapour_pressure;
//! # let temperature = 300.0;
//! # let pressure = 100000.0;
//! # let vp =
//! vapour_pressure::buck1(temperature, pressure)
//! # .unwrap();
//! ```
//!
//! Where the module name (`vapour_pressure`) indicates the computed quantity, function name (`buck1`) indicates the author of formula
//! and the function arguments (`temperature, pressure`) are variables used to compute the quantity.
//!
//! # Double precision
//!
//! By default floccus uses single-precision (32-bit) floating-point variables.
//! If increased accuracy is needed (at the cost of performance) `double_precision` feature can be enabled
//! to use double-precision (64-bit) floating point.
//!
//! # Input checking
//!
//! To prevent any unexpected behaviour, all functions check whether provided inputs are within a reasonable range.
//! Exact limits are specified in the documentation of each function.
//! If the input is out of range the function will return an [`InputError::OutOfRange`](errors::InputError::OutOfRange) with erronous input specified.
//!
//! # Units
//!
//! This crate uses basic SI units in the interface.
//!
//! Units for each quantity are:
//! - Pressure: Pascals (Pa)
//! - Temperature: Kelvins (K)
//! - Mass: kilograms (kg)
//! - Length: meters (m)
//! - Relative humidity: ratio (%/100)
//! - Volume: meters cubed (m^3)
//! - Density: kilograms per meter cubed (kg*m^3)
//! - Mixing ratio: kilograms per kilogram (kg*kg^-1)
//! - Specific humidity: kilograms per kilogram (kg*kg^-1)
//!
//! If the formula uses numbers of very different scales there can be an exception from that rule described in the function documentation.
//!
//! # Debugging
//!
//! If additional information is needed about which function returns the error and why, `debug` feature can be enabled.
//! With that feature when returning the error function will also print the error message to `log` with additional
//! information about the error. This feature potentially is not zero-cost so it is optional.
type Float = f32;
type Float = f64;