Type-safe Pydantic models for all EnergyPlus IDF objects
Project description
idfpy
Type-safe Pydantic models for all EnergyPlus IDF object types, plus IDF file read/write and simulation execution, optimized for LLM tool calling and IDE auto-completion.
Auto-generated from Energy+.schema.epJSON version 26.1.0.
Features
- 859 object types as Pydantic v2 models with full validation
- 275 reference types with cross-object validation
- Forward navigation —
surface.zoneresolves a reference field to the target object - Reverse navigation —
zone.referencing("Lights")finds all objects that reference a given object - Reference validation —
idf.validate()batch-checks all cross-object references for existence and type compatibility - Extension plugin system —
surface.area,.normal,.centroidvia auto-discovered geometry mixins with full IDE support - Case-insensitive Literal field matching (EnergyPlus IDF is case-insensitive)
- Extensible field support (vertices, schedule data, etc.)
- IDF read/write with positional field ordering
- epJSON read/write with auto-detection by file extension
to_dict()/from_dict()for in-memory dict conversion (ideal for LLM tool calls)- EnergyPlus simulation execution with ExpandObjects support
- Accepts both
snake_caseand original EnergyPlus schema key names
Why idfpy over eppy?
| idfpy | eppy | |
|---|---|---|
| No EnergyPlus IDD required at runtime | ✅ | ❌ |
| Type-safe field validation | ✅ Pydantic v2 | ❌ |
| epJSON read/write | ✅ | ❌ |
| Cross-reference validation | ✅ 275 ref groups | ❌ |
| Forward/reverse navigation | ✅ 2849 properties | ❌ |
| Surface geometry (area/normal) | ✅ ext plugin | ❌ |
to_dict() / from_dict() for LLM |
✅ | ❌ |
| Dependencies | 4 (pydantic, jinja2, loguru, typer) | 12+ (lxml, pyparsing...) |
Installation
pip install idfpy
Quick Start
from pathlib import Path
from idfpy import IDF
from idfpy.models import Version, Building, Zone
# Create an IDF
idf = IDF()
idf.add(Version())
idf.add(Building(name='MyBuilding', north_axis=0.0))
idf.add(Zone(name='Zone1'))
# Save as IDF
idf.save(Path('output.idf'))
# Save as epJSON
idf.save(Path('output.epjson'), output_type='epjson')
# Load (auto-detects format by extension)
idf = IDF.load(Path('existing.idf')) # IDF format
idf = IDF.load(Path('existing.epjson')) # epJSON format
# Run simulation
from idfpy.sim import simulate
result = simulate(Path('output.idf'), weather=Path('weather.epw'), output_dir=Path('results/'))
print(result.success) # True / False
In-memory dict conversion
from pathlib import Path
from idfpy import IDF
idf = IDF.load(Path('model.idf'))
# IDF → dict (epJSON structure)
data = idf.to_dict()
# {
# "Building": {"MyBuilding": {"north_axis": 0.0, "terrain": "Suburbs"}},
# "Zone": {"Zone1": {"direction_of_relative_north": 0.0}},
# ...
# }
# dict → IDF
idf = IDF.from_dict(data)
Object navigation
Every reference field generates a @property for forward navigation. Reverse navigation is available via referencing(). All query methods (get / has / all_of_type / remove) accept either an EnergyPlus type string, a Python class name, or the model class itself — passing the class preserves precise typing in your IDE.
from pathlib import Path
from idfpy import IDF
from idfpy.models import BuildingSurfaceDetailed, Zone
idf = IDF.load(Path('model.idf'))
# Forward navigation — resolve reference to target object
surface = idf.get(BuildingSurfaceDetailed, 'Wall1') # → BuildingSurfaceDetailed | None
surface.zone_name # "Zone1" (raw string, always works)
surface.zone # Zone object (resolved via IDF)
surface.construction # Construction object
# Reverse navigation — find all objects referencing a given object
zone = idf.get(Zone, 'Zone1')
zone.referencing(BuildingSurfaceDetailed) # → [Wall1, Wall2, ...]
zone.referencing('Lights') # → [OfficeLights, ...]
# Chained navigation
zone.referencing(BuildingSurfaceDetailed)[0].construction
Strict type-name validation (default)
Query methods raise UnknownObjectTypeError when the type name cannot be resolved — this surfaces typos immediately instead of returning an empty result. Pass strict=False for the legacy silent behavior.
from idfpy import UnknownObjectTypeError
try:
idf.get('BuildingSurface:detailed', 'Wall1') # note the lowercase 'd'
except UnknownObjectTypeError as e:
print(e) # → Unknown object type: 'BuildingSurface:detailed'. ...
# Opt-in legacy silent behavior
idf.get('BuildingSurface:detailed', 'Wall1', strict=False) # → None
Reference validation
from idfpy import IDF, RefValidationError
idf = IDF.load(Path('model.idf'))
# Batch check all cross-object references
errors = idf.validate()
for e in errors:
print(e)
# [missing] Lights/OffLights.schedule_name: "BadSched" not found in any of [ScheduleNames]
# Or raise on first broken reference set
try:
idf.validate_or_raise()
except RefValidationError as exc:
print(f"{len(exc.errors)} broken reference(s)")
Real-world Example
from pathlib import Path
from idfpy import IDF
# Load a DOE reference building
idf = IDF.load(Path("LargeOffice.idf"))
# Modify all exterior walls' insulation
for con_name, con in idf.all_of_type('Construction').items():
layer = con.outside_layer_ref
if layer and hasattr(layer, "conductivity"):
print(f"{con.name}: k={layer.conductivity} W/m·K")
# Validate all references
errors = idf.validate()
print(f"{len(errors)} broken references")
Geometry extensions
Surface models include geometry properties via the built-in ext.geometry plugin — area, normal vector, and centroid are computed from vertices using Newell's method, with full IDE autocompletion.
from idfpy import IDF
from pathlib import Path
idf = IDF.load(Path('model.idf'))
surface = idf.get('BuildingSurface:Detailed', 'Wall1')
surface.area # 30.0 (m²)
surface.normal # (0.0, -1.0, 0.0) — outward unit normal
surface.centroid # (5.0, 0.0, 1.5)
surface.vertices_as_tuples # [(0,0,3), (0,0,0), (10,0,0), (10,0,3)]
window = idf.get('FenestrationSurface:Detailed', 'Win1')
window.area # 16.0 (m²)
Supported surface types: BuildingSurface:Detailed, FenestrationSurface:Detailed, Floor:Detailed, RoofCeiling:Detailed, Wall:Detailed, Shading:Building:Detailed, Shading:Site:Detailed, Shading:Zone:Detailed.
Creating custom plugins
Extensions live in idfpy/ext/ as sub-packages. Each plugin exposes a MIXIN_MAP that the code generator auto-discovers:
# idfpy/ext/thermal/__init__.py
from .mixins import ThermalPropertyMixin
MIXIN_MAP: dict[str, type] = {
'BuildingSurfaceDetailed': ThermalPropertyMixin,
}
# idfpy/ext/thermal/mixins.py
class ThermalPropertyMixin:
@property
def u_value(self) -> float:
"""Compute U-value from construction layers."""
...
After adding a plugin, re-run idfpy codegen to regenerate models — the mixin is injected into the class hierarchy and IDE autocompletion works immediately.
Container mutation
from idfpy.models import Zone
idf.remove(Zone, 'Zone1') # unbinds + unregisters references
idf.remove('Zone', 'Zone1') # string form (EnergyPlus or Python class name)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file idfpy-25.1.0.post2.tar.gz.
File metadata
- Download URL: idfpy-25.1.0.post2.tar.gz
- Upload date:
- Size: 614.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8cc6ea9d9fc30e77934d15012c949da38499b92a37ee94b4afed0bd742f31213
|
|
| MD5 |
b1673687409d6d2ac8060c2ea8484d5a
|
|
| BLAKE2b-256 |
44048d88992ad0d147c72520420dee98801d003dce6821e7e9dce81dc2886955
|
Provenance
The following attestation bundles were made for idfpy-25.1.0.post2.tar.gz:
Publisher:
release-version.yml on ITOTI-Y/idfpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
idfpy-25.1.0.post2.tar.gz -
Subject digest:
8cc6ea9d9fc30e77934d15012c949da38499b92a37ee94b4afed0bd742f31213 - Sigstore transparency entry: 1505384137
- Sigstore integration time:
-
Permalink:
ITOTI-Y/idfpy@60113a57be189ac79c9f94d10ed0c6f8e6240111 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/ITOTI-Y
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-version.yml@60113a57be189ac79c9f94d10ed0c6f8e6240111 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file idfpy-25.1.0.post2-py3-none-any.whl.
File metadata
- Download URL: idfpy-25.1.0.post2-py3-none-any.whl
- Upload date:
- Size: 627.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e0b9e6297d7d5ff4b10c1be305d571255efbd2488e3c51722907d5778494798
|
|
| MD5 |
3bc0eba8d258510651248cea609664fb
|
|
| BLAKE2b-256 |
2ae0d0d2c0cf47a73ca08f71e4222680b616e1dbe50e60bb41463c8a516c889b
|
Provenance
The following attestation bundles were made for idfpy-25.1.0.post2-py3-none-any.whl:
Publisher:
release-version.yml on ITOTI-Y/idfpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
idfpy-25.1.0.post2-py3-none-any.whl -
Subject digest:
5e0b9e6297d7d5ff4b10c1be305d571255efbd2488e3c51722907d5778494798 - Sigstore transparency entry: 1505384294
- Sigstore integration time:
-
Permalink:
ITOTI-Y/idfpy@60113a57be189ac79c9f94d10ed0c6f8e6240111 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/ITOTI-Y
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-version.yml@60113a57be189ac79c9f94d10ed0c6f8e6240111 -
Trigger Event:
workflow_dispatch
-
Statement type: