Skip to content

Commit

Permalink
EC-247 add missing elec_storage_heater methods and use them in common.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
rachowell committed Feb 11, 2025
1 parent 951924e commit 00c34b0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/core/heating_systems/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ pub enum SpaceHeatSystem {
impl SpaceHeatSystem {
pub fn temp_setpnt(&self, simulation_time_iteration: SimulationTimeIteration) -> Option<f64> {
match self {
SpaceHeatSystem::ElecStorage(..) => unimplemented!("TODO 0.32"),
SpaceHeatSystem::ElecStorage(elec_storage) => {
elec_storage.temp_setpnt(&simulation_time_iteration)
}
SpaceHeatSystem::Instant(instant) => instant.temp_setpnt(&simulation_time_iteration),
SpaceHeatSystem::WarmAir(warm_air) => warm_air.temp_setpnt(&simulation_time_iteration),
SpaceHeatSystem::WetDistribution(wet_distribution) => {
Expand All @@ -137,7 +139,7 @@ impl SpaceHeatSystem {
simulation_time_iteration: SimulationTimeIteration,
) -> anyhow::Result<(f64, f64)> {
match self {
SpaceHeatSystem::ElecStorage(..) => unimplemented!("TODO 0.32"),
SpaceHeatSystem::ElecStorage(..) => unreachable!(), // it isn't expected that this will be called on electric storage heaters,
SpaceHeatSystem::Instant(_instant) => unreachable!(), // it isn't expected that this will be called on instant heaters
SpaceHeatSystem::WarmAir(warm_air) => warm_air.running_time_throughput_factor(
energy_demand,
Expand All @@ -159,7 +161,9 @@ impl SpaceHeatSystem {
simulation_time_iteration: SimulationTimeIteration,
) -> anyhow::Result<f64> {
Ok(match self {
SpaceHeatSystem::ElecStorage(..) => unimplemented!("TODO 0.32"),
SpaceHeatSystem::ElecStorage(elec_storage) => {
elec_storage.demand_energy(energy_demand, &simulation_time_iteration)?
}
SpaceHeatSystem::Instant(ref mut instant) => {
instant.demand_energy(energy_demand, simulation_time_iteration)
}
Expand All @@ -177,7 +181,9 @@ impl SpaceHeatSystem {
simulation_time_iteration: SimulationTimeIteration,
) -> Option<bool> {
match self {
SpaceHeatSystem::ElecStorage(..) => unimplemented!("TODO 0.32"),
SpaceHeatSystem::ElecStorage(elec_storage) => {
elec_storage.in_required_period(&simulation_time_iteration)
}
SpaceHeatSystem::Instant(instant) => {
instant.in_required_period(&simulation_time_iteration)
}
Expand Down
15 changes: 15 additions & 0 deletions src/core/heating_systems/elec_storage_heater.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::core::controls::time_control::{per_control, ControlBehaviour};
use crate::{
core::{
controls::time_control::Control, energy_supply::energy_supply::EnergySupplyConnection,
Expand Down Expand Up @@ -313,6 +314,20 @@ impl ElecStorageHeater {
})
}

pub(crate) fn temp_setpnt(
&self,
simulation_time_iteration: &SimulationTimeIteration,
) -> Option<f64> {
per_control!(self.control.as_ref(), ctrl => { ctrl.setpnt(simulation_time_iteration) })
}

pub(crate) fn in_required_period(
&self,
simulation_time_iteration: &SimulationTimeIteration,
) -> Option<bool> {
per_control!(self.control.as_ref(), ctrl => { ctrl.in_required_period(simulation_time_iteration) })
}

fn convert_to_kwh(power: f64, time: f64) -> f64 {
// Converts power value supplied to the correct energy unit
// Arguments
Expand Down

0 comments on commit 00c34b0

Please sign in to comment.