From f460da5efbaa1bb81fa7b8092fa71ed279566d77 Mon Sep 17 00:00:00 2001 From: Douglas Greenshields Date: Wed, 13 Mar 2024 19:46:50 +0000 Subject: [PATCH] WIP --- src/lib.rs | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 68 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 4604997..20c1b60 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -17,11 +17,12 @@ use crate::read_weather_file::ExternalConditions as ExternalConditionsFromFile; use std::collections::HashMap; use crate::core::units::{SECONDS_PER_HOUR, WATTS_PER_KILOWATT}; -use crate::corpus::Corpus; +use crate::corpus::{Corpus, HotWaterResultMap}; use crate::external_conditions::{DaylightSavingsConfig, ExternalConditions}; use crate::simulation_time::{SimulationTime, SimulationTimeIteration, SimulationTimeIterator}; use std::error::Error; use std::ffi::OsStr; +use std::fmt::Arguments; use std::ops::Deref; use std::path::Path; use std::sync::Arc; @@ -41,9 +42,9 @@ pub fn run_project( Some(ext) => &input_file[..(input_file.len() - ext.len() - 1)], None => input_file, }; - let _output_file = format_args!("{input_file_stem}_results.csv"); - let _output_file_static = format_args!("{input_file_stem}_results_static.csv"); - let _output_file_summary = format_args!("{input_file_stem}_results_summary.csv"); + let output_file_detailed = format!("{input_file_stem}_results.csv"); + let _output_file_static = format!("{input_file_stem}_results_static.csv"); + let _output_file_summary = format!("{input_file_stem}_results_summary.csv"); println!("about to try and open {}", input_file); @@ -61,7 +62,48 @@ pub fn run_project( let mut corpus: Corpus = Corpus::from_inputs(input, external_conditions)?; - corpus.run(); + let ( + timestep_array, + results_totals, + results_end_user, + energy_import, + energy_export, + energy_generated_consumed, + energy_to_storage, + energy_from_storage, + energy_diverted, + betafactor, + zone_dict, + zone_list, + hc_system_dict, + hot_water_dict, + heat_cop_dict, + cool_cop_dict, + dhw_cop_dict, + ductwork_gains, + heat_balance_dict, + heat_source_wet_results_dict, + heat_source_wet_results_annual_dict, + ) = corpus.run(); + + write_core_output_file( + output_file_detailed, + timestep_array, + results_totals, + results_end_user, + energy_import, + energy_export, + energy_generated_consumed, + energy_to_storage, + energy_from_storage, + energy_diverted, + betafactor, + zone_dict, + zone_list, + hc_system_dict, + hot_water_dict, + ductwork_gains, + ); Ok(()) } @@ -118,3 +160,24 @@ fn external_conditions_from_input( ), } } + +fn write_core_output_file( + output_file: String, + timestep_array: Vec, + results_totals: HashMap<&str, f64>, + results_end_user: HashMap<&str, HashMap<&str, f64>>, + energy_import: HashMap<&str, f64>, + energy_export: HashMap<&str, f64>, + energy_generated_consumed: HashMap<&str, f64>, + energy_to_storage: HashMap<&str, f64>, + energy_from_storage: HashMap<&str, f64>, + energy_diverted: HashMap<&str, f64>, + betafactor: HashMap<&str, f64>, + zone_dict: HashMap<&str, HashMap>>, + zone_list: Vec<&str>, + hc_system_dict: HashMap<&str, HashMap>>, + hot_water_dict: HashMap<&str, HotWaterResultMap>, + ductwork_gains: HashMap<&str, Vec>, +) { + // +}