Skip to content

Commit

Permalink
add energy supplies to solar thermal system struct
Browse files Browse the repository at this point in the history
  • Loading branch information
shieldo committed Mar 22, 2024
1 parent 59ee2d9 commit db87561
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
14 changes: 9 additions & 5 deletions src/core/heating_systems/storage_tank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ impl StorageTank {
.lock()
.demand_energy(input_energy_adj, simulation_time_iteration),
HeatSource::Storage(HeatSourceWithStorageTank::Solar(ref mut solar)) => {
solar.demand_energy(input_energy_adj)
solar.demand_energy(input_energy_adj, simulation_time_iteration.index)
}
_ => {
// TODO need to be able to call demand_energy on the other heat sources
Expand Down Expand Up @@ -1047,7 +1047,7 @@ pub struct SolarThermalSystem {
collector_mass_flow_rate: f64,
power_pump: f64,
power_pump_control: f64,
// energy supply
energy_supply_connection: EnergySupplyConnection,
tilt: f64,
orientation: f64,
solar_loop_piping_hlc: f64,
Expand Down Expand Up @@ -1078,7 +1078,7 @@ impl SolarThermalSystem {
collector_mass_flow_rate: f64,
power_pump: f64,
power_pump_control: f64,
// energy supply
energy_supply_connection: EnergySupplyConnection,
tilt: f64,
orientation: f64,
solar_loop_piping_hlc: f64,
Expand All @@ -1096,6 +1096,7 @@ impl SolarThermalSystem {
collector_mass_flow_rate,
power_pump,
power_pump_control,
energy_supply_connection,
tilt,
orientation,
solar_loop_piping_hlc,
Expand Down Expand Up @@ -1204,7 +1205,7 @@ impl SolarThermalSystem {
inlet_temp2 = inlet_temp2_temp;

// Eq 58
let avg_collector_water_temp = (self.inlet_temp + inlet_temp2) / 2.
let _avg_collector_water_temp = (self.inlet_temp + inlet_temp2) / 2.
+ self.heat_output_collector_loop / (self.collector_mass_flow_rate * self.cp * 2.);
}

Expand All @@ -1213,7 +1214,7 @@ impl SolarThermalSystem {
self.heat_output_collector_loop
}

pub fn demand_energy(&mut self, energy_demand: f64) -> f64 {
pub fn demand_energy(&mut self, energy_demand: f64, timestep_idx: usize) -> f64 {
self.energy_supplied = min_of_2(energy_demand, self.heat_output_collector_loop);

// Eq 59 and 60 to calculate auxiliary energy - note that the if condition
Expand All @@ -1225,6 +1226,9 @@ impl SolarThermalSystem {
};

// TODO register demand to energy supply
self.energy_supply_connection
.demand_energy(auxiliary_energy_consumption, timestep_idx)
.unwrap();

self.energy_supplied
}
Expand Down
46 changes: 27 additions & 19 deletions src/corpus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2354,7 +2354,7 @@ impl HeatSource {
.lock()
.demand_energy(energy_demand, simulation_time_iteration),
HeatSourceWithStorageTank::Solar(ref mut solar) => {
solar.demand_energy(energy_demand)
solar.demand_energy(energy_demand, simulation_time_iteration.index)
}
},
HeatSource::Wet(ref mut wet) => match wet.as_mut() {
Expand Down Expand Up @@ -2605,25 +2605,33 @@ fn heat_source_from_input(
tilt,
orientation,
solar_loop_piping_hlc,
energy_supply,
..
} => HeatSource::Storage(HeatSourceWithStorageTank::Solar(SolarThermalSystem::new(
solar_cell_location,
area_module,
modules,
peak_collector_efficiency,
incidence_angle_modifier,
first_order_hlc,
second_order_hlc,
collector_mass_flow_rate,
power_pump,
power_pump_control,
tilt,
orientation,
solar_loop_piping_hlc,
external_conditions.clone(),
simulation_time.step_in_hours(),
WATER.clone(),
))),
} => {
let energy_supply =
energy_supplies.ensured_get_for_type(energy_supply, simulation_time.total_steps());
let energy_supply_conn = EnergySupply::connection(energy_supply.clone(), name).unwrap();

HeatSource::Storage(HeatSourceWithStorageTank::Solar(SolarThermalSystem::new(
solar_cell_location,
area_module,
modules,
peak_collector_efficiency,
incidence_angle_modifier,
first_order_hlc,
second_order_hlc,
collector_mass_flow_rate,
power_pump,
power_pump_control,
energy_supply_conn,
tilt,
orientation,
solar_loop_piping_hlc,
external_conditions.clone(),
simulation_time.step_in_hours(),
WATER.clone(),
)))
}
HeatSourceInput::Wet {
name,
cold_water_source: cold_water_source_type,
Expand Down

0 comments on commit db87561

Please sign in to comment.