thermalcomfort
A comprehensive Rust port of the pythermalcomfort Python package (v3.9.1) for thermal comfort calculations. All 38 core models, all utility functions, and all clothing databases are implemented with identical results to the Python reference.
This library is no_std compatible and can run in WASM environments, making it suitable for embedded systems, web applications, and resource-constrained environments.
For model documentation, parameters, and references, see the pythermalcomfort documentation.
Features
- 100% Feature Complete: All 38 core models from pythermalcomfort v3.9.1
- Identical Results: Perfect accuracy compared to the Python reference for all models (see Accuracy for the one
no_stdexception) no_stdcompatible: Works in embedded and WASM environments (default)stdfeature: Optional for perfect PET accuracy in extreme cold+wind conditions- Rigorously Validated: 202 tests (88 unit + 56 Python comparison + 58 doctests)
- Type-safe: All physical quantities use typed wrappers to prevent unit errors at compile time
- Standards Compliant: ISO 7730, ISO 7933, ASHRAE 55, EN 16798-1, ISO 9920
Re-exported Types
The library re-exports the following types for convenience:
From the measurements crate:
Temperature- Celsius, Fahrenheit, Kelvin, RankineSpeed- m/s, km/h, mph, knots, etc.Humidity- Relative humidity (0-100%)Length- meters, centimeters, feet, inches, etc.Mass- kilograms, pounds, etc.Power- watts, kilowatts, horsepower, etc.Area- m², ft², etc.Pressure- Pa, kPa, mmHg, atm, etc.
Defined in this crate:
ClothingInsulation- Clothing insulation (clo, tog, m²·K/W)MetabolicRate- Metabolic rate (met, W/m², Btu/(h·ft²))Sex- Biological sex for physiological models
All types support automatic unit conversion through the type system, preventing errors like passing Fahrenheit where Celsius is expected.
Optional std Feature
For applications requiring perfect Python accuracy matching in extreme PET conditions, enable the std feature:
[]
= { = "3.9.1", = ["std"] }
This uses nalgebra for numerically stable linear algebra (LU decomposition), matching Python's scipy.optimize.fsolve. The trade-off is breaking no_std compatibility and a slightly larger binary (~100KB). Only needed when extreme cold+wind PET accuracy is critical (< 5°C, > 2 m/s).
Installation
Add this to your Cargo.toml:
[]
= "3.9.1"
Usage
Basic PMV/PPD Calculation
use ;
Sports Heat Stress Risk
use ;
use ;
UTCI (Universal Thermal Climate Index)
use ;
use utci;
PET (Physiological Equivalent Temperature)
use ;
use pet_steady;
PHS (Predicted Heat Strain)
use ;
use ;
Unit Conversions
All measurement types support automatic unit conversion:
use ;
Clothing Insulation Lookups
use ;
use clo_intrinsic_insulation_ensemble;
WASM Support
This library is no_std compatible and can be compiled to WebAssembly:
Accuracy & Validation
All models produce identical results to pythermalcomfort v3.9.1. The only exception is the PET model under extreme cold+wind conditions when using the default no_std build:
| Condition | Python | Rust (no_std) |
Rust (std) |
|---|---|---|---|
| Normal (25°C, 0.1 m/s, 50% RH) | 24.17°C | 24.17°C | 24.17°C |
| Hot (35°C, 1.0 m/s, 60% RH) | 36.26°C | 36.26°C | 36.26°C |
| Cold+wind (5°C, 2.0 m/s, 50% RH) | -0.46°C | 2.06°C | -0.46°C |
The no_std PET solver uses a custom Newton-Raphson method with a full 3x3 Jacobian, which is less numerically stable than Python's scipy HYBRD algorithm in extreme conditions. Enabling the std feature switches to a MINPACK-based HYBRD solver for perfect accuracy in all conditions.
All other models (PMV/PPD, UTCI, PHS, SET, Gagge variants, sports heat stress risk, etc.) produce identical results in both no_std and std builds.
Testing
# Run all tests
# Run only library tests (88 tests)
# Run documentation tests (58 tests)
# Run Python comparison tests (56 tests, requires pythermalcomfort)
Standards Compliance
- ISO 7730:2005 - PMV/PPD
- ISO 7933:2004/2023 - Predicted Heat Strain
- ASHRAE 55 - Thermal Environmental Conditions for Human Occupancy
- ISO 7726:1998 - Instruments for measuring physical quantities
- ISO 9920:2007 - Clothing insulation estimation
- EN 16798-1 - Adaptive comfort
Credits
Rust port of pythermalcomfort (v3.9.1), developed by the Center for the Built Environment at UC Berkeley.
License
MIT License - see LICENSE file for details.