Exemplo n.º 1
0
        public static SpaceSimulationResult SpaceSimulationResult(this ZoneData zoneData, LoadType loadType)
        {
            if (zoneData == null)
            {
                return(null);
            }

            string name      = zoneData.name;
            string reference = zoneData.zoneGUID;
            double area      = zoneData.floorArea;
            double volume    = zoneData.volume;

            SpaceSimulationResult result = Analytical.Create.SpaceSimulationResult(name, Query.Source(), reference, volume, area, loadType, 0);

            ParameterSet parameterSet = ParameterSet_SpaceSimulationResult(ActiveSetting.Setting, zoneData);

            if (parameterSet != null)
            {
                result.Add(parameterSet);
            }

            result.SetValue(SpaceSimulationResultParameter.ZoneGuid, zoneData.zoneGUID);

            return(result);
        }
Exemplo n.º 2
0
        private static SpaceSimulationResult SpaceSimulationResult_Heating(float load_Simulation, int index_Simulation, ZoneData zoneData_Simulation, float load_DesignDay, int index_DesignDay, ZoneData zoneData_DesignDay)
        {
            if (float.IsNaN(load_Simulation) || float.IsNaN(load_DesignDay))
            {
                return(null);
            }

            if (load_Simulation == 0 && load_DesignDay == 0)
            {
                SpaceSimulationResult result = SpaceSimulationResult(zoneData_Simulation, LoadType.Heating);
                if (zoneData_DesignDay != null)
                {
                    double dryBulbTemp = zoneData_DesignDay.GetHourlyZoneResult(1, (short)tsdZoneArray.dryBulbTemp);
                    result.SetValue(Analytical.SpaceSimulationResultParameter.DryBulbTempearture, dryBulbTemp);

                    double resultantTemp = zoneData_DesignDay.GetHourlyZoneResult(1, (short)tsdZoneArray.resultantTemp);
                    result.SetValue(Analytical.SpaceSimulationResultParameter.ResultantTemperature, resultantTemp);
                }
                return(result);
            }

            int          index        = -1;
            ZoneData     zoneData     = null;
            SizingMethod sizingMethod = SizingMethod.Undefined;

            if (load_Simulation > load_DesignDay)
            {
                sizingMethod = SizingMethod.Simulation;
                index        = index_Simulation;
                zoneData     = zoneData_Simulation;
            }
            else
            {
                sizingMethod = SizingMethod.HDD;
                index        = index_DesignDay;
                zoneData     = zoneData_DesignDay;
            }

            return(SpaceSimulationResult(zoneData, index, LoadType.Heating, sizingMethod));
        }
Exemplo n.º 3
0
        public static SpaceSimulationResult SpaceSimulationResult(this TBD.zone zone, LoadType loadType)
        {
            if (zone == null || loadType == LoadType.Undefined)
            {
                return(null);
            }

            string name       = zone.name;
            string reference  = zone.GUID;
            double area       = zone.floorArea;
            double volume     = zone.volume;
            double designLoad = loadType == LoadType.Cooling ? zone.maxCoolingLoad : zone.maxHeatingLoad;

            SpaceSimulationResult result = new SpaceSimulationResult(name, Query.Source(), reference);

            result.SetValue(Analytical.SpaceSimulationResultParameter.Area, area);
            result.SetValue(Analytical.SpaceSimulationResultParameter.Volume, volume);
            result.SetValue(Analytical.SpaceSimulationResultParameter.DesignLoad, designLoad);
            result.SetValue(Analytical.SpaceSimulationResultParameter.LoadType, loadType.Text());

            return(result);
        }
Exemplo n.º 4
0
        public static SpaceSimulationResult ToSAM_SpaceSimulationResult(this TSD.ZoneData zoneData, IEnumerable <SpaceDataType> spaceDataTypes = null)
        {
            SpaceSimulationResult result = new SpaceSimulationResult(zoneData.name, Assembly.GetExecutingAssembly().GetName()?.Name, zoneData.zoneGUID);

            result.SetValue("Zone Number", zoneData.zoneNumber);
            result.SetValue("Description", zoneData.description);
            result.SetValue("Convective Weighting Factors Count", zoneData.nConvWeightingFactors);
            result.SetValue("Radiat Weighting Factors Count", zoneData.nRadWeightingFactors);
            result.SetValue(Analytical.SpaceSimulationResultParameter.Area, zoneData.floorArea);
            result.SetValue(Analytical.SpaceSimulationResultParameter.Volume, zoneData.volume);
            result.SetValue("Convective Common Ratio", zoneData.convectiveCommonRatio);
            result.SetValue("Radiat Common Ratio", zoneData.radiantCommonRatio);

            ParameterSet parameterSet = Create.ParameterSet_SpaceSimulationResult(ActiveSetting.Setting, zoneData);

            if (spaceDataTypes != null)
            {
                foreach (SpaceDataType spaceDataType in spaceDataTypes)
                {
                    List <double> values = zoneData.AnnualZoneResult <double>(spaceDataType);
                    if (values == null)
                    {
                        continue;
                    }

                    JArray jArray = new JArray();
                    values.ForEach(x => jArray.Add(x));

                    parameterSet.Add(spaceDataType.Text(), jArray);
                }
            }

            result.Add(parameterSet);

            result.SetValue(SpaceSimulationResultParameter.ZoneGuid, zoneData.zoneGUID);

            return(result);
        }
