Spaces:
Sleeping
Sleeping
Update app/components.py
Browse files- app/components.py +32 -12
app/components.py
CHANGED
|
@@ -293,6 +293,15 @@ def display_component_tab(comp_type: str):
|
|
| 293 |
help="Shading coefficient for external or internal shading devices (0.0 to 1.0)."
|
| 294 |
)
|
| 295 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 296 |
# Function Type (Operable/Fixed)
|
| 297 |
function_type_options = ["Operable", "Fixed"]
|
| 298 |
function_type = st.selectbox(
|
|
@@ -363,6 +372,7 @@ def display_component_tab(comp_type: str):
|
|
| 363 |
component_data["parent_component"] = parent_component
|
| 364 |
component_data["function_type"] = function_type
|
| 365 |
component_data["shading_coefficient"] = shading_coefficient
|
|
|
|
| 366 |
# Fix: Handle both GlazingMaterial and dictionary for fenestration_data
|
| 367 |
if fenestration in available_items:
|
| 368 |
fenestration_data = available_items[fenestration]
|
|
@@ -406,7 +416,7 @@ def display_component_tab(comp_type: str):
|
|
| 406 |
def display_wall_window_table(comp_type: str, components: List[Dict[str, Any]]):
|
| 407 |
"""Display a table of walls or windows with appropriate columns."""
|
| 408 |
# Create column headers
|
| 409 |
-
cols = st.columns([2, 1, 1, 1, 1, 1, 1, 1, 1] if comp_type == "walls" else [2, 1, 1, 1, 1, 1, 1, 1])
|
| 410 |
cols[0].write("**Name**")
|
| 411 |
cols[1].write("**U-Value**")
|
| 412 |
cols[2].write("**Area (m²)**")
|
|
@@ -419,12 +429,13 @@ def display_wall_window_table(comp_type: str, components: List[Dict[str, Any]]):
|
|
| 419 |
cols[8].write("**Delete**")
|
| 420 |
else: # windows
|
| 421 |
cols[5].write("**SC**")
|
| 422 |
-
cols[6].write("**
|
| 423 |
-
cols[7].write("**
|
|
|
|
| 424 |
|
| 425 |
# Display each component
|
| 426 |
for idx, comp in enumerate(components):
|
| 427 |
-
cols = st.columns([2, 1, 1, 1, 1, 1, 1, 1, 1] if comp_type == "walls" else [2, 1, 1, 1, 1, 1, 1, 1])
|
| 428 |
cols[0].write(comp["name"])
|
| 429 |
cols[1].write(f"{comp.get('u_value', 0.0):.3f}")
|
| 430 |
cols[2].write(f"{comp['area']:.2f}")
|
|
@@ -433,10 +444,13 @@ def display_wall_window_table(comp_type: str, components: List[Dict[str, Any]]):
|
|
| 433 |
if comp_type == "walls":
|
| 434 |
cols[5].write("Yes" if comp.get("adiabatic", False) else "No")
|
| 435 |
cols[6].write("Yes" if comp.get("ground_contact", False) else "No")
|
|
|
|
|
|
|
|
|
|
| 436 |
|
| 437 |
# Edit button
|
| 438 |
edit_key = f"edit_{comp_type}_{comp['name']}_{idx}"
|
| 439 |
-
edit_col = 7 if comp_type == "walls" else
|
| 440 |
with cols[edit_col].container():
|
| 441 |
if st.button("Edit", key=edit_key):
|
| 442 |
editor_data = {
|
|
@@ -457,6 +471,7 @@ def display_wall_window_table(comp_type: str, components: List[Dict[str, Any]]):
|
|
| 457 |
editor_data["fenestration"] = comp.get("fenestration", "")
|
| 458 |
editor_data["parent_component"] = comp.get("parent_component", "")
|
| 459 |
editor_data["shading_coefficient"] = comp.get("shading_coefficient", 1.0)
|
|
|
|
| 460 |
editor_data["function_type"] = comp.get("function_type", "Fixed")
|
| 461 |
|
| 462 |
st.session_state[f"{comp_type}_editor"] = editor_data
|
|
@@ -465,7 +480,7 @@ def display_wall_window_table(comp_type: str, components: List[Dict[str, Any]]):
|
|
| 465 |
|
| 466 |
# Delete button
|
| 467 |
delete_key = f"delete_{comp_type}_{comp['name']}_{idx}"
|
| 468 |
-
delete_col = 8 if comp_type == "walls" else
|
| 469 |
with cols[delete_col].container():
|
| 470 |
if st.button("Delete", key=delete_key):
|
| 471 |
st.session_state.project_data["components"][comp_type].pop(idx)
|
|
@@ -476,7 +491,7 @@ def display_wall_window_table(comp_type: str, components: List[Dict[str, Any]]):
|
|
| 476 |
def display_roof_skylight_table(comp_type: str, components: List[Dict[str, Any]]):
|
| 477 |
"""Display a table of roofs or skylights with appropriate columns."""
|
| 478 |
# Create column headers
|
| 479 |
-
cols = st.columns([2, 1, 1, 1, 1, 1, 1, 1, 1] if comp_type == "roofs" else [2, 1, 1, 1, 1, 1, 1, 1])
|
| 480 |
cols[0].write("**Name**")
|
| 481 |
cols[1].write("**U-Value**")
|
| 482 |
cols[2].write("**Area (m²)**")
|
|
@@ -489,12 +504,13 @@ def display_roof_skylight_table(comp_type: str, components: List[Dict[str, Any]]
|
|
| 489 |
cols[8].write("**Delete**")
|
| 490 |
else: # skylights
|
| 491 |
cols[5].write("**SC**")
|
| 492 |
-
cols[6].write("**
|
| 493 |
-
cols[7].write("**
|
|
|
|
| 494 |
|
| 495 |
# Display each component
|
| 496 |
for idx, comp in enumerate(components):
|
| 497 |
-
cols = st.columns([2, 1, 1, 1, 1, 1, 1, 1, 1] if comp_type == "roofs" else [2, 1, 1, 1, 1, 1, 1, 1])
|
| 498 |
cols[0].write(comp["name"])
|
| 499 |
cols[1].write(f"{comp.get('u_value', 0.0):.3f}")
|
| 500 |
cols[2].write(f"{comp['area']:.2f}")
|
|
@@ -505,10 +521,11 @@ def display_roof_skylight_table(comp_type: str, components: List[Dict[str, Any]]
|
|
| 505 |
cols[6].write("Yes" if comp.get("ground_contact", False) else "No")
|
| 506 |
else: # skylights
|
| 507 |
cols[5].write(f"{comp.get('shading_coefficient', 1.0):.2f}")
|
|
|
|
| 508 |
|
| 509 |
# Edit button
|
| 510 |
edit_key = f"edit_{comp_type}_{comp['name']}_{idx}"
|
| 511 |
-
edit_col = 7 if comp_type == "roofs" else
|
| 512 |
with cols[edit_col].container():
|
| 513 |
if st.button("Edit", key=edit_key):
|
| 514 |
editor_data = {
|
|
@@ -529,6 +546,7 @@ def display_roof_skylight_table(comp_type: str, components: List[Dict[str, Any]]
|
|
| 529 |
editor_data["fenestration"] = comp.get("fenestration", "")
|
| 530 |
editor_data["parent_component"] = comp.get("parent_component", "")
|
| 531 |
editor_data["shading_coefficient"] = comp.get("shading_coefficient", 1.0)
|
|
|
|
| 532 |
editor_data["function_type"] = comp.get("function_type", "Fixed")
|
| 533 |
|
| 534 |
st.session_state[f"{comp_type}_editor"] = editor_data
|
|
@@ -537,7 +555,7 @@ def display_roof_skylight_table(comp_type: str, components: List[Dict[str, Any]]
|
|
| 537 |
|
| 538 |
# Delete button
|
| 539 |
delete_key = f"delete_{comp_type}_{comp['name']}_{idx}"
|
| 540 |
-
delete_col = 8 if comp_type == "roofs" else
|
| 541 |
with cols[delete_col].container():
|
| 542 |
if st.button("Delete", key=delete_key):
|
| 543 |
st.session_state.project_data["components"][comp_type].pop(idx)
|
|
@@ -699,6 +717,7 @@ def display_components_help():
|
|
| 699 |
* **Surface Tilt**: Angle of the component relative to horizontal (0° = horizontal, 90° = vertical).
|
| 700 |
* **Parent Component**: The wall or roof that contains a window or skylight.
|
| 701 |
* **Shading Coefficient (SC)**: Factor for shading devices on windows/skylights (0.0 to 1.0).
|
|
|
|
| 702 |
* **Adiabatic**: Indicates if a wall, roof, or floor has no heat transfer across it (Yes/No).
|
| 703 |
* **Ground Contact**: Indicates if a wall, roof, or floor is in contact with the ground (Yes/No).
|
| 704 |
|
|
@@ -716,4 +735,5 @@ def display_components_help():
|
|
| 716 |
* Ensure the total area of skylights doesn't exceed the area of their parent roofs.
|
| 717 |
* Set adiabatic to 'Yes' for components with no heat transfer, such as internal partitions.
|
| 718 |
* Set ground contact to 'Yes' for components in direct contact with the ground for accurate heat transfer calculations.
|
|
|
|
| 719 |
""")
|
|
|
|
| 293 |
help="Shading coefficient for external or internal shading devices (0.0 to 1.0)."
|
| 294 |
)
|
| 295 |
|
| 296 |
+
# Shading Type
|
| 297 |
+
shading_type_options = ["No Shading", "Internal Shading", "External Shading"]
|
| 298 |
+
shading_type = st.selectbox(
|
| 299 |
+
"Shading Type",
|
| 300 |
+
shading_type_options,
|
| 301 |
+
index=shading_type_options.index(editor_state.get("shading_type", "No Shading")) if editor_state.get("shading_type") in shading_type_options else 0,
|
| 302 |
+
help="Select the type of shading for this fenestration."
|
| 303 |
+
)
|
| 304 |
+
|
| 305 |
# Function Type (Operable/Fixed)
|
| 306 |
function_type_options = ["Operable", "Fixed"]
|
| 307 |
function_type = st.selectbox(
|
|
|
|
| 372 |
component_data["parent_component"] = parent_component
|
| 373 |
component_data["function_type"] = function_type
|
| 374 |
component_data["shading_coefficient"] = shading_coefficient
|
| 375 |
+
component_data["shading_type"] = shading_type
|
| 376 |
# Fix: Handle both GlazingMaterial and dictionary for fenestration_data
|
| 377 |
if fenestration in available_items:
|
| 378 |
fenestration_data = available_items[fenestration]
|
|
|
|
| 416 |
def display_wall_window_table(comp_type: str, components: List[Dict[str, Any]]):
|
| 417 |
"""Display a table of walls or windows with appropriate columns."""
|
| 418 |
# Create column headers
|
| 419 |
+
cols = st.columns([2, 1, 1, 1, 1, 1, 1, 1, 1, 1] if comp_type == "walls" else [2, 1, 1, 1, 1, 1, 1, 1, 1])
|
| 420 |
cols[0].write("**Name**")
|
| 421 |
cols[1].write("**U-Value**")
|
| 422 |
cols[2].write("**Area (m²)**")
|
|
|
|
| 429 |
cols[8].write("**Delete**")
|
| 430 |
else: # windows
|
| 431 |
cols[5].write("**SC**")
|
| 432 |
+
cols[6].write("**Shading Type**")
|
| 433 |
+
cols[7].write("**Edit**")
|
| 434 |
+
cols[8].write("**Delete**")
|
| 435 |
|
| 436 |
# Display each component
|
| 437 |
for idx, comp in enumerate(components):
|
| 438 |
+
cols = st.columns([2, 1, 1, 1, 1, 1, 1, 1, 1] if comp_type == "walls" else [2, 1, 1, 1, 1, 1, 1, 1, 1])
|
| 439 |
cols[0].write(comp["name"])
|
| 440 |
cols[1].write(f"{comp.get('u_value', 0.0):.3f}")
|
| 441 |
cols[2].write(f"{comp['area']:.2f}")
|
|
|
|
| 444 |
if comp_type == "walls":
|
| 445 |
cols[5].write("Yes" if comp.get("adiabatic", False) else "No")
|
| 446 |
cols[6].write("Yes" if comp.get("ground_contact", False) else "No")
|
| 447 |
+
else: # windows
|
| 448 |
+
cols[5].write(f"{comp.get('shading_coefficient', 1.0):.2f}")
|
| 449 |
+
cols[6].write(comp.get("shading_type", "No Shading"))
|
| 450 |
|
| 451 |
# Edit button
|
| 452 |
edit_key = f"edit_{comp_type}_{comp['name']}_{idx}"
|
| 453 |
+
edit_col = 7 if comp_type == "walls" else 7
|
| 454 |
with cols[edit_col].container():
|
| 455 |
if st.button("Edit", key=edit_key):
|
| 456 |
editor_data = {
|
|
|
|
| 471 |
editor_data["fenestration"] = comp.get("fenestration", "")
|
| 472 |
editor_data["parent_component"] = comp.get("parent_component", "")
|
| 473 |
editor_data["shading_coefficient"] = comp.get("shading_coefficient", 1.0)
|
| 474 |
+
editor_data["shading_type"] = comp.get("shading_type", "No Shading")
|
| 475 |
editor_data["function_type"] = comp.get("function_type", "Fixed")
|
| 476 |
|
| 477 |
st.session_state[f"{comp_type}_editor"] = editor_data
|
|
|
|
| 480 |
|
| 481 |
# Delete button
|
| 482 |
delete_key = f"delete_{comp_type}_{comp['name']}_{idx}"
|
| 483 |
+
delete_col = 8 if comp_type == "walls" else 8
|
| 484 |
with cols[delete_col].container():
|
| 485 |
if st.button("Delete", key=delete_key):
|
| 486 |
st.session_state.project_data["components"][comp_type].pop(idx)
|
|
|
|
| 491 |
def display_roof_skylight_table(comp_type: str, components: List[Dict[str, Any]]):
|
| 492 |
"""Display a table of roofs or skylights with appropriate columns."""
|
| 493 |
# Create column headers
|
| 494 |
+
cols = st.columns([2, 1, 1, 1, 1, 1, 1, 1, 1, 1] if comp_type == "roofs" else [2, 1, 1, 1, 1, 1, 1, 1, 1])
|
| 495 |
cols[0].write("**Name**")
|
| 496 |
cols[1].write("**U-Value**")
|
| 497 |
cols[2].write("**Area (m²)**")
|
|
|
|
| 504 |
cols[8].write("**Delete**")
|
| 505 |
else: # skylights
|
| 506 |
cols[5].write("**SC**")
|
| 507 |
+
cols[6].write("**Shading Type**")
|
| 508 |
+
cols[7].write("**Edit**")
|
| 509 |
+
cols[8].write("**Delete**")
|
| 510 |
|
| 511 |
# Display each component
|
| 512 |
for idx, comp in enumerate(components):
|
| 513 |
+
cols = st.columns([2, 1, 1, 1, 1, 1, 1, 1, 1] if comp_type == "roofs" else [2, 1, 1, 1, 1, 1, 1, 1, 1])
|
| 514 |
cols[0].write(comp["name"])
|
| 515 |
cols[1].write(f"{comp.get('u_value', 0.0):.3f}")
|
| 516 |
cols[2].write(f"{comp['area']:.2f}")
|
|
|
|
| 521 |
cols[6].write("Yes" if comp.get("ground_contact", False) else "No")
|
| 522 |
else: # skylights
|
| 523 |
cols[5].write(f"{comp.get('shading_coefficient', 1.0):.2f}")
|
| 524 |
+
cols[6].write(comp.get("shading_type", "No Shading"))
|
| 525 |
|
| 526 |
# Edit button
|
| 527 |
edit_key = f"edit_{comp_type}_{comp['name']}_{idx}"
|
| 528 |
+
edit_col = 7 if comp_type == "roofs" else 7
|
| 529 |
with cols[edit_col].container():
|
| 530 |
if st.button("Edit", key=edit_key):
|
| 531 |
editor_data = {
|
|
|
|
| 546 |
editor_data["fenestration"] = comp.get("fenestration", "")
|
| 547 |
editor_data["parent_component"] = comp.get("parent_component", "")
|
| 548 |
editor_data["shading_coefficient"] = comp.get("shading_coefficient", 1.0)
|
| 549 |
+
editor_data["shading_type"] = comp.get("shading_type", "No Shading")
|
| 550 |
editor_data["function_type"] = comp.get("function_type", "Fixed")
|
| 551 |
|
| 552 |
st.session_state[f"{comp_type}_editor"] = editor_data
|
|
|
|
| 555 |
|
| 556 |
# Delete button
|
| 557 |
delete_key = f"delete_{comp_type}_{comp['name']}_{idx}"
|
| 558 |
+
delete_col = 8 if comp_type == "roofs" else 8
|
| 559 |
with cols[delete_col].container():
|
| 560 |
if st.button("Delete", key=delete_key):
|
| 561 |
st.session_state.project_data["components"][comp_type].pop(idx)
|
|
|
|
| 717 |
* **Surface Tilt**: Angle of the component relative to horizontal (0° = horizontal, 90° = vertical).
|
| 718 |
* **Parent Component**: The wall or roof that contains a window or skylight.
|
| 719 |
* **Shading Coefficient (SC)**: Factor for shading devices on windows/skylights (0.0 to 1.0).
|
| 720 |
+
* **Shading Type**: Type of shading for windows/skylights (No Shading, Internal Shading, External Shading).
|
| 721 |
* **Adiabatic**: Indicates if a wall, roof, or floor has no heat transfer across it (Yes/No).
|
| 722 |
* **Ground Contact**: Indicates if a wall, roof, or floor is in contact with the ground (Yes/No).
|
| 723 |
|
|
|
|
| 735 |
* Ensure the total area of skylights doesn't exceed the area of their parent roofs.
|
| 736 |
* Set adiabatic to 'Yes' for components with no heat transfer, such as internal partitions.
|
| 737 |
* Set ground contact to 'Yes' for components in direct contact with the ground for accurate heat transfer calculations.
|
| 738 |
+
* Specify shading type for windows and skylights to account for different shading effects.
|
| 739 |
""")
|