示例#1
0
        public static CSOpaqueConstruction MixConstructions(string newName, CSOpaqueConstruction c1, CSOpaqueConstruction c2, double areaFractionC2)
        {
            //find layer with lowest conductivity in C1
            double minLamdaC1          = double.MaxValue;
            double thicknessMinLamdaC1 = 0;
            int    minLamdaC1Index     = -1;
            double thicknessC1         = 0;

            for (int i = 0; i < c1.Layers.Count; i++)
            {
                var layer = c1.Layers[i];
                thicknessC1 += layer.Thickness;
                if (layer.Material.Conductivity < minLamdaC1)
                {
                    minLamdaC1          = layer.Material.Conductivity;
                    thicknessMinLamdaC1 = layer.Thickness;
                    minLamdaC1Index     = i;
                }
            }

            double rLayer = thicknessMinLamdaC1 / minLamdaC1;

            // claculate target R-value
            double r1           = c1.GetRvalueLayers();
            double r2           = c2.GetRvalueLayers();
            double rTarget      = r1 * (1.0 - areaFractionC2) + r2 * areaFractionC2;
            double r1_2         = r1 - rLayer;
            double newThickness = (rTarget - r1_2) * minLamdaC1;


            List <Layer <CSOpaqueMaterial> > newLayerset = new List <Layer <CSOpaqueMaterial> >();

            for (int i = 0; i < c1.Layers.Count; i++)
            {
                if (i == minLamdaC1Index)
                {
                    newLayerset.Add(new Layer <CSOpaqueMaterial>(newThickness, c1.Layers[i].Material));
                }
                else
                {
                    newLayerset.Add(new Layer <CSOpaqueMaterial>(c1.Layers[i].Thickness, c1.Layers[i].Material));
                }
            }

            CSOpaqueConstruction c = new CSOpaqueConstruction()
            {
                Name           = newName,
                Type           = c1.Type,
                EmbodiedCarbon = c1.EmbodiedCarbon * (1.0 - areaFractionC2) + c2.EmbodiedCarbon * areaFractionC2,
                Cost           = c1.Cost * (1.0 - areaFractionC2) + c2.Cost * areaFractionC2,
                EmbodiedEnergy = c1.EmbodiedEnergy * (1.0 - areaFractionC2) + c2.EmbodiedEnergy * areaFractionC2,
                Life           = c1.Life,
                Comment        = c1.Comment,
                Category       = c1.Category,
                DataSource     = c1.DataSource,
                Layers         = newLayerset
            };

            return(c);
        }
示例#2
0
        public static CSOpaqueConstruction QuickConstruction(string name, ConstructionCategory type, string[] layers, double[] thickness, string category, string source, ref CSLibrary Library)
        {
            CSOpaqueConstruction oc = new CSOpaqueConstruction();

            for (int i = 0; i < layers.Length; i++)
            {
                try
                {
                    if (thickness.Length != layers.Length)
                    {
                        continue;
                    }
                    if (!(thickness[i] > 0))
                    {
                        continue;
                    }

                    if (Library.OpaqueMaterials.Any(x => x.Name == layers[i]))
                    {
                        var mat = Library.OpaqueMaterials.First(o => o.Name == layers[i]);
                        Layer <CSOpaqueMaterial> layer = new Layer <CSOpaqueMaterial>(thickness[i], mat);
                        oc.Layers.Add(layer);
                    }
                    else
                    {
                        Debug.WriteLine("ERROR: " + "Could not find " + layers[i]);
                        Logger.WriteLine("ERROR: " + "Could not find " + layers[i]);
                        return(null);
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                }
            }

            oc.Name       = name;
            oc.Type       = type;
            oc.Category   = category;
            oc.DataSource = source;


            Library.Add(oc);
            return(oc);
        }