Skip to content

Commit 1025c4f

Browse files
author
1jhu1
committed
Merge branch 'roof-insulation-rsmeans' of https://github.com/NatLabRockies/openstudio-ee-gem into replace-windows-EC
2 parents 5e87666 + d3224f6 commit 1025c4f

12 files changed

Lines changed: 2130 additions & 422 deletions
Lines changed: 63 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,73 @@
11

2+
# IncreaseInsulationRValueForRoofs
23

3-
###### (Automatically generated documentation)
4+
This measure upgrades roof insulation to a target R-value, estimates added embodied carbon from EC3 EPD data, and estimates added installed cost using RSMeans (or user-provided custom cost inputs).
45

5-
# Increase R-value of Insulation for Roofs to a Specific Value
6-
7-
## Description
8-
9-
10-
## Modeler Description
11-
12-
13-
## Measure Type
14-
ModelMeasure
15-
16-
## Taxonomy
6+
## What It Does
177

8+
- Identifies roof constructions and computes the insulation delta required to hit the target R-value.
9+
- Applies insulation updates on cloned constructions, leaving the original unchanged.
10+
- Aggregates added insulation quantities and embodied carbon (GWP) from EC3 EPDs.
11+
- Runs RSMeans lookup for retrofit materials and stores full match/search diagnostics.
12+
- Writes standardized outputs into model-level AdditionalProperties buckets.
1813

1914
## Arguments
2015

21-
22-
### Insulation R-value (ft^2*h*R/Btu).
23-
24-
**Name:** r_value,
25-
**Type:** Double,
26-
**Units:** ,
27-
**Required:** true,
28-
**Model Dependent:** false
29-
30-
### Allow both increase and decrease in R-value to reach requested target?
31-
32-
**Name:** allow_reduction,
33-
**Type:** Boolean,
34-
**Units:** ,
35-
**Required:** true,
36-
**Model Dependent:** false
37-
38-
### Increase in Material and Installation Costs for Construction per Area Used ($/ft^2).
39-
40-
**Name:** material_cost_increase_ip,
41-
**Type:** Double,
42-
**Units:** ,
43-
**Required:** true,
44-
**Model Dependent:** false
45-
46-
### One Time Retrofit Cost to Add Insulation to Construction ($/ft^2).
47-
48-
**Name:** one_time_retrofit_cost_ip,
49-
**Type:** Double,
50-
**Units:** ,
51-
**Required:** true,
52-
**Model Dependent:** false
53-
54-
### Year to Incur One Time Retrofit Cost (whole years).
55-
56-
**Name:** years_until_retrofit_cost,
57-
**Type:** Integer,
58-
**Units:** ,
59-
**Required:** true,
60-
**Model Dependent:** false
61-
16+
| Argument | Type | Default | Description |
17+
|---|---|---|---|
18+
| `r_value` | Double | 30.0 | Target R-value (ft²·h·°F/Btu) |
19+
| `analysis_period` | Integer | 30 | Analysis period for embodied carbon (years) |
20+
| `gwp_statistic` | Choice | median | Statistic for EPD GWP values (min/max/mean/median) |
21+
| `api_key` | String || EC3 API token |
22+
| `insulation_material_type` | Choice | Fiberglass Batts | Material for EPD lookup and RSMeans search |
23+
| `insulation_material_lifetime` | Integer | 30 | Fallback lifetime if EPD has none (years) |
24+
| `insulation_thermal_conductivity` | Double | 0.0 | 0 = use typical value for selected material (W/m·K) |
25+
| `insulation_material_density` | Double | 0.0 | 0 = use typical or EPD-derived value (kg/m³) |
26+
| `calculate_costs` | Boolean | true | Enable cost calculation (RSMeans or custom) |
27+
| `use_custom_costs` | Boolean | false | Skip RSMeans; use custom cost inputs instead |
28+
| `use_exact_costline_id` | Boolean | false | Force RSMeans to use the exact `exact_costline_id` |
29+
| `exact_costline_id` | String | "" | Exact RSMeans unit costline ID |
30+
| `custom_cost_per_cf` | Double | 0.0 | Custom insulation cost per cubic foot ($/CF) |
31+
| `labor_cost_multiplier` | Double | 1.0 | Multiplier on custom material cost to derive labor cost |
32+
| `overhead_profit_percent` | Double | 10.0 | Overhead + profit applied on top of RSMeans cost (%) |
33+
34+
## AdditionalProperties Bucket Map
35+
36+
| OpenStudio Object | Variable | Contents |
37+
|---|---|---|
38+
| Building | `basic_input` | Measure name, analysis period, GWP statistic, construction names |
39+
| Site | `reno_detail` | Target R-value, material type, total renovated area |
40+
| Facility | `factors` | Mirrored cost totals, cost source, cost basis metadata, GWP factors |
41+
| SimulationControl | `results` | All cost fields + RSMeans diagnostics JSON payloads |
42+
| SizingParameters | `mtrl_prop` | Material density, conductivity, lifetime, RSMeans extracted hints |
43+
44+
## Cost Source Modes
45+
46+
- `rsmeans_api` — RSMeans closest-match or exact-ID lookup succeeded.
47+
- `custom_input` — custom volume-based cost mode used.
48+
- `none` — costing disabled or unresolved.
49+
50+
Cost basis is persisted as:
51+
- `roof_insulation_cost_factor_basis` (e.g. `cost_per_volume`, `cost_per_area`, `custom_cost_per_volume`)
52+
- `roof_insulation_cost_unit_basis` (e.g. `CF`, `SF`)
53+
54+
## Quick Start
55+
56+
```powershell
57+
cd lib/measures/IncreaseInsulationRValueForRoofs
58+
./setup_environment.ps1
59+
python apply_measure.py
60+
```
61+
62+
Outputs are written to:
63+
- `tests/output/DOE_small_office_roof_insulation_upgraded.osm`
64+
- `tests/output/apply_measure_results.json`
65+
66+
## Documentation
67+
68+
- [docs/Increase_Insulation_Roofs.md](docs/Increase_Insulation_Roofs.md) — full measure guide
69+
- [docs/RSMEANS_SEARCH_STRATEGY.md](docs/RSMEANS_SEARCH_STRATEGY.md) — RSMeans search and scoring details
70+
- [docs/ENVIRONMENT_SETUP.md](docs/ENVIRONMENT_SETUP.md) — environment setup and troubleshooting
6271

