Skip to content

Commit

Permalink
resolve remaining compiler/clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
shieldo committed Apr 29, 2024
1 parent 10a1838 commit b551948
Show file tree
Hide file tree
Showing 18 changed files with 149 additions and 164 deletions.
2 changes: 1 addition & 1 deletion src/core/cooling_systems/air_conditioning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ mod tests {
use super::*;
use crate::core::controls::time_control::OnOffTimeControl;
use crate::core::energy_supply::energy_supply::EnergySupply;
use crate::input::{EnergySupplyType, FuelType};
use crate::input::FuelType;
use crate::simulation_time::SimulationTime;
use parking_lot::Mutex;
use rstest::*;
Expand Down
6 changes: 4 additions & 2 deletions src/core/ductwork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ pub struct Ductwork {
length_in_in_m: f64,
length_out_in_m: f64,
mvhr_location: MVHRLocation,
diameter_including_insulation_in_m: f64,
internal_surface_resistance: f64,
// in K m / W
insulation_resistance: f64,
// in K m / W
external_surface_resistance: f64, // K m / W
#[cfg(test)]
diameter_including_insulation_in_m: f64,
}

impl Ductwork {
Expand Down Expand Up @@ -70,10 +71,11 @@ impl Ductwork {
length_in_in_m,
length_out_in_m,
mvhr_location,
diameter_including_insulation_in_m,
internal_surface_resistance,
insulation_resistance,
external_surface_resistance,
#[cfg(test)]
diameter_including_insulation_in_m,
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/core/energy_supply/energy_supply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ impl EnergySupply {

enum BetaFactorFunction {
Pv,
// variant currently commented out in upstream
#[allow(dead_code)]
Wind,
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/energy_supply/pv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ mod tests {
use crate::external_conditions::{
DaylightSavingsConfig, ShadingObject, ShadingObjectType, ShadingSegment,
};
use crate::input::{EnergySupplyType, FuelType};
use crate::input::FuelType;
use crate::simulation_time::SimulationTime;
use parking_lot::Mutex;
use rstest::*;
Expand Down
1 change: 1 addition & 0 deletions src/core/heating_systems/boiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ struct ServiceResult {
mod tests {
use super::*;
use crate::core::controls::time_control::SetpointTimeControl;
use crate::core::water_heat_demand::cold_water_source::ColdWaterSource;
use crate::external_conditions::{DaylightSavingsConfig, ShadingSegment};
use crate::input::{ColdWaterSourceType, FuelType, HeatSourceControlType, HeatSourceWetType};
use crate::simulation_time::SimulationTime;
Expand Down
28 changes: 9 additions & 19 deletions src/core/heating_systems/heat_battery.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use crate::compare_floats::min_of_2;
use crate::core::controls::time_control::{per_control, Control, ControlBehaviour};
use crate::core::energy_supply::energy_supply::{EnergySupply, EnergySupplyConnection};
use crate::core::water_heat_demand::cold_water_source::ColdWaterSource;
use crate::external_conditions::ExternalConditions;
use crate::input::{HeatSourceLocation, HeatSourceWetDetails};
use crate::input::HeatSourceWetDetails;
use crate::simulation_time::{SimulationTimeIteration, SimulationTimeIterator};
use anyhow::bail;
use interp::interp;
Expand All @@ -13,7 +11,7 @@ use std::sync::Arc;

/// This module provides object(s) to model the behaviour of heat batteries.

enum ServiceType {
pub enum ServiceType {
WaterRegular,
Space,
}
Expand All @@ -28,7 +26,6 @@ pub struct HeatBatteryServiceWaterRegular {
service_name: String,
control: Option<Arc<Control>>,
temp_hot_water: f64,
cold_feed: Arc<ColdWaterSource>,
temp_return: f64,
}

Expand All @@ -37,7 +34,6 @@ impl HeatBatteryServiceWaterRegular {
heat_battery: Arc<Mutex<HeatBattery>>,
service_name: String,
temp_hot_water: f64,
cold_feed: Arc<ColdWaterSource>,
temp_return: f64,
control: Option<Arc<Control>>,
) -> Self {
Expand All @@ -46,7 +42,6 @@ impl HeatBatteryServiceWaterRegular {
service_name,
control,
temp_hot_water,
cold_feed,
temp_return,
}
}
Expand Down Expand Up @@ -150,7 +145,8 @@ impl HeatBatteryServiceSpace {
}
}

const LABS_TESTS_RATED_OUTPUT: [[f64; 2]; 21] = [
// TODO - check upstream whether it's an error that these numbers are not used
const _LABS_TESTS_RATED_OUTPUT: [[f64; 2]; 21] = [
[0.0, 0.0],
[0.08, 0.00],
[0.16, 0.03],
Expand Down Expand Up @@ -218,7 +214,9 @@ const LABS_TESTS_LOSSES: [[f64; 2]; 20] = [

const HEAT_BATTERY_TIME_UNIT: u32 = 3_600;

// nothing seems to read this - check upstream whether service_results field is necessary
#[derive(Clone, Debug)]
#[allow(dead_code)]
struct HeatBatteryResult {
service_name: String,
time_running: f64,
Expand All @@ -228,11 +226,9 @@ struct HeatBatteryResult {
#[derive(Clone, Debug)]
pub struct HeatBattery {
simulation_time: Arc<SimulationTimeIterator>,
external_conditions: Arc<ExternalConditions>,
energy_supply: Arc<Mutex<EnergySupply>>,
energy_supply_connection: EnergySupplyConnection,
energy_supply_connections: HashMap<String, EnergySupplyConnection>,
heat_battery_location: HeatSourceLocation,
pwr_in: f64,
heat_storage_capacity: f64,
max_rated_heat_output: f64,
Expand All @@ -241,6 +237,7 @@ pub struct HeatBattery {
power_standby: f64,
n_units: usize,
charge_control: Arc<Control>, // ToUChargeControl variant expected
// nothing external seems to read this - check upstream whether service_results field is necessary
service_results: Vec<HeatBatteryResult>,
total_time_running_current_timestamp: f64,
flag_first_call: bool,
Expand All @@ -257,19 +254,17 @@ impl HeatBattery {
energy_supply: Arc<Mutex<EnergySupply>>,
energy_supply_connection: EnergySupplyConnection,
simulation_time: Arc<SimulationTimeIterator>,
external_conditions: Arc<ExternalConditions>,
) -> Self {
let (
heat_battery_location,
pwr_in,
heat_storage_capacity,
max_rated_heat_output,
max_rated_losses,
power_circ_pump,
power_standby,
n_units,
..,
) = if let HeatSourceWetDetails::HeatBattery {
heat_battery_location,
rated_charge_power: pwr_in,
heat_storage_capacity,
max_rated_heat_output,
Expand All @@ -281,7 +276,6 @@ impl HeatBattery {
} = heat_battery_details
{
(
*heat_battery_location,
*pwr_in,
*heat_storage_capacity,
*max_rated_heat_output,
Expand All @@ -296,11 +290,9 @@ impl HeatBattery {

Self {
simulation_time,
external_conditions,
energy_supply,
energy_supply_connection,
energy_supply_connections: Default::default(),
heat_battery_location,
pwr_in,
heat_storage_capacity,
max_rated_heat_output,
Expand Down Expand Up @@ -354,7 +346,6 @@ impl HeatBattery {
heat_battery: Arc<Mutex<Self>>,
service_name: &str,
temp_hot_water: f64,
cold_feed: Arc<ColdWaterSource>,
temp_return: f64,
control: Option<Arc<Control>>,
) -> HeatBatteryServiceWaterRegular {
Expand All @@ -363,7 +354,6 @@ impl HeatBattery {
heat_battery,
service_name.to_string(),
temp_hot_water,
cold_feed,
temp_return,
control,
)
Expand All @@ -385,7 +375,7 @@ impl HeatBattery {
/// * `timestep` - length of the timestep
///
/// returns -- Energy in kWH
fn convert_to_energy(&self, power: f64, timestep: f64) -> f64 {
fn _convert_to_energy(&self, power: f64, timestep: f64) -> f64 {
power * timestep * self.n_units as f64
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/heating_systems/heat_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ mod tests {
use super::*;
use crate::core::controls::time_control::SetpointTimeControl;
use crate::core::water_heat_demand::cold_water_source::ColdWaterSource;
use crate::input::{EnergySupplyType, FuelType};
use crate::input::FuelType;
use crate::simulation_time::SimulationTime;
use rstest::*;

Expand Down Expand Up @@ -411,7 +411,7 @@ mod tests {

#[rstest]
pub fn should_calc_heat_network_energy_output_provider(
mut heat_network: (Arc<Mutex<HeatNetwork>>, Arc<Mutex<EnergySupply>>),
heat_network: (Arc<Mutex<HeatNetwork>>, Arc<Mutex<EnergySupply>>),
two_len_simulation_time: SimulationTime,
) {
let (heat_network, energy_supply) = heat_network;
Expand Down Expand Up @@ -523,7 +523,7 @@ mod tests {
#[rstest]
pub fn should_calc_demand_hot_water_for_water_direct(
mut heat_network_water_direct: HeatNetworkServiceWaterDirect,
mut heat_network_for_water_direct: Arc<Mutex<HeatNetwork>>,
heat_network_for_water_direct: Arc<Mutex<HeatNetwork>>,
two_len_simulation_time: SimulationTime,
) {
let volume_demanded = [50.0, 100.0];
Expand Down
4 changes: 2 additions & 2 deletions src/core/heating_systems/heat_pump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2862,7 +2862,7 @@ pub enum ServiceResult {
}

#[derive(Debug)]
struct HeatPumpEnergyCalculation {
pub struct HeatPumpEnergyCalculation {
service_name: ResultString,
service_type: ServiceType,
service_on: bool,
Expand Down Expand Up @@ -2975,7 +2975,7 @@ impl Div for ResultParamValue {
}

#[derive(Debug)]
struct AuxiliaryParameters {
pub struct AuxiliaryParameters {
_energy_standby: f64,
_energy_crankcase_heater_mode: f64,
_energy_off_mode: f64,
Expand Down
2 changes: 1 addition & 1 deletion src/core/heating_systems/instant_elec_heater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ mod tests {
use super::*;
use crate::core::controls::time_control::OnOffTimeControl;
use crate::core::energy_supply::energy_supply::EnergySupply;
use crate::input::{EnergySupplyType, FuelType};
use crate::input::FuelType;
use crate::simulation_time::SimulationTime;
use parking_lot::Mutex;
use rstest::*;
Expand Down
24 changes: 7 additions & 17 deletions src/core/heating_systems/storage_tank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const STORAGE_TANK_F_RVD_AUX: f64 = 0.25;
// part of the thermal losses transmitted to the room
const STORAGE_TANK_F_STO_M: f64 = 0.75;

// ambient temperature - degress (sic - from Python code)
// ambient temperature - degrees
const STORAGE_TANK_TEMP_AMB: f64 = 16.;

#[derive(Clone, Debug)]
Expand All @@ -54,7 +54,6 @@ pub struct StorageTank {
temp_set_on: f64, // set point temperature
cold_feed: WaterSourceWithTemperature,
simulation_timestep: f64,
contents: MaterialProperties,
energy_supply_connection_unmet_demand: Option<EnergySupplyConnection>,
control_hold_at_setpoint: Option<Arc<Control>>,
volume_total_in_litres: f64,
Expand Down Expand Up @@ -138,7 +137,6 @@ impl StorageTank {
temp_set_on,
cold_feed,
simulation_timestep,
contents,
energy_supply_connection_unmet_demand,
control_hold_at_setpoint,
volume_total_in_litres,
Expand Down Expand Up @@ -668,19 +666,17 @@ impl StorageTank {
// TODO 6.4.3.11 Heat exchanger

// demand adjusted energy from heat source (before was just using potential without taking it)
let mut input_energy_adj = q_in_h_w;
let input_energy_adj = q_in_h_w;

#[cfg(test)]
{
self.energy_demand_test = input_energy_adj;
}

// energy demand saved for unittest (not implemented in Rust until needed)
// self.__energy_demand_test = deepcopy(input_energy_adj)

let heat_source_output =
let _heat_source_output =
self.heat_source_output(heat_source, input_energy_adj, simulation_time_iteration);
input_energy_adj -= heat_source_output;
// variable is updated in upstream but then never read
// input_energy_adj -= _heat_source_output;

(
temp_s8_n, q_x_in_n, q_s6, temp_s6_n, temp_s7_n, q_in_h_w, q_ls, q_ls_n,
Expand Down Expand Up @@ -1038,9 +1034,8 @@ impl PVDiverter {
supply_surplus: f64,
simulation_time_iteration: SimulationTimeIteration,
) -> f64 {
let mut imm_heater_max_capacity_spare: f64 = Default::default();
// check how much spare capacity the immersion heater has
imm_heater_max_capacity_spare = self
let imm_heater_max_capacity_spare = self
.immersion_heater
.lock()
.energy_output_max(simulation_time_iteration, true)
Expand Down Expand Up @@ -1288,7 +1283,7 @@ mod tests {
use crate::external_conditions::{
DaylightSavingsConfig, ShadingObject, ShadingObjectType, ShadingSegment,
};
use crate::input::{EnergySupplyType, FuelType};
use crate::input::FuelType;
use crate::simulation_time::SimulationTime;
use rstest::*;

Expand Down Expand Up @@ -1630,11 +1625,6 @@ mod tests {
let cold_feed = WaterSourceWithTemperature::ColdWaterSource(Arc::new(
ColdWaterSource::new(cold_water_temps.to_vec(), &simulation_time, 1.),
));
let control = OnOffTimeControl::new(
vec![true, false, false, false, true, true, true, true],
0,
1.,
);
let energy_supply = Arc::new(Mutex::new(EnergySupply::new(
FuelType::Electricity,
simulation_time.total_steps(),
Expand Down
2 changes: 1 addition & 1 deletion src/core/space_heat_demand/internal_gains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl ApplianceGains {
mod tests {
use super::*;
use crate::core::energy_supply::energy_supply::EnergySupply;
use crate::input::{EnergySupplyType, FuelType};
use crate::input::FuelType;
use crate::simulation_time::{SimulationTime, SimulationTimeIterator};
use parking_lot::Mutex;
use rstest::*;
Expand Down
Loading

0 comments on commit b551948

Please sign in to comment.