Skip to content

Commit

Permalink
(#12) moved methods from climate toolkit
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Kingstone authored and Fraser Greenroyd committed Sep 11, 2023
1 parent 9e866fe commit 276ba3d
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 27 deletions.
55 changes: 55 additions & 0 deletions Psychrometrics_Engine/Compute/DensityWater.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, 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 System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using BH.oM.Base.Attributes;
using BH.oM.Base;
using BH.Engine.Base;

namespace BH.Engine.Psychrometrics
{
public static partial class Compute
{
[Description("Calculates water density from temperature.")]
[Input("temperature", "temperature (C).")]
[Output("density", "Density (kg/m3).")]
[PreviousVersion("6.3", "BH.Engine.Climate.Compute.DensityWater(System.Double)")]
public static double DensityWater(double temperature)
{
double t = temperature;
if (t < 0 || t > 150)
{
BH.Engine.Base.Compute.RecordError("Temperature must be greater than 0 and less than 150 degC.");
return double.NaN;
}
else
{
return 999.792764532729 + 0.07544354069978 * t - 8.88812233461067e-03 * Math.Pow(t, 2) + 7.43496157156187e-05 * Math.Pow(t, 3) - 5.05819372165206e-07 * Math.Pow(t, 4) + 1.71286251848812e-09 * Math.Pow(t, 5) - 3.41712769191815e-13 * Math.Pow(t, 6) - 8.9940922954777e-15 * Math.Pow(t, 7);
}
}
}
}
18 changes: 9 additions & 9 deletions Psychrometrics_Engine/Compute/FromHumidityRatio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ namespace BH.Engine.Psychrometrics
public static partial class Compute
{
[Description("Calculates density, enthalpy, dew-point temperature, relative humidity, specific volume and wet-bulb temperature from dry-bulb temperature, pressure and humidity ratio.")]
[Input("dryBulbTemperature", "Dry-bulb temperature (C)")]
[Input("humidityRatio", "Humidity ratio (kg_water/kg_dryair")]
[Input("pressure", "Air pressure (Pa), defaults to sea level air pressure (101,325 Pa)")]
[MultiOutput(0, "density", "Density (kg/m3)")]
[MultiOutput(1, "enthalpy", "Enthalpy (J/kg)")]
[MultiOutput(2, "dewPoint", "Dew-point temperature (C)")]
[MultiOutput(3, "relativeHumidity", "Relative humidity (%)")]
[MultiOutput(4, "specificVolume", "Specific Volume (m3/kg)")]
[MultiOutput(5, "wetBulbTemperature", "Wet-bulb temperature (C)")]
[Input("dryBulbTemperature", "Dry-bulb temperature (C).")]
[Input("humidityRatio", "Humidity ratio (kg_water/kg_dryair).")]
[Input("pressure", "Air pressure (Pa), defaults to sea level air pressure (101,325 Pa).")]
[MultiOutput(0, "density", "Density (kg/m3).")]
[MultiOutput(1, "enthalpy", "Enthalpy (J/kg).")]
[MultiOutput(2, "dewPoint", "Dew-point temperature (C).")]
[MultiOutput(3, "relativeHumidity", "Relative humidity (%).")]
[MultiOutput(4, "specificVolume", "Specific Volume (m3/kg).")]
[MultiOutput(5, "wetBulbTemperature", "Wet-bulb temperature (C).")]
[PreviousVersion("6.3", "BH.Engine.Psychrometrics.Compute.DensityHumidityRatio(System.Double, System.Double, System.Double)")]
[PreviousVersion("6.3", "BH.Engine.Psychrometrics.Compute.EnthalpyHumidityRatio(System.Double, System.Double)")]
[PreviousVersion("6.3", "BH.Engine.Psychrometrics.Compute.DewPointHumidityRatio(System.Double, System.Double, System.Double)")]
Expand Down
18 changes: 9 additions & 9 deletions Psychrometrics_Engine/Compute/FromRelativeHumidity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ namespace BH.Engine.Psychrometrics
public static partial class Compute
{
[Description("Calculates density, enthalpy, dew-point temperature, humidity ratio, specific volume and wet-bulb temperature from dry-bulb temperature, pressure and relative humidity.")]
[Input("dryBulbTemperature", "Dry-bulb temperature (C)")]
[Input("relativeHumidity", "Relative humidity (%)")]
[Input("pressure", "Air pressure (Pa), defaults to sea level air pressure (101,325 Pa)")]
[MultiOutput(0, "density", "Density (kg/m3)")]
[MultiOutput(1, "enthalpy", "Enthalpy (J/kg)")]
[MultiOutput(2, "dewPoint", "Dew-point temperature (C)")]
[MultiOutput(3, "humidityRatio", "Humidity ratio (kg_water/kg_dryair)")]
[MultiOutput(4, "specificVolume", "Specific Volume (m3/kg)")]
[MultiOutput(5, "wetBulbTemperature", "Wet-bulb temperature (C)")]
[Input("dryBulbTemperature", "Dry-bulb temperature (C).")]
[Input("relativeHumidity", "Relative humidity (%).")]
[Input("pressure", "Air pressure (Pa), defaults to sea level air pressure (101,325 Pa).")]
[MultiOutput(0, "density", "Density (kg/m3).")]
[MultiOutput(1, "enthalpy", "Enthalpy (J/kg).")]
[MultiOutput(2, "dewPoint", "Dew-point temperature (C).")]
[MultiOutput(3, "humidityRatio", "Humidity ratio (kg_water/kg_dryair).")]
[MultiOutput(4, "specificVolume", "Specific Volume (m3/kg).")]
[MultiOutput(5, "wetBulbTemperature", "Wet-bulb temperature (C).")]
[PreviousVersion("6.3", "BH.Engine.Psychrometrics.Compute.DensityRelativeHumidity(System.Double, System.Double, System.Double)")]
[PreviousVersion("6.3", "BH.Engine.Psychrometrics.Compute.EnthalpyRelativeHumidity(System.Double, System.Double, System.Double)")]
[PreviousVersion("6.3", "BH.Engine.Psychrometrics.Compute.DewPointRelativeHumidity(System.Double, System.Double, System.Double)")]
Expand Down
18 changes: 9 additions & 9 deletions Psychrometrics_Engine/Compute/FromWetBulbTemperature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ namespace BH.Engine.Psychrometrics
public static partial class Compute
{
[Description("Calculates density, enthalpy, dew-point temperature, humidity ratio, relative humidity and specific volume from dry-bulb temperature, pressure and wet-bulb temperature.")]
[Input("dryBulbTemperature", "Dry-bulb temperature (C)")]
[Input("wetBulbTemperature", "Wet-bulb temperature (C)")]
[Input("pressure", "Air pressure (Pa), defaults to sea level air pressure (101,325 Pa)")]
[MultiOutput(0, "density", "Density (kg/m3)")]
[MultiOutput(1, "enthalpy", "Enthalpy (J/kg)")]
[MultiOutput(2, "dewPoint", "Dew-point temperature (C)")]
[MultiOutput(3, "humidityRatio", "Humidity ratio (kg_water/kg_dryair)")]
[MultiOutput(4, "relativeHumidity", "Relative humidity (%)")]
[MultiOutput(5, "specificVolume", "Specific Volume (m3/kg)")]
[Input("dryBulbTemperature", "Dry-bulb temperature (C).")]
[Input("wetBulbTemperature", "Wet-bulb temperature (C).")]
[Input("pressure", "Air pressure (Pa), defaults to sea level air pressure (101,325 Pa).")]
[MultiOutput(0, "density", "Density (kg/m3).")]
[MultiOutput(1, "enthalpy", "Enthalpy (J/kg).")]
[MultiOutput(2, "dewPoint", "Dew-point temperature (C).")]
[MultiOutput(3, "humidityRatio", "Humidity ratio (kg_water/kg_dryair).")]
[MultiOutput(4, "relativeHumidity", "Relative humidity (%).")]
[MultiOutput(5, "specificVolume", "Specific Volume (m3/kg).")]
[PreviousVersion("6.3", "BH.Engine.Psychrometrics.Compute.DensityWetBulbTemperature(System.Double, System.Double, System.Double)")]
[PreviousVersion("6.3", "BH.Engine.Psychrometrics.Compute.EnthalpyWetBulbTemperature(System.Double, System.Double, System.Double)")]
[PreviousVersion("6.3", "BH.Engine.Psychrometrics.Compute.DewPointWetBulbTemperature(System.Double, System.Double, System.Double)")]
Expand Down
61 changes: 61 additions & 0 deletions Psychrometrics_Engine/Compute/SaturatedVapourPressureWater.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, 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 System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using BH.oM.Base.Attributes;
using BH.oM.Base;
using BH.Engine.Base;

namespace BH.Engine.Psychrometrics
{
public static partial class Compute
{
[Description("Calculates water SaturatedVapourPressure from temperature.")]
[Input("temperature", "temperature (degC).")]
[Output("saturatedVapourPressure", "Saturated Vapour Pressure (Pa).")]
[PreviousVersion("6.3", "BH.Engine.Climate.Compute.SaturatedVapourPressureWater(Systetm.Double)")]
public static double SaturatedVapourPressureWater(double temperature)
{
BH.Engine.Base.Compute.RecordWarning("This method has not been thoroughly tested. The output may be incorrect. Use at own risk.");

double t = temperature;
if (t < 0 || t > 150)
{
BH.Engine.Base.Compute.RecordError("Temperature must be greater than 0 and less than 150 degC.");
return double.NaN;
}
else if (temperature < 21)
{
return 6.10830198582769e-03 + 3.69554702125838e-04 * t + 2.4671509929139e-05 * Math.Pow(t, 2);
}
else
{
return 2.76521518826485e-02 - 1.9984832033515e-03 * t + 1.26386221381836e-04 * Math.Pow(t, 2) - 2.43248314291122E-06 * Math.Pow(t, 3) + 3.97667179186101E-08 * Math.Pow(t, 4) - 2.63438493242063e-10 * Math.Pow(t, 5) + 1.23191485224688e-12 * Math.Pow(t, 6) - 2.20158156672378E-15 * Math.Pow(t, 7);
}
}
}
}
55 changes: 55 additions & 0 deletions Psychrometrics_Engine/Compute/SpecificHeatCapacityWater.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* This file is part of the Buildings and Habitats object Model (BHoM)
* Copyright (c) 2015 - 2023, 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 System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using BH.oM.Base.Attributes;
using BH.oM.Base;
using BH.Engine.Base;

namespace BH.Engine.Psychrometrics
{
public static partial class Compute
{
[Description("Calculates Water SpecificHeatCapacity from temperature.")]
[Input("temperature", "temperature (C).")]
[Output("specificHeatCapacity", "Specific Heat Capacity (kJ/kgK).")]
[PreviousVersion("6.3", "BH.Engine.Climate.Compute.SpecificHeatCapacityWater(System.Double)")]
public static double SpecificHeatCapacityWater(double temperature)
{
double t = temperature;
if (t < 0 || t > 150)
{
BH.Engine.Base.Compute.RecordError("Temperature must be greater than 0 and less than 150 degC.");
return double.NaN;
}
else
{
return 4.21704317315562 - 3.38336617551249e-03 * t + 1.15883761850455e-04 * Math.Pow(t, 2) - 2.08959843561729e-06 * Math.Pow(t, 3) + 2.27639253003176e-08 * Math.Pow(t, 4) - 1.42019051900533e-10 * Math.Pow(t, 5) + 4.7949488211343e-13 * Math.Pow(t, 6) - 6.7653778811732e-16 * Math.Pow(t, 7);
}
}
}
}

0 comments on commit 276ba3d

Please sign in to comment.