|
| 1 | +# Simulation |
| 2 | + |
| 3 | +COMcheck evaluates whether a building design meets energy code requirements |
| 4 | +by running a compliance simulation. The simulation compares the proposed |
| 5 | +building envelope against baseline performance factors and returns a |
| 6 | +**performance rating** that indicates pass/fail status. |
| 7 | + |
| 8 | +## Workflow |
| 9 | + |
| 10 | +A simulation run follows three steps: |
| 11 | + |
| 12 | +1. **Start** the simulation with a project. |
| 13 | +2. **Poll** for completion. |
| 14 | +3. **Retrieve** the results. |
| 15 | + |
| 16 | +```python |
| 17 | +import time |
| 18 | +from comcheck_api import COMcheckClient |
| 19 | + |
| 20 | +client = COMcheckClient(api_key="your-key") |
| 21 | +project = client.get_project("project-id") |
| 22 | + |
| 23 | +# 1. Start |
| 24 | +session_id = client.start_run_simulation(project) |
| 25 | + |
| 26 | +# 2. Poll |
| 27 | +while True: |
| 28 | + status = client.get_simulation_status(session_id) |
| 29 | + if status["status"] == "COMPLETED": |
| 30 | + break |
| 31 | + time.sleep(2) |
| 32 | + |
| 33 | +# 3. Results |
| 34 | +result = client.get_simulation_result(session_id) |
| 35 | +print(f"Performance Rating: {result['performanceRating']}") |
| 36 | +``` |
| 37 | + |
| 38 | +## Running without a saved project |
| 39 | + |
| 40 | +You can simulate a project that only exists locally without saving it to the |
| 41 | +server first. Build a project from the default template, configure it, and |
| 42 | +pass it directly: |
| 43 | + |
| 44 | +```python |
| 45 | +from comcheck_api import COMcheckClient |
| 46 | +from comcheck_api.defaults import get_default_project_template |
| 47 | +from comcheck_api.types.core_types import EnergyCodeOptions |
| 48 | + |
| 49 | +client = COMcheckClient(api_key="your-key") |
| 50 | + |
| 51 | +project = get_default_project_template() |
| 52 | +project.control.code = EnergyCodeOptions.CEZ_90_1_2022 |
| 53 | + |
| 54 | +session_id = client.start_run_simulation(project) |
| 55 | +``` |
| 56 | + |
| 57 | +## Running for an existing project |
| 58 | + |
| 59 | +When you pass a `project_id`, the client saves the project via |
| 60 | +`update_project` before launching the simulation: |
| 61 | + |
| 62 | +```python |
| 63 | +session_id = client.start_run_simulation(project, project_id="your-project-id") |
| 64 | +``` |
| 65 | + |
| 66 | +## Simulation status |
| 67 | + |
| 68 | +`get_simulation_status` returns a dict with: |
| 69 | + |
| 70 | +| Key | Description | |
| 71 | +| --- | --- | |
| 72 | +| `sessionId` | The session identifier | |
| 73 | +| `status` | `"RUNNING"`, `"COMPLETED"`, or `"FAILED"` | |
| 74 | +| `message` | Optional details (present on failure) | |
| 75 | + |
| 76 | +## Simulation results |
| 77 | + |
| 78 | +`get_simulation_result` returns a dict with: |
| 79 | + |
| 80 | +| Key | Description | |
| 81 | +| --- | --- | |
| 82 | +| `sessionId` | The session identifier | |
| 83 | +| `performanceRating` | Overall compliance rating | |
| 84 | +| `energyCreditPerformanceRating` | Rating including energy credits | |
| 85 | +| `proposedBpf` | Proposed building performance factor | |
| 86 | +| `baselineBpf` | Baseline building performance factor | |
0 commit comments