Exemplo n.º 5
0
        public static SpaceSimulationResult ToSAM_SpaceSimulationResult(this TAS3D.Zone zone)
        {
            if (zone == null)
            {
                return(null);
            }

            SpaceSimulationResult result = new SpaceSimulationResult(zone.name, Assembly.GetExecutingAssembly().GetName()?.Name, zone.GUID);

            result.SetValue("Color", Core.Convert.ToColor(zone.colour));
            result.SetValue("Description", zone.description);
            result.SetValue("External", zone.external);
            result.SetValue("Is Used", zone.isUsed);
            result.SetValue(Analytical.SpaceSimulationResultParameter.Area, zone.floorArea);
            result.SetValue(Analytical.SpaceSimulationResultParameter.Volume, zone.volume);

            return(result);
        }
Exemplo n.º 6
0
        //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);
        }
Exemplo n.º 7
0
        public static SpaceSimulationResult SpaceSimulationResult(this ZoneData zoneData, int index, LoadType loadType, SizingMethod sizingMethod)
        {
            if (zoneData == null || index == -1 || loadType == LoadType.Undefined)
            {
                return(null);
            }

            string name      = zoneData.name;
            string reference = zoneData.zoneGUID;
            double area      = zoneData.floorArea;
            double volume    = zoneData.volume;

            float dryBulbTemp               = zoneData.GetHourlyZoneResult(index, (short)tsdZoneArray.dryBulbTemp);
            float resultantTemp             = zoneData.GetHourlyZoneResult(index, (short)tsdZoneArray.resultantTemp);
            float load                      = zoneData.GetHourlyZoneResult(index, loadType == LoadType.Cooling ? (short)tsdZoneArray.coolingLoad : (short)tsdZoneArray.heatingLoad);
            float infVentGain               = zoneData.GetHourlyZoneResult(index, (short)tsdZoneArray.infVentGain);
            float airMovementGain           = zoneData.GetHourlyZoneResult(index, (short)tsdZoneArray.airMovementGain);
            float buildingHeatTransfer      = zoneData.GetHourlyZoneResult(index, (short)tsdZoneArray.buildingHeatTransfer);
            float externalConductionGlazing = zoneData.GetHourlyZoneResult(index, (short)tsdZoneArray.externalConductionGlazing);
            float externalConductionOpaque  = zoneData.GetHourlyZoneResult(index, (short)tsdZoneArray.externalConductionOpaque);
            float spaceHumidityRatio        = zoneData.GetHourlyZoneResult(index, (short)tsdZoneArray.humidityRatio);

            SpaceSimulationResult result = null;

            if (loadType == LoadType.Heating)
            {
                result = Analytical.Create.SpaceSimulationResult(name, Query.Source(), reference, volume, area, LoadType.Heating, load, index, sizingMethod, dryBulbTemp, resultantTemp,
                                                                 infiltartionGain: infVentGain,
                                                                 airMovementGain: airMovementGain,
                                                                 buildingHeatTransfer: buildingHeatTransfer,
                                                                 glazingExternalConduction: externalConductionGlazing,
                                                                 opaqueExternalConduction: externalConductionOpaque,
                                                                 humidityRatio: spaceHumidityRatio);
            }
            else if (loadType == LoadType.Cooling)
            {
                float solarGain             = zoneData.GetHourlyZoneResult(index, (short)tsdZoneArray.solarGain);
                float lightingGain          = zoneData.GetHourlyZoneResult(index, (short)tsdZoneArray.lightingGain);
                float occupancySensibleGain = zoneData.GetHourlyZoneResult(index, (short)tsdZoneArray.occupantSensibleGain);
                float equipmentSensibleGain = zoneData.GetHourlyZoneResult(index, (short)tsdZoneArray.equipmentSensibleGain);
                float equipmentLatentGain   = zoneData.GetHourlyZoneResult(index, (short)tsdZoneArray.equipmentLatentGain);
                float occupancyLatentGain   = zoneData.GetHourlyZoneResult(index, (short)tsdZoneArray.occupancyLatentGain);
                float relativeHumidity      = zoneData.GetHourlyZoneResult(index, (short)tsdZoneArray.relativeHumidity);
                float zoneApertureFlowIn    = zoneData.GetHourlyZoneResult(index, (short)tsdZoneArray.zoneApertureFlowIn);
                float zoneApertureFlowOut   = zoneData.GetHourlyZoneResult(index, (short)tsdZoneArray.zoneApertureFlowOut);
                float pollutant             = zoneData.GetHourlyZoneResult(index, (short)tsdZoneArray.pollutant);

                result = Analytical.Create.SpaceSimulationResult(name, Query.Source(), reference, volume, area, loadType, load, index, sizingMethod,
                                                                 dryBulbTemp, resultantTemp, solarGain, lightingGain, infVentGain, airMovementGain,
                                                                 buildingHeatTransfer, externalConductionGlazing, externalConductionOpaque, occupancySensibleGain,
                                                                 occupancyLatentGain, equipmentSensibleGain, equipmentLatentGain, spaceHumidityRatio, relativeHumidity,
                                                                 zoneApertureFlowIn, zoneApertureFlowOut, pollutant);
            }

            if (result == null)
            {
                return(null);
            }

            List <double> dryBulbTemperatures = zoneData.AnnualZoneResult <double>(tsdZoneArray.dryBulbTemp);

            if (dryBulbTemperatures != null)
            {
                result.SetValue(SpaceSimulationResultParameter.DryBulbTemperatureProfile, new Profile("Dry Bulb Temperature", "Annual Space Values", dryBulbTemperatures));
            }

            result.SetValue(SpaceSimulationResultParameter.ZoneGuid, zoneData.zoneGUID);

            ParameterSet parameterSet = ParameterSet_SpaceSimulationResult(ActiveSetting.Setting, zoneData);

            if (parameterSet != null)
            {
                result.Add(parameterSet);
            }

            return(result);
        }
