Example #1
0
        public static global::OpenStudio.Material ToOSM(this BHM.Material material, global::OpenStudio.Model modelReference, double thickness = 0.0, bool isGlazed = false)
        {
            List <BHM.IMaterialProperties> environmentMaterialProperties = material.Properties.Where(x => x is BHEM.IEnvironmentMaterial).ToList();

            if (environmentMaterialProperties.Count > 0)
            {
                if (environmentMaterialProperties[0].GetType() == typeof(BHEM.SolidMaterial))
                {
                    if (material.IsTransparent())
                    {
                        return(material.ToOSMGlazing(thickness, modelReference));
                    }
                    else
                    {
                        return(material.ToOSMOpaqueMaterial((environmentMaterialProperties[0] as BHEM.IEnvironmentMaterial).Roughness, thickness, modelReference));
                    }
                }
                else if (environmentMaterialProperties[0].GetType() == typeof(BHEM.GasMaterial))
                {
                    if (isGlazed)
                    {
                        return(material.ToOSMGas(thickness, modelReference));
                    }
                    else
                    {
                        return(material.ToOSMAirGap(modelReference));
                    }
                }
            }

            return(null);
        }
Example #2
0
        public static global::OpenStudio.Model CreateModel(List <List <BHE.Panel> > panelsAsSpaces, global::OpenStudio.Model modelReference)
        {
            List <BHC.Construction> uniqueConstructions = panelsAsSpaces.UniqueConstructions();

            //Create a curtain wall construction
            BHC.Construction curtainWallConstruction = new BHC.Construction();
            curtainWallConstruction.Name = "Curtain Wall Construction Replacement";

            BHC.Layer curtainWallLayer = new BHC.Layer();
            curtainWallLayer.Thickness = 0.1;

            BHM.Material curtainWallMaterial = new BHM.Material();
            curtainWallMaterial.Name = "Curtain Wall Construction Replacement";

            BHEM.SolidMaterial curtainWallMaterialProperties = new BHEM.SolidMaterial();
            curtainWallMaterialProperties.Roughness                = BHEM.Roughness.VerySmooth;
            curtainWallMaterialProperties.SpecificHeat             = 101;
            curtainWallMaterialProperties.Conductivity             = 0.1;
            curtainWallMaterialProperties.EmissivityExternal       = 0.1;
            curtainWallMaterialProperties.SolarReflectanceExternal = 0.1;
            curtainWallMaterialProperties.LightReflectanceExternal = 0.1;
            curtainWallMaterialProperties.Density = 0.1;

            curtainWallMaterial.Properties.Add(curtainWallMaterialProperties);
            curtainWallLayer.Material = curtainWallMaterial;
            curtainWallConstruction.Layers.Add(curtainWallLayer);

            Dictionary <string, Construction> osmConstructions = new Dictionary <string, Construction>();

            foreach (BHC.Construction c in uniqueConstructions)
            {
                osmConstructions.Add(c.UniqueConstructionName(), c.ToOSM(modelReference));
            }

            osmConstructions.Add("CurtainWallReplacementConstruction", curtainWallConstruction.ToOSM(modelReference));

            foreach (List <BHE.Panel> space in panelsAsSpaces)
            {
                ThermalZone osmZone  = new ThermalZone(modelReference);
                Space       osmSpace = new Space(modelReference);
                osmSpace.setThermalZone(osmZone);

                foreach (BHE.Panel be in space)
                {
                    string conName = be.Construction.UniqueConstructionName();

                    //be.ToOSM(modelReference, osmSpace, (conName == "" ? null : osmConstructions[conName]));
                    Surface host = be.ToOSM(modelReference, osmSpace, osmConstructions, be.OutsideBoundaryCondition(be.AdjacentSpaces(panelsAsSpaces)));

                    foreach (BHE.Opening o in be.Openings)
                    {
                        conName = o.OpeningConstruction.UniqueConstructionName();

                        o.ToOSM(host, (conName == "" ? null : osmConstructions[conName]), modelReference);
                    }
                }
            }

            return(modelReference);
        }
