public static WeatherData ToSAM_WeatherData(string path) { if (string.IsNullOrWhiteSpace(path)) { return(null); } WeatherData result = null; string extension = System.IO.Path.GetExtension(path).ToLower().Trim(); if (extension.EndsWith("tbd")) { using (SAMTBDDocument sAMTBDDocument = new SAMTBDDocument(path)) { result = ToSAM_WeatherData(sAMTBDDocument); } } else if (extension.EndsWith("tsd")) { using (SAMTSDDocument sAMTSDDocument = new SAMTSDDocument(path)) { result = ToSAM_WeatherData(sAMTSDDocument); } } return(result); }
public static List <Core.Result> AddResults(this SAMTSDDocument sAMTSDDocument, AdjacencyCluster adjacencyCLuster) { if (sAMTSDDocument == null || adjacencyCLuster == null) { return(null); } return(AddResults(sAMTSDDocument.TSDDocument, adjacencyCLuster)); }
public static List <Core.Result> ToSAM(this SAMTSDDocument sAMTSDDocument) { if (sAMTSDDocument == null) { return(null); } return(ToSAM(sAMTSDDocument.TSDDocument?.SimulationData)); }
public static List <Core.Result> AddResults(this SAMTSDDocument sAMTSDDocument, BuildingModel buildingModel) { if (sAMTSDDocument == null || buildingModel == null) { return(null); } return(AddResults(sAMTSDDocument.TSDDocument, buildingModel)); }
public static WeatherData ToSAM_WeatherData(this SAMTSDDocument sAMTSDDocument, int year = 2018) { if (sAMTSDDocument == null) { return(null); } return(ToSAM_WeatherData(sAMTSDDocument.TSDDocument, year)); }
public static WeatherYear WeatherYear(this SAMTSDDocument sAMTSDDocument, int year = 2018) { if (sAMTSDDocument == null) { return(null); } return(WeatherYear(sAMTSDDocument.TSDDocument, year)); }
public static List <Core.Result> AddResults(this string path_TSD, AdjacencyCluster adjacencyCLuster) { if (adjacencyCLuster == null || string.IsNullOrWhiteSpace(path_TSD)) { return(null); } List <Core.Result> result = null; using (SAMTSDDocument sAMTSDDocument = new SAMTSDDocument(path_TSD, true)) { result = AddResults(sAMTSDDocument, adjacencyCLuster); } return(result); }
public static List <Core.Result> ToSAM(string path_TSD) { if (string.IsNullOrWhiteSpace(path_TSD) || !System.IO.File.Exists(path_TSD)) { return(null); } List <Core.Result> result = null; using (SAMTSDDocument sAMTBDDocument = new SAMTSDDocument(path_TSD, true)) { result = ToSAM(sAMTBDDocument); } return(result); }
public static List <Core.Result> AddResults(this string path_TSD, BuildingModel buildingModel) { if (buildingModel == null || string.IsNullOrWhiteSpace(path_TSD)) { return(null); } List <Core.Result> result = null; using (SAMTSDDocument sAMTSDDocument = new SAMTSDDocument(path_TSD, true)) { result = AddResults(sAMTSDDocument, buildingModel); } return(result); }
public static AdjacencyCluster ToSAM_AdjacencyCluster(this string path_TSD, IEnumerable <SpaceDataType> spaceDataTypes = null, IEnumerable <PanelDataType> panelDataTypes = null) { if (string.IsNullOrWhiteSpace(path_TSD)) { return(null); } AdjacencyCluster result = null; using (SAMTSDDocument sAMTSDDocument = new SAMTSDDocument(path_TSD)) { result = sAMTSDDocument.ToSAM(spaceDataTypes, panelDataTypes); } return(result); }
public static WeatherYear WeatherYear(this string path_TSD, int year = 2018) { if (string.IsNullOrWhiteSpace(path_TSD)) { return(null); } WeatherYear result = null; using (SAMTSDDocument sAMTSDDocument = new SAMTSDDocument(path_TSD, true)) { result = WeatherYear(sAMTSDDocument, year); } return(result); }
public static List <Tuple <string, string, string> > DesignDayNames(this string path_TSD) { if (string.IsNullOrWhiteSpace(path_TSD)) { return(null); } List <Tuple <string, string, string> > result = null; using (SAMTSDDocument sAMTSDDocument = new SAMTSDDocument(path_TSD)) { Dictionary <string, Tuple <CoolingDesignData, double, int, HeatingDesignData, double, int> > dictionary = DesignDataDictionary(sAMTSDDocument); if (dictionary != null) { result = new List <Tuple <string, string, string> >(); foreach (KeyValuePair <string, Tuple <CoolingDesignData, double, int, HeatingDesignData, double, int> > keyValuePair in dictionary) { result.Add(new Tuple <string, string, string>(keyValuePair.Key, keyValuePair.Value.Item1?.name, keyValuePair.Value.Item4?.name)); } } } return(result); }
public static Dictionary <string, Tuple <CoolingDesignData, double, int, HeatingDesignData, double, int> > DesignDataDictionary(this SAMTSDDocument sAMTSDDocument) { return(DesignDataDictionary(sAMTSDDocument?.TSDDocument?.SimulationData)); }
public static AdjacencyCluster ToSAM(this SAMTSDDocument sAMTSDDocument, IEnumerable <SpaceDataType> spaceDataTypes = null, IEnumerable <PanelDataType> panelDataTypes = null) { return(ToSAM(sAMTSDDocument?.TSDDocument, spaceDataTypes, panelDataTypes)); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="dataAccess">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess dataAccess) { int index_Successful; index_Successful = Params.IndexOfOutputParam("successful"); if (index_Successful != -1) { dataAccess.SetData(index_Successful, false); } int index; bool run = false; index = Params.IndexOfInputParam("_run"); if (index != -1) { if (!dataAccess.GetData(index, ref run)) { run = false; } } if (!run) { return; } index = Params.IndexOfInputParam("_pathTasTSD"); if (index == -1) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); return; } string path = null; if (!dataAccess.GetData(index, ref path) || string.IsNullOrWhiteSpace(path) || !System.IO.File.Exists(path)) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); return; } List <PanelDataType> panelDataTypes = null; index = Params.IndexOfInputParam("panelDataTypes_"); if (index != -1) { List <GH_ObjectWrapper> objectWrappers = new List <GH_ObjectWrapper>(); if (dataAccess.GetDataList(index, objectWrappers)) { panelDataTypes = new List <PanelDataType>(); foreach (GH_ObjectWrapper objectWrapper in objectWrappers) { PanelDataType panelDataType = PanelDataType.Undefined; if (objectWrapper.Value is GH_String) { panelDataType = Analytical.Tas.Query.PanelDataType(((GH_String)objectWrapper.Value).Value); } else { panelDataType = Analytical.Tas.Query.PanelDataType(objectWrapper.Value); } if (panelDataType != PanelDataType.Undefined) { panelDataTypes.Add(panelDataType); } } } } List <SpaceDataType> spaceDataTypes = null; index = Params.IndexOfInputParam("spaceDataTypes_"); if (index != -1) { List <GH_ObjectWrapper> objectWrappers = new List <GH_ObjectWrapper>(); if (dataAccess.GetDataList(index, objectWrappers)) { spaceDataTypes = new List <SpaceDataType>(); foreach (GH_ObjectWrapper objectWrapper in objectWrappers) { SpaceDataType spaceDataType = SpaceDataType.Undefined; if (objectWrapper.Value is GH_String) { spaceDataType = Analytical.Tas.Query.SpaceDataType(((GH_String)objectWrapper.Value).Value); } else { spaceDataType = Analytical.Tas.Query.SpaceDataType(objectWrapper.Value); } if (spaceDataType != SpaceDataType.Undefined) { spaceDataTypes.Add(spaceDataType); } } } } AdjacencyCluster adjacencyCluster = null; List <Core.Result> results = new List <Core.Result>(); int index_Result = Params.IndexOfOutputParam("results"); int index_AdjacencyCluster = Params.IndexOfOutputParam("adjacencyCluster"); if (index_Result != -1 || index_AdjacencyCluster != -1) { using (SAMTSDDocument sAMTSDDocument = new SAMTSDDocument(path, true)) { if (index_AdjacencyCluster != -1) { adjacencyCluster = sAMTSDDocument.ToSAM(spaceDataTypes, panelDataTypes); dataAccess.SetData(index_AdjacencyCluster, new GooAdjacencyCluster(adjacencyCluster)); } if (index_Result != -1) { results = Analytical.Tas.Convert.ToSAM(sAMTSDDocument); dataAccess.SetDataList(index_Result, results?.ConvertAll(x => new GooResult(x))); } sAMTSDDocument.Close(); } } if (index_Successful != -1) { dataAccess.SetData(index_Successful, true); } }
public static List <Core.Result> UnmetHours(string path_TSD, string path_TBD, double margin = 0.5) { if (string.IsNullOrWhiteSpace(path_TSD) || !File.Exists(path_TSD)) { return(null); } if (string.IsNullOrWhiteSpace(path_TBD) || !File.Exists(path_TBD)) { return(null); } Dictionary <TBD.Profiles, Dictionary <string, double[]> > temperatureSetPointDictionary = null; using (SAMTBDDocument sAMTBDDocument = new SAMTBDDocument(path_TBD, true)) { temperatureSetPointDictionary = sAMTBDDocument.TBDDocument?.Building?.TemperatureSetPointDictionary(TBD.Profiles.ticLL, TBD.Profiles.ticUL); sAMTBDDocument.Close(); } if (temperatureSetPointDictionary == null || temperatureSetPointDictionary.Count == 0) { return(null); } Dictionary <tsdZoneArray, Dictionary <string, double[]> > yearlyValues = null; Dictionary <string, SpaceSimulationResult> dictionary_SpaceSimulationResult = null; AdjacencyClusterSimulationResult adjacencyClusterSimulationResult = null; using (SAMTSDDocument sAMTSDDocument = new SAMTSDDocument(path_TSD, true)) { BuildingData buildingData = sAMTSDDocument.TSDDocument?.SimulationData?.GetBuildingData(); if (buildingData != null) { adjacencyClusterSimulationResult = Create.AdjacencyClusterSimulationResult(buildingData); yearlyValues = sAMTSDDocument.TSDDocument?.SimulationData?.GetBuildingData()?.YearlyValues(new tsdZoneArray[] { tsdZoneArray.dryBulbTemp, tsdZoneArray.occupantSensibleGain }); dictionary_SpaceSimulationResult = new Dictionary <string, SpaceSimulationResult>(); foreach (KeyValuePair <string, ZoneData> keyValuePair in buildingData.ZoneDataDictionary()) { dictionary_SpaceSimulationResult[keyValuePair.Key] = Create.SpaceSimulationResult(keyValuePair.Value); } } } Dictionary <string, bool[]> dictionary_Heating = null; Dictionary <string, bool[]> dictionary_Cooling = null; if (yearlyValues != null && yearlyValues.Count != 0) { dictionary_Heating = Compare(temperatureSetPointDictionary[TBD.Profiles.ticLL], yearlyValues[tsdZoneArray.dryBulbTemp], margin, LoadType.Heating); if (dictionary_Heating == null) { return(null); } dictionary_Cooling = Compare(temperatureSetPointDictionary[TBD.Profiles.ticUL], yearlyValues[tsdZoneArray.dryBulbTemp], margin, LoadType.Cooling); if (dictionary_Cooling == null) { return(null); } } Dictionary <string, bool[]> dictionary_OccupantSensibleGain = new Dictionary <string, bool[]>(); foreach (KeyValuePair <string, double[]> aKeyValuePair in yearlyValues[tsdZoneArray.occupantSensibleGain]) { dictionary_OccupantSensibleGain.Add(aKeyValuePair.Key, aKeyValuePair.Value.ToList().ConvertAll(x => x > 0).ToArray()); } List <Core.Result> result = new List <Core.Result>(); foreach (KeyValuePair <string, SpaceSimulationResult> keyValuePair in dictionary_SpaceSimulationResult) { SpaceSimulationResult spaceSimulationResult = keyValuePair.Value; if (spaceSimulationResult == null) { continue; } if (dictionary_OccupantSensibleGain.TryGetValue(keyValuePair.Key, out bool[] occupantSensibleGain))