Metadata-Version: 2.2
Name: libraryfemtherm
Version: 0.19.0
Summary: Python bindings for LibraryFEMTherm – THMZ file parsing and thermal simulation data
Author-Email: LBNL-ETA <SimonMN@lbl.gov>
License: *** License Agreement ***
         
         Berkeley Lab LibraryFEMTHERM Copyright (c) 2025, The
         Regents of the University of California, through Lawrence Berkeley National
         Laboratory (subject to receipt of any required approvals from the U.S.
         Dept. of Energy).  All rights reserved.
         
         Redistribution and use in source and binary forms, with or without
         modification, are permitted provided that the following conditions are met:
         
         (1) Redistributions of source code must retain the above copyright notice,
         this list of conditions and the following disclaimer.
         
         (2) Redistributions in binary form must reproduce the above copyright
         notice, this list of conditions and the following disclaimer in the
         documentation and/or other materials provided with the distribution.
         
         (3) Neither the name of the University of California, Lawrence Berkeley
         National Laboratory, U.S. Dept. of Energy nor the names of its contributors
         may be used to endorse or promote products derived from this software
         without specific prior written permission.
         
         THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
         AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
         IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
         ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
         LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
         CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
         SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
         INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
         CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
         ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
         POSSIBILITY OF SUCH DAMAGE.
         
         You are under no obligation whatsoever to provide any bug fixes, patches,
         or upgrades to the features, functionality or performance of the source
         code ("Enhancements") to anyone; however, if you choose to make your
         Enhancements available either publicly, or directly to Lawrence Berkeley
         National Laboratory, without imposing a separate written license agreement
         for such Enhancements, then you hereby grant the following license: a
         non-exclusive, royalty-free perpetual license to install, use, modify,
         prepare derivative works, incorporate into other computer software,
         distribute, and sublicense such enhancements or derivative works thereof,
         in binary and source code form.
         
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: C++
Classifier: Topic :: Scientific/Engineering
Project-URL: Homepage, https://github.com/LBNL-ETA/LibraryFEMTherm
Project-URL: Repository, https://github.com/LBNL-ETA/LibraryFEMTherm
Requires-Python: >=3.11
Description-Content-Type: text/markdown

# LibraryFEMTherm

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.

## Requirements

- 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)

## Building

### C++ only (default)

```bash
cmake --preset default
cmake --build build/default --config Release
```

### C++ with Python bindings

```bash
cmake --preset python
cmake --build build/python --config Release
```

### Manual configuration (Visual Studio generator)

```bash
cmake -G "Visual Studio 17 2022" -A x64 -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release
```

Add `-DBUILD_PYTHON_BINDINGS=ON` to include Python bindings.

## CMake presets

| 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.

## Running tests

```bash
ctest --test-dir build/python -C Release -V
```

This runs both C++ Google Tests and Python pytest tests (when built with the `python` preset).

## CMake options

| Option                        | Default | Description                          |
|-------------------------------|---------|--------------------------------------|
| `BUILD_PYTHON_BINDINGS`       | OFF     | Build Python bindings via pybind11   |
| `BUILD_LibraryFEMTHERM_TESTING` | ON   | Build C++ test targets               |

## Python bindings

Install from PyPI:

```bash
pip install libraryfemtherm
```

Or build from source with `BUILD_PYTHON_BINDINGS=ON` (see above).

```python
import pylibraryfemtherm as fem

# Load a THMZ file
model = fem.load_model_from_zip_file("sample-sill.thmz")
print(f"Polygons:   {len(model.polygons)}")
print(f"Boundaries: {len(model.boundary_conditions)}")

# 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", [fem.zip.MATERIALS_FILE_NAME])
db = fem.MaterialsDB()
db.load_from_string(contents[fem.zip.MATERIALS_FILE_NAME])
```

For comprehensive Python API documentation with examples, see [doc/python.md](doc/python.md).

## Project structure

```
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
```

## Dependencies (fetched automatically)

- [FileParse](https://github.com/LBNL-ETA/FileParse) - XML/JSON serialization
- [LBNLCPPCommon](https://github.com/LBNL-ETA/LBNLCPPCommon) - Common utilities
- [miniz](https://github.com/richgel999/miniz) - ZIP compression
- [pybind11](https://github.com/pybind/pybind11) v2.13.6 - Python bindings (optional)
- [Google Test](https://github.com/google/googletest) v1.13.0 - Testing (optional)
