1
+ /*
2
+ * This file is part of the Buildings and Habitats object Model (BHoM)
3
+ * Copyright (c) 2015 - 2024, the respective contributors. All rights reserved.
4
+ *
5
+ * Each contributor holds copyright over their respective contributions.
6
+ * The project versioning (Git) records all such contribution source information.
7
+ *
8
+ *
9
+ * The BHoM is free software: you can redistribute it and/or modify
10
+ * it under the terms of the GNU Lesser General Public License as published by
11
+ * the Free Software Foundation, either version 3.0 of the License, or
12
+ * (at your option) any later version.
13
+ *
14
+ * The BHoM is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ * GNU Lesser General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU Lesser General Public License
20
+ * along with this code. If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
21
+ */
22
+
23
+ using BH . oM . Geometry ;
24
+ using BH . oM . Dimensional ;
25
+ using System ;
26
+ using System . Collections . Generic ;
27
+ using System . Linq ;
28
+ using BH . oM . Base ;
29
+ using BH . Engine . Geometry ;
30
+ using BH . Engine . Spatial ;
31
+ using BH . Engine . Base ;
32
+ using BH . oM . Physical . FramingProperties ;
33
+
34
+ using BH . oM . Base . Attributes ;
35
+ using System . ComponentModel ;
36
+ using BH . oM . LifeCycleAssessment . MaterialFragments ;
37
+ using BH . oM . Quantities . Attributes ;
38
+ using System . Reflection ;
39
+
40
+ namespace BH . Engine . Facade
41
+ {
42
+ public static partial class Modify
43
+ {
44
+ /***************************************************/
45
+ /**** Public Methods ****/
46
+ /***************************************************/
47
+
48
+ [ Description ( "Scales the quantity values in an area based insulation EPD based on project RSI (m2K/W)." ) ]
49
+ [ Input ( "insulationEPD" , "Insulation EPD to scale quantity values for." ) ]
50
+ [ Input ( "rSI" , "RSI for insulation (m2K/W)." ) ]
51
+ [ Output ( "modifiedEPD" , "FrameEdgeProperty with modified section profile depth." ) ]
52
+ public static EnvironmentalProductDeclaration ModifyInsulationEPD ( this EnvironmentalProductDeclaration insulationEPD , double rSI )
53
+ {
54
+ if ( rSI <= 0 || rSI == double . NaN )
55
+ {
56
+ Base . Compute . RecordError ( $ "Valid RSI is not assigned.") ;
57
+ return null ;
58
+ }
59
+
60
+ if ( insulationEPD == null )
61
+ {
62
+ Base . Compute . RecordError ( $ "Cannot convert null EPD.") ;
63
+ return null ;
64
+ }
65
+
66
+ if ( insulationEPD . QuantityType != oM . LifeCycleAssessment . QuantityType . Area )
67
+ {
68
+ Base . Compute . RecordError ( $ "ModifyInsulationEPD only works on insulation EPDs with Area quantity type.") ;
69
+ return null ;
70
+ }
71
+
72
+ foreach ( EnvironmentalMetric environmentalMetric in insulationEPD . EnvironmentalMetrics )
73
+ {
74
+ foreach ( PropertyInfo property in environmentalMetric . GetType ( ) . GetProperties ( ) . ToList ( ) )
75
+ {
76
+ if ( property . PropertyType == typeof ( double ) )
77
+ environmentalMetric . SetPropertyValue ( property . Name , ( double ) property . GetValue ( environmentalMetric ) * rSI ) ;
78
+ }
79
+ }
80
+
81
+ return insulationEPD ;
82
+ }
83
+ }
84
+ }
0 commit comments