Пример #1
0
        /***************************************************/

        public static List <BHEG.Profile> Profiles(this TBD.Thermostat tbdThermostat)
        {
            List <BHEG.Profile> bHoMProfiles = new List <BHEG.Profile>();

            bHoMProfiles.Add(tbdThermostat.GetProfile((int)TBD.Profiles.ticUL).FromTAS());
            bHoMProfiles.Add(tbdThermostat.GetProfile((int)TBD.Profiles.ticUL).FromTAS());
            bHoMProfiles.Add(tbdThermostat.GetProfile((int)TBD.Profiles.ticHUL).FromTAS());
            bHoMProfiles.Add(tbdThermostat.GetProfile((int)TBD.Profiles.ticHLL).FromTAS());

            return(bHoMProfiles);
        }
Пример #2
0
        public static Profile ToSAM(this TBD.Thermostat thermostat, TBD.Profiles profiles, ProfileType profileType, string prefix = null)
        {
            if (thermostat == null)
            {
                return(null);
            }

            TBD.profile profile = thermostat.GetProfile((int)profiles);
            if (profile == null)
            {
                return(null);
            }

            List <double> values = Core.Tas.Query.Values(profile);

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

            string name = null;

            if (string.IsNullOrEmpty(prefix))
            {
                name = profile.name;
            }
            else
            {
                name = string.Format("{0} [{1}]", prefix, profile.name);
            }

            Profile result = new Profile(name, profileType, values);

            return(result);
        }
