Skip to content

Commit

Permalink
add corpus run method
Browse files Browse the repository at this point in the history
  • Loading branch information
shieldo committed Mar 12, 2024
1 parent 1496c34 commit 408fbf9
Show file tree
Hide file tree
Showing 4 changed files with 565 additions and 77 deletions.
20 changes: 20 additions & 0 deletions src/core/energy_supply/energy_supply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ pub struct EnergySupplies {
pub unmet_demand: EnergySupply,
}

impl EnergySupplies {
pub fn calc_energy_import_export_betafactor(&mut self, timestep_idx: usize) {
if let Some(ref mut supply) = self.mains_electricity {
supply.calc_energy_import_export_betafactor(timestep_idx);
}
if let Some(ref mut supply) = self.mains_gas {
supply.calc_energy_import_export_betafactor(timestep_idx);
}
if let Some(ref mut supply) = self.bulk_lpg {
supply.calc_energy_import_export_betafactor(timestep_idx);
}
self.unmet_demand
.calc_energy_import_export_betafactor(timestep_idx);
}
}

#[derive(Clone)]
pub struct EnergySupply {
fuel_type: EnergySupplyType,
Expand Down Expand Up @@ -153,6 +169,10 @@ impl EnergySupply {
//
// HashMap::from([])
// }

pub fn calc_energy_import_export_betafactor(&mut self, _timestep_idx: usize) {
// TODO finish this
}
}

fn init_demand_list(timestep_count: usize) -> Vec<f64> {
Expand Down
30 changes: 19 additions & 11 deletions src/core/heating_systems/boiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub struct BoilerServiceWaterCombi {
rejected_factor_3: Option<f64>,
daily_hot_water_usage: f64,
simulation_timestep: f64,
combi_loss: f64,
}

#[derive(Debug)]
Expand Down Expand Up @@ -89,6 +90,7 @@ impl BoilerServiceWaterCombi {
daily_hot_water_usage,
cold_feed,
simulation_timestep,
combi_loss: Default::default(),
})
}
_ => Err(IncorrectBoilerDataType),
Expand Down Expand Up @@ -176,17 +178,19 @@ impl BoilerServiceWaterCombi {
combi_loss
}

// pub fn internal_gains(&self) -> f64 {
// // TODO (from the Python) Fraction of hot water energy resulting in internal gains should
// // ideally be defined in one place, but it is duplicated here and in
// // main hot water demand calculation for now.
// let frac_dhw_energy_internal_gains = 0.25;
// let gain_internal = frac_dhw_energy_internal_gains * self.combi_loss * WATTS_PER_KILOWATT as f64 / self.simulation_timestep;
//
// // TODO account for the weird nixing/zeroing of the combi_loss in the Python
//
// gain_internal
// }
pub fn internal_gains(&mut self) -> f64 {
// TODO (from the Python) Fraction of hot water energy resulting in internal gains should
// ideally be defined in one place, but it is duplicated here and in
// main hot water demand calculation for now.
let frac_dhw_energy_internal_gains = 0.25;
let gain_internal =
frac_dhw_energy_internal_gains * self.combi_loss * WATTS_PER_KILOWATT as f64
/ self.simulation_timestep;

self.combi_loss = Default::default();

gain_internal
}

pub fn energy_output_max(&self) -> f64 {
self.boiler
Expand Down Expand Up @@ -713,6 +717,10 @@ impl Boiler {
energy_output_provided
}

pub fn timestep_end(&mut self) {
// TODO complete me with calc_auxiliary_energy method
}

pub fn energy_output_max(&self, _temp_output: f64) -> f64 {
let timestep = self.simulation_timestep;
let time_available = timestep - self.total_time_running_current_timestep;
Expand Down
2 changes: 1 addition & 1 deletion src/core/heating_systems/heat_pump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2524,7 +2524,7 @@ impl HeatPump {
}

/// Calculations to be done at the end of each timestep
fn timestep_end(&mut self) {
pub fn timestep_end(&mut self) {
let timestep = self.simulation_timestep;
let time_remaining_current_timestep = timestep - self.total_time_running_current_timestep;

Expand Down
Loading

0 comments on commit 408fbf9

Please sign in to comment.