6372

6473

lib/measures/IncreaseInsulationRValueForRoofs/apply_measure.py

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,39 @@
1414
import json
1515
import os
1616
import configparser
17-
import platform
1817

1918
# ---------------------------------------------------------------------------
2019
# OpenStudio path setup
2120
# ---------------------------------------------------------------------------
22-
# Try to use installed openstudio package first (via pip/conda)
23-
# Fall back to system installations if needed
21+
def configure_openstudio_python_path():
22+
"""Add OpenStudio Python bindings directory to sys.path when needed."""
23+
env_path = os.getenv("OPENSTUDIO_PYTHON_PATH")
24+
candidates = []
25+
if env_path:
26+
candidates.append(Path(env_path))
27+
28+
candidates.extend([
29+
Path(r"C:\openstudio-3.11.0\Python"),
30+
Path(r"C:\openstudio-3.10.0\Python"),
31+
Path(r"C:\openstudio-3.9.0\Python"),
32+
Path("/Applications/OpenStudio-3.11.0/Python"),
33+
Path("/Applications/OpenStudio-3.10.0/Python"),
34+
Path("/Applications/OpenStudio-3.9.0/Python"),
35+
])
36+
37+
for candidate in candidates:
38+
if candidate.exists() and str(candidate) not in sys.path:
39+
sys.path.insert(0, str(candidate))
40+
os.environ["OPENSTUDIO_PYTHON_PATH"] = str(candidate)
41+
print(f"Using OpenStudio Python path: {candidate}")
42+
return
43+
44+
2445
try:
2546
import openstudio
2647
print("Using OpenStudio from installed package")
2748
except ImportError:
28-
OPENSTUDIO_VERSION = "3.9.0"
29-
WINDOWS_OPENSTUDIO_PATH = rf"C:\openstudio-{OPENSTUDIO_VERSION}\Python"
30-
mac_openstudio_path = f"/Applications/OpenStudio-{OPENSTUDIO_VERSION}/Python"
31-
32-
openstudio_path = None
33-
if platform.system() == "Windows":
34-
if Path(WINDOWS_OPENSTUDIO_PATH).exists():
35-
openstudio_path = WINDOWS_OPENSTUDIO_PATH
36-
sys.path.insert(0, openstudio_path)
37-
print(f"Using OpenStudio from: {openstudio_path}")
38-
else:
39-
if Path(mac_openstudio_path).exists():
40-
openstudio_path = mac_openstudio_path
41-
sys.path.insert(0, openstudio_path)
42-
print(f"Using OpenStudio from: {openstudio_path}")
43-
44-
if openstudio_path is None:
45-
print("Warning: OpenStudio path not found")
49+
configure_openstudio_python_path()
4650

