From 3dc84aec7d7ca2f4d9892580d17909c554aec581 Mon Sep 17 00:00:00 2001 From: Douglas Greenshields Date: Thu, 4 Jan 2024 12:37:44 +0000 Subject: [PATCH] add function to build ventilation ductwork for corpus --- src/core/mod.rs | 2 +- src/corpus.rs | 20 +++++++++++++++++++- src/input.rs | 18 +++++++++--------- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/core/mod.rs b/src/core/mod.rs index 01fc0f4..8947b3b 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -4,7 +4,7 @@ pub mod heating_systems; pub mod material_properties; mod pipework; -mod ductwork; +pub mod ductwork; pub mod schedule; pub mod space_heat_demand; pub mod units; diff --git a/src/corpus.rs b/src/corpus.rs index 67d5fd9..f150097 100644 --- a/src/corpus.rs +++ b/src/corpus.rs @@ -1,6 +1,7 @@ use crate::core::controls::time_control::{ Control, OnOffMinimisingTimeControl, OnOffTimeControl, SetpointTimeControl, ToUChargeControl, }; +use crate::core::ductwork::Ductwork; use crate::core::energy_supply::energy_supply::{EnergySupplies, EnergySupply}; use crate::core::heating_systems::wwhrs::{ WWHRSInstantaneousSystemA, WWHRSInstantaneousSystemB, WWHRSInstantaneousSystemC, Wwhrs, @@ -10,6 +11,7 @@ use crate::core::schedule::{ }; use crate::core::space_heat_demand::internal_gains::InternalGains; use crate::core::space_heat_demand::ventilation_element::VentilationElementInfiltration; +use crate::core::units::MILLIMETRES_IN_METRE; use crate::core::water_heat_demand::cold_water_source::ColdWaterSource; use crate::core::water_heat_demand::dhw_demand::DomesticHotWaterDemand; use crate::external_conditions::ExternalConditions; @@ -17,7 +19,7 @@ use crate::input::{ ColdWaterSourceDetails, ColdWaterSourceInput, ColdWaterSourceType, Control as ControlInput, ControlDetails, EnergyDiverter, EnergySupplyDetails, EnergySupplyInput, EnergySupplyType, ExternalConditionsInput, HotWaterSourceDetails, Infiltration, Input, - InternalGains as InternalGainsInput, InternalGainsDetails, WasteWaterHeatRecovery, + InternalGains as InternalGainsInput, InternalGainsDetails, Ventilation, WasteWaterHeatRecovery, WasteWaterHeatRecoveryDetails, WaterHeatingEvent, WaterHeatingEvents, WwhrsType, }; use crate::simulation_time::{SimulationTime, SimulationTimeIterator}; @@ -506,3 +508,19 @@ fn schedule_event_from_input( let total_timesteps = simulation_time_iterator.total_steps(); expand_water_heating_events(events_input, sim_timestep, total_timesteps) } + +fn ductwork_from_ventilation_input(ventilation: &Option) -> Option { + ventilation.as_ref().and_then(|v| match v { + Ventilation::MVHR { ductwork, .. } => Some(Ductwork::new( + ductwork.internal_diameter_mm / MILLIMETRES_IN_METRE as f64, + ductwork.external_diameter_mm / MILLIMETRES_IN_METRE as f64, + ductwork.length_in, + ductwork.length_out, + ductwork.insulation_thermal_conductivity, + ductwork.insulation_thickness_mm / MILLIMETRES_IN_METRE as f64, + ductwork.reflective, + ductwork.mvhr_location, + )), + _ => None, + }) +} diff --git a/src/input.rs b/src/input.rs index a752659..fa47bcf 100644 --- a/src/input.rs +++ b/src/input.rs @@ -604,18 +604,18 @@ pub enum Ventilation { #[derive(Debug, Deserialize)] #[serde(deny_unknown_fields)] pub struct VentilationDuctwork { - internal_diameter_mm: f64, - external_diameter_mm: f64, - length_in: f64, - length_out: f64, - insulation_thermal_conductivity: f64, - insulation_thickness_mm: f64, - reflective: bool, + pub internal_diameter_mm: f64, + pub external_diameter_mm: f64, + pub length_in: f64, + pub length_out: f64, + pub insulation_thermal_conductivity: f64, + pub insulation_thickness_mm: f64, + pub reflective: bool, #[serde(rename(deserialize = "MVHR_location"))] - mvhr_location: MVHRLocation, + pub mvhr_location: MVHRLocation, } -#[derive(Debug, Deserialize)] +#[derive(Copy, Clone, Debug, Deserialize)] #[serde(rename_all = "lowercase")] pub enum MVHRLocation { Inside,