Esempio n. 1
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. 2
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. 3
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);
        }