public static Dictionary <string, ZoneData> ZoneDataDictionary(this CoolingDesignData coolingDesignData) { if (coolingDesignData == null) { return(null); } Dictionary <string, ZoneData> result = new Dictionary <string, ZoneData>(); int index = 1; ZoneData zoneData = coolingDesignData.GetZoneData(index); while (zoneData != null) { string reference = zoneData.zoneGUID; if (reference == null) { continue; } result[reference] = zoneData; index++; zoneData = coolingDesignData.GetZoneData(index); } return(result); }
public static List <ZoneData> ZoneDatas(this CoolingDesignData coolingDesignData) { if (coolingDesignData == null) { return(null); } List <ZoneData> result = new List <ZoneData>(); int index = 1; ZoneData zoneData = coolingDesignData.GetZoneData(index); while (zoneData != null) { result.Add(zoneData); index++; zoneData = coolingDesignData.GetZoneData(index); } return(result); }
public static Dictionary <string, Tuple <CoolingDesignData, double, int, HeatingDesignData, double, int> > DesignDataDictionary(this SimulationData simulationData) { if (simulationData == null) { return(null); } Dictionary <string, Tuple <double, int, CoolingDesignData> > dictionary_DesignDay_Cooling = MaxValueDictionary(simulationData.CoolingDesignDatas(), tsdZoneArray.coolingLoad); Dictionary <string, Tuple <double, int, HeatingDesignData> > dictionary_DesignDay_Heating = MaxValueDictionary(simulationData.HeatingDesignDatas(), tsdZoneArray.heatingLoad); BuildingData buildingData = simulationData.GetBuildingData(); if (buildingData != null) { Dictionary <string, Tuple <double, int> > dictionary = null; dictionary = ValueDictionary(buildingData, tsdZoneArray.coolingLoad); if (dictionary != null && dictionary_DesignDay_Cooling != null) { foreach (KeyValuePair <string, Tuple <double, int> > keyValuePair in dictionary) { if (!dictionary_DesignDay_Cooling.TryGetValue(keyValuePair.Key, out Tuple <double, int, CoolingDesignData> tuple) || tuple == null) { continue; } if (tuple.Item1 < keyValuePair.Value.Item1) { tuple = new Tuple <double, int, CoolingDesignData>(keyValuePair.Value.Item1, keyValuePair.Value.Item2, null); dictionary_DesignDay_Cooling[keyValuePair.Key] = tuple; } } } dictionary = ValueDictionary(buildingData, tsdZoneArray.heatingLoad); if (dictionary != null && dictionary_DesignDay_Heating != null) { foreach (KeyValuePair <string, Tuple <double, int> > keyValuePair in dictionary) { if (!dictionary_DesignDay_Heating.TryGetValue(keyValuePair.Key, out Tuple <double, int, HeatingDesignData> tuple) || tuple == null) { continue; } if (tuple.Item1 < keyValuePair.Value.Item1) { tuple = new Tuple <double, int, HeatingDesignData>(keyValuePair.Value.Item1, keyValuePair.Value.Item2, null); dictionary_DesignDay_Heating[keyValuePair.Key] = tuple; } } } } Dictionary <string, Tuple <CoolingDesignData, double, int, HeatingDesignData, double, int> > result = new Dictionary <string, Tuple <CoolingDesignData, double, int, HeatingDesignData, double, int> >(); if (dictionary_DesignDay_Cooling != null) { foreach (KeyValuePair <string, Tuple <double, int, CoolingDesignData> > keyValuePair_Cooling in dictionary_DesignDay_Cooling) { Tuple <double, int, HeatingDesignData> tuple_Heating = null; if (dictionary_DesignDay_Heating == null || !dictionary_DesignDay_Heating.TryGetValue(keyValuePair_Cooling.Key, out tuple_Heating)) { tuple_Heating = null; } double coolingLoad = keyValuePair_Cooling.Value.Item1; int coolingIndex = keyValuePair_Cooling.Value.Item2; CoolingDesignData coolingDesignData = keyValuePair_Cooling.Value.Item3; double heatingLoad = double.NaN; int heatingIndex = -1; HeatingDesignData heatingDesignData = null; if (tuple_Heating != null) { heatingLoad = tuple_Heating.Item1; heatingDesignData = tuple_Heating.Item3; heatingIndex = tuple_Heating.Item2; } result[keyValuePair_Cooling.Key] = new Tuple <CoolingDesignData, double, int, HeatingDesignData, double, int>(coolingDesignData, coolingLoad, coolingIndex, heatingDesignData, heatingLoad, heatingIndex); } } if (dictionary_DesignDay_Heating != null) { foreach (KeyValuePair <string, Tuple <double, int, HeatingDesignData> > keyValuePair_Heating in dictionary_DesignDay_Heating) { if (result.ContainsKey(keyValuePair_Heating.Key)) { continue; } double coolingLoad = double.NaN; int coolingIndex = -1; CoolingDesignData coolingDesignData = null; double heatingLoad = keyValuePair_Heating.Value.Item1; HeatingDesignData heatingDesignData = keyValuePair_Heating.Value.Item3; int heatingIndex = keyValuePair_Heating.Value.Item2; result[keyValuePair_Heating.Key] = new Tuple <CoolingDesignData, double, int, HeatingDesignData, double, int>(coolingDesignData, coolingLoad, coolingIndex, heatingDesignData, heatingLoad, heatingIndex); } } return(result); }
//Pull/Convert data for Spaces (in Tas they call them Zones) but not for SAM Zones (in Tas ZoneGroups) public static List <Core.Result> ToSAM(SimulationData simulationData) { //buildingData is is yearly dynamic simulation data BuildingData buildingData = simulationData?.GetBuildingData(); if (buildingData == null) { return(null); } List <ZoneData> zoneDatas = Query.ZoneDatas(buildingData); if (zoneDatas == null || zoneDatas.Count == 0) { return(null); } Dictionary <string, Tuple <CoolingDesignData, double, int, HeatingDesignData, double, int> > designDataDictionary = Query.DesignDataDictionary(simulationData); List <List <Core.Result> > results = Enumerable.Repeat <List <Core.Result> >(null, zoneDatas.Count).ToList(); foreach (KeyValuePair <string, Tuple <CoolingDesignData, double, int, HeatingDesignData, double, int> > keyValuePair in designDataDictionary) { int index = zoneDatas.FindIndex(x => x.zoneGUID == keyValuePair.Key); if (index == -1) { continue; } ZoneData zoneData_BuildingData = zoneDatas[index]; if (zoneData_BuildingData == null) { continue; } SizingMethod sizingMethod = SizingMethod.Undefined; ZoneData zoneData_Cooling = zoneData_BuildingData; CoolingDesignData coolingDesignData = keyValuePair.Value.Item1; double coolingLoad = keyValuePair.Value.Item2; int coolingIndex = keyValuePair.Value.Item3; if (coolingDesignData != null) { sizingMethod = SizingMethod.CDD; zoneData_Cooling = coolingDesignData.GetZoneData(zoneData_BuildingData.zoneNumber); } else { sizingMethod = SizingMethod.Simulation; } ZoneData zoneData_Heating = zoneData_BuildingData; SpaceSimulationResult spaceSimulationResult_Cooling = Create.SpaceSimulationResult(zoneData_Cooling, coolingIndex, LoadType.Cooling, sizingMethod); if (spaceSimulationResult_Cooling != null && coolingDesignData != null) { spaceSimulationResult_Cooling.SetValue(SpaceSimulationResultParameter.DesignDayName, coolingDesignData.name); } HeatingDesignData heatingDesignData = keyValuePair.Value.Item4; double heatingLoad = keyValuePair.Value.Item5; int heatingIndex = keyValuePair.Value.Item6; if (heatingDesignData != null) { sizingMethod = SizingMethod.HDD; zoneData_Heating = heatingDesignData.GetZoneData(zoneData_BuildingData.zoneNumber); } else { sizingMethod = SizingMethod.Simulation; } SpaceSimulationResult spaceSimulationResult_Heating = Create.SpaceSimulationResult(zoneData_Heating, heatingIndex, LoadType.Heating, sizingMethod); if (spaceSimulationResult_Heating != null && heatingDesignData != null) { spaceSimulationResult_Heating.SetValue(SpaceSimulationResultParameter.DesignDayName, heatingDesignData.name); } if (spaceSimulationResult_Cooling != null || spaceSimulationResult_Heating != null) { Dictionary <Analytical.SpaceSimulationResultParameter, object> dictionary = Query.Overheating(zoneData_BuildingData, simulationData.firstDay, simulationData.lastDay); results[index] = new List <Core.Result>(); if (spaceSimulationResult_Cooling != null) { foreach (KeyValuePair <Analytical.SpaceSimulationResultParameter, object> keyValuePair_Temp in dictionary) { spaceSimulationResult_Cooling.SetValue(keyValuePair_Temp.Key, keyValuePair_Temp.Value); } results[index].Add(spaceSimulationResult_Cooling); } if (spaceSimulationResult_Heating != null) { foreach (KeyValuePair <Analytical.SpaceSimulationResultParameter, object> keyValuePair_Temp in dictionary) { spaceSimulationResult_Heating.SetValue(keyValuePair_Temp.Key, keyValuePair_Temp.Value); } results[index].Add(spaceSimulationResult_Heating); } } if (spaceSimulationResult_Cooling != null) { if (!spaceSimulationResult_Cooling.TryGetValue(Analytical.SpaceSimulationResultParameter.LoadIndex, out int loadIndex)) { continue; } List <PanelSimulationResult> panelSimulationResults = zoneData_Cooling.ToSAM_PanelSimulationResults(loadIndex); if (panelSimulationResults == null) { continue; } foreach (PanelSimulationResult panelSimulationResult in panelSimulationResults) { panelSimulationResult.SetValue(Analytical.PanelSimulationResultParameter.LoadType, LoadType.Cooling.ToString()); results[index].Add(panelSimulationResult); } } if (spaceSimulationResult_Heating != null) { if (!spaceSimulationResult_Heating.TryGetValue(Analytical.SpaceSimulationResultParameter.LoadIndex, out int loadIndex)) { continue; } List <PanelSimulationResult> panelSimulationResults = zoneData_Heating.ToSAM_PanelSimulationResults(loadIndex); if (panelSimulationResults == null) { continue; } foreach (PanelSimulationResult panelSimulationResult in panelSimulationResults) { panelSimulationResult.SetValue(Analytical.PanelSimulationResultParameter.LoadType, LoadType.Heating.ToString()); results[index].Add(panelSimulationResult); } } } List <Core.Result> result = new List <Core.Result>(); foreach (List <Core.Result> spaceSimulationResults_Temp in results) { if (spaceSimulationResults_Temp != null) { result.AddRange(spaceSimulationResults_Temp); } } return(result); }
public static Dictionary <string, Tuple <double, int, CoolingDesignData> > MaxValueDictionary(this IEnumerable <CoolingDesignData> coolingDesignDatas, tsdZoneArray tsdZoneArray) { if (coolingDesignDatas == null) { return(null); } Dictionary <string, Tuple <double, int, CoolingDesignData> > result = new Dictionary <string, Tuple <double, int, CoolingDesignData> >(); if (coolingDesignDatas.Count() == 0) { return(result); } CoolingDesignData coolingDesignData = coolingDesignDatas.ElementAt(0); if (coolingDesignData == null) { return(result); } List <ZoneData> zoneDatas = coolingDesignData.ZoneDatas(); if (zoneDatas == null || zoneDatas.Count == 0) { return(result); } object[,] values = coolingDesignData.GetPeakZoneGains(new short[1] { (short)tsdZoneArray }); for (int i = 0; i < zoneDatas.Count; i++) { string id = zoneDatas[i].zoneGUID; double value = (float)values[1, i]; int index = (int)values[2, i]; result[id] = new Tuple <double, int, CoolingDesignData>(value, index, coolingDesignData); } for (int i = 1; i < coolingDesignDatas.Count(); i++) { values = coolingDesignDatas.ElementAt(i).GetPeakZoneGains(new short[1] { (short)tsdZoneArray }); for (int j = 0; j < zoneDatas.Count; j++) { string id = zoneDatas[j].zoneGUID; double value = (float)values[1, j]; int index = (int)values[2, j]; if (!result.TryGetValue(id, out Tuple <double, int, CoolingDesignData> tuple)) { result[id] = new Tuple <double, int, CoolingDesignData>(value, index, coolingDesignData); } else if (tuple.Item1 < value) { tuple = new Tuple <double, int, CoolingDesignData>(value, index, coolingDesignDatas.ElementAt(i)); result[id] = tuple; } } } return(result); }
public static Dictionary <string, double[]> YearlyValues(this CoolingDesignData coolingDesignData, tsdZoneArray tSDZoneArray) { return(YearlyValues(coolingDesignData, new tsdZoneArray[] { tSDZoneArray })?[tSDZoneArray]); }
public static Dictionary <tsdZoneArray, Dictionary <string, double[]> > YearlyValues(this CoolingDesignData coolingDesignData, IEnumerable <tsdZoneArray> tSDZoneArrays) { if (coolingDesignData == null || tSDZoneArrays == null) { return(null); } return(YearlyValues(coolingDesignData.ZoneDatas(), tSDZoneArrays)); }