Esempio n. 1
0
        public static bool UpdateBuildingElements(this TBDDocument tBDDocument, AnalyticalModel analyticalModel)
        {
            if (tBDDocument == null || analyticalModel == null)
            {
                return(false);
            }

            Building building = tBDDocument.Building;

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

            UpdateConstructions(tBDDocument, analyticalModel);

            List <buildingElement> buildingElements = building.BuildingElements();

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

            List <TBD.Construction> constructions = building.Constructions();

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

            foreach (buildingElement buildingElement in buildingElements)
            {
                string name = Query.Name(buildingElement);
                if (string.IsNullOrWhiteSpace(name))
                {
                    continue;
                }

                TBD.Construction construction = constructions.Find(x => name.Equals(x.name));
                if (construction == null)
                {
                    List <TBD.Construction> constructions_Temp = constructions.FindAll(x => name.EndsWith(x.name));
                    if (constructions_Temp != null && constructions_Temp.Count != 0)
                    {
                        constructions_Temp.Sort((x, y) => System.Math.Abs(x.name.Length - name.Length).CompareTo(System.Math.Abs(y.name.Length - name.Length)));
                        construction = constructions_Temp.First();
                    }
                }

                if (construction == null)
                {
                    continue;
                }

                buildingElement.AssignConstruction(construction);
            }

            return(true);
        }
Esempio n. 2
0
        public static List <Construction> UpdateConstructions(this Building building, IEnumerable <Construction> constructions, MaterialLibrary materialLibrary)
        {
            if (constructions == null || building == null)
            {
                return(null);
            }

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

            foreach (Construction construction in constructions)
            {
                if (construction == null)
                {
                    continue;
                }

                string uniqueName = construction.UniqueName();
                if (string.IsNullOrWhiteSpace(uniqueName))
                {
                    continue;
                }

                List <ConstructionLayer> constructionLayers = construction.ConstructionLayers;
                if (constructionLayers == null || constructionLayers.Count == 0)
                {
                    continue;
                }

                TBD.Construction construction_TBD = building.GetConstructionByName(uniqueName);
                if (construction_TBD == null)
                {
                    construction_TBD      = building.AddConstruction(null);
                    construction_TBD.name = uniqueName;
                }

                construction_TBD.type = Query.ConstructionTypes(constructionLayers, materialLibrary);

                if (construction_TBD.UpdateConstruction(constructionLayers, materialLibrary))
                {
                    result.Add(construction);
                }
            }

            return(result);
        }
Esempio n. 3
0
        public static List <ApertureConstruction> UpdateConstructions(this Building building, IEnumerable <ApertureConstruction> apertureConstructions, MaterialLibrary materialLibrary)
        {
            if (apertureConstructions == null || building == null)
            {
                return(null);
            }

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

            foreach (ApertureConstruction apertureConstruction in apertureConstructions)
            {
                if (apertureConstruction == null)
                {
                    continue;
                }

                string uniqueName = apertureConstruction.UniqueName();
                if (string.IsNullOrWhiteSpace(uniqueName))
                {
                    continue;
                }

                TBD.Construction         construction_TBD   = null;
                List <ConstructionLayer> constructionLayers = null;
                ConstructionTypes        constructionTypes;


                //Pane Construction
                string paneApertureConstructionUniqueName = apertureConstruction.PaneApertureConstructionUniqueName();
                construction_TBD = building.GetConstructionByName(paneApertureConstructionUniqueName);
                if (construction_TBD == null)
                {
                    construction_TBD      = building.AddConstruction(null);
                    construction_TBD.name = paneApertureConstructionUniqueName;
                }

                constructionTypes  = ConstructionTypes.tcdTransparentConstruction;
                constructionLayers = apertureConstruction.PaneConstructionLayers;
                if (constructionLayers != null && constructionLayers.Count != 0)
                {
                    constructionTypes = Query.ConstructionTypes(constructionLayers, materialLibrary);
                }

                construction_TBD.type = constructionTypes;

                if (construction_TBD.UpdateConstruction(constructionLayers, materialLibrary))
                {
                    result.Add(apertureConstruction);
                }


                //Frame Construction
                string frameApertureConstructionUniqueName = apertureConstruction.FrameApertureConstructionUniqueName();
                construction_TBD = building.GetConstructionByName(frameApertureConstructionUniqueName);
                if (construction_TBD == null)
                {
                    construction_TBD      = building.AddConstruction(null);
                    construction_TBD.name = frameApertureConstructionUniqueName;
                }

                constructionTypes  = ConstructionTypes.tcdOpaqueConstruction;
                constructionLayers = apertureConstruction.FrameConstructionLayers;

                //Frame TBD.Construction cannot be empty
                if (constructionLayers == null || constructionLayers.Count == 0)
                {
                    constructionLayers = apertureConstruction.PaneConstructionLayers;
                }

                if (constructionLayers != null && constructionLayers.Count != 0)
                {
                    constructionTypes = Query.ConstructionTypes(constructionLayers, materialLibrary);
                }

                construction_TBD.type = constructionTypes;

                if (construction_TBD.UpdateConstruction(constructionLayers, materialLibrary))
                {
                    result.Add(apertureConstruction);
                }
            }

            return(result);
        }
