Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facade_Engine: Update Methods to Handle UValueCavity Fragment #2955

Merged
merged 3 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ci/Datasets/Facade_Engine/Compute/UValueOpeningAW.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .ci/Datasets/Facade_Engine/Compute/UValuePanelAW.json

Large diffs are not rendered by default.

97 changes: 71 additions & 26 deletions Facade_Engine/Compute/UValueOpeningAW.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,48 +56,69 @@ public static OverallUValue UValueOpeningAW(this Opening opening)
}

List<IFragment> glassUValues = opening.OpeningConstruction.GetAllFragments(typeof(UValueGlassCentre));
if (glassUValues.Count <= 0)
List<IFragment> glassEdgeUValues = opening.OpeningConstruction.GetAllFragments(typeof(UValueGlassEdge));
List<IFragment> contUValues = opening.OpeningConstruction.GetAllFragments(typeof(UValueContinuous));
List<IFragment> cavityUValues = opening.OpeningConstruction.GetAllFragments(typeof(UValueCavity));
double contUValue = 0;
double cavityUValue = 0;

double glassUValue = 0;
double glassEdgeUValue = 0;

if ((glassUValues.Count <= 0) && (glassEdgeUValues.Count <= 0) && (contUValues.Count <= 0) && (cavityUValues.Count <= 0))
{
BH.Engine.Base.Compute.RecordError($"Opening {opening.BHoM_Guid} does not have Glass U-value assigned.");
BH.Engine.Base.Compute.RecordError($"Opening {opening.BHoM_Guid} does not have Glass U-values, Continuous U-value, or Cavity U-value assigned.");
return null;
}
if (glassUValues.Count > 1)
if ((glassUValues.Count == 1) && (glassEdgeUValues.Count <= 0))
{
BH.Engine.Base.Compute.RecordError($"Opening {opening.BHoM_Guid} has more than one Glass U-value assigned.");
BH.Engine.Base.Compute.RecordError($"Opening {opening.BHoM_Guid} has center of Glass U-value without Edge of Glass u-values assigned.");
return null;
}
double glassUValue = (glassUValues[0] as UValueGlassCentre).UValue;

List<IFragment> glassEdgeUValues = opening.OpeningConstruction.GetAllFragments(typeof(UValueGlassEdge));
if (glassEdgeUValues.Count <= 0)
if ((glassUValues.Count <= 0) && (glassEdgeUValues.Count == 1))
{
Base.Compute.RecordError($"Opening {opening.BHoM_Guid} does not have Glass edge U-value assigned.");
BH.Engine.Base.Compute.RecordError($"Opening {opening.BHoM_Guid} has Edge of Glass U-values without center of Glass u-value assigned.");
return null;
}
if (contUValues.Count > 1)
{
Base.Compute.RecordError($"Opening {opening.BHoM_Guid} has more than one continuous U-value assigned.");
return null;
}
if (cavityUValues.Count > 1)
{
Base.Compute.RecordError($"Opening {opening.BHoM_Guid} has more than one cavity U-value assigned.");
return null;
}
if (glassUValues.Count > 1)
{
BH.Engine.Base.Compute.RecordError($"Opening {opening.BHoM_Guid} has more than one Glass U-value assigned.");
return null;
}
if (glassEdgeUValues.Count > 1)
{
Base.Compute.RecordError($"Opening {opening.BHoM_Guid} has more than one Glass edge U-value assigned.");
return null;
}
double glassEdgeUValue = (glassEdgeUValues[0] as UValueGlassEdge).UValue;

double contUValue = 0;
List<IFragment> contUValues = opening.OpeningConstruction.GetAllFragments(typeof(UValueContinuous));
if (contUValues.Count == 1)
{
contUValue = (contUValues[0] as UValueContinuous).UValue;
}
if (contUValues.Count > 1)
if (cavityUValues.Count == 1)
{
Base.Compute.RecordError($"Opening {opening.BHoM_Guid} has more than one continuous U-value assigned.");
return null;
cavityUValue = (cavityUValues[0] as UValueCavity).UValue;
}
if (glassUValues.Count == 1 || glassEdgeUValues.Count == 1)
{
glassUValue = (glassUValues[0] as UValueGlassCentre).UValue;
glassEdgeUValue = (glassEdgeUValues[0] as UValueGlassEdge).UValue;
}

List<FrameEdge> frameEdges = opening.Edges;
List<double> frameAreas = new List<double>();
List<double> frameUValues = new List<double>();
List<double> edgeAreas = new List<double>();
List<double> edgeUValues = new List<double>();

int h;
int j;
Expand Down Expand Up @@ -150,28 +171,52 @@ public static OverallUValue UValueOpeningAW(this Opening opening)
frameUValues.Add(frameUValue);
}

