Skip to content

Commit 7f9d8b0

Browse files
author
Fraser Greenroyd
authored
Thermal Resistance Conversion Methods (#113)
2 parents b2398d6 + d0a9a65 commit 7f9d8b0

File tree

2 files changed

+124
-0
lines changed

2 files changed

+124
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 System;
24+
using System.Collections.Generic;
25+
using System.Linq;
26+
using System.Text;
27+
using System.Threading.Tasks;
28+
29+
using UN = UnitsNet; //This is to avoid clashes between UnitsNet quantity attributes and BHoM quantity attributes
30+
using UnitsNet.Units;
31+
32+
using System.ComponentModel;
33+
using BH.oM.Base.Attributes;
34+
using BH.oM.Quantities.Attributes;
35+
36+
namespace BH.Engine.Units
37+
{
38+
public static partial class Convert
39+
{
40+
[Description("Convert metric RSI (m2K/W) into R-value (ft2-h-F/Btu)")]
41+
[Input("metricRSI", "Metric RSI (m2K/W) to convert", typeof(ThermalResistanceUnit))]
42+
[Output("rValue", "Imperial R-value in ft2-h-F/Btu")]
43+
public static double ToRValue(this double metricRSI)
44+
{
45+
UN.QuantityValue qv = metricRSI;
46+
return UN.UnitConverter.Convert(qv, ThermalResistanceUnit.SquareMeterKelvinPerWatt, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu);
47+
}
48+
49+
[Description("Convert R-value (ft2-h-F/Btu) into metric RSI (m2K/W)")]
50+
[Input("rValue", "Imperial R-value (ft2-h-F/Btu) to convert")]
51+
[Output("metricRSI", "Metric RSI in m2K/W", typeof(ThermalResistanceUnit))]
52+
public static double FromRvalue(this double rValue)
53+
{
54+
UN.QuantityValue qv = rValue;
55+
return UN.UnitConverter.Convert(qv, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, ThermalResistanceUnit.SquareMeterKelvinPerWatt);
56+
}
57+
}
58+
}
59+
60+
61+
62+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 System;
24+
using System.Collections.Generic;
25+
using System.Linq;
26+
using System.Text;
27+
using System.Threading.Tasks;
28+
29+
using UN = UnitsNet; //This is to avoid clashes between UnitsNet quantity attributes and BHoM quantity attributes
30+
using UnitsNet.Units;
31+
32+
using System.ComponentModel;
33+
using BH.oM.Base.Attributes;
34+
using BH.oM.Quantities.Attributes;
35+
36+
namespace BH.Engine.Units
37+
{
38+
public static partial class Convert
39+
{
40+
[Description("Convert metric U-value (W/m2K) into imperial U-value (Btu/ft2-h-F)")]
41+
[Input("metricUValue", "Metric U-value (W/m2K) to convert")]
42+
[Output("uValue", "Imperial U-value in Btu/ft2-h-F")]
43+
public static double ToUValue(this double metricUValue)
44+
{
45+
double rSI = 1/metricUValue;
46+
return 1/ToRValue(rSI);
47+
}
48+
49+
[Description("Convert U-value (Btu/ft2-h-F) into metric U-value (W/m2K)")]
50+
[Input("uValue", "Imperial U-value (Btu/ft2-h-F) to convert")]
51+
[Output("metricUValue", "Metric U-value in W/m2K", typeof(ThermalResistanceUnit))]
52+
public static double FromUvalue(this double uValue)
53+
{
54+
double rValue = 1/uValue;
55+
return 1/FromRvalue(rValue);
56+
}
57+
}
58+
}
59+
60+
61+
62+

0 commit comments

Comments
 (0)