Пример #3
0
        public static float GetSingleValueUpperLimit(this TBD.Thermostat tbdICThermostat)
        {
            float maxUL = 150;

            if (tbdICThermostat == null)
            {
                return(-1);
            }

            TBD.profile tbdUpperLimitProfile = tbdICThermostat.GetProfile((int)TBD.Profiles.ticUL);
            switch (tbdUpperLimitProfile.type)
            {
            case TBD.ProfileTypes.ticValueProfile:
                maxUL = tbdUpperLimitProfile.value;
                break;

            case TBD.ProfileTypes.ticHourlyProfile:
                for (int i = 1; i <= 24; i++)
                {
                    if (tbdUpperLimitProfile.hourlyValues[i] <= maxUL)
                    {
                        maxUL = tbdUpperLimitProfile.hourlyValues[i];
                    }
                }

                break;

            case TBD.ProfileTypes.ticYearlyProfile:
                for (int i = 1; i <= 8760; i++)
                {
                    if (tbdUpperLimitProfile.yearlyValues[i] >= maxUL)
                    {
                        maxUL = tbdUpperLimitProfile.yearlyValues[i];
                    }
                }
                break;
                // case other profile types etc.
            }

            return(maxUL);
        }
        public static bool UpdateInternalCondition_HDD(this TBD.InternalCondition internalCondition_TBD, InternalCondition internalCondition, ProfileLibrary profileLibrary)
        {
            if (internalCondition_TBD == null || internalCondition == null)
            {
                return(false);
            }

            internalCondition_TBD.description = internalCondition.Name + " - HDD";

            internalCondition_TBD.includeSolarInMRT = 0;

            TBD.Emitter emitter = null;
            double      value   = double.NaN;

            emitter = internalCondition_TBD.GetHeatingEmitter();
            if (emitter != null)
            {
                if (internalCondition.TryGetValue(InternalConditionParameter.HeatingEmitterRadiantProportion, out value))
                {
                    emitter.radiantProportion = System.Convert.ToSingle(value);
                }

                if (internalCondition.TryGetValue(InternalConditionParameter.HeatingEmitterCoefficient, out value))
                {
                    emitter.viewCoefficient = System.Convert.ToSingle(value);
                }
            }

            emitter = internalCondition_TBD.GetCoolingEmitter();
            if (emitter != null)
            {
                if (internalCondition.TryGetValue(InternalConditionParameter.CoolingEmitterRadiantProportion, out value))
                {
                    emitter.radiantProportion = System.Convert.ToSingle(value);
                }

                if (internalCondition.TryGetValue(InternalConditionParameter.CoolingEmitterCoefficient, out value))
                {
                    emitter.viewCoefficient = System.Convert.ToSingle(value);
                }
            }

            TBD.InternalGain internalGain = internalCondition_TBD.GetInternalGain();
            internalGain.name = internalCondition.Name + " - HDD";

            Profile profile = null;

            profile = internalCondition.GetProfile(ProfileType.Infiltration, profileLibrary);
            if (profile != null)
            {
                if (internalCondition.TryGetValue(InternalConditionParameter.InfiltrationAirChangesPerHour, out value))
                {
                    TBD.profile profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticI);
                    if (profile_TBD != null)
                    {
                        profile_TBD.name   = profile.Name;
                        profile_TBD.type   = TBD.ProfileTypes.ticValueProfile;
                        profile_TBD.factor = 1;
                        profile_TBD.value  = System.Convert.ToSingle(value);
                    }
                }
            }

            TBD.Thermostat thermostat = internalCondition_TBD.GetThermostat();
            if (thermostat != null)
            {
                thermostat.controlRange        = 0;
                thermostat.proportionalControl = 0;

                profile = internalCondition.GetProfile(ProfileType.Heating, profileLibrary);
                if (profile != null)
                {
                    thermostat.name = profile.Name;

                    TBD.profile profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticLL);
                    if (profile_TBD != null)
                    {
                        value = profile.MaxValue;
                        if (!double.IsNaN(value))
                        {
                            profile_TBD.name   = profile.Name;
                            profile_TBD.type   = TBD.ProfileTypes.ticValueProfile;
                            profile_TBD.factor = 1;
                            profile_TBD.value  = System.Convert.ToSingle(value);
                        }
                    }
                }
            }

            return(true);
        }
        public static Dictionary <TBD.Profiles, Dictionary <string, double[]> > TemperatureSetPointDictionary(this TBD.Building building, params TBD.Profiles[] profiles)
        {
            List <TBD.zone> zones = building?.Zones();

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

            List <TBD.dayType> dayTypes = building.DayTypes();

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

            Dictionary <TBD.Profiles, Dictionary <string, Dictionary <string, double[]> > > dictionary_DayType = new Dictionary <TBD.Profiles, Dictionary <string, Dictionary <string, double[]> > >();

            foreach (TBD.Profiles profiles_Enum in profiles)
            {
                dictionary_DayType[profiles_Enum] = new Dictionary <string, Dictionary <string, double[]> >();

                foreach (TBD.dayType dayType in dayTypes)
                {
                    Dictionary <string, double[]> dictionary_Zone = new Dictionary <string, double[]>();
                    dictionary_DayType[profiles_Enum][dayType.name] = dictionary_Zone;

                    foreach (TBD.zone zone in zones)
                    {
                        TBD.InternalCondition internalCondition = InternalCondition(zone, dayType);
                        if (internalCondition == null)
                        {
                            continue;
                        }

                        TBD.Thermostat thermostat  = internalCondition.GetThermostat();
                        TBD.profile    profile     = thermostat.GetProfile((int)profiles_Enum);
                        double[]       dailyValues = DailyValues(profile);
                        dictionary_Zone.Add(zone.GUID, dailyValues);
                    }
                }
            }

            dayTypes = building.DayTypes(0, 365);

            Dictionary <TBD.Profiles, Dictionary <string, double[]> > result = new Dictionary <TBD.Profiles, Dictionary <string, double[]> >();

            foreach (KeyValuePair <TBD.Profiles, Dictionary <string, Dictionary <string, double[]> > > keyValuePair in dictionary_DayType)
            {
                Dictionary <string, double[]> dictionary_Zone = new Dictionary <string, double[]>();

                foreach (TBD.zone zone in zones)
                {
                    bool exists = true;

                    double[] yearlyValues = new double[8760];
                    int      aCount       = 0;
                    for (int i = 0; i < 365; i++)
                    {
                        TBD.dayType dayType = dayTypes[i];

                        if (!keyValuePair.Value.ContainsKey(dayType.name) || !keyValuePair.Value[dayType.name].ContainsKey(zone.GUID))
                        {
                            exists = false;
                            break;
                        }

                        double[] dailyValues = keyValuePair.Value[dayType.name][zone.GUID];
                        for (int j = 0; j < 24; j++)
                        {
                            yearlyValues[aCount] = dailyValues[j];
                            aCount++;
                        }
                    }

                    if (exists)
                    {
                        dictionary_Zone.Add(zone.GUID, yearlyValues);
                    }
                }

                result[keyValuePair.Key] = dictionary_Zone;
            }

            return(result);
        }
