C++20 static library for reading, writing, and manipulating THERM (.thmz) files. Provides data structures and serialization for thermal models, materials, boundary conditions, gases, glazing systems, and CMA data. Optional Python bindings via pybind11.
- CMake 3.8+
- C++20 compiler (MSVC 2022, GCC 11+, Clang 14+)
- Ninja or Visual Studio generator
- Python 3.11+ (only when building Python bindings)
cmake --preset default
cmake --build build/default --config Releasecmake --preset python
cmake --build build/python --config Releasecmake -G "Visual Studio 17 2022" -A x64 -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config ReleaseAdd -DBUILD_PYTHON_BINDINGS=ON to include Python bindings.
| Preset | Description | Python bindings | C++ tests |
|---|---|---|---|
default |
C++ only | OFF | ON |
python |
C++ with Python bindings | ON | ON |
CLion and VS Code automatically detect these presets.
ctest --test-dir build/python -C Release -VThis runs both C++ Google Tests and Python pytest tests (when built with the python preset).
| Option | Default | Description |
|---|---|---|
BUILD_PYTHON_BINDINGS |
OFF | Build Python bindings via pybind11 |
BUILD_LibraryFEMTHERM_TESTING |
ON | Build C++ test targets |
When built with BUILD_PYTHON_BINDINGS=ON, a _femtherm Python extension module is produced in the python/ directory.
import sys
sys.path.insert(0, "python") # or python/Release on Windows with MSVC
import _femtherm as fem
# Load a THMZ file
model = fem.load_model_from_zip_file("tst/products/sample-sill.thmz")
print(f"Polygons: {len(model.polygons)}, Boundaries: {len(model.boundaries)}")
# Save to XML string
xml = fem.save_model_to_string(model)
# Save to a new THMZ file
fem.save_model_to_zip_file(model, "output.thmz")
# Work with ZIP contents directly
contents = fem.zip.unzip_files("sample.thmz", ["Materials.xml"])
db = fem.MaterialsDB()
db.load_from_string(contents["Materials.xml"])src/
BCSteadyState/ # Steady-state boundary conditions
BCTransient/ # Transient boundary conditions
CMA/ # CMA (Component Modeling Approach) data
Common/ # Shared utilities
Gases/ # Gas properties and mixtures
Materials/ # Material definitions (solid, cavity, radiation)
THMZ/ # ThermModel, geometry, preferences, properties, zip I/O
LibraryUtilities/ # Common helpers
Schemas/ # XML/JSON schemas
python/
src/ # pybind11 binding source files
tests/ # pytest test suite
tst/
units/ # C++ Google Test files
products/ # Test THMZ data files
cmake/ # CMake macros and compiler config
- FileParse - XML/JSON serialization
- LBNLCPPCommon - Common utilities
- miniz - ZIP compression
- pybind11 v2.13.6 - Python bindings (optional)
- Google Test v1.13.0 - Testing (optional)