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: SAM and CAM methods fixed and improved #2731

Merged
merged 1 commit into from
Jan 25, 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
35 changes: 17 additions & 18 deletions Facade_Engine/Compute/UValueOpeningAW.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static partial class Compute
/**** Public Methods ****/
/***************************************************/

[Description("Returns effective U-Value of opening calculated using the Area Weighting Method. Requires center of opening U-value, frame U-value and edge U-value as Opening fragments.")]
[Description("Returns effective U-Value of opening calculated using the Area Weighting Method. Requires center of opening U-value, frame U-value and edge U-value as OpeningConstruction and FrameEdgeProperty fragments.")]
[Input("opening", "Opening to find U-value for.")]
[Output("effectiveUValue", "Effective U-value result of opening calculated using area weighting.")]
public static OverallUValue UValueOpeningAW(this Opening opening)
Expand All @@ -55,7 +55,7 @@ public static OverallUValue UValueOpeningAW(this Opening opening)
return null;
}

List<IFragment> glassUValues = opening.GetAllFragments(typeof(UValueGlassCentre));
List<IFragment> glassUValues = opening.OpeningConstruction.GetAllFragments(typeof(UValueGlassCentre));

if (glassUValues.Count <= 0)
{
Expand All @@ -69,6 +69,19 @@ public static OverallUValue UValueOpeningAW(this Opening opening)
}
double glassUValue = (glassUValues[0] as UValueGlassCentre).UValue;

