ems_model/building/
insulation.rs

1use std::collections::HashMap;
2
3/// heating demand in kWh/m2/year
4pub struct HeatingNeed {
5    pub national_minimum_requirement: f64,
6    pub improved_standard: f64,
7    pub ambitious_standard: f64,
8}
9
10impl HeatingNeed {
11    pub fn new(
12        national_minimum_requirement: f64,
13        improved_standard: f64,
14        ambitious_standard: f64,
15    ) -> Self {
16        Self {
17            national_minimum_requirement,
18            improved_standard,
19            ambitious_standard,
20        }
21    }
22}
23
24#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
25pub enum BuildingTypeEnum {
26    SingleFamily,
27    Terraced,
28    MultiFamily,
29    Apartment,
30}
31
32pub struct BuildingTypeMapping {
33    pub mapping: HashMap<BuildingTypeEnum, HeatingNeed>,
34}
35
36impl BuildingTypeMapping {
37    pub fn new() -> Self {
38        let mapping = HashMap::new();
39        Self { mapping }
40    }
41
42    pub fn get(&self, building_type: BuildingTypeEnum) -> Option<&HeatingNeed> {
43        self.mapping.get(&building_type)
44    }
45
46    pub fn insert(&mut self, building_type: BuildingTypeEnum, heating_need: HeatingNeed) {
47        self.mapping.insert(building_type, heating_need);
48    }
49}
50
51#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
52pub enum YearCategoryESEnum {
53    Before1900,
54    Between1901and1936,
55    Between1937and1959,
56    Between1960and1979,
57    Between1980and2006,
58    After2007,
59}
60
61pub struct YearCategoryESMapping {
62    pub mapping: HashMap<YearCategoryESEnum, BuildingTypeMapping>,
63}
64
65impl YearCategoryESMapping {
66    pub fn new() -> Self {
67        let mapping = HashMap::new();
68        Self { mapping }
69    }
70
71    pub fn get(&self, year_category: YearCategoryESEnum) -> Option<&BuildingTypeMapping> {
72        self.mapping.get(&year_category)
73    }
74
75    pub fn insert(
76        &mut self,
77        year_category: YearCategoryESEnum,
78        building_type_mapping: BuildingTypeMapping,
79    ) {
80        self.mapping.insert(year_category, building_type_mapping);
81    }
82}
83
84impl Default for YearCategoryESMapping {
85    fn default() -> Self {
86        let mut mapping = HashMap::new();
87
88        // Before1900
89        let mut before1900 = BuildingTypeMapping::new();
90        before1900.insert(
91            BuildingTypeEnum::SingleFamily,
92            HeatingNeed::new(10.6, 10.7, 11.0),
93        );
94        before1900.insert(BuildingTypeEnum::Terraced, HeatingNeed::new(7.1, 4.0, 3.4));
95        before1900.insert(
96            BuildingTypeEnum::MultiFamily,
97            HeatingNeed::new(11.8, 6.1, 6.1),
98        );
99        before1900.insert(BuildingTypeEnum::Apartment, HeatingNeed::new(7.8, 5.9, 5.6));
100        mapping.insert(YearCategoryESEnum::Before1900, before1900);
101
102        // Between1901and1936
103        let mut between1901and1936 = BuildingTypeMapping::new();
104        between1901and1936.insert(
105            BuildingTypeEnum::SingleFamily,
106            HeatingNeed::new(14.8, 8.0, 7.1),
107        );
108        between1901and1936.insert(
109            BuildingTypeEnum::Terraced,
110            HeatingNeed::new(17.9, 11.7, 11.5),
111        );
112        between1901and1936.insert(
113            BuildingTypeEnum::MultiFamily,
114            HeatingNeed::new(7.7, 4.9, 5.6),
115        );
116        between1901and1936.insert(BuildingTypeEnum::Apartment, HeatingNeed::new(8.5, 4.5, 6.1));
117        mapping.insert(YearCategoryESEnum::Between1901and1936, between1901and1936);
118
119        // Between1937and1959
120        let mut between1937and1959 = BuildingTypeMapping::new();
121        between1937and1959.insert(
122            BuildingTypeEnum::SingleFamily,
123            HeatingNeed::new(8.1, 4.1, 3.4),
124        );
125        between1937and1959.insert(
126            BuildingTypeEnum::Terraced,
127            HeatingNeed::new(20.7, 15.2, 15.2),
128        );
129        between1937and1959.insert(
130            BuildingTypeEnum::MultiFamily,
131            HeatingNeed::new(11.3, 5.5, 5.1),
132        );
133        between1937and1959.insert(BuildingTypeEnum::Apartment, HeatingNeed::new(7.4, 3.6, 3.1));
134        mapping.insert(YearCategoryESEnum::Between1937and1959, between1937and1959);
135
136        // Between1960and1979
137        let mut between1960and1979 = BuildingTypeMapping::new();
138        between1960and1979.insert(
139            BuildingTypeEnum::SingleFamily,
140            HeatingNeed::new(12.4, 10.2, 9.1),
141        );
142        between1960and1979.insert(BuildingTypeEnum::Terraced, HeatingNeed::new(7.6, 5.0, 6.6));
143        between1960and1979.insert(
144            BuildingTypeEnum::MultiFamily,
145            HeatingNeed::new(9.8, 6.3, 6.0),
146        );
147        between1960and1979.insert(BuildingTypeEnum::Apartment, HeatingNeed::new(4.3, 2.3, 2.3));
148        mapping.insert(YearCategoryESEnum::Between1960and1979, between1960and1979);
149
150        // Between1980and2006
151        let mut between1980and2006 = BuildingTypeMapping::new();
152        between1980and2006.insert(
153            BuildingTypeEnum::SingleFamily,
154            HeatingNeed::new(5.8, 4.7, 5.7),
155        );
156        between1980and2006.insert(BuildingTypeEnum::Terraced, HeatingNeed::new(5.8, 5.4, 6.7));
157        between1980and2006.insert(
158            BuildingTypeEnum::MultiFamily,
159            HeatingNeed::new(3.9, 3.3, 2.8),
160        );
161        between1980and2006.insert(BuildingTypeEnum::Apartment, HeatingNeed::new(2.3, 1.9, 3.5));
162        mapping.insert(YearCategoryESEnum::Between1980and2006, between1980and2006);
163
164        // After2007
165        let mut after2007 = BuildingTypeMapping::new();
166        after2007.insert(
167            BuildingTypeEnum::SingleFamily,
168            HeatingNeed::new(6.4, 2.9, 2.4),
169        );
170        after2007.insert(BuildingTypeEnum::Terraced, HeatingNeed::new(2.5, 2.2, 1.9));
171        after2007.insert(
172            BuildingTypeEnum::MultiFamily,
173            HeatingNeed::new(3.5, 1.9, 1.5),
174        );
175        after2007.insert(BuildingTypeEnum::Apartment, HeatingNeed::new(2.4, 1.5, 1.2));
176        mapping.insert(YearCategoryESEnum::After2007, after2007);
177
178        Self { mapping }
179    }
180}
181
182pub struct YearCategory {
183    pub es: YearCategoryESMapping,
184}