Spaces:
Sleeping
Sleeping
Update app/materials_library.py
Browse files- app/materials_library.py +11 -11
app/materials_library.py
CHANGED
@@ -38,6 +38,10 @@ FENESTRATION_TYPES = [
|
|
38 |
"Door"
|
39 |
]
|
40 |
|
|
|
|
|
|
|
|
|
41 |
class MaterialCategory(Enum):
|
42 |
INSULATION = "Insulation"
|
43 |
STRUCTURAL = "Structural"
|
@@ -72,8 +76,11 @@ class Material:
|
|
72 |
return "High"
|
73 |
|
74 |
def get_u_value(self) -> float:
|
75 |
-
# Calculate U-value: 位 / d (W/m虏路K)
|
76 |
-
|
|
|
|
|
|
|
77 |
|
78 |
class GlazingMaterial:
|
79 |
def __init__(self, name: str, shgc: float, u_value: float, h_o: float, category: str, is_library: bool = True):
|
@@ -505,13 +512,6 @@ def display_materials_tab(material_library: MaterialLibrary):
|
|
505 |
help="Material type classification",
|
506 |
key="material_category_input"
|
507 |
)
|
508 |
-
conductivity = st.number_input(
|
509 |
-
"Thermal Conductivity (W/m路K)",
|
510 |
-
min_value=0.01,
|
511 |
-
value=form_state.get("conductivity", editor_state.get("conductivity", 0.1)),
|
512 |
-
help="Heat flow ease",
|
513 |
-
key="material_conductivity_input"
|
514 |
-
)
|
515 |
density = st.number_input(
|
516 |
"Density (kg/m鲁)",
|
517 |
min_value=1.0,
|
@@ -571,7 +571,6 @@ def display_materials_tab(material_library: MaterialLibrary):
|
|
571 |
st.session_state.material_form_state = {
|
572 |
"name": name,
|
573 |
"category": category,
|
574 |
-
"conductivity": conductivity,
|
575 |
"density": density,
|
576 |
"specific_heat": specific_heat,
|
577 |
"default_thickness": default_thickness,
|
@@ -587,6 +586,8 @@ def display_materials_tab(material_library: MaterialLibrary):
|
|
587 |
st.error(f"Material '{name}' already exists.")
|
588 |
else:
|
589 |
try:
|
|
|
|
|
590 |
new_material = Material(
|
591 |
name=name,
|
592 |
category=MaterialCategory[category.upper().replace("-", "_")],
|
@@ -612,7 +613,6 @@ def display_materials_tab(material_library: MaterialLibrary):
|
|
612 |
st.session_state.material_form_state = {
|
613 |
"name": "",
|
614 |
"category": "Insulation",
|
615 |
-
"conductivity": 0.1,
|
616 |
"density": 1000.0,
|
617 |
"specific_heat": 1000.0,
|
618 |
"default_thickness": 0.1,
|
|
|
38 |
"Door"
|
39 |
]
|
40 |
|
41 |
+
# Surface resistances (EN ISO 6946 or ASHRAE standards)
|
42 |
+
R_SI = 0.12 # Internal surface resistance (m虏路K/W)
|
43 |
+
R_SE = 0.04 # External surface resistance (m虏路K/W)
|
44 |
+
|
45 |
class MaterialCategory(Enum):
|
46 |
INSULATION = "Insulation"
|
47 |
STRUCTURAL = "Structural"
|
|
|
76 |
return "High"
|
77 |
|
78 |
def get_u_value(self) -> float:
|
79 |
+
# Calculate U-value: U = 1 / (R_si + (位 / d) + R_se) (W/m虏路K)
|
80 |
+
if self.default_thickness > 0:
|
81 |
+
r_value = R_SI + (self.conductivity / self.default_thickness) + R_SE
|
82 |
+
return 1.0 / r_value if r_value > 0 else 0.0
|
83 |
+
return 0.0
|
84 |
|
85 |
class GlazingMaterial:
|
86 |
def __init__(self, name: str, shgc: float, u_value: float, h_o: float, category: str, is_library: bool = True):
|
|
|
512 |
help="Material type classification",
|
513 |
key="material_category_input"
|
514 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
515 |
density = st.number_input(
|
516 |
"Density (kg/m鲁)",
|
517 |
min_value=1.0,
|
|
|
571 |
st.session_state.material_form_state = {
|
572 |
"name": name,
|
573 |
"category": category,
|
|
|
574 |
"density": density,
|
575 |
"specific_heat": specific_heat,
|
576 |
"default_thickness": default_thickness,
|
|
|
586 |
st.error(f"Material '{name}' already exists.")
|
587 |
else:
|
588 |
try:
|
589 |
+
# Use default conductivity from library or a fallback value
|
590 |
+
conductivity = form_state.get("conductivity", editor_state.get("conductivity", 0.1))
|
591 |
new_material = Material(
|
592 |
name=name,
|
593 |
category=MaterialCategory[category.upper().replace("-", "_")],
|
|
|
613 |
st.session_state.material_form_state = {
|
614 |
"name": "",
|
615 |
"category": "Insulation",
|
|
|
616 |
"density": 1000.0,
|
617 |
"specific_heat": 1000.0,
|
618 |
"default_thickness": 0.1,
|