Example #3
0
        public static BHC.Layer ToBHoM(this BHX.Layer gbLayer, BHM.Material material, double thickness)
        {
            BHC.Layer layer = new BHC.Layer();
            layer.Name      = gbLayer.Name;
            layer.Thickness = thickness;
            layer.Material  = material;

            return(layer);
        }
Example #4
0
        public static global::OpenStudio.Gas ToOSMGas(this BHM.Material material, double thickness, global::OpenStudio.Model modelReference)
        {
            BHEM.GasMaterial matProp = material.Properties.Where(x => x.GetType() == typeof(BHEM.GasMaterial)).FirstOrDefault() as BHEM.GasMaterial;

            Gas gas = new Gas(modelReference);

            gas.setName(material.Name);
            gas.setThickness(thickness);
            gas.setGasType(matProp.Gas.ToOSM());

            return(gas);
        }
Example #5
0
        public static global::OpenStudio.AirGap ToOSMAirGap(this BHM.Material material, global::OpenStudio.Model modelReference)
        {
            AirGap airGap = new AirGap(modelReference);

            airGap.setName(material.Name);

            if (material.Properties.Where(x => x is BHEM.IEnvironmentMaterial).FirstOrDefault() != null)
            {
                airGap.setThermalConductivity((material.Properties.Where(x => x is BHEM.IEnvironmentMaterial).FirstOrDefault() as BHEM.IEnvironmentMaterial).Conductivity);
            }

            return(airGap);
        }
Example #6
0
        public static BHPMC.Layer FromTAS(this TBD.material tbdMaterial, TBD.Construction tbdConstruction)
        {
            if (tbdMaterial == null)
            {
                return(null);
            }

            BHPMC.Layer layer = new BHPMC.Layer();
            layer.Thickness = tbdMaterial.width;

            BHPM.Material material = new BHPM.Material();
            material.Name = tbdMaterial.name;
            material.Properties.Add(tbdMaterial.FromTASProperties(tbdConstruction));

            layer.Material = material;

            return(layer);
        }
Example #7
0
        public static global::OpenStudio.OpaqueMaterial ToOSMOpaqueMaterial(this BHM.Material material, BHEM.Roughness roughness, double thickness, global::OpenStudio.Model modelReference)
        {
            BHEM.SolidMaterial matProp = material.Properties.Where(x => x.GetType() == typeof(BHEM.SolidMaterial)).FirstOrDefault() as BHEM.SolidMaterial;

            StandardOpaqueMaterial osmMaterial = new StandardOpaqueMaterial(modelReference);

            osmMaterial.setName(material.Name);
            osmMaterial.setRoughness(roughness.ToOSM());
            osmMaterial.setThickness(thickness);

            if (matProp != null)
            {
                osmMaterial.setConductivity(matProp.Conductivity);
                osmMaterial.setDensity(matProp.Density);
                osmMaterial.setSpecificHeat(matProp.SpecificHeat);
                osmMaterial.setThermalAbsorptance(1 - matProp.EmissivityExternal);       //ToDo Review for external and internal as appropriate at some point
                osmMaterial.setSolarAbsorptance(1 - matProp.SolarReflectanceExternal);   //ToDo Review for external and internal as appropriate at some point
                osmMaterial.setVisibleAbsorptance(1 - matProp.LightReflectanceExternal); //ToDo Review for external and internal as appropriate at some point
            }

            return(osmMaterial);
        }
Example #8
0
        public static BHC.Layer ToBHoM(this BHX.Material gbMaterial)
        {
            BHC.Layer     layer = new BHC.Layer();
            SolidMaterial materialProperties = new SolidMaterial();

            try
            {
                layer.Thickness = System.Convert.ToDouble(gbMaterial.Thickness.Value);
                materialProperties.Conductivity = System.Convert.ToDouble(gbMaterial.Conductivity.Value);
                materialProperties.SpecificHeat = System.Convert.ToDouble(gbMaterial.SpecificHeat.Value);
                materialProperties.Density      = System.Convert.ToDouble(gbMaterial.Density.Value);
            }
            catch { }

            BHM.Material material = new BHM.Material();
            material.Name = gbMaterial.Name;

            material.Properties.Add(materialProperties);
            layer.Material = material;

            return(layer);
        }
