예제 #1
0
        public static bool TBDSizing(string tbdFile, bool run = false)
        {
            if (!run)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(tbdFile))
            {
                BH.Engine.Base.Compute.RecordError("Please provide a valid TBD file path");
                return(false);
            }

            TBDDocument tbdDocument = new TBDDocument();

            tbdDocument.open(tbdFile);
            if (tbdDocument != null)
            {
                tbdDocument.sizing(0);
            }
            tbdDocument.save();
            tbdDocument.close();

            int intrefcountTBD = 0;

            do
            {
                intrefcountTBD = Marshal.FinalReleaseComObject(tbdDocument);
            } while (intrefcountTBD > 0);
            tbdDocument = null;

            return(true);
        }
예제 #2
0
        private static bool Sizing_ApplyAirGlass(string path_TBD, bool excludePositiveInternalGains = false)
        {
            if (string.IsNullOrWhiteSpace(path_TBD) || !global::System.IO.File.Exists(path_TBD))
            {
                return(false);
            }

            bool result = false;

            using (SAMTBDDocument sAMTBDDocument = new SAMTBDDocument(path_TBD))
            {
                TBDDocument tBDDocument = sAMTBDDocument.TBDDocument;
                Building    building    = tBDDocument?.Building;
                if (building != null)
                {
                    TBD.Construction construction = building.GetConstructionByName("Air_Glass");
                    if (construction == null)
                    {
                        construction      = building.AddConstruction(null);
                        construction.name = "Air_Glass";
                        construction.type = TBD.ConstructionTypes.tcdTransparentConstruction;
                        material material = construction.AddMaterial();
                        material.name                  = "Air_Glass";
                        material.description           = "Special for HDD sizing";
                        material.type                  = (int)MaterialTypes.tcdTransparentLayer;
                        material.width                 = global::System.Convert.ToSingle(0.02 / 1000);
                        material.conductivity          = 1;
                        material.vapourDiffusionFactor = 1;
                        material.solarTransmittance    = 0.999999f;
                        material.externalEmissivity    = 0.00001f;
                        material.internalEmissivity    = 0.00001f;
                    }

                    List <buildingElement> buildingElements = building.BuildingElements();
                    foreach (buildingElement buildingElement in buildingElements)
                    {
                        if (!buildingElement.name.Contains("_AIR"))
                        {
                            continue;
                        }

                        buildingElement.ghost = 0;
                        buildingElement.AssignConstruction(construction);
                    }

                    if (excludePositiveInternalGains)
                    {
                        Sizing_ExcludePositiveInternalGains(tBDDocument);
                    }
                    else
                    {
                        SizingType sizingType = SizingType.tbdDesignSizingOnly;

                        List <zone> zones = building.Zones();
                        foreach (zone zone in zones)
                        {
                            zone.sizeCooling = (int)sizingType;
                            zone.sizeHeating = (int)sizingType;
                        }

                        tBDDocument.sizing(0);
                    }

                    sAMTBDDocument.Save();
                    result = true;
                }
            }

            return(result);
        }
예제 #3
0
        private static bool Sizing_ExcludePositiveInternalGains(this TBDDocument tBDDocument)
        {
            if (tBDDocument == null)
            {
                return(false);
            }

            List <zone> zones = tBDDocument?.Building?.Zones();

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

            SizingType sizingType = SizingType.tbdDesignSizingOnly;

            List <Tuple <zone, TBD.InternalCondition, double> > tuples = new List <Tuple <zone, TBD.InternalCondition, double> >();

            foreach (zone zone in zones)
            {
                zone.sizeHeating = (int)sizingType;
                zone.sizeCooling = (int)sizingType;

                List <TBD.InternalCondition> internalConditions = zone.InternalConditions();
                if (internalConditions == null || internalConditions.Count == 0)
                {
                    tuples.Add(new Tuple <zone, TBD.InternalCondition, double>(zone, null, -50));
                    continue;
                }

                TBD.InternalCondition internalCondition = internalConditions.Find(x => x.name.EndsWith(" - HDD"));
                if (internalCondition == null)
                {
                    tuples.Add(new Tuple <zone, TBD.InternalCondition, double>(zone, null, -50));
                    continue;
                }

                tuples.Add(new Tuple <zone, TBD.InternalCondition, double>(zone, internalCondition, internalCondition.GetLowerLimit()));
            }

            List <double> temperatures_Unique = tuples.ConvertAll(x => x.Item3).Distinct().ToList();

            temperatures_Unique.Sort();

            if (temperatures_Unique.Count == 0)
            {
                return(false);
            }

            Dictionary <zone, double> dictionary = new Dictionary <zone, double>();

            foreach (double tempearture in temperatures_Unique)
            {
                if (tempearture <= -50)
                {
                    continue;
                }

                //Here we filter room that have higher temperature than current set point
                List <Tuple <zone, TBD.InternalCondition, double> > tuples_Temperature = tuples.FindAll(x => x.Item3 >= tempearture);

                foreach (Tuple <zone, TBD.InternalCondition, double> tuple in tuples_Temperature)
                {
                    Thermostat thermostat = tuple.Item2?.GetThermostat();
                    if (thermostat == null)
                    {
                        continue;
                    }

                    profile profile = thermostat.GetProfile((int)Profiles.ticLL);
                    if (profile == null)
                    {
                        continue;
                    }

                    profile.value = global::System.Convert.ToSingle(tempearture);
                }

                tBDDocument.save();
                tBDDocument.sizing(0);

                tuples_Temperature = tuples_Temperature.FindAll(x => x.Item3 == tempearture);
                foreach (Tuple <zone, TBD.InternalCondition, double> tuple in tuples_Temperature)
                {
                    if (!dictionary.ContainsKey(tuple.Item1))
                    {
                        dictionary[tuple.Item1] = tuple.Item1.maxHeatingLoad;
                    }
                }
            }

            sizingType = SizingType.tbdNoSizing;
            foreach (KeyValuePair <zone, double> keyValuePair in dictionary)
            {
                zone zone = keyValuePair.Key;

                zone.sizeCooling = (int)sizingType;
                zone.sizeHeating = (int)sizingType;

                zone.maxHeatingLoad = global::System.Convert.ToSingle(keyValuePair.Value);
            }

            return(true);
        }