Skip to content

Commit

Permalink
add on site generation to corpus
Browse files Browse the repository at this point in the history
  • Loading branch information
shieldo committed Feb 15, 2024
1 parent c78df6d commit 1fc3066
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 15 deletions.
60 changes: 55 additions & 5 deletions src/corpus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::core::controls::time_control::{
use crate::core::cooling_systems::air_conditioning::AirConditioning;
use crate::core::ductwork::Ductwork;
use crate::core::energy_supply::energy_supply::{EnergySupplies, EnergySupply};
use crate::core::energy_supply::pv::PhotovoltaicSystem;
use crate::core::heating_systems::boiler::{Boiler, BoilerServiceWaterCombi};
use crate::core::heating_systems::common::{HeatSourceWet, SpaceHeatSystem};
use crate::core::heating_systems::heat_battery::HeatBattery;
Expand Down Expand Up @@ -42,11 +43,12 @@ use crate::input::{
ExternalConditionsInput, HeatSource as HeatSourceInput, HeatSourceControl,
HeatSourceControlType, HeatSourceWetDetails, HeatSourceWetType, HotWaterSourceDetails,
Infiltration, Input, InternalGains as InternalGainsInput, InternalGainsDetails,
SpaceCoolSystem as SpaceCoolSystemInput, SpaceCoolSystemDetails, SpaceCoolSystemType,
SpaceHeatSystem as SpaceHeatSystemInput, SpaceHeatSystemDetails,
ThermalBridging as ThermalBridgingInput, ThermalBridgingDetails, Ventilation,
WasteWaterHeatRecovery, WasteWaterHeatRecoveryDetails, WaterHeatingEvent, WaterHeatingEvents,
WindowOpeningForCooling as WindowOpeningForCoolingInput, WwhrsType, ZoneDictionary, ZoneInput,
OnSiteGeneration, OnSiteGenerationDetails, SpaceCoolSystem as SpaceCoolSystemInput,
SpaceCoolSystemDetails, SpaceCoolSystemType, SpaceHeatSystem as SpaceHeatSystemInput,
SpaceHeatSystemDetails, ThermalBridging as ThermalBridgingInput, ThermalBridgingDetails,
Ventilation, WasteWaterHeatRecovery, WasteWaterHeatRecoveryDetails, WaterHeatingEvent,
WaterHeatingEvents, WindowOpeningForCooling as WindowOpeningForCoolingInput, WwhrsType,
ZoneDictionary, ZoneInput,
};
use crate::simulation_time::{SimulationTime, SimulationTimeIteration, SimulationTimeIterator};
use indexmap::IndexMap;
Expand Down Expand Up @@ -80,6 +82,7 @@ pub struct Corpus {
pub heat_system_names_requiring_overvent: Vec<String>,
pub space_heat_systems: HashMap<String, SpaceHeatSystem>,
pub space_cool_systems: HashMap<String, AirConditioning>,
pub on_site_generation: HashMap<String, PhotovoltaicSystem>,
}

impl TryFrom<Input> for Corpus {
Expand Down Expand Up @@ -254,6 +257,17 @@ impl TryFrom<Input> for Corpus {
})
.unwrap_or_default();

let on_site_generation = input
.on_site_generation
.map(|on_site_generation| {
on_site_generation_from_input(
&on_site_generation,
external_conditions.clone(),
&simulation_time_iterator,
)
})
.unwrap_or_default();

Ok(Self {
external_conditions,
infiltration,
Expand All @@ -276,6 +290,7 @@ impl TryFrom<Input> for Corpus {
heat_system_names_requiring_overvent,
space_heat_systems,
space_cool_systems,
on_site_generation,
})
}
}
Expand Down Expand Up @@ -1611,3 +1626,38 @@ fn space_cool_systems_from_input(
})
.collect::<HashMap<_, _>>()
}

fn on_site_generation_from_input(
input: &OnSiteGeneration,
external_conditions: Arc<ExternalConditions>,
simulation_time_iterator: &SimulationTimeIterator,
) -> HashMap<String, PhotovoltaicSystem> {
input
.iter()
.map(|(name, generation_details)| {
((*name).clone(), {
let OnSiteGenerationDetails {
peak_power,
ventilation_strategy,
pitch,
orientation,
base_height,
height,
width,
..
} = generation_details;
PhotovoltaicSystem::new(
*peak_power,
*ventilation_strategy,
*pitch,
*orientation,
*base_height,
*height,
*width,
external_conditions.clone(),
simulation_time_iterator.step_in_hours(),
)
})
})
.collect::<HashMap<_, _>>()
}
22 changes: 12 additions & 10 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct Input {
pub heat_source_wet: Option<HeatSourceWet>,
#[serde(rename(deserialize = "WWHRS"))]
pub waste_water_heat_recovery: Option<WasteWaterHeatRecovery>,
on_site_generation: Option<OnSiteGeneration>,
pub on_site_generation: Option<OnSiteGeneration>,
#[serde(rename(deserialize = "Window_Opening_For_Cooling"))]
pub window_opening_for_cooling: Option<WindowOpeningForCooling>,
}
Expand Down Expand Up @@ -1246,23 +1246,25 @@ pub type OnSiteGeneration = HashMap<String, OnSiteGenerationDetails>;
pub struct OnSiteGenerationDetails {
#[serde(rename(deserialize = "type"))]
generation_type: OnSiteGenerationType,
peak_power: f64,
ventilation_strategy: OnSiteGenerationVentilationStrategy,
pitch: f64,
orientation360: f64,
base_height: f64,
height: f64,
width: f64,
pub peak_power: f64,
pub ventilation_strategy: OnSiteGenerationVentilationStrategy,
pub pitch: f64,
#[serde(rename(deserialize = "orientation360"))]
#[serde(deserialize_with = "deserialize_orientation")]
pub orientation: f64,
pub base_height: f64,
pub height: f64,
pub width: f64,
#[serde(rename(deserialize = "EnergySupply"))]
energy_supply: EnergySupplyType,
pub energy_supply: EnergySupplyType,
}

#[derive(Debug, Deserialize)]
pub enum OnSiteGenerationType {
PhotovoltaicSystem,
}

#[derive(Debug, Deserialize)]
#[derive(Copy, Clone, Debug, Deserialize)]
pub enum OnSiteGenerationVentilationStrategy {
#[serde(alias = "unventilated")]
Unventilated,
Expand Down

0 comments on commit 1fc3066

Please sign in to comment.