List<IFragment> glassEdgeUValues = opening.OpeningConstruction.GetAllFragments(typeof(UValueGlassEdge));
if (glassEdgeUValues.Count <= 0)
{
Base.Compute.RecordError($"Opening {opening.BHoM_Guid} does not have Glass edge 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;

List<FrameEdge> frameEdges = opening.Edges;
List<double> frameAreas = new List<double>();
List<double> frameUValues = new List<double>();
Expand Down Expand Up @@ -111,7 +124,7 @@ public static OverallUValue UValueOpeningAW(this Opening opening)
totEdgeArea += e_area;
totFrameArea += f_area;

List<IFragment> f_uValues = frameEdges[i].GetAllFragments(typeof(UValueFrame));
List<IFragment> f_uValues = frameEdges[i].FrameEdgeProperty.GetAllFragments(typeof(UValueFrame));
if (f_uValues.Count <= 0)
{
BH.Engine.Base.Compute.RecordError($"Opening {opening.BHoM_Guid} does not have Frame U-value assigned.");
Expand All @@ -124,20 +137,6 @@ public static OverallUValue UValueOpeningAW(this Opening opening)
}
double frameUValue = (f_uValues[0] as UValueFrame).UValue;
frameUValues.Add(frameUValue);

List<IFragment> e_uValues = frameEdges[i].GetAllFragments(typeof(UValueGlassEdge));
if (e_uValues.Count <= 0)
{
BH.Engine.Base.Compute.RecordError($"Opening {opening.BHoM_Guid} does not have Frame U-value assigned.");
return null;
}
if (e_uValues.Count > 1)
{
BH.Engine.Base.Compute.RecordError($"Opening {opening.BHoM_Guid} has more than one Frame U-value assigned.");
return null;
}
double edgeUValue = (e_uValues[0] as UValueGlassEdge).UValue;
edgeUValues.Add(edgeUValue);
}

double glassArea = opening.Area() - totEdgeArea - totFrameArea;
Expand All @@ -147,7 +146,7 @@ public static OverallUValue UValueOpeningAW(this Opening opening)
for (int i = 0; i < frameUValues.Count; i++)
{
FrameUValProduct += (frameUValues[i] * frameAreas[i]);
EdgeUValProduct += (edgeUValues[i] * edgeAreas[i]);
EdgeUValProduct += (glassEdgeUValue * edgeAreas[i]);
}

double totArea = opening.Area();
Expand Down
10 changes: 5 additions & 5 deletions Facade_Engine/Compute/UValueOpeningCAM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static partial class Compute
/**** Public Methods ****/
/***************************************************/

[Description("Returns effective U-Value of opening calculated using the Component Assessment Method (Using Psi-g). Requires center of opening U-value as Opening fragment and frame Psi-tj value as list of Edge fragments.")]
[Description("Returns effective U-Value of opening calculated using the Component Assessment Method (Using Psi-g). Requires center of opening U-value and frame Psi-tj value as OpeningConstruction and FrameEdgeProperty fragments.")]
[Input("opening", "Opening to find U-value for.")]
[Output("effectiveUValue", "Effective U-value result of opening calculated using CAM.")]
public static OverallUValue UValueOpeningCAM(this Opening opening)
Expand All @@ -57,10 +57,10 @@ public static OverallUValue UValueOpeningCAM(this Opening opening)

double glassArea = opening.ComponentAreas().Item1;

List<IFragment> glassUValues = opening.GetAllFragments(typeof(UValueGlassCentre));
List<IFragment> glassUValues = opening.OpeningConstruction.GetAllFragments(typeof(UValueGlassCentre));
if (glassUValues.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 a Glass U-value assigned.");
return null;
}
if (glassUValues.Count > 1)
Expand Down Expand Up @@ -104,7 +104,7 @@ public static OverallUValue UValueOpeningCAM(this Opening opening)
frameAreas.Add(area);
psigLengths.Add(innerLength);

List<IFragment> uValues = frameEdges[i].GetAllFragments(typeof(UValueFrame));
List<IFragment> uValues = frameEdges[i].FrameEdgeProperty.GetAllFragments(typeof(UValueFrame));
if (uValues.Count <= 0)
{
BH.Engine.Base.Compute.RecordError($"Opening {opening.BHoM_Guid} does not have Frame U-value assigned.");
Expand All @@ -118,7 +118,7 @@ public static OverallUValue UValueOpeningCAM(this Opening opening)
double frameUValue = (uValues[0] as UValueFrame).UValue;
frameUValues.Add(frameUValue);

List<IFragment> psiGs = frameEdges[i].GetAllFragments(typeof(PsiGlassEdge));
List<IFragment> psiGs = frameEdges[i].FrameEdgeProperty.GetAllFragments(typeof(PsiGlassEdge));
if (psiGs.Count <= 0)
{
BH.Engine.Base.Compute.RecordError($"One or more FrameEdges belonging to {opening.BHoM_Guid} does not have PsiG value assigned.");
Expand Down
6 changes: 3 additions & 3 deletions Facade_Engine/Compute/UValueOpeningSAM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static partial class Compute
/**** Public Methods ****/
/***************************************************/

[Description("Returns effective U-Value of opening calculated using the Single Assessment Method (Using Psi-tj). Requires center of opening U-value as Opening fragment and frame Psi-tj value as list of Edge fragments.")]
[Description("Returns effective U-Value of opening calculated using the Single Assessment Method (Using Psi-tj). Requires center of opening U-value and frame Psi-tj value as OpeningConstruction and FrameEdgeProperty fragments.")]
[Input("opening", "Opening to find U-value for.")]
[Output("effectiveUValue", "Effective U-value result of opening caclulated using SAM.")]
public static OverallUValue UValueOpeningSAM(this Opening opening)
Expand All @@ -57,7 +57,7 @@ public static OverallUValue UValueOpeningSAM(this Opening opening)

double area = opening.Area();

List<IFragment> uValues = opening.GetAllFragments(typeof(UValueGlassCentre));
List<IFragment> uValues = opening.OpeningConstruction.GetAllFragments(typeof(UValueGlassCentre));
if (uValues.Count <= 0)
{
BH.Engine.Base.Compute.RecordError($"Opening {opening.BHoM_Guid} does not have U-value assigned.");
Expand All @@ -76,7 +76,7 @@ public static OverallUValue UValueOpeningSAM(this Opening opening)

foreach (FrameEdge frameEdge in frameEdges)
{
List<IFragment> psiJoints = frameEdge.GetAllFragments(typeof(PsiJoint));
List<IFragment> psiJoints = frameEdge.FrameEdgeProperty.GetAllFragments(typeof(PsiJoint));
if (psiJoints.Count <= 0)
{
BH.Engine.Base.Compute.RecordError($"One or more FrameEdges belonging to {opening.BHoM_Guid} does not have PsiJoint value assigned.");
Expand Down
74 changes: 74 additions & 0 deletions Facade_Engine/Compute/UValueOpeningsAW.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2022, the respective contributors. All rights reserved.
*
* Each contributor holds copyright over their respective contributions.
* The project versioning (Git) records all such contribution source information.
*
*
* The BHoM is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3.0 of the License, or
* (at your option) any later version.
*
* The BHoM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/

using BH.oM.Geometry;
using BH.oM.Dimensional;
using System;
using System.Collections.Generic;
using System.Linq;
using BH.oM.Facade.Elements;
using BH.oM.Base;
using BH.Engine.Geometry;
using BH.Engine.Spatial;
using BH.Engine.Base;
using BH.oM.Facade.Fragments;

using BH.oM.Base.Attributes;
using BH.oM.Facade.Results;
using System.ComponentModel;

namespace BH.Engine.Facade
{
public static partial class Compute
{
/***************************************************/
/**** Public Methods ****/
/***************************************************/

[Description("Returns effective U-Value of a collection of openings calculated using the Area Weighting Method. Requires center of opening U-value, frame U-value and edge U-value as OpeningConstruction and FrameEdgeProperty fragments.")]
[Input("openings", "Openings to find U-value for.")]
[Output("effectiveUValue", "Effective total U-value result of openings calculated using CAM.")]
public static OverallUValue UValueOpeningsAW(this List<Opening> openings)
{
double uValueProduct = 0;
double totalArea = 0;
foreach (Opening opening in openings)
{
double area = opening.Area();
uValueProduct += opening.UValueOpeningAW().UValue * area;
totalArea += area;
}
if (totalArea == 0)
{
Base.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;
}

/***************************************************/

}
}
2 changes: 1 addition & 1 deletion Facade_Engine/Compute/UValueOpeningsCAM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static partial class Compute
/**** Public Methods ****/
/***************************************************/

[Description("Returns effective U-Value of a collection of openings calculated using the Component Assessment Method (Using Psi-g). Requires center of opening U-value as Opening fragment and frame Psi-tj value as list of Edge fragments.")]
[Description("Returns effective U-Value of a collection of openings calculated using the Component Assessment Method (Using Psi-g). Requires center of opening U-value and frame Psi-tj value as OpeningConstruction and FrameEdgeProperty fragments..")]
[Input("openings", "Openings to find U-value for.")]
[Output("effectiveUValue", "Effective total U-value result of openings calculated using CAM.")]
public static OverallUValue UValueOpeningsCAM(this List<Opening> openings)
Expand Down
2 changes: 1 addition & 1 deletion Facade_Engine/Compute/UValueOpeningsSAM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static partial class Compute
/**** Public Methods ****/
/***************************************************/

[Description("Returns effective U-Value of a collection of openings calculated using the Single Assessment Method (Using Psi-tj). Requires center of opening U-value as Opening fragment and frame Psi-tj value as list of Edge fragments.")]
[Description("Returns effective U-Value of a collection of openings calculated using the Single Assessment Method (Using Psi-tj). Requires center of opening U-value and frame Psi-tj value as OpeningConstruction and FrameEdgeProperty fragments.")]
[Input("openings", "Openings to find U-value for.")]
[Output("effectiveUValue", "Effective total U-value result of opening calculated using SAM.")]
public static OverallUValue UValueOpeningsSAM(this List<Opening> openings)
Expand Down