Skip to content

Commit

Permalink
add total floor area and total volume to corpus
Browse files Browse the repository at this point in the history
  • Loading branch information
shieldo committed Jan 9, 2024
1 parent f9940b5 commit e9acc42
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/core/space_heat_demand/zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ impl Zone {
}
}

pub fn area(&self) -> f64 {
self.useful_area
}

pub fn volume(&self) -> f64 {
self.volume
}
Expand Down
10 changes: 9 additions & 1 deletion src/corpus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ pub struct Corpus {
pub zones: HashMap<String, Zone>,
pub heat_system_name_for_zone: HashMap<String, Option<String>>,
pub cool_system_name_for_zone: HashMap<String, Option<String>>,
pub total_floor_area: f64,
pub total_volume: f64,
}

impl TryFrom<Input> for Corpus {
Expand Down Expand Up @@ -118,7 +120,7 @@ impl TryFrom<Input> for Corpus {
let mut heat_system_name_for_zone: HashMap<String, Option<String>> = Default::default();
let mut cool_system_name_for_zone: HashMap<String, Option<String>> = Default::default();

let zones = input
let zones: HashMap<String, Zone> = input
.zone
.iter()
.map(|(i, zone)| {
Expand Down Expand Up @@ -149,6 +151,10 @@ impl TryFrom<Input> for Corpus {

// TODO: there needs to be some equivalent here of the Python code that builds the dict __energy_supply_conn_unmet_demand_zone

let (total_floor_area, total_volume) = zones.values().fold((0., 0.), |acc, zone| {
(zone.area() + acc.0, zone.volume() + acc.1)
});

Ok(Self {
external_conditions,
infiltration,
Expand All @@ -164,6 +170,8 @@ impl TryFrom<Input> for Corpus {
zones,
heat_system_name_for_zone,
cool_system_name_for_zone,
total_floor_area,
total_volume,
})
}
}
Expand Down

0 comments on commit e9acc42

Please sign in to comment.