Exemplo n.º 8
0
        public static List <Space> UpdateDesignLoads(this BuildingModel buildingModel, TBDDocument tBDDocument)
        {
            if (tBDDocument == null || buildingModel == null)
            {
                return(null);
            }

            Building building = tBDDocument.Building;

            if (building == null)
            {
                return(null);
            }

            List <Space> spaces = buildingModel.GetSpaces();

            if (spaces == null || spaces.Count == 0)
            {
                return(spaces);
            }

            Dictionary <string, zone> zones = building.ZoneDictionary();

            if (zones == null)
            {
                return(null);
            }

            List <Space> result = new List <Space>();

            foreach (Space space in spaces)
            {
                string name = space?.Name;
                if (string.IsNullOrEmpty(name))
                {
                    continue;
                }

                zone zone;
                if (!zones.TryGetValue(name, out zone) || zone == null)
                {
                    continue;
                }

                result.Add(space);

                space.SetValue(SpaceParameter.DesignHeatingLoad, zone.maxHeatingLoad);
                space.SetValue(SpaceParameter.DesignCoolingLoad, zone.maxCoolingLoad);

                buildingModel.Add(space);

                List <SpaceSimulationResult> spaceSimulationResults = buildingModel.GetResults <SpaceSimulationResult>(space, Query.Source());
                foreach (LoadType loadType in new LoadType[] { LoadType.Heating, LoadType.Cooling })
                {
                    SpaceSimulationResult spaceSimulationResult = spaceSimulationResults?.Find(x => x.LoadType() == loadType);
                    if (spaceSimulationResult == null)
                    {
                        spaceSimulationResult = Create.SpaceSimulationResult(zone, loadType);
                    }
                    else
                    {
                        spaceSimulationResult.SetValue(Analytical.SpaceSimulationResultParameter.Area, zone.floorArea);
                        spaceSimulationResult.SetValue(Analytical.SpaceSimulationResultParameter.Volume, zone.volume);
                        spaceSimulationResult.SetValue(Analytical.SpaceSimulationResultParameter.DesignLoad, loadType == LoadType.Cooling ? zone.maxCoolingLoad : zone.maxHeatingLoad);
                    }

                    if (spaceSimulationResult != null)
                    {
                        buildingModel.Add(spaceSimulationResult, space);
                    }
                }
            }

            return(result);
        }