4751
import openstudio
4852
from measure import IncreaseInsulationRValueForRoofs
@@ -210,6 +214,8 @@ def build_cost_response(ap_data):
210214

211215
cost_response = {
212216
"cost_source": props.get("roof_insulation_cost_source"),
217+
"cost_factor_basis": props.get("roof_insulation_cost_factor_basis"),
218+
"cost_unit_basis": props.get("roof_insulation_cost_unit_basis"),
213219
"selection_mode": props.get("roof_insulation_rsmeans_selection_mode"),
214220
"material_cost": {
215221
"value": props.get(
Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,78 @@
1-
# Environment Setup for Increase Insulation R-Value for Roofs
1+
# Environment Setup for IncreaseInsulationRValueForRoofs
22

33
## Overview
44

5-
This measure requires Python 3.8+ and OpenStudio 3.11.0. Use the repository's environment.yml to keep dependencies consistent.
5+
The roof insulation measure depends on:
66

7-
## Prerequisites
7+
- A Python environment where this repository runs.
8+
- OpenStudio Python bindings.
9+
- `python-dotenv` (used by RSMeans helper credential loading).
810

9-
- Conda (Anaconda or Miniconda)
10-
- Git with the openstudio-ee-gem repository cloned
11+
## Fastest Setup (PowerShell)
1112

12-
## Quick Setup
13+
From the measure directory:
1314

14-
### 1. Create the Environment
15+
```powershell
16+
cd lib/measures/IncreaseInsulationRValueForRoofs
17+
./setup_environment.ps1
18+
```
19+
20+
What this script does:
21+
22+
- Detects `OPENSTUDIO_PYTHON_PATH` or common local OpenStudio Python install paths.
23+
- Installs/updates `python-dotenv` in the active Python environment.
24+
- Runs a quick import validation for `openstudio` and `dotenv`.
25+
26+
## Manual Setup
1527

16-
From the repository root:
28+
1. Create and activate environment from repository root:
1729

18-
```bash
30+
```powershell
1931
conda env create -f environment.yml
32+
conda activate openstudio312
2033
```
2134

22-
### 2. Activate the Environment
35+
2. Ensure OpenStudio bindings are reachable:
2336

24-
```bash
25-
conda activate openstudio-3.11
37+
- Preferred: set `OPENSTUDIO_PYTHON_PATH` to your OpenStudio `Python` folder.
38+
- Or ensure `openstudio` is importable directly in your environment.
39+
40+
3. Install required package:
41+
42+
```powershell
43+
python -m pip install python-dotenv
2644
```
2745

28-
### 3. Verify Installation
46+
4. Validate imports:
2947

30-
```bash
31-
python -c "import openstudio; print(openstudio.openStudioVersion())"
48+
```powershell
49+
python -c "import openstudio, dotenv; print(openstudio.openStudioVersion())"
3250
```
3351

3452
## Running the Measure
3553

36-
```bash
54+
```powershell
3755
cd lib/measures/IncreaseInsulationRValueForRoofs
3856
python apply_measure.py
3957
```
4058

4159
## Troubleshooting
4260

43-
### "ModuleNotFoundError: No module named 'openstudio'"
61+
### `ModuleNotFoundError: No module named 'openstudio'`
4462

45-
Ensure the environment is activated and has the openstudio package:
63+
- Set `OPENSTUDIO_PYTHON_PATH` to the OpenStudio `Python` directory.
64+
- Re-run `setup_environment.ps1` in the same shell session.
4665

47-
```bash
48-
conda activate openstudio-3.11
49-
python -c "import openstudio; print(openstudio.openStudioVersion())"
50-
```
66+
### `ModuleNotFoundError: No module named 'dotenv'`
5167

52-
### DLL or Version Errors
68+
- Run `python -m pip install python-dotenv` in the active environment.
5369

54-
Use the conda environment from environment.yml and avoid mixing system Python with OpenStudio packages.
70+
### Mixed Python installations
5571

56-
## Additional Resources
72+
- Confirm interpreter path with:
73+
74+
```powershell
75+
python -c "import sys; print(sys.executable)"
76+
```
5777

58-
- [Conda Environments](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html)
59-
- [Measure Documentation](Increase_Insulation_Roofs.md)
60-
- [RSMeans Search Strategy](RSMEANS_SEARCH_STRATEGY.md)
78+
- Ensure that is the same interpreter you used for package install.

0 commit comments

Comments
 (0)