### 11 releases

0.4.0-alpha.3 | Apr 5, 2024 |
---|---|

0.4.0-alpha.2 | Mar 28, 2024 |

0.3.7 | Dec 30, 2022 |

0.3.6 | Feb 12, 2022 |

0.1.0 | Sep 1, 2021 |

#**2** in #thermodynamics

**520** downloads per month

**Apache-2.0**

160KB

3.5K
SLoC

# floccus

Rust crate providing formulae for air thermodynamic calculations.

This crate contains functions for computing thermodynamic quantities commonly used in atmospheric sciences. It is currently developed by one person so **if there is a function you would like to be added do not hesitate to post an issue or pull request in the Github repository**.

The purpose of this crate is to be an academic reference of thermodynamic formulae, so that researchers looking for a particular formula do not need to search it in the literature. Therefore all functions documentation provides a reference to the paper from which formula is taken.

Also, check the contributors guide of this crate.

## How to use

To use this crate simply import it with

statement and then use desired function from chosen module.`use`

`use` `floccus``::`vapour_pressure`;`
`//`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`)``;`
`//`The result is 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:

`vapour_pressure``::`buck1`(`temperature`,` pressure`)``;`

Where the module name (

) indicates the computed quantity, function name (`vapour_pressure`

) indicates the author of formula
and the function arguments (`buck1`

) are variables used to compute the quantity.`temperature , pressure`

## Double precision

By default floccus uses single-precision (32-bit) floating-point variables.
If increased accuracy is needed (at the cost of performance)

feature can be enabled
to use double-precision (64-bit) floating point.`double_precision`

## Input checking

To prevent any unexpected behavior, 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

with erroneous input specified.`InputError ::`OutOfRange

Each function also has

and `_unchecked`

versions. The `_validate`

version only checks the inputs with bounds defined for its "parent" function.
The `_validate`

version performs only the calculation without any input checking. All "parent" functions simply call `_unchecked`

and then `_validate`

.`_unchecked`

## Debugging

If additional information is needed about which function returns the error and why,

feature can be enabled.
With that feature when returning the error function will also print the error message to `debug`

with additional
information about the error. This feature potentially is not zero-cost so it is optional.`log`

## Benchmarks

Functions provided in this crate are intended for use in, i. a., numerical models. To provide the user information about performance overhead of each function all functions are can be benchmarked using criterion.rs.

#### Dependencies

~1.5–2.6MB

~53K SLoC