Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
shieldo committed Mar 13, 2024
1 parent f460da5 commit e261434
Showing 1 changed file with 52 additions and 3 deletions.
55 changes: 52 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ extern crate lazy_static;

use crate::input::{parse_input_file, ExternalConditionsInput, Input, Ventilation};
use crate::read_weather_file::ExternalConditions as ExternalConditionsFromFile;
use std::borrow::Cow;
use std::collections::HashMap;

use crate::core::units::{SECONDS_PER_HOUR, WATTS_PER_KILOWATT};
use crate::corpus::{Corpus, HotWaterResultMap};
use crate::external_conditions::{DaylightSavingsConfig, ExternalConditions};
use crate::simulation_time::{SimulationTime, SimulationTimeIteration, SimulationTimeIterator};
use csv::Writer;
use lazy_static::lazy_static;
use std::error::Error;
use std::ffi::OsStr;
use std::fmt::Arguments;
use std::ops::Deref;
use std::path::Path;
use std::sync::Arc;
Expand Down Expand Up @@ -178,6 +180,53 @@ fn write_core_output_file(
hc_system_dict: HashMap<&str, HashMap<String, Vec<f64>>>,
hot_water_dict: HashMap<&str, HotWaterResultMap>,
ductwork_gains: HashMap<&str, Vec<f64>>,
) {
//
) -> Result<(), anyhow::Error> {
let mut writer = Writer::from_path(output_file)?;

let mut headings: Vec<Cow<'static, str>> = vec!["Timestep".into()];
let mut units_row = vec!["[count]"];
for totals_key in results_totals.keys() {
let totals_header = format!("{totals_key} total");
headings.push(totals_header.into());
units_row.push("[kWh]");
// TODO enable when energy supplies implemented
// for end_user_key in results_end_user[totals_key].keys() {
// headings.push(end_user_key.into());
// units_row.push("[kWh]");
// }
headings.push(format!("{totals_key} import").into());
units_row.push("[kWh]");
headings.push(format!("{totals_key} export").into());
units_row.push("[kWh]");
headings.push(format!("{totals_key} generated and consumed").into());
units_row.push("[kWh]");
headings.push(format!("{totals_key} beta factor").into());
units_row.push("[ratio]");
headings.push(format!("{totals_key} to storage").into());
units_row.push("[kWh]");
headings.push(format!("{totals_key} from storage").into());
units_row.push("[kWh]");
headings.push(format!("{totals_key} diverted").into());
units_row.push("[kWh]");

// TODO complete me!!!
}

Ok(())
}

lazy_static! {
pub static ref UNITS_MAP: HashMap<&'static str, &'static str> = HashMap::from([
("Internal gains", "[W]"),
("Solar gains", "[W]"),
("Operative temp", "[deg C]"),
("Internal air temp", "[deg C]"),
("Space heat demand", "[kWh]"),
("Space cool demand", "[kWh]"),
("Hot water demand", "[litres]"),
("Hot water energy demand", "[kWh]"),
("Hot water duration", "[mins]"),
("Hot Water Events", "[count]"),
("Pipework losses", "[kWh]")
]);
}

0 comments on commit e261434

Please sign in to comment.