Пример #6
0
        public static bool UpdateInternalCondition(this TBD.InternalCondition internalCondition_TBD, Space space, ProfileLibrary profileLibrary)
        {
            if (space == null || internalCondition_TBD == null)
            {
                return(false);
            }

            InternalCondition internalCondition = space.InternalCondition;

            if (internalCondition == null)
            {
                return(false);
            }

            internalCondition_TBD.name        = space.Name;
            internalCondition_TBD.description = internalCondition.Name;

            internalCondition_TBD.includeSolarInMRT = 1;

            TBD.Emitter emitter = null;
            double      value   = double.NaN;

            emitter = internalCondition_TBD.GetHeatingEmitter();
            if (emitter != null)
            {
                emitter.name = internalCondition.GetSystemTypeName <HeatingSystemType>();

                if (internalCondition.TryGetValue(InternalConditionParameter.HeatingEmitterRadiantProportion, out value))
                {
                    emitter.radiantProportion = System.Convert.ToSingle(value);
                }

                if (internalCondition.TryGetValue(InternalConditionParameter.HeatingEmitterCoefficient, out value))
                {
                    emitter.viewCoefficient = System.Convert.ToSingle(value);
                }
            }

            emitter = internalCondition_TBD.GetCoolingEmitter();
            if (emitter != null)
            {
                emitter.name = internalCondition.GetSystemTypeName <CoolingSystemType>();

                if (internalCondition.TryGetValue(InternalConditionParameter.CoolingEmitterRadiantProportion, out value))
                {
                    emitter.radiantProportion = System.Convert.ToSingle(value);
                }

                if (internalCondition.TryGetValue(InternalConditionParameter.CoolingEmitterCoefficient, out value))
                {
                    emitter.viewCoefficient = System.Convert.ToSingle(value);
                }
            }

            TBD.InternalGain internalGain = internalCondition_TBD.GetInternalGain();

            if (internalCondition.TryGetValue(InternalConditionParameter.LightingRadiantProportion, out value))
            {
                internalGain.lightingRadProp = System.Convert.ToSingle(value);
            }

            if (internalCondition.TryGetValue(InternalConditionParameter.OccupancyRadiantProportion, out value))
            {
                internalGain.occupantRadProp = System.Convert.ToSingle(value);
            }

            if (internalCondition.TryGetValue(InternalConditionParameter.EquipmentRadiantProportion, out value))
            {
                internalGain.equipmentRadProp = System.Convert.ToSingle(value);
            }

            if (internalCondition.TryGetValue(InternalConditionParameter.LightingViewCoefficient, out value))
            {
                internalGain.lightingViewCoefficient = System.Convert.ToSingle(value);
            }

            if (internalCondition.TryGetValue(InternalConditionParameter.OccupancyViewCoefficient, out value))
            {
                internalGain.occupantViewCoefficient = System.Convert.ToSingle(value);
            }

            if (internalCondition.TryGetValue(InternalConditionParameter.EquipmentViewCoefficient, out value))
            {
                internalGain.equipmentViewCoefficient = System.Convert.ToSingle(value);
            }

            internalGain.domesticHotWater = (float)0.197;

            internalGain.name        = internalCondition.Name;
            internalGain.description = internalCondition.GetSystemTypeName <VentilationSystemType>();

            if (internalCondition.TryGetValue(InternalConditionParameter.LightingLevel, out value))
            {
                internalGain.targetIlluminance = System.Convert.ToSingle(value);
            }

            internalGain.personGain = 0;
            double occupancyGainPerPerson = Analytical.Query.OccupancyGainPerPerson(space);

            if (!double.IsNaN(occupancyGainPerPerson))
            {
                internalGain.personGain = System.Convert.ToSingle(occupancyGainPerPerson);
            }

            Profile profile = null;

            profile = internalCondition.GetProfile(ProfileType.Infiltration, profileLibrary);
            if (profile != null)
            {
                if (internalCondition.TryGetValue(InternalConditionParameter.InfiltrationAirChangesPerHour, out value))
                {
                    TBD.profile profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticI);
                    if (profile_TBD != null)
                    {
                        Update(profile_TBD, profile, value);
                    }
                }
            }

            double area = double.NaN;

            if (!space.TryGetValue(SpaceParameter.Area, out area))
            {
                area = double.NaN;
            }

            profile = internalCondition.GetProfile(ProfileType.Lighting, profileLibrary);
            if (profile != null)
            {
                TBD.profile profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticLG);
                if (profile_TBD != null)
                {
                    double gain = Analytical.Query.CalculatedLightingGain(space);
                    if (double.IsNaN(area) || area == 0 || double.IsNaN(gain))
                    {
                        gain = 0;
                    }
                    else
                    {
                        gain = gain / area;
                    }

                    Update(profile_TBD, profile, gain);
                }
            }

            profile = internalCondition.GetProfile(ProfileType.Occupancy, profileLibrary);
            if (profile != null)
            {
                TBD.profile profile_TBD = null;

                profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticOLG);
                if (profile_TBD != null)
                {
                    double gain = Analytical.Query.OccupancyLatentGain(space);
                    if (double.IsNaN(area) || area == 0 || double.IsNaN(gain))
                    {
                        gain = 0;
                    }
                    else
                    {
                        gain = gain / area;
                    }

                    Update(profile_TBD, profile, gain);
                }

                profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticOSG);
                if (profile_TBD != null)
                {
                    double gain = Analytical.Query.OccupancySensibleGain(space);
                    if (double.IsNaN(area) || area == 0 || double.IsNaN(gain))
                    {
                        gain = 0;
                    }
                    else
                    {
                        gain = gain / area;
                    }

                    Update(profile_TBD, profile, gain);
                }
            }

            profile = internalCondition.GetProfile(ProfileType.EquipmentSensible, profileLibrary);
            if (profile != null)
            {
                TBD.profile profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticESG);
                if (profile_TBD != null)
                {
                    double gain = Analytical.Query.CalculatedEquipmentSensibleGain(space);
                    if (double.IsNaN(area) || area == 0 || double.IsNaN(gain))
                    {
                        gain = 0;
                    }
                    else
                    {
                        gain = gain / area;
                    }

                    Update(profile_TBD, profile, gain);
                }
            }

            profile = internalCondition.GetProfile(ProfileType.EquipmentLatent, profileLibrary);
            if (profile != null)
            {
                TBD.profile profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticELG);
                if (profile_TBD != null)
                {
                    double gain = Analytical.Query.CalculatedEquipmentLatentGain(space);
                    if (double.IsNaN(area) || area == 0 || double.IsNaN(gain))
                    {
                        gain = 0;
                    }
                    else
                    {
                        gain = gain / area;
                    }

                    Update(profile_TBD, profile, gain);
                }
            }

            profile = internalCondition.GetProfile(ProfileType.Pollutant, profileLibrary);
            if (profile != null)
            {
                TBD.profile profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticCOG);
                if (profile_TBD != null)
                {
                    double generation = Analytical.Query.CalculatedPollutantGeneration(space);
                    if (double.IsNaN(area) || area == 0 || double.IsNaN(generation))
                    {
                        generation = 0;
                    }
                    else
                    {
                        generation = generation / area;
                    }

                    Update(profile_TBD, profile, generation);
                }
            }

            TBD.Thermostat thermostat = internalCondition_TBD.GetThermostat();
            if (thermostat != null)
            {
                List <string> names = new List <string>();

                thermostat.controlRange        = 0;
                thermostat.proportionalControl = 0;

                profile = internalCondition.GetProfile(ProfileType.Cooling, profileLibrary);
                if (profile != null)
                {
                    names.Add(profile.Name);

                    TBD.profile profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticUL);
                    if (profile_TBD != null)
                    {
                        Update(profile_TBD, profile, 1);
                    }
                }

                profile = internalCondition.GetProfile(ProfileType.Heating, profileLibrary);
                if (profile != null)
                {
                    names.Add(profile.Name);

                    TBD.profile profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticLL);
                    if (profile_TBD != null)
                    {
                        Update(profile_TBD, profile, 1);
                    }
                }

                profile = internalCondition.GetProfile(ProfileType.Humidification, profileLibrary);
                if (profile != null)
                {
                    names.Add(profile.Name);

                    TBD.profile profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticHLL);
                    if (profile_TBD != null)
                    {
                        Update(profile_TBD, profile, 1);
                    }
                }

                profile = internalCondition.GetProfile(ProfileType.Dehumidification, profileLibrary);
                if (profile != null)
                {
                    names.Add(profile.Name);

                    TBD.profile profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticHUL);
                    if (profile_TBD != null)
                    {
                        Update(profile_TBD, profile, 1);
                    }
                }

                names.RemoveAll(x => string.IsNullOrWhiteSpace(x));

                if (names.Count != 0)
                {
                    thermostat.name = string.Join(" & ", names);
                }
            }

            return(true);
        }