Esempio n. 4
0
        public static double ThermalTransmittance(this TBD.Construction construction, PanelType panelType, double tolerance = Core.Tolerance.MacroDistance)
        {
            object @object = construction?.GetUValue();

            if (@object == null)
            {
                return(double.NaN);
            }


            float[] values = Array <float>(@object);
            if (values == null || values.Length == 0)
            {
                return(double.NaN);
            }


            int index = -1;

            switch (panelType)
            {
            case Analytical.PanelType.Shade:
            case Analytical.PanelType.SolarPanel:
            case Analytical.PanelType.Undefined:
                index = -1;
                break;

            case Analytical.PanelType.UndergroundWall:
            case Analytical.PanelType.WallExternal:
                index = 0;
                break;

            case Analytical.PanelType.Roof:
                index = 1;
                break;

            case Analytical.PanelType.UndergroundCeiling:
            case Analytical.PanelType.UndergroundSlab:
            case Analytical.PanelType.SlabOnGrade:
            case Analytical.PanelType.FloorExposed:
                index = 2;
                break;

            case Analytical.PanelType.WallInternal:
                index = 3;
                break;

            case Analytical.PanelType.Ceiling:
                index = 4;
                break;

            case Analytical.PanelType.FloorInternal:
            case Analytical.PanelType.FloorRaised:
                index = 5;
                break;

            case Analytical.PanelType.CurtainWall:
                index = 6;
                break;
            }

            return(index == -1 || values.Length <= index ? double.NaN : Core.Query.Round(values[index], tolerance));
        }
Esempio n. 5
0
        public static double ThermalTransmittance(this buildingElement buildingElement, double tolerance = Core.Tolerance.MacroDistance)
        {
            TBD.Construction construction = buildingElement?.GetConstruction();
            if (construction == null)
            {
                return(double.NaN);
            }

            object @object = construction.GetUValue();

            float[] values = Array <float>(@object);
            if (values == null || values.Length == 0)
            {
                return(double.NaN);
            }


            int index = -1;

            switch ((TBD.BuildingElementType)buildingElement.BEType)
            {
            case TBD.BuildingElementType.SHADEELEMENT:
            case TBD.BuildingElementType.SOLARPANEL:
            case TBD.BuildingElementType.NOBETYPE:
            case TBD.BuildingElementType.NULLELEMENT:
                index = -1;
                break;

            case TBD.BuildingElementType.UNDERGROUNDWALL:
            case TBD.BuildingElementType.VEHICLEDOOR:
            case TBD.BuildingElementType.FRAMEELEMENT:
            case TBD.BuildingElementType.EXTERNALWALL:
            case TBD.BuildingElementType.DOORELEMENT:
                index = 0;
                break;

            case TBD.BuildingElementType.ROOFELEMENT:
                index = 1;
                break;

            case TBD.BuildingElementType.UNDERGROUNDCEILING:
            case TBD.BuildingElementType.UNDERGROUNDSLAB:
            case TBD.BuildingElementType.SLABONGRADE:
            case TBD.BuildingElementType.EXPOSEDFLOOR:
                index = 2;
                break;

            case TBD.BuildingElementType.INTERNALWALL:
                index = 3;
                break;

            case TBD.BuildingElementType.CEILING:
                index = 4;
                break;

            case TBD.BuildingElementType.INTERNALFLOOR:
            case TBD.BuildingElementType.RAISEDFLOOR:
                index = 5;
                break;

            case TBD.BuildingElementType.ROOFLIGHT:
            case TBD.BuildingElementType.CURTAINWALL:
            case TBD.BuildingElementType.GLAZING:
                index = 6;
                break;
            }

            return(index == -1 || values.Length <= index ? double.NaN : Core.Query.Round(values[index], tolerance));
        }
Esempio n. 6
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);
        }