From d0a9a65d0da35ccdb15631af0c24e17fc7a8f7cf Mon Sep 17 00:00:00 2001 From: Valerie Green Date: Tue, 23 Apr 2024 15:41:14 -0700 Subject: [PATCH] R-Value and U-value conversion methods --- .../Convert/ThermalResistance/RValue.cs | 62 +++++++++++++++++++ .../Convert/ThermalResistance/UValue.cs | 62 +++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 Units_Engine/Convert/ThermalResistance/RValue.cs create mode 100644 Units_Engine/Convert/ThermalResistance/UValue.cs diff --git a/Units_Engine/Convert/ThermalResistance/RValue.cs b/Units_Engine/Convert/ThermalResistance/RValue.cs new file mode 100644 index 0000000..28db7b7 --- /dev/null +++ b/Units_Engine/Convert/ThermalResistance/RValue.cs @@ -0,0 +1,62 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2024, 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 . + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using UN = UnitsNet; //This is to avoid clashes between UnitsNet quantity attributes and BHoM quantity attributes +using UnitsNet.Units; + +using System.ComponentModel; +using BH.oM.Base.Attributes; +using BH.oM.Quantities.Attributes; + +namespace BH.Engine.Units +{ + public static partial class Convert + { + [Description("Convert metric RSI (m2K/W) into R-value (ft2-h-F/Btu)")] + [Input("metricRSI", "Metric RSI (m2K/W) to convert", typeof(ThermalResistanceUnit))] + [Output("rValue", "Imperial R-value in ft2-h-F/Btu")] + public static double ToRValue(this double metricRSI) + { + UN.QuantityValue qv = metricRSI; + return UN.UnitConverter.Convert(qv, ThermalResistanceUnit.SquareMeterKelvinPerWatt, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); + } + + [Description("Convert R-value (ft2-h-F/Btu) into metric RSI (m2K/W)")] + [Input("rValue", "Imperial R-value (ft2-h-F/Btu) to convert")] + [Output("metricRSI", "Metric RSI in m2K/W", typeof(ThermalResistanceUnit))] + public static double FromRvalue(this double rValue) + { + UN.QuantityValue qv = rValue; + return UN.UnitConverter.Convert(qv, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, ThermalResistanceUnit.SquareMeterKelvinPerWatt); + } + } +} + + + + diff --git a/Units_Engine/Convert/ThermalResistance/UValue.cs b/Units_Engine/Convert/ThermalResistance/UValue.cs new file mode 100644 index 0000000..78b5b67 --- /dev/null +++ b/Units_Engine/Convert/ThermalResistance/UValue.cs @@ -0,0 +1,62 @@ +/* + * This file is part of the Buildings and Habitats object Model (BHoM) + * Copyright (c) 2015 - 2024, 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 . + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using UN = UnitsNet; //This is to avoid clashes between UnitsNet quantity attributes and BHoM quantity attributes +using UnitsNet.Units; + +using System.ComponentModel; +using BH.oM.Base.Attributes; +using BH.oM.Quantities.Attributes; + +namespace BH.Engine.Units +{ + public static partial class Convert + { + [Description("Convert metric U-value (W/m2K) into imperial U-value (Btu/ft2-h-F)")] + [Input("metricUValue", "Metric U-value (W/m2K) to convert")] + [Output("uValue", "Imperial U-value in Btu/ft2-h-F")] + public static double ToUValue(this double metricUValue) + { + double rSI = 1/metricUValue; + return 1/ToRValue(rSI); + } + + [Description("Convert U-value (Btu/ft2-h-F) into metric U-value (W/m2K)")] + [Input("uValue", "Imperial U-value (Btu/ft2-h-F) to convert")] + [Output("metricUValue", "Metric U-value in W/m2K", typeof(ThermalResistanceUnit))] + public static double FromUvalue(this double uValue) + { + double rValue = 1/uValue; + return 1/FromRvalue(rValue); + } + } +} + + + +