Upload material_library.py
Browse files- data/material_library.py +461 -0
data/material_library.py
ADDED
|
@@ -0,0 +1,461 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Material Library for HVAC Load Calculator
|
| 3 |
+
Updated 2025-05-17: Added all materials and constructions from ASHRAE_2005_HOF_Materials.idf.
|
| 4 |
+
Updated 2025-05-16: Removed mass_per_meter, added thermal_mass method, updated CSV handling.
|
| 5 |
+
Updated 2025-05-16: Fixed U-value calculation in Material.get_u_value.
|
| 6 |
+
Updated 2025-05-16: Updated MaterialCategory to Finishing Materials, Structural Materials, Sub-Structural Materials, Insulation.
|
| 7 |
+
Updated 2025-05-16: Fixed Construction.get_thermal_mass to use avg_specific_heat.
|
| 8 |
+
|
| 9 |
+
Developed by: Dr Majed Abuseif, Deakin University
|
| 10 |
+
漏 2025
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
from typing import Dict, List, Optional, Tuple
|
| 14 |
+
from enum import Enum
|
| 15 |
+
import pandas as pd
|
| 16 |
+
|
| 17 |
+
class MaterialCategory(Enum):
|
| 18 |
+
FINISHING_MATERIALS = "Finishing Materials"
|
| 19 |
+
STRUCTURAL_MATERIALS = "Structural Materials"
|
| 20 |
+
SUB_STRUCTURAL_MATERIALS = "Sub-Structural Materials"
|
| 21 |
+
INSULATION = "Insulation"
|
| 22 |
+
|
| 23 |
+
class ThermalMass(Enum):
|
| 24 |
+
HIGH = "High"
|
| 25 |
+
MEDIUM = "Medium"
|
| 26 |
+
LOW = "Low"
|
| 27 |
+
NO_MASS = "No Mass"
|
| 28 |
+
|
| 29 |
+
class Material:
|
| 30 |
+
def __init__(self, name: str, category: MaterialCategory, conductivity: float, density: float,
|
| 31 |
+
specific_heat: float, default_thickness: float, embodied_carbon: float,
|
| 32 |
+
solar_absorption: float, price: float, is_library: bool = True):
|
| 33 |
+
self.name = name
|
| 34 |
+
self.category = category
|
| 35 |
+
self.conductivity = max(0.01, conductivity) # W/m路K
|
| 36 |
+
self.density = max(1.0, density) # kg/m鲁
|
| 37 |
+
self.specific_heat = max(100.0, specific_heat) # J/kg路K
|
| 38 |
+
self.default_thickness = max(0.01, default_thickness) # m
|
| 39 |
+
self.embodied_carbon = max(0.0, embodied_carbon) # kgCO鈧俥/kg
|
| 40 |
+
self.solar_absorption = min(max(0.0, solar_absorption), 1.0)
|
| 41 |
+
self.price = max(0.0, price) # USD/m虏
|
| 42 |
+
self.is_library = is_library
|
| 43 |
+
|
| 44 |
+
def get_thermal_mass(self) -> ThermalMass:
|
| 45 |
+
if self.density < 100.0 or self.specific_heat < 800.0:
|
| 46 |
+
return ThermalMass.NO_MASS
|
| 47 |
+
elif self.density > 2000.0 and self.specific_heat > 800.0:
|
| 48 |
+
return ThermalMass.HIGH
|
| 49 |
+
elif 1000.0 <= self.density <= 2000.0 and 800.0 <= self.specific_heat <= 1200.0:
|
| 50 |
+
return ThermalMass.MEDIUM
|
| 51 |
+
else:
|
| 52 |
+
return ThermalMass.LOW
|
| 53 |
+
|
| 54 |
+
def get_u_value(self) -> float:
|
| 55 |
+
return self.conductivity / self.default_thickness if self.default_thickness > 0 else 0.1
|
| 56 |
+
|
| 57 |
+
class Construction:
|
| 58 |
+
def __init__(self, name: str, component_type: str, layers: List[Dict], is_library: bool = True):
|
| 59 |
+
self.name = name
|
| 60 |
+
self.component_type = component_type
|
| 61 |
+
self.layers = layers or []
|
| 62 |
+
self.is_library = is_library
|
| 63 |
+
self.u_value = self.calculate_u_value()
|
| 64 |
+
self.total_thickness = sum(layer["thickness"] for layer in self.layers)
|
| 65 |
+
self.embodied_carbon = sum(layer["material"].embodied_carbon * layer["material"].density * layer["thickness"]
|
| 66 |
+
for layer in self.layers)
|
| 67 |
+
self.solar_absorption = max(layer["material"].solar_absorption for layer in self.layers) if self.layers else 0.6
|
| 68 |
+
self.price = sum(layer["material"].price * layer["thickness"] / layer["material"].default_thickness
|
| 69 |
+
for layer in self.layers)
|
| 70 |
+
|
| 71 |
+
def calculate_u_value(self) -> float:
|
| 72 |
+
if not self.layers:
|
| 73 |
+
return 0.1
|
| 74 |
+
r_total = sum(layer["thickness"] / layer["material"].conductivity for layer in self.layers)
|
| 75 |
+
return 1 / r_total if r_total > 0 else 0.1
|
| 76 |
+
|
| 77 |
+
def get_thermal_mass(self) -> ThermalMass:
|
| 78 |
+
if not self.layers:
|
| 79 |
+
return ThermalMass.NO_MASS
|
| 80 |
+
total_thickness = self.total_thickness
|
| 81 |
+
if total_thickness == 0:
|
| 82 |
+
return ThermalMass.NO_MASS
|
| 83 |
+
avg_density = sum(layer["material"].density * layer["thickness"] for layer in self.layers) / total_thickness
|
| 84 |
+
avg_specific_heat = sum(layer["material"].specific_heat * layer["thickness"] for layer in self.layers) / total_thickness
|
| 85 |
+
if avg_density < 100.0 or avg_specific_heat < 800.0:
|
| 86 |
+
return ThermalMass.NO_MASS
|
| 87 |
+
elif avg_density > 2000.0 and avg_specific_heat > 800.0:
|
| 88 |
+
return ThermalMass.HIGH
|
| 89 |
+
elif 1000.0 <= avg_density <= 2000.0 and 800.0 <= avg_specific_heat <= 1200.0:
|
| 90 |
+
return ThermalMass.MEDIUM
|
| 91 |
+
else:
|
| 92 |
+
return ThermalMass.LOW
|
| 93 |
+
|
| 94 |
+
class MaterialLibrary:
|
| 95 |
+
def __init__(self):
|
| 96 |
+
self.library_materials = self.initialize_materials()
|
| 97 |
+
self.library_constructions = self.initialize_constructions()
|
| 98 |
+
|
| 99 |
+
def initialize_materials(self) -> Dict[str, Material]:
|
| 100 |
+
materials = [
|
| 101 |
+
# Original materials
|
| 102 |
+
Material("Fiberglass Insulation", MaterialCategory.INSULATION, 0.04, 12.0, 840.0, 0.1, 0.5, 0.6, 5.0),
|
| 103 |
+
Material("Concrete", MaterialCategory.STRUCTURAL_MATERIALS, 1.4, 2400.0, 900.0, 0.2, 1.5, 0.65, 20.0),
|
| 104 |
+
Material("Steel", MaterialCategory.SUB_STRUCTURAL_MATERIALS, 50.0, 7800.0, 500.0, 0.003, 2.0, 0.7, 100.0),
|
| 105 |
+
Material("Oak Wood", MaterialCategory.SUB_STRUCTURAL_MATERIALS, 0.15, 700.0, 2400.0, 0.05, 0.7, 0.5, 30.0),
|
| 106 |
+
Material("Float Glass", MaterialCategory.INSULATION, 0.96, 2500.0, 840.0, 0.006, 1.0, 0.8, 50.0),
|
| 107 |
+
Material("Clay Brick", MaterialCategory.STRUCTURAL_MATERIALS, 0.72, 1900.0, 900.0, 0.115, 1.2, 0.7, 15.0),
|
| 108 |
+
Material("Gypsum Plaster", MaterialCategory.FINISHING_MATERIALS, 0.22, 1200.0, 1000.0, 0.013, 0.6, 0.4, 10.0),
|
| 109 |
+
Material("Asphalt shingle", MaterialCategory.FINISHING_MATERIALS, 0.16, 1100.0, 1000.0, 0.003, 0.8, 0.9, 8.0),
|
| 110 |
+
# ASHRAE 2005 HOF Materials
|
| 111 |
+
# Material entries
|
| 112 |
+
Material("F06 EIFS finish", MaterialCategory.FINISHING_MATERIALS, 0.72, 1856.0, 840.0, 0.0095, 0.3, 0.5, 12.0),
|
| 113 |
+
Material("F07 25mm stucco", MaterialCategory.FINISHING_MATERIALS, 0.72, 1856.0, 840.0, 0.0254, 0.3, 0.6, 15.0),
|
| 114 |
+
Material("F08 Metal surface", MaterialCategory.SUB_STRUCTURAL_MATERIALS, 45.28, 7824.0, 500.0, 0.0008, 2.0, 0.7, 80.0),
|
| 115 |
+
Material("F09 25mm cement plaster", MaterialCategory.FINISHING_MATERIALS, 0.72, 1856.0, 840.0, 0.0254, 0.3, 0.6, 15.0),
|
| 116 |
+
Material("F10 13mm gypsum board", MaterialCategory.FINISHING_MATERIALS, 0.16, 800.0, 1090.0, 0.0127, 0.2, 0.4, 10.0),
|
| 117 |
+
Material("F11 16mm gypsum board", MaterialCategory.FINISHING_MATERIALS, 0.16, 800.0, 1090.0, 0.0159, 0.2, 0.4, 11.0),
|
| 118 |
+
Material("F12 19mm gypsum board", MaterialCategory.FINISHING_MATERIALS, 0.16, 800.0, 1090.0, 0.0191, 0.2, 0.4, 12.0),
|
| 119 |
+
Material("F13 13mm cement plaster", MaterialCategory.FINISHING_MATERIALS, 0.72, 1856.0, 840.0, 0.0127, 0.3, 0.6, 13.0),
|
| 120 |
+
Material("F14 13mm lime plaster", MaterialCategory.FINISHING_MATERIALS, 0.72, 1600.0, 840.0, 0.0127, 0.3, 0.5, 13.0),
|
| 121 |
+
Material("F15 22mm cement plaster", MaterialCategory.FINISHING_MATERIALS, 0.72, 1856.0, 840.0, 0.0222, 0.3, 0.6, 14.0),
|
| 122 |
+
Material("F16 Acoustic tile", MaterialCategory.FINISHING_MATERIALS, 0.06, 368.0, 590.0, 0.0191, 0.2, 0.4, 12.0),
|
| 123 |
+
Material("F17 13mm slag", MaterialCategory.FINISHING_MATERIALS, 0.16, 960.0, 1090.0, 0.0127, 0.2, 0.5, 10.0),
|
| 124 |
+
Material("F18 25mm slag", MaterialCategory.FINISHING_MATERIALS, 0.16, 960.0, 1090.0, 0.0254, 0.2, 0.5, 11.0),
|
| 125 |
+
Material("G01 13mm gypsum board", MaterialCategory.FINISHING_MATERIALS, 0.16, 800.0, 1090.0, 0.0127, 0.2, 0.4, 10.0),
|
| 126 |
+
Material("G01a 19mm gypsum board", MaterialCategory.FINISHING_MATERIALS, 0.16, 800.0, 1090.0, 0.0191, 0.2, 0.4, 12.0),
|
| 127 |
+
Material("G02 25mm cement plaster", MaterialCategory.FINISHING_MATERIALS, 0.72, 1856.0, 840.0, 0.0254, 0.3, 0.6, 15.0),
|
| 128 |
+
Material("G03 13mm lime plaster", MaterialCategory.FINISHING_MATERIALS, 0.72, 1600.0, 840.0, 0.0127, 0.3, 0.5, 13.0),
|
| 129 |
+
Material("G04 13mm cement plaster", MaterialCategory.FINISHING_MATERIALS, 0.72, 1856.0, 840.0, 0.0127, 0.3, 0.6, 13.0),
|
| 130 |
+
Material("G05 25mm wood", MaterialCategory.SUB_STRUCTURAL_MATERIALS, 0.15, 608.0, 1630.0, 0.0254, 0.5, 0.5, 30.0),
|
| 131 |
+
Material("G06 19mm wood", MaterialCategory.SUB_STRUCTURAL_MATERIALS, 0.15, 608.0, 1630.0, 0.0191, 0.5, 0.5, 28.0),
|
| 132 |
+
Material("I01 25mm insulation board", MaterialCategory.INSULATION, 0.03, 43.0, 1210.0, 0.0254, 1.0, 0.5, 7.0),
|
| 133 |
+
Material("I02 50mm insulation board", MaterialCategory.INSULATION, 0.03, 43.0, 1210.0, 0.0508, 1.0, 0.5, 8.0),
|
| 134 |
+
Material("I03 75mm insulation board", MaterialCategory.INSULATION, 0.03, 43.0, 1210.0, 0.0762, 1.0, 0.5, 9.0),
|
| 135 |
+
Material("M01 100mm brick", MaterialCategory.STRUCTURAL_MATERIALS, 0.89, 1920.0, 790.0, 0.1016, 0.3, 0.7, 20.0),
|
| 136 |
+
Material("M02 100mm face brick", MaterialCategory.STRUCTURAL_MATERIALS, 1.33, 2000.0, 790.0, 0.1016, 0.3, 0.7, 22.0),
|
| 137 |
+
Material("M03 150mm brick", MaterialCategory.STRUCTURAL_MATERIALS, 0.89, 1920.0, 790.0, 0.1524, 0.3, 0.7, 25.0),
|
| 138 |
+
Material("M04 200mm concrete block", MaterialCategory.STRUCTURAL_MATERIALS, 0.51, 800.0, 920.0, 0.2032, 0.15, 0.65, 20.0),
|
| 139 |
+
Material("M05 200mm concrete block", MaterialCategory.STRUCTURAL_MATERIALS, 1.11, 1280.0, 920.0, 0.2032, 0.15, 0.65, 22.0),
|
| 140 |
+
Material("M06 150mm concrete block", MaterialCategory.STRUCTURAL_MATERIALS, 0.51, 800.0, 920.0, 0.1524, 0.15, 0.65, 18.0),
|
| 141 |
+
Material("M07 100mm concrete block", MaterialCategory.STRUCTURAL_MATERIALS, 0.51, 800.0, 920.0, 0.1016, 0.15, 0.65, 15.0),
|
| 142 |
+
Material("M08 150mm concrete block", MaterialCategory.STRUCTURAL_MATERIALS, 1.11, 1280.0, 920.0, 0.1524, 0.15, 0.65, 20.0),
|
| 143 |
+
Material("M09 100mm concrete block", MaterialCategory.STRUCTURAL_MATERIALS, 1.11, 1280.0, 920.0, 0.1016, 0.15, 0.65, 15.0),
|
| 144 |
+
Material("M10 100mm lightweight concrete", MaterialCategory.STRUCTURAL_MATERIALS, 0.53, 1280.0, 840.0, 0.1016, 0.15, 0.65, 25.0),
|
| 145 |
+
Material("M11 100mm lightweight concrete", MaterialCategory.STRUCTURAL_MATERIALS, 0.53, 1280.0, 840.0, 0.1016, 0.15, 0.65, 25.0),
|
| 146 |
+
Material("M12 150mm lightweight concrete", MaterialCategory.STRUCTURAL_MATERIALS, 0.53, 1280.0, 840.0, 0.1524, 0.15, 0.65, 28.0),
|
| 147 |
+
Material("M13 200mm lightweight concrete", MaterialCategory.STRUCTURAL_MATERIALS, 0.53, 1280.0, 840.0, 0.2032, 0.15, 0.65, 30.0),
|
| 148 |
+
Material("M14 100mm heavyweight concrete", MaterialCategory.STRUCTURAL_MATERIALS, 1.95, 2240.0, 900.0, 0.1016, 0.15, 0.65, 25.0),
|
| 149 |
+
Material("M14a 100mm heavyweight concrete", MaterialCategory.STRUCTURAL_MATERIALS, 1.95, 2240.0, 900.0, 0.1016, 0.15, 0.65, 25.0),
|
| 150 |
+
Material("M15 200mm heavyweight concrete", MaterialCategory.STRUCTURAL_MATERIALS, 1.95, 2240.0, 900.0, 0.2032, 0.15, 0.65, 30.0),
|
| 151 |
+
Material("M16 300mm heavyweight concrete", MaterialCategory.STRUCTURAL_MATERIALS, 1.95, 2240.0, 900.0, 0.3048, 0.15, 0.65, 35.0),
|
| 152 |
+
Material("M17 100mm stone", MaterialCategory.STRUCTURAL_MATERIALS, 2.10, 2240.0, 880.0, 0.1016, 0.2, 0.7, 30.0),
|
| 153 |
+
Material("M18 150mm stone", MaterialCategory.STRUCTURAL_MATERIALS, 2.10, 2240.0, 880.0, 0.1524, 0.2, 0.7, 35.0),
|
| 154 |
+
Material("M19 100mm limestone", MaterialCategory.STRUCTURAL_MATERIALS, 1.80, 2320.0, 880.0, 0.1016, 0.2, 0.6, 28.0),
|
| 155 |
+
Material("M20 150mm limestone", MaterialCategory.STRUCTURAL_MATERIALS, 1.80, 2320.0, 880.0, 0.1524, 0.2, 0.6, 32.0),
|
| 156 |
+
Material("M21 200mm limestone", MaterialCategory.STRUCTURAL_MATERIALS, 1.80, 2320.0, 880.0, 0.2032, 0.2, 0.6, 35.0),
|
| 157 |
+
Material("M22 100mm granite", MaterialCategory.STRUCTURAL_MATERIALS, 2.80, 2640.0, 880.0, 0.1016, 0.2, 0.7, 40.0),
|
| 158 |
+
Material("M23 150mm granite", MaterialCategory.STRUCTURAL_MATERIALS, 2.80, 2640.0, 880.0, 0.1524, 0.2, 0.7, 45.0),
|
| 159 |
+
Material("M24 200mm granite", MaterialCategory.STRUCTURAL_MATERIALS, 2.80, 2640.0, 880.0, 0.2032, 0.2, 0.7, 50.0),
|
| 160 |
+
Material("M25 100mm marble", MaterialCategory.STRUCTURAL_MATERIALS, 2.50, 2720.0, 880.0, 0.1016, 0.2, 0.6, 45.0),
|
| 161 |
+
Material("M26 150mm marble", MaterialCategory.STRUCTURAL_MATERIALS, 2.50, 2720.0, 880.0, 0.1524, 0.2, 0.6, 50.0),
|
| 162 |
+
Material("M27 200mm marble", MaterialCategory.STRUCTURAL_MATERIALS, 2.50, 2720.0, 880.0, 0.2032, 0.2, 0.6, 55.0),
|
| 163 |
+
# Material:AirGap entries
|
| 164 |
+
Material("F04 Wall air space resistance", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 2.0), # R=0.15 m虏路K/W
|
| 165 |
+
Material("F05 Ceiling air space resistance", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 2.0), # R=0.18 m虏路K/W
|
| 166 |
+
# Material:NoMass entries
|
| 167 |
+
Material("R01 Roof membrane", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.9, 5.0), # R=0.17 m虏路K/W
|
| 168 |
+
Material("R02 Built-up roofing", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.9, 6.0), # R=0.06 m虏路K/W
|
| 169 |
+
Material("R03 Asphalt roofing", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.9, 7.0), # R=0.02 m虏路K/W
|
| 170 |
+
Material("R04 Felt and membrane", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.7, 5.0), # R=0.03 m虏路K/W
|
| 171 |
+
Material("R05 Bituminous covering", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.9, 6.0), # R=0.01 m虏路K/W
|
| 172 |
+
Material("R06 Slate roofing", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.8, 8.0), # R=0.01 m虏路K/W
|
| 173 |
+
Material("R07 Tile roofing", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.7, 7.0), # R=0.03 m虏路K/W
|
| 174 |
+
Material("R08 Wood shingle", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.6, 6.0), # R=0.15 m虏路K/W
|
| 175 |
+
Material("R09 Vaporpermeable felt", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 4.0), # R=0.01 m虏路K/W
|
| 176 |
+
Material("R10 Vaporproof membrane", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 4.0), # R=0.01 m虏路K/W
|
| 177 |
+
Material("R11 Carpet and fibrous pad", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.6, 5.0), # R=0.37 m虏路K/W
|
| 178 |
+
Material("R12 Carpet and rubber pad", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.6, 5.0), # R=0.14 m虏路K/W
|
| 179 |
+
Material("R13 Linoleum", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.6, 5.0), # R=0.02 m虏路K/W
|
| 180 |
+
Material("R14 Cork tile", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 6.0), # R=0.06 m虏路K/W
|
| 181 |
+
Material("R15 Vinyl tile", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.6, 5.0), # R=0.01 m虏路K/W
|
| 182 |
+
Material("R16 Terrazzo", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.6, 8.0), # R=0.01 m虏路K/W
|
| 183 |
+
Material("R17 Rubber flooring", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.6, 6.0), # R=0.02 m虏路K/W
|
| 184 |
+
Material("R18 Concrete finish", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.65, 5.0), # R=0.01 m虏路K/W
|
| 185 |
+
Material("R19 Acoustical tile 19mm", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.4, 10.0), # R=0.33 m虏路K/W
|
| 186 |
+
Material("R20 Acoustical tile 22mm", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.4, 11.0), # R=0.39 m虏路K/W
|
| 187 |
+
Material("R21 Acoustical tile 25mm", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.4, 12.0), # R=0.45 m虏路K/W
|
| 188 |
+
Material("R22 Plasterboard 13mm", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.4, 10.0), # R=0.08 m虏路K/W
|
| 189 |
+
Material("R23 Plasterboard 16mm", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.4, 11.0), # R=0.10 m虏路K/W
|
| 190 |
+
Material("R24 Fiberboard 13mm", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 8.0), # R=0.28 m虏路K/W
|
| 191 |
+
Material("R25 Plywood 6mm", MaterialCategory.SUB_STRUCTURAL_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 10.0), # R=0.08 m虏路K/W
|
| 192 |
+
Material("R26 Plywood 10mm", MaterialCategory.SUB_STRUCTURAL_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 12.0), # R=0.13 m虏路K/W
|
| 193 |
+
Material("R27 Plywood 13mm", MaterialCategory.SUB_STRUCTURAL_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 15.0), # R=0.17 m虏路K/W
|
| 194 |
+
Material("R28 Fiberboard sheathing 13mm", MaterialCategory.SUB_STRUCTURAL_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 8.0), # R=0.23 m虏路K/W
|
| 195 |
+
Material("R29 Fiberboard sheathing 25mm", MaterialCategory.SUB_STRUCTURAL_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 10.0), # R=0.46 m虏路K/W
|
| 196 |
+
Material("R30 Hardboard siding 10mm", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 10.0), # R=0.12 m虏路K/W
|
| 197 |
+
Material("R31 Particle board 13mm", MaterialCategory.SUB_STRUCTURAL_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 12.0), # R=0.17 m虏路K/W
|
| 198 |
+
Material("R32 Particle board underlayment", MaterialCategory.SUB_STRUCTURAL_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 10.0), # R=0.14 m虏路K/W
|
| 199 |
+
Material("R33 Wood subfloor 19mm", MaterialCategory.SUB_STRUCTURAL_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 15.0), # R=0.25 m虏路K/W
|
| 200 |
+
Material("R34 Wood siding 10mm", MaterialCategory.FINISHING_MATERIALS, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 10.0), # R=0.15 m虏路K/W
|
| 201 |
+
Material("R35 Batt insulation 25mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 5.0), # R=0.44 m虏路K/W
|
| 202 |
+
Material("R36 Batt insulation 38mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 6.0), # R=0.67 m虏路K/W
|
| 203 |
+
Material("R37 Batt insulation 50mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 7.0), # R=0.88 m虏路K/W
|
| 204 |
+
Material("R38 Batt insulation 65mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 8.0), # R=1.14 m虏路K/W
|
| 205 |
+
Material("R39 Batt insulation 75mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 9.0), # R=1.32 m虏路K/W
|
| 206 |
+
Material("R40 Batt insulation 90mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 10.0), # R=1.58 m虏路K/W
|
| 207 |
+
Material("R41 Batt insulation 100mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 11.0), # R=1.76 m虏路K/W
|
| 208 |
+
Material("R42 Batt insulation 125mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 12.0), # R=2.20 m虏路K/W
|
| 209 |
+
Material("R43 Batt insulation 140mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 13.0), # R=2.46 m虏路K/W
|
| 210 |
+
Material("R44 Batt insulation 150mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 14.0), # R=2.64 m虏路K/W
|
| 211 |
+
Material("R45 Batt insulation 165mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 15.0), # R=2.90 m虏路K/W
|
| 212 |
+
Material("R46 Batt insulation 175mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 16.0), # R=3.08 m虏路K/W
|
| 213 |
+
Material("R47 Batt insulation 190mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 17.0), # R=3.34 m虏路K/W
|
| 214 |
+
Material("R48 Batt insulation 200mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 18.0), # R=3.52 m虏路K/W
|
| 215 |
+
Material("R49 Blown insulation 25mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 5.0), # R=0.44 m虏路K/W
|
| 216 |
+
Material("R50 Blown insulation 50mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 6.0), # R=0.88 m虏路K/W
|
| 217 |
+
Material("R51 Blown insulation 75mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 7.0), # R=1.32 m虏路K/W
|
| 218 |
+
Material("R52 Blown insulation 100mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 8.0), # R=1.76 m虏路K/W
|
| 219 |
+
Material("R53 Blown insulation 125mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 9.0), # R=2.20 m虏路K/W
|
| 220 |
+
Material("R54 Blown insulation 150mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 10.0), # R=2.64 m虏路K/W
|
| 221 |
+
Material("R55 Blown insulation 175mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 11.0), # R=3.08 m虏路K/W
|
| 222 |
+
Material("R56 Blown insulation 200mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 12.0), # R=3.52 m虏路K/W
|
| 223 |
+
Material("R57 Board insulation 25mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 7.0), # R=0.88 m虏路K/W
|
| 224 |
+
Material("R58 Board insulation 50mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 8.0), # R=1.76 m虏路K/W
|
| 225 |
+
Material("R59 Board insulation 75mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 9.0), # R=2.64 m虏路K/W
|
| 226 |
+
Material("R60 Board insulation 100mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 10.0), # R=3.52 m虏路K/W
|
| 227 |
+
Material("R61 Board insulation 125mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 11.0), # R=4.40 m虏路K/W
|
| 228 |
+
Material("R62 Board insulation 150mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 12.0), # R=5.28 m虏路K/W
|
| 229 |
+
Material("R63 Board insulation 175mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 13.0), # R=6.16 m虏路K/W
|
| 230 |
+
Material("R64 Board insulation 200mm", MaterialCategory.INSULATION, 0.01, 1.0, 1000.0, 0.01, 0.01, 0.5, 14.0), # R=7.04 m虏路K/W
|
| 231 |
+
]
|
| 232 |
+
return {mat.name: mat for mat in materials}
|
| 233 |
+
|
| 234 |
+
def initialize_constructions(self) -> Dict[str, Construction]:
|
| 235 |
+
constructions = [
|
| 236 |
+
# Original constructions
|
| 237 |
+
Construction("Exterior Wall", "Wall", [
|
| 238 |
+
{"material": self.library_materials["Clay Brick"], "thickness": 0.115},
|
| 239 |
+
{"material": self.library_materials["Fiberglass Insulation"], "thickness": 0.1},
|
| 240 |
+
{"material": self.library_materials["Gypsum Plaster"], "thickness": 0.013}
|
| 241 |
+
]),
|
| 242 |
+
Construction("Flat Roof", "Roof", [
|
| 243 |
+
{"material": self.library_materials["Asphalt shingle"], "thickness": 0.003},
|
| 244 |
+
{"material": self.library_materials["Fiberglass Insulation"], "thickness": 0.15},
|
| 245 |
+
{"material": self.library_materials["Concrete"], "thickness": 0.1}
|
| 246 |
+
]),
|
| 247 |
+
Construction("Slab Floor", "Floor", [
|
| 248 |
+
{"material": self.library_materials["Concrete"], "thickness": 0.1},
|
| 249 |
+
{"material": self.library_materials["Fiberglass Insulation"], "thickness": 0.05}
|
| 250 |
+
]),
|
| 251 |
+
# ASHRAE 2005 HOF Constructions
|
| 252 |
+
Construction("Light Exterior Wall", "Wall", [
|
| 253 |
+
{"material": self.library_materials["F08 Metal surface"], "thickness": 0.0008},
|
| 254 |
+
{"material": self.library_materials["I02 50mm insulation board"], "thickness": 0.0508},
|
| 255 |
+
{"material": self.library_materials["F04 Wall air space resistance"], "thickness": 0.01},
|
| 256 |
+
{"material": self.library_materials["G01a 19mm gypsum board"], "thickness": 0.0191}
|
| 257 |
+
]),
|
| 258 |
+
Construction("Light Roof/Ceiling", "Roof", [
|
| 259 |
+
{"material": self.library_materials["M11 100mm lightweight concrete"], "thickness": 0.1016},
|
| 260 |
+
{"material": self.library_materials["F05 Ceiling air space resistance"], "thickness": 0.01},
|
| 261 |
+
{"material": self.library_materials["F16 Acoustic tile"], "thickness": 0.0191}
|
| 262 |
+
]),
|
| 263 |
+
Construction("Light Partitions", "Partition", [
|
| 264 |
+
{"material": self.library_materials["G01a 19mm gypsum board"], "thickness": 0.0191},
|
| 265 |
+
{"material": self.library_materials["F04 Wall air space resistance"], "thickness": 0.01},
|
| 266 |
+
{"material": self.library_materials["G01a 19mm gypsum board"], "thickness": 0.0191}
|
| 267 |
+
]),
|
| 268 |
+
Construction("Light Floor", "Floor", [
|
| 269 |
+
{"material": self.library_materials["F16 Acoustic tile"], "thickness": 0.0191},
|
| 270 |
+
{"material": self.library_materials["F05 Ceiling air space resistance"], "thickness": 0.01},
|
| 271 |
+
{"material": self.library_materials["M11 100mm lightweight concrete"], "thickness": 0.1016}
|
| 272 |
+
]),
|
| 273 |
+
Construction("Light Furnishings", "Furnishing", [
|
| 274 |
+
{"material": self.library_materials["G05 25mm wood"], "thickness": 0.0254}
|
| 275 |
+
]),
|
| 276 |
+
Construction("Medium Exterior Wall", "Wall", [
|
| 277 |
+
{"material": self.library_materials["M01 100mm brick"], "thickness": 0.1016},
|
| 278 |
+
{"material": self.library_materials["I02 50mm insulation board"], "thickness": 0.0508},
|
| 279 |
+
{"material": self.library_materials["F04 Wall air space resistance"], "thickness": 0.01},
|
| 280 |
+
{"material": self.library_materials["G01a 19mm gypsum board"], "thickness": 0.0191}
|
| 281 |
+
]),
|
| 282 |
+
Construction("Medium Roof/Ceiling", "Roof", [
|
| 283 |
+
{"material": self.library_materials["M14a 100mm heavyweight concrete"], "thickness": 0.1016},
|
| 284 |
+
{"material": self.library_materials["F05 Ceiling air space resistance"], "thickness": 0.01},
|
| 285 |
+
{"material": self.library_materials["F16 Acoustic tile"], "thickness": 0.0191}
|
| 286 |
+
]),
|
| 287 |
+
Construction("Medium Partitions", "Partition", [
|
| 288 |
+
{"material": self.library_materials["G01a 19mm gypsum board"], "thickness": 0.0191},
|
| 289 |
+
{"material": self.library_materials["F04 Wall air space resistance"], "thickness": 0.01},
|
| 290 |
+
{"material": self.library_materials["G01a 19mm gypsum board"], "thickness": 0.0191}
|
| 291 |
+
]),
|
| 292 |
+
Construction("Medium Floor", "Floor", [
|
| 293 |
+
{"material": self.library_materials["F16 Acoustic tile"], "thickness": 0.0191},
|
| 294 |
+
{"material": self.library_materials["F05 Ceiling air space resistance"], "thickness": 0.01},
|
| 295 |
+
{"material": self.library_materials["M14a 100mm heavyweight concrete"], "thickness": 0.1016}
|
| 296 |
+
]),
|
| 297 |
+
Construction("Medium Furnishings", "Furnishing", [
|
| 298 |
+
{"material": self.library_materials["G05 25mm wood"], "thickness": 0.0254}
|
| 299 |
+
]),
|
| 300 |
+
Construction("Heavy Exterior Wall", "Wall", [
|
| 301 |
+
{"material": self.library_materials["M01 100mm brick"], "thickness": 0.1016},
|
| 302 |
+
{"material": self.library_materials["M15 200mm heavyweight concrete"], "thickness": 0.2032},
|
| 303 |
+
{"material": self.library_materials["I02 50mm insulation board"], "thickness": 0.0508},
|
| 304 |
+
{"material": self.library_materials["F04 Wall air space resistance"], "thickness": 0.01},
|
| 305 |
+
{"material": self.library_materials["G01a 19mm gypsum board"], "thickness": 0.0191}
|
| 306 |
+
]),
|
| 307 |
+
Construction("Heavy Roof/Ceiling", "Roof", [
|
| 308 |
+
{"material": self.library_materials["M15 200mm heavyweight concrete"], "thickness": 0.2032},
|
| 309 |
+
{"material": self.library_materials["F05 Ceiling air space resistance"], "thickness": 0.01},
|
| 310 |
+
{"material": self.library_materials["F16 Acoustic tile"], "thickness": 0.0191}
|
| 311 |
+
]),
|
| 312 |
+
Construction("Heavy Partitions", "Partition", [
|
| 313 |
+
{"material": self.library_materials["G01a 19mm gypsum board"], "thickness": 0.0191},
|
| 314 |
+
{"material": self.library_materials["M05 200mm concrete block"], "thickness": 0.2032},
|
| 315 |
+
{"material": self.library_materials["G01a 19mm gypsum board"], "thickness": 0.0191}
|
| 316 |
+
]),
|
| 317 |
+
Construction("Heavy Floor", "Floor", [
|
| 318 |
+
{"material": self.library_materials["F16 Acoustic tile"], "thickness": 0.0191},
|
| 319 |
+
{"material": self.library_materials["F05 Ceiling air space resistance"], "thickness": 0.01},
|
| 320 |
+
{"material": self.library_materials["M15 200mm heavyweight concrete"], "thickness": 0.2032}
|
| 321 |
+
]),
|
| 322 |
+
Construction("Heavy Furnishings", "Furnishing", [
|
| 323 |
+
{"material": self.library_materials["G05 25mm wood"], "thickness": 0.0254}
|
| 324 |
+
])
|
| 325 |
+
]
|
| 326 |
+
return {cons.name: cons for cons in constructions}
|
| 327 |
+
|
| 328 |
+
def get_all_materials(self, project_materials: Optional[Dict[str, Material]] = None) -> List[Material]:
|
| 329 |
+
materials = list(self.library_materials.values())
|
| 330 |
+
if project_materials:
|
| 331 |
+
materials.extend(list(project_materials.values()))
|
| 332 |
+
return materials
|
| 333 |
+
|
| 334 |
+
def add_project_material(self, material: Material, project_materials: Dict[str, Material]) -> Tuple[bool, str]:
|
| 335 |
+
if len(project_materials) >= 20:
|
| 336 |
+
return False, "Maximum 20 project materials allowed."
|
| 337 |
+
if material.name in project_materials or material.name in self.library_materials:
|
| 338 |
+
return False, f"Material name '{material.name}' already exists."
|
| 339 |
+
project_materials[material.name] = material
|
| 340 |
+
return True, f"Material '{material.name}' added to project materials."
|
| 341 |
+
|
| 342 |
+
def edit_project_material(self, old_name: str, new_material: Material, project_materials: Dict[str, Material],
|
| 343 |
+
components: Dict[str, List]) -> Tuple[bool, str]:
|
| 344 |
+
if old_name not in project_materials:
|
| 345 |
+
return False, f"Material '{old_name}' not found in project materials."
|
| 346 |
+
if new_material.name != old_name and (new_material.name in project_materials or new_material.name in self.library_materials):
|
| 347 |
+
return False, f"Material name '{new_material.name}' already exists."
|
| 348 |
+
for comp_list in components.values():
|
| 349 |
+
for comp in comp_list:
|
| 350 |
+
if comp.construction and any(layer["material"].name == old_name for layer in comp.layers):
|
| 351 |
+
comp.layers = [{"material": new_material if layer["material"].name == old_name else layer["material"],
|
| 352 |
+
"thickness": layer["thickness"]} for layer in comp.layers]
|
| 353 |
+
comp.construction = Construction(
|
| 354 |
+
name=comp.construction.name,
|
| 355 |
+
component_type=comp.construction.component_type,
|
| 356 |
+
layers=comp.layers,
|
| 357 |
+
is_library=comp.construction.is_library
|
| 358 |
+
)
|
| 359 |
+
project_materials.pop(old_name)
|
| 360 |
+
project_materials[new_material.name] = new_material
|
| 361 |
+
return True, f"Material '{old_name}' updated to '{new_material.name}'."
|
| 362 |
+
|
| 363 |
+
def delete_project_material(self, name: str, project_materials: Dict[str, Material], components: Dict[str, List[Dict]]) -> Tuple[bool, str]:
|
| 364 |
+
if name not in project_materials:
|
| 365 |
+
return False, f"Material '{name}' not found in project materials."
|
| 366 |
+
|
| 367 |
+
# Check if material is used in any project constructions
|
| 368 |
+
for cons in self.project_constructions.values():
|
| 369 |
+
if any(layer["material"].name == name for layer in cons.layers):
|
| 370 |
+
return False, f"Cannot delete '{name}' as it is used in construction '{cons.name}'."
|
| 371 |
+
|
| 372 |
+
# Check if material is used in any library constructions
|
| 373 |
+
for cons in self.library_constructions.values():
|
| 374 |
+
if any(layer["material"].name == name for layer in cons.layers):
|
| 375 |
+
return False, f"Cannot delete '{name}' as it is used in library construction '{cons.name}'."
|
| 376 |
+
|
| 377 |
+
# Check if material is used in any components
|
| 378 |
+
for comp_type, comp_list in components.items():
|
| 379 |
+
for comp in comp_list:
|
| 380 |
+
if 'layers' in comp and any(layer["material"].name == name for layer in comp["layers"]):
|
| 381 |
+
return False, f"Cannot delete '{name}' as it is used in component '{comp['name']}' ({comp_type})."
|
| 382 |
+
|
| 383 |
+
del project_materials[name]
|
| 384 |
+
return True, f"Material '{name}' deleted successfully."
|
| 385 |
+
|
| 386 |
+
def add_project_construction(self, construction: Construction, project_constructions: Dict[str, Construction]) -> Tuple[bool, str]:
|
| 387 |
+
if len(project_constructions) >= 20:
|
| 388 |
+
return False, "Maximum 20 project constructions allowed."
|
| 389 |
+
if construction.name in project_constructions or construction.name in self.library_constructions:
|
| 390 |
+
return False, f"Construction name '{construction.name}' already exists."
|
| 391 |
+
project_constructions[construction.name] = construction
|
| 392 |
+
return True, f"Construction '{construction.name}' added to project constructions."
|
| 393 |
+
|
| 394 |
+
def edit_project_construction(self, old_name: str, new_construction: Construction,
|
| 395 |
+
project_constructions: Dict[str, Construction],
|
| 396 |
+
components: Dict[str, List]) -> Tuple[bool, str]:
|
| 397 |
+
if old_name not in project_constructions:
|
| 398 |
+
return False, f"Construction '{old_name}' not found in project constructions."
|
| 399 |
+
if new_construction.name != old_name and (new_construction.name in project_constructions or new_construction.name in self.library_constructions):
|
| 400 |
+
return False, f"Construction name '{new_construction.name}' already exists."
|
| 401 |
+
for comp_list in components.values():
|
| 402 |
+
for comp in comp_list:
|
| 403 |
+
if comp.construction and comp.construction.name == old_name:
|
| 404 |
+
comp.construction = new_construction
|
| 405 |
+
comp.layers = new_construction.layers
|
| 406 |
+
comp.u_value = new_construction.u_value
|
| 407 |
+
project_constructions.pop(old_name)
|
| 408 |
+
project_constructions[new_construction.name] = new_construction
|
| 409 |
+
return True, f"Construction '{old_name}' updated to '{new_construction.name}'."
|
| 410 |
+
|
| 411 |
+
def delete_project_construction(self, name: str, project_constructions: Dict[str, Construction],
|
| 412 |
+
components: Dict[str, List]) -> Tuple[bool, str]:
|
| 413 |
+
if name not in project_constructions:
|
| 414 |
+
return False, f"Construction '{name}' not found in project constructions."
|
| 415 |
+
for comp_list in components.values():
|
| 416 |
+
for comp in comp_list:
|
| 417 |
+
if comp.construction and comp.construction.name == name:
|
| 418 |
+
return False, f"Construction '{name}' is used in component '{comp.name}'."
|
| 419 |
+
project_constructions.pop(name)
|
| 420 |
+
return True, f"Construction '{name}' deleted."
|
| 421 |
+
|
| 422 |
+
def to_dataframe(self, data_type: str, project_materials: Optional[Dict[str, Material]] = None,
|
| 423 |
+
project_constructions: Optional[Dict[str, Construction]] = None,
|
| 424 |
+
only_project: bool = False) -> pd.DataFrame:
|
| 425 |
+
if data_type == "materials":
|
| 426 |
+
data = []
|
| 427 |
+
materials = project_materials.values() if only_project else self.get_all_materials(project_materials)
|
| 428 |
+
for mat in materials:
|
| 429 |
+
data.append({
|
| 430 |
+
"Name": mat.name,
|
| 431 |
+
"Category": mat.category.value,
|
| 432 |
+
"Conductivity (W/m路K)": mat.conductivity,
|
| 433 |
+
"Density (kg/m鲁)": mat.density,
|
| 434 |
+
"Specific Heat (J/kg路K)": mat.specific_heat,
|
| 435 |
+
"Default Thickness (m)": mat.default_thickness,
|
| 436 |
+
"Embodied Carbon (kgCO鈧俥/kg)": mat.embodied_carbon,
|
| 437 |
+
"Solar Absorption": mat.solar_absorption,
|
| 438 |
+
"Price (USD/m虏)": mat.price,
|
| 439 |
+
"Source": "Project" if not mat.is_library else "Library"
|
| 440 |
+
})
|
| 441 |
+
return pd.DataFrame(data)
|
| 442 |
+
elif data_type == "constructions":
|
| 443 |
+
data = []
|
| 444 |
+
constructions = project_constructions.values() if only_project else list(self.library_constructions.values())
|
| 445 |
+
if not only_project and project_constructions:
|
| 446 |
+
constructions.extend(list(project_constructions.values()))
|
| 447 |
+
for cons in constructions:
|
| 448 |
+
layers_str = "; ".join(f"{layer['material'].name} ({layer['thickness']}m)" for layer in cons.layers)
|
| 449 |
+
data.append({
|
| 450 |
+
"Name": cons.name,
|
| 451 |
+
"Component Type": cons.component_type,
|
| 452 |
+
"U-Value (W/m虏路K)": cons.u_value,
|
| 453 |
+
"Total Thickness (m)": cons.total_thickness,
|
| 454 |
+
"Embodied Carbon (kgCO鈧俥/m虏)": cons.embodied_carbon,
|
| 455 |
+
"Solar Absorption": cons.solar_absorption,
|
| 456 |
+
"Price (USD/m虏)": cons.price,
|
| 457 |
+
"Layers": layers_str,
|
| 458 |
+
"Source": "Project" if not cons.is_library else "Library"
|
| 459 |
+
})
|
| 460 |
+
return pd.DataFrame(data)
|
| 461 |
+
return pd.DataFrame()
|