Skip to content

Commit

Permalink
make clippy/other warning fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shieldo committed Oct 16, 2024
1 parent abf9d80 commit e687c18
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 37 deletions.
5 changes: 3 additions & 2 deletions src/core/ductwork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ const EXTERNAL_REFLECTIVE_HTC: f64 = 5.7;
// low emissivity reflective surface, CIBSE Guide C, Table 3.25
const EXTERNAL_NONREFLECTIVE_HTC: f64 = 10.0; // high emissivity non-reflective surface, CIBSE Guide C, Table 3.25

/// A struct to represent ductwork for mechanical ventilation with heat recovery
/// (MVHR), assuming steady state heat transfer in, 1. a hollow cylinder (duct)
/// A struct to represent ductwork for mechanical ventilation with heat recovery (MVHR)
///
/// Assumes steady state heat transfer in, 1. a hollow cylinder (duct)
/// with radial heat flow and 2. a rectangular cross-section ISO 12241:2022
#[derive(Clone, Copy)]
pub struct Ductwork {
Expand Down
3 changes: 1 addition & 2 deletions src/core/energy_supply/pv.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// This module contains objects that represent photovoltaic systems.
use crate::compare_floats::min_of_2;
use crate::core::energy_supply::energy_supply::EnergySupplyConnection;
use crate::core::space_heat_demand::building_element::projected_height;
Expand All @@ -7,8 +8,6 @@ use crate::input::OnSiteGenerationVentilationStrategy;
use crate::simulation_time::SimulationTimeIteration;
use std::sync::Arc;

/// This module contains objects that represent photovoltaic systems.

/// system performance factor lookup
/// informative values from table C.4 Annex C BS EN 15316-4-3:2017
/// note from 6.2.4.7.2 rear surface free - is if PV system is not integrated.
Expand Down
6 changes: 2 additions & 4 deletions src/core/heating_systems/emitters.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// This module provides objects to represent radiator and underfloor emitter systems.
use crate::compare_floats::{max_of_2, min_of_2};
use crate::core::heating_systems::common::SpaceHeatingService;
use crate::core::heating_systems::heat_pump::{
Expand All @@ -17,8 +18,6 @@ type State = Vector1<f64>; // type State = OVector<f32, U3>;
type Time = f64;
// type Result = SolverResult<Time, State>;

/// This module provides objects to represent radiator and underfloor emitter systems.

/// Convert flow temperature to return temperature using the 6/7th rule.
///
/// Parameters:
Expand Down Expand Up @@ -408,8 +407,7 @@ impl Emitters {
// finds the exact x (time) value for that event occuring
// and sets time_temp_diff_max_reached

let mut y_out_reversed: Vec<f64> =
stepper.y_out().iter().flatten().copied().collect();
let mut y_out_reversed: Vec<f64> = stepper.y_out().iter().flatten().copied().collect();
y_out_reversed.reverse();

let mut x_out_reversed = stepper.x_out().clone();
Expand Down
3 changes: 1 addition & 2 deletions src/core/heating_systems/heat_battery.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/// This module provides object(s) to model the behaviour of heat batteries.
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};
Expand All @@ -9,8 +10,6 @@ use parking_lot::{Mutex, RwLock};
use std::collections::HashMap;
use std::sync::Arc;

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

pub enum ServiceType {
WaterRegular,
Space,
Expand Down
11 changes: 5 additions & 6 deletions src/core/heating_systems/heat_pump.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/// This module provides objects to represent heat pumps and heat pump test data.
/// The calculations are based on the DAHPSE method developed for generating PCDB
/// entries for SAP 2012 and SAP 10. DAHPSE was based on a draft of
/// BS EN 15316-4-2:2017 and is described in the SAP calculation method CALCM-01.
use crate::compare_floats::{max_of_2, min_of_2};
use crate::core::common::WaterSourceWithTemperature;
use crate::core::controls::time_control::{per_control, Control, ControlBehaviour};
Expand Down Expand Up @@ -36,11 +40,6 @@ use std::iter::Sum;
use std::ops::{Add, AddAssign, Div};
use std::sync::Arc;

/// This module provides objects to represent heat pumps and heat pump test data.
/// The calculations are based on the DAHPSE method developed for generating PCDB
/// entries for SAP 2012 and SAP 10. DAHPSE was based on a draft of
/// BS EN 15316-4-2:2017 and is described in the SAP calculation method CALCM-01.

const N_EXER: f64 = 3.0;

impl HeatPumpSourceType {
Expand Down Expand Up @@ -814,7 +813,7 @@ impl HeatPumpTestData {

self.test_data[&OrderedFloat(dsgn_flow_temp)]
.iter()
.position(|test_record| &test_record.test_letter.to_string() == test_condition)
.position(|test_record| test_record.test_letter.to_string() == test_condition)
}

/// Return value at specified test condition, interpolated between design flow temps
Expand Down
5 changes: 2 additions & 3 deletions src/core/heating_systems/instant_elec_heater.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/// This module provides object(s) to model the behaviour of instantaneous electric
/// room heaters.
use crate::compare_floats::min_of_2;
use crate::core::controls::time_control::{per_control, Control, ControlBehaviour};
use crate::core::energy_supply::energy_supply::EnergySupplyConnection;
use crate::simulation_time::SimulationTimeIteration;
use std::sync::Arc;

/// This module provides object(s) to model the behaviour of instantaneous electric
/// room heaters.

/// Type to represent instantaneous electric heaters
#[derive(Clone)]
pub struct InstantElecHeater {
Expand Down
6 changes: 3 additions & 3 deletions src/core/space_heat_demand/thermal_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ pub fn heat_transfer_coefficient_for_thermal_bridge(thermal_bridge: &ThermalBrid
}
}

/// Converts the serde_json value for ThermalBridging into structs as have not been able to handle these variants
/// Ultimately this field in the JSON should be divided into different attributes (one for bridging elements, one for a number)
/// and then this would not be necessary (as serde_json would handle it) and could be removed!
// Converts the serde_json value for ThermalBridging into structs as have not been able to handle these variants
// Ultimately this field in the JSON should be divided into different attributes (one for bridging elements, one for a number)
// and then this would not be necessary (as serde_json would handle it) and could be removed!
pub fn thermal_bridging_from_input(input: Value) -> ThermalBridging {
match input {
Value::Object(map) => {
Expand Down
14 changes: 7 additions & 7 deletions src/core/space_heat_demand/zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1421,13 +1421,13 @@ impl Hash for NamedBuildingElement {
}
}

/// There are cases where functions in the upstream Python code have some optional arguments to do with
/// air changes per hour (ach), but EITHER ach_cooling OR both ach_target and ach_windows_open need to
/// have values given (i.e. not None). The relation between these arguments is not explicit in the Python,
/// but de facto the above both always holds and must hold in order for there not to be errors present
/// such as arithmetic attempted with None values. This enum makes this relationship between arguments
/// explicit in the Rust, so that we aren't forced to make assertions about the "someness" of a value
/// when we need to use the underlying argument values.
// There are cases where functions in the upstream Python code have some optional arguments to do with
// air changes per hour (ach), but EITHER ach_cooling OR both ach_target and ach_windows_open need to
// have values given (i.e. not None). The relation between these arguments is not explicit in the Python,
// but de facto the above both always holds and must hold in order for there not to be errors present
// such as arithmetic attempted with None values. This enum makes this relationship between arguments
// explicit in the Rust, so that we aren't forced to make assertions about the "someness" of a value
// when we need to use the underlying argument values.
#[derive(Clone, Copy, Debug)]
pub enum AirChangesPerHourArgument {
Cooling {
Expand Down
2 changes: 1 addition & 1 deletion src/corpus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4212,7 +4212,7 @@ fn space_heat_systems_from_input(
heat_system_names_requiring_overvent: &mut Vec<String>,
heat_system_name_for_zone: &IndexMap<String, String>,
zones: &Arc<IndexMap<String, Zone>>,
heat_sources_wet_with_buffer_tank: &Vec<String>,
heat_sources_wet_with_buffer_tank: &[String],
temp_internal_air_accessor: TempInternalAirAccessor,
external_conditions: Arc<ExternalConditions>,
) -> anyhow::Result<SpaceHeatSystemsWithEnergyConnections> {
Expand Down
17 changes: 11 additions & 6 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,11 @@ pub enum SecondarySupplyType {
Diverter,
}

/// TODO clarify further
/// It's not completely clear at the moment what the difference between fuel type and energy supply type is,
/// but electricity and gas each seem to be indicated using different strings between fuel and energy supply
/// in the input examples, so keeping them separate for the time being
/// (It's also hard to see some of these as types of fuel)
// TODO clarify further
// It's not completely clear at the moment what the difference between fuel type and energy supply type is,
// but electricity and gas each seem to be indicated using different strings between fuel and energy supply
// in the input examples, so keeping them separate for the time being
// (It's also hard to see some of these as types of fuel)
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
Expand Down Expand Up @@ -544,13 +544,15 @@ pub(crate) enum ControlDetails {
OnOffTime {
start_day: u32,
time_series_step: f64,
#[allow(dead_code)]
logic_type: Option<ControlLogicType>,
schedule: BooleanSchedule,
},
#[serde(rename = "OnOffCostMinimisingTimeControl")]
OnOffCostMinimisingTime {
start_day: u32,
time_series_step: f64,
#[allow(dead_code)]
logic_type: Option<ControlLogicType>,
time_on_daily: Option<f64>,
schedule: NumericSchedule,
Expand All @@ -560,6 +562,7 @@ pub(crate) enum ControlDetails {
start_day: u32,
time_series_step: f64,
advanced_start: Option<f64>,
#[allow(dead_code)]
logic_type: Option<ControlLogicType>,
setpoint_min: Option<f64>,
setpoint_max: Option<f64>,
Expand All @@ -570,9 +573,11 @@ pub(crate) enum ControlDetails {
ToUCharge {
start_day: u32,
time_series_step: f64,
#[allow(dead_code)]
logic_type: Option<ControlLogicType>,
charge_level: Option<ChargeLevel>,
target_charge: Option<f64>,
#[serde(rename = "target_charge")]
_target_charge: Option<f64>,
schedule: BooleanSchedule,
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use serde_json::json;
/// This module provides functions to implement pre- and post-processing
/// steps for the Fabric Energy Efficiency calculation run for the Future Homes
/// Standard.

pub fn apply_fhs_fee_preprocessing(input: &mut InputForProcessing) -> anyhow::Result<()> {
// Calculation assumptions (expressed in comments) are based on SAP 10.2 FEE specification
//
Expand Down

0 comments on commit e687c18

Please sign in to comment.