Skip to main content

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.

Auto-generated from Energy+.schema.epJSON version 25.2.0.

Features

  • 858 object types as Pydantic v2 models with full validation
  • 275 reference types with cross-object validation
  • Forward navigationsurface.zone resolves a reference field to the target object
  • Reverse navigationzone.referencing("Lights") finds all objects that reference a given object
  • Reference validationidf.validate() batch-checks all cross-object references for existence and type compatibility
  • 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_case and original EnergyPlus schema key names

Installation

pip install idfpy

Quick Start

from pathlib import Path
from idfpy import IDF
from idfpy.models.simulation import Version, Building
from idfpy.models.thermal_zones import 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
idf.run(
    idf_path=Path('model.idf'),
    weather_path=Path('weather.epw'),
    output_dir=Path('results/'),
)

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

from pathlib import Path
from idfpy import IDF

idf = IDF.load(Path('model.idf'))

# Forward navigation — resolve reference to target object
surface = idf.get('BuildingSurface:Detailed', 'Wall1')
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('BuildingSurface:Detailed')  # → [Wall1, Wall2, ...]
zone.referencing('Lights')                     # → [OfficeLights, ...]

# Chained navigation
zone.referencing('BuildingSurface:Detailed')[0].construction

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

Container mutation

idf.remove('Zone', 'Zone1')  # unbinds + unregisters references

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

idfpy-25.2.0.post2.tar.gz (559.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

idfpy-25.2.0.post2-py3-none-any.whl (578.0 kB view details)

Uploaded Python 3

File details

Details for the file idfpy-25.2.0.post2.tar.gz.

File metadata

  • Download URL: idfpy-25.2.0.post2.tar.gz
  • Upload date:
  • Size: 559.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for idfpy-25.2.0.post2.tar.gz
Algorithm Hash digest
SHA256 fc7c32f23f86965d32fc26247d6afae4996f96b425156d833aae537252fbfe3b
MD5 e9e0ceb0fa41b883c402d56e0183b17e
BLAKE2b-256 6ca819b5cd471a6fcaf02382a5133497867bf7e2b238df940a17d75cc8068ecd

See more details on using hashes here.

Provenance

The following attestation bundles were made for idfpy-25.2.0.post2.tar.gz:

Publisher: publish.yml on ITOTI-Y/idfpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file idfpy-25.2.0.post2-py3-none-any.whl.

File metadata

  • Download URL: idfpy-25.2.0.post2-py3-none-any.whl
  • Upload date:
  • Size: 578.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for idfpy-25.2.0.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 45c543ab7d900a7b50b51beb4483a065c968c38c290dcfa6ecd4cfeee59350a3
MD5 2446bfcd820c6a1cebecea280ef15d7a
BLAKE2b-256 04cd2eeeefc86c822772c622d0d96a2f64fe53138289d8088c3d969b259b8a78

See more details on using hashes here.

Provenance

The following attestation bundles were made for idfpy-25.2.0.post2-py3-none-any.whl:

Publisher: publish.yml on ITOTI-Y/idfpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page