Example #9
0
        public static TBD.MaterialTypes ToTASType(this BHPM.Material material)
        {
            BHM.IEnvironmentMaterial envMaterial = material.Properties.Where(x => x.GetType() == typeof(BHM.IEnvironmentMaterial)).FirstOrDefault() as BHM.IEnvironmentMaterial;

            if (envMaterial == null)
            {
                return(TBD.MaterialTypes.tcdOpaqueLayer);
            }

            if (envMaterial.GetType() == typeof(BHM.GasMaterial))
            {
                return(TBD.MaterialTypes.tcdGasLayer);
            }
            else if (material.IsTransparent())
            {
                return(TBD.MaterialTypes.tcdTransparentLayer);
            }
            else
            {
                return(TBD.MaterialTypes.tcdOpaqueLayer);
            }
        }
Example #10
0
        /***************************************************/
        /****               Public Methods              ****/
        /***************************************************/

        public static Material ToRevitMaterial(this BHP.Material material, Document document, RevitSettings settings = null, Dictionary <Guid, List <int> > refObjects = null)
        {
            if (material == null)
            {
                return(null);
            }

            Material revitMaterial = refObjects.GetValue <Material>(document, material.BHoM_Guid);

            if (revitMaterial != null)
            {
                return(revitMaterial);
            }

            settings = settings.DefaultIfNull();

            try
            {
                revitMaterial = document.GetElement(Material.Create(document, material.Name)) as Material;
            }
            catch
            {
                BH.Engine.Reflection.Compute.RecordError(String.Format("Revit material could not be created because a material with the same name already exists in the model or the name is incorrect. BHoM_Guid: {0}", material.BHoM_Guid));
                return(null);
            }

            foreach (BHP.IMaterialProperties property in material.Properties)
            {
                revitMaterial.ICopyCharacteristics(property);
            }

            // Copy parameters from BHoM object to Revit element
            revitMaterial.CopyParameters(material, settings);

            refObjects.AddOrReplace(material, revitMaterial);
            return(revitMaterial);
        }
Example #11
0
        public static global::OpenStudio.StandardGlazing ToOSMGlazing(this BHM.Material material, double thickness, global::OpenStudio.Model modelReference)
        {
            BHEM.SolidMaterial matProp = material.Properties.Where(x => x.GetType() == typeof(BHEM.SolidMaterial)).FirstOrDefault() as BHEM.SolidMaterial;

            StandardGlazing glazing = new StandardGlazing(modelReference);

            //ToDo: Front and back side checks and inclusion when required - issue raised
            glazing.setName(material.Name);
            glazing.setOpticalDataType("SpectralAverage");
            glazing.setThickness(thickness);
            glazing.setSolarTransmittance(matProp.SolarTransmittance);
            glazing.setFrontSideSolarReflectanceatNormalIncidence(0);
            glazing.setBackSideSolarReflectanceatNormalIncidence(0);
            glazing.setVisibleTransmittance(matProp.LightTransmittance);
            glazing.setFrontSideVisibleReflectanceatNormalIncidence(0);
            glazing.setBackSideVisibleReflectanceatNormalIncidence(0);
            //ToDo: Figure out infrared transmittance if required
            glazing.setFrontSideInfraredHemisphericalEmissivity(0);
            glazing.setBackSideInfraredHemisphericalEmissivity(0);
            glazing.setConductivity(matProp.Conductivity);
            glazing.setSolarDiffusing(false);

            return(glazing);
        }
Example #12
0
        /***************************************************/

        public static Element ToRevit(this BH.oM.Physical.Materials.Material material, Document document, RevitSettings settings = null, Dictionary <Guid, List <int> > refObjects = null)
        {
            return(material.ToRevitMaterial(document, settings, refObjects));
        }