double glassArea = opening.Area() - totEdgeArea - totFrameArea;
double totArea = opening.Area();
if (totArea == 0)
{
BH.Engine.Base.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 glassArea = totArea - totEdgeArea - totFrameArea;
double centerArea = totArea - totFrameArea;

double edgeUValProduct = 0;
double centerUValue = 0;

if ((glassEdgeUValue > 0) && (glassUValue > 0))
{
for (int i = 0; i < edgeAreas.Count; i++)
{
edgeUValProduct += (glassEdgeUValue * edgeAreas[i]);
}
centerUValue = (((glassArea * glassUValue) + edgeUValProduct) / centerArea);
if (cavityUValue > 0)
{
centerUValue = 1 / (1 / cavityUValue + 1 / centerUValue);
}
}
else
{
centerUValue = cavityUValue;
}
double centerUValProduct = centerUValue * centerArea;

double FrameUValProduct = 0;
double EdgeUValProduct = 0;
for (int i = 0; i < frameUValues.Count; i++)
{
FrameUValProduct += (frameUValues[i] * frameAreas[i]);
EdgeUValProduct += (glassEdgeUValue * edgeAreas[i]);
}

double totArea = opening.Area();
if (totArea == 0)
{
BH.Engine.Base.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 baseUValue = (((glassArea * glassUValue) + EdgeUValProduct + FrameUValProduct) / totArea);
double baseUValue = ((centerUValProduct + FrameUValProduct) / totArea);

double effectiveUValue = 0;
if (contUValue == 0)
{
effectiveUValue = baseUValue;
}
else if (centerUValue == 0)
{
effectiveUValue = contUValue;
}
else
{
effectiveUValue = 1 / (1 / baseUValue + 1 / contUValue);
Expand Down
34 changes: 29 additions & 5 deletions Facade_Engine/Compute/UValuePanelAW.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static OverallUValue UValuePanelAW(this Panel panel)
List<IFragment> glassUValues = panel.Construction.GetAllFragments(typeof(UValueGlassCentre));
if (glassUValues.Count > 0)
{
BH.Engine.Base.Compute.RecordError($"Panel {panel.BHoM_Guid} has Glass U-value assigned. Panels can only receive Continuous U-value");
BH.Engine.Base.Compute.RecordError($"Panel {panel.BHoM_Guid} has Glass U-value assigned. Panels can only receive Continuous U-value and/or Cavity U-value.");
return null;
}

Expand All @@ -70,17 +70,42 @@ public static OverallUValue UValuePanelAW(this Panel panel)
}

List<IFragment> contUValues = panel.Construction.GetAllFragments(typeof(UValueContinuous));
if (contUValues.Count <= 0)
List<IFragment> cavityUValues = panel.Construction.GetAllFragments(typeof(UValueCavity));
double contUValue = 0;
double cavityUValue = 0;
double panelUValue = 0;

if ((contUValues.Count <= 0) && (cavityUValues.Count <= 0))
{
Base.Compute.RecordError($"Panel {panel.BHoM_Guid} does not have Continuous U-value assigned.");
Base.Compute.RecordError($"Panel {panel.BHoM_Guid} does not have Continuous U-value or Cavity U-value assigned.");
return null;
}
if (contUValues.Count > 1)
{
Base.Compute.RecordError($"Panel {panel.BHoM_Guid} has more than one Continuous U-value assigned.");
return null;
}
double contUValue = (contUValues[0] as UValueContinuous).UValue;
if (cavityUValues.Count > 1)
{
Base.Compute.RecordError($"Panel {panel.BHoM_Guid} has more than one Cavity U-value assigned.");
return null;
}
if ((contUValues.Count == 1) && (cavityUValues.Count == 1))
{
contUValue = (contUValues[0] as UValueContinuous).UValue;
cavityUValue = (cavityUValues[0] as UValueCavity).UValue;
panelUValue = 1 / (1 / contUValue + 1 / cavityUValue);
}
if ((contUValues.Count == 1) && (cavityUValues.Count <= 0))
{
contUValue = (contUValues[0] as UValueContinuous).UValue;
panelUValue = contUValue;
}
if ((contUValues.Count <= 0) && (cavityUValues.Count == 1))
{
cavityUValue = (cavityUValues[0] as UValueCavity).UValue;
panelUValue = cavityUValue;
}

List<FrameEdge> frameEdges = panel.ExternalEdges;
List<double> frameUValues = new List<double>();
Expand All @@ -99,7 +124,6 @@ public static OverallUValue UValuePanelAW(this Panel panel)
{
BH.Engine.Base.Compute.RecordError($"Panel {panel.BHoM_Guid} has a calculated area of 0. Ensure the panel is valid with associated edges defining its geometry and try again.");
}
double panelUValue = contUValue;
double effectiveUValue = panelUValue;

List<Opening> panelOpenings = panel.Openings;
Expand Down