Пример #7
0
        public static InternalCondition ToSAM(this TBD.InternalCondition internalCondition, double area = double.NaN)
        {
            if (internalCondition == null)
            {
                return(null);
            }

            InternalCondition result = new InternalCondition(internalCondition.name);

            TBD.Emitter emitter = null;

            emitter = internalCondition.GetHeatingEmitter();
            if (emitter != null)
            {
                result.SetValue(InternalConditionParameter.HeatingEmitterRadiantProportion, emitter.radiantProportion);
                result.SetValue(InternalConditionParameter.HeatingEmitterCoefficient, emitter.viewCoefficient);
            }

            emitter = internalCondition.GetCoolingEmitter();
            if (emitter != null)
            {
                result.SetValue(InternalConditionParameter.CoolingEmitterRadiantProportion, emitter.radiantProportion);
                result.SetValue(InternalConditionParameter.CoolingEmitterCoefficient, emitter.viewCoefficient);
            }

            TBD.InternalGain internalGain = internalCondition.GetInternalGain();
            if (internalGain != null)
            {
                result.SetValue(InternalConditionParameter.LightingRadiantProportion, internalGain.lightingRadProp);
                result.SetValue(InternalConditionParameter.OccupancyRadiantProportion, internalGain.occupantRadProp);
                result.SetValue(InternalConditionParameter.EquipmentRadiantProportion, internalGain.equipmentRadProp);

                result.SetValue(InternalConditionParameter.LightingViewCoefficient, internalGain.lightingViewCoefficient);
                result.SetValue(InternalConditionParameter.OccupancyViewCoefficient, internalGain.occupantViewCoefficient);
                result.SetValue(InternalConditionParameter.EquipmentViewCoefficient, internalGain.equipmentViewCoefficient);

                TBD.profile profile_TBD = null;
                profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticI);
                if (profile_TBD != null)
                {
                    result.SetValue(InternalConditionParameter.InfiltrationProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name));
                    result.SetValue(InternalConditionParameter.InfiltrationAirChangesPerHour, profile_TBD.GetExtremeValue(true));
                }

                profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticLG);
                if (profile_TBD != null)
                {
                    result.SetValue(InternalConditionParameter.LightingProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name));
                    result.SetValue(InternalConditionParameter.LightingGainPerArea, profile_TBD.GetExtremeValue(true));
                    result.SetValue(InternalConditionParameter.LightingLevel, internalGain.targetIlluminance);
                }

                double personGain = internalGain.personGain;
                double gain       = 0;

                profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticOSG);
                if (profile_TBD != null)
                {
                    double value = profile_TBD.GetExtremeValue(true);
                    result.SetValue(InternalConditionParameter.OccupancySensibleGainPerPerson, value);
                    gain += value;
                }

                profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticOLG);
                if (profile_TBD != null)
                {
                    double value = profile_TBD.GetExtremeValue(true);
                    result.SetValue(InternalConditionParameter.OccupancyProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name));
                    result.SetValue(InternalConditionParameter.OccupancyLatentGainPerPerson, value);
                    gain += value;
                }

                if (!double.IsNaN(area) && !double.IsNaN(gain))
                {
                    double occupancy = (gain * area) / personGain;
                    result.SetValue(InternalConditionParameter.AreaPerPerson, area / occupancy);
                }

                profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticESG);
                if (profile_TBD != null)
                {
                    result.SetValue(InternalConditionParameter.EquipmentSensibleProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name));
                    result.SetValue(InternalConditionParameter.EquipmentSensibleGainPerArea, profile_TBD.GetExtremeValue(true));
                }

                profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticELG);
                if (profile_TBD != null)
                {
                    result.SetValue(InternalConditionParameter.EquipmentLatentProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name));
                    result.SetValue(InternalConditionParameter.EquipmentLatentGainPerArea, profile_TBD.GetExtremeValue(true));
                }

                profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticCOG);
                if (profile_TBD != null)
                {
                    result.SetValue(InternalConditionParameter.PollutantProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name));
                    result.SetValue(InternalConditionParameter.PollutantGenerationPerArea, profile_TBD.GetExtremeValue(true));
                }
            }

            TBD.Thermostat thermostat = internalCondition.GetThermostat();
            if (internalGain != null)
            {
                TBD.profile profile_TBD = null;

                profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticUL);
                if (profile_TBD != null)
                {
                    result.SetValue(InternalConditionParameter.CoolingProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name));
                }

                profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticLL);
                if (profile_TBD != null)
                {
                    result.SetValue(InternalConditionParameter.HeatingProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name));
                }

                profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticHLL);
                if (profile_TBD != null)
                {
                    result.SetValue(InternalConditionParameter.HumidificationProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name));
                }

                profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticHUL);
                if (profile_TBD != null)
                {
                    result.SetValue(InternalConditionParameter.DehumidificationProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name));
                }
            }

            return(result);
        }