public static OverallUValue UValueOpeningsSAM(this List <Opening> openings) { double uValueProduct = 0; double totalArea = 0; foreach (Opening opening in openings) { double area = opening.Area(); uValueProduct += opening.UValueOpeningSAM().UValue *area; totalArea += area; } if (totalArea == 0) { BH.Engine.Reflection.Compute.RecordError("Openings have a total calculated area of 0. Ensure Openings are valid with associated edges defining their geometry and try again."); return(null); } double effectiveUValue = uValueProduct / totalArea; OverallUValue result = new OverallUValue(effectiveUValue, openings.Select(x => x.BHoM_Guid as IComparable).ToList()); return(result); }
public static OverallUValue UValueOpeningSAM(this Opening opening) { if (opening == null) { Reflection.Compute.RecordWarning("U Value can not be calculated for a null opening."); return(null); } double area = opening.Area(); List <IFragment> uValues = opening.GetAllFragments(typeof(UValueGlassCentre)); if (uValues.Count <= 0) { BH.Engine.Reflection.Compute.RecordError($"Opening {opening.BHoM_Guid} does not have U-value assigned."); return(null); } if (uValues.Count > 1) { BH.Engine.Reflection.Compute.RecordError($"Opening {opening.BHoM_Guid} has more than one U-value assigned."); return(null); } double uValue = (uValues[0] as UValueGlassCentre).UValue; List <FrameEdge> frameEdges = opening.Edges; List <double> psiValues = new List <double>(); List <double> lengths = new List <double>(); foreach (FrameEdge frameEdge in frameEdges) { List <IFragment> psiJoints = frameEdge.GetAllFragments(typeof(PsiJoint)); if (psiJoints.Count <= 0) { BH.Engine.Reflection.Compute.RecordError($"One or more FrameEdges belonging to {opening.BHoM_Guid} does not have PsiJoint value assigned."); return(null); } if (psiJoints.Count > 1) { BH.Engine.Reflection.Compute.RecordError($"One or more FrameEdges belonging to {opening.BHoM_Guid} has more than one PsiJoint value assigned. Each FrameEdge should only have one unique PsiJoint value assigned to it."); return(null); } double psiJoint = (psiJoints[0] as PsiJoint).PsiValue; psiValues.Add(psiJoint); double length = frameEdge.Length(); lengths.Add(length); } double psiProduct = 0; for (int i = 0; i < lengths.Count; i++) { psiProduct = psiProduct + (lengths[i] * psiValues[i]); } double effectiveUValue = (((area * uValue) + psiProduct) / area); OverallUValue result = new OverallUValue(effectiveUValue, new List <IComparable> { opening.BHoM_Guid }); return(result); }
public static OverallUValue UValueOpeningCAM(this Opening opening) { if (opening == null) { Reflection.Compute.RecordWarning("U Value can not be calculated for a null opening."); return(null); } double glassArea = opening.ComponentAreas().Item1; List <IFragment> glassUValues = opening.GetAllFragments(typeof(UValueGlassCentre)); if (glassUValues.Count <= 0) { BH.Engine.Reflection.Compute.RecordError($"Opening {opening.BHoM_Guid} does not have Glass U-value assigned."); return(null); } if (glassUValues.Count > 1) { BH.Engine.Reflection.Compute.RecordError($"Opening {opening.BHoM_Guid} has more than one Glass U-value assigned."); return(null); } double glassUValue = (glassUValues[0] as UValueGlassCentre).UValue; List <FrameEdge> frameEdges = opening.Edges; List <double> frameAreas = new List <double>(); List <double> frameUValues = new List <double>(); List <double> psigLengths = new List <double>(); List <double> psigValues = new List <double>(); int h; int j; for (int i = 0; i < frameEdges.Count; i++) { if (i == 0) { h = frameEdges.Count - 1; j = i + 1; } else if (i == frameEdges.Count - 1) { h = i - 1; j = 0; } else { h = i - 1; j = i + 1; } double outerLength = frameEdges[i].Length(); double wi = frameEdges[i].FrameEdgeProperty.Width(); double wh = frameEdges[h].FrameEdgeProperty.Width(); double wj = frameEdges[j].FrameEdgeProperty.Width(); double innerLength = outerLength - wj - wh; double area = wi * (outerLength + innerLength) / 2; frameAreas.Add(area); psigLengths.Add(innerLength); List <IFragment> uValues = frameEdges[i].GetAllFragments(typeof(UValueFrame)); if (uValues.Count <= 0) { BH.Engine.Reflection.Compute.RecordError($"Opening {opening.BHoM_Guid} does not have Frame U-value assigned."); return(null); } if (uValues.Count > 1) { BH.Engine.Reflection.Compute.RecordError($"Opening {opening.BHoM_Guid} has more than one Frame U-value assigned."); return(null); } double frameUValue = (uValues[0] as UValueFrame).UValue; frameUValues.Add(frameUValue); List <IFragment> psiGs = frameEdges[i].GetAllFragments(typeof(PsiGlassEdge)); if (psiGs.Count <= 0) { BH.Engine.Reflection.Compute.RecordError($"One or more FrameEdges belonging to {opening.BHoM_Guid} does not have PsiG value assigned."); return(null); } if (psiGs.Count > 1) { BH.Engine.Reflection.Compute.RecordError($"One or more FrameEdges belonging to {opening.BHoM_Guid} has more than one PsiG value assigned. Each FrameEdge should only have one unique PsiG value assigned to it."); return(null); } double psiG = (psiGs[0] as PsiGlassEdge).PsiValue; psigValues.Add(psiG); } double psigProduct = 0; double FrameUValProduct = 0; for (int i = 0; i < psigLengths.Count; i++) { psigProduct += (psigLengths[i] * psigValues[i]); FrameUValProduct += (frameUValues[i] * frameAreas[i]); } double totArea = opening.Area(); if (totArea == 0) { BH.Engine.Reflection.Compute.RecordError($"Opening {opening.BHoM_Guid} has a calculated area of 0. Ensure the opening is valid with associated edges defining its geometry and try again."); } double effectiveUValue = (((glassArea * glassUValue) + psigProduct + FrameUValProduct) / totArea); OverallUValue result = new OverallUValue(effectiveUValue, new List <IComparable> { opening.BHoM_Guid }); return(result); }