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

Combined methods with similar inputs #54

Merged
merged 4 commits into from
Sep 4, 2023
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
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);
}
}
}
}
76 changes: 76 additions & 0 deletions Psychrometrics_Engine/Compute/FromHumidityRatio.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* 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 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).")]
[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)")]
[PreviousVersion("6.3", "BH.Engine.Psychrometrics.Compute.RelativeHumidityHumidityRatio(System.Double, System.Double, System.Double)")]
[PreviousVersion("6.3", "BH.Engine.Psychrometrics.Compute.SpecificVolumeHumidityRatio(System.Double, System.Double, System.Double)")]
[PreviousVersion("6.3", "BH.Engine.Psychrometrics.Compute.WetBulbHumidityRatio(System.Double, System.Double, System.Double)")]
public static Output<double, double, double, double, double, double> FromHumidityRatio(
double dryBulbTemperature,
double humidityRatio,
double pressure = 101325)
{
double Density = DensityHumidityRatio(dryBulbTemperature, humidityRatio, pressure);
double Enthalpy = EnthalpyHumidityRatio(dryBulbTemperature, humidityRatio);
double DewPoint = DewPointHumidityRatio(dryBulbTemperature, humidityRatio, pressure);
double RelativeHumidity = RelativeHumidityHumidityRatio(dryBulbTemperature, humidityRatio, pressure);
double SpecificVolume = SpecificVolumeHumidityRatio(dryBulbTemperature, humidityRatio, pressure);
double WetBulbTemperature = WetBulbHumidityRatio(dryBulbTemperature, humidityRatio, pressure);

return new Output<double, double, double, double, double, double>
{
Item1 = Density,
Item2 = Enthalpy,
Item3 = DewPoint,
Item4 = RelativeHumidity,
Item5 = SpecificVolume,
Item6 = WetBulbTemperature
};
}
}
}
76 changes: 76 additions & 0 deletions Psychrometrics_Engine/Compute/FromRelativeHumidity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* 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 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).")]
[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)")]
[PreviousVersion("6.3", "BH.Engine.Psychrometrics.Compute.HumidityRatioRelativeHumidity(System.Double, System.Double, System.Double)")]
[PreviousVersion("6.3", "BH.Engine.Psychrometrics.Compute.SpecificVolumeRelativeHumidity(System.Double, System.Double, System.Double)")]
[PreviousVersion("6.3", "BH.Engine.Psychrometrics.Compute.WetBulbTemperatureRelativeHumidity(System.Double, System.Double, System.Double)")]
public static Output<double, double, double, double, double, double> FromRelativeHumidity(
double dryBulbTemperature,
double relativeHumidity,
double pressure = 101325)
{
double Density = DensityRelativeHumidity(dryBulbTemperature, relativeHumidity, pressure);
double Enthalpy = EnthalpyRelativeHumidity(dryBulbTemperature, relativeHumidity, pressure);
double DewPoint = DewPointRelativeHumidity(dryBulbTemperature, relativeHumidity, pressure);
double HumidityRatio = HumidityRatioRelativeHumidity(dryBulbTemperature, relativeHumidity, pressure);
double SpecificVolume = SpecificVolumeRelativeHumidity(dryBulbTemperature, relativeHumidity, pressure);
double WetBulbTemperature = WetBulbTemperatureRelativeHumidity(dryBulbTemperature, relativeHumidity, pressure);

return new Output<double, double, double, double, double, double>
{
Item1 = Density,
Item2 = Enthalpy,
Item3 = DewPoint,
Item4 = HumidityRatio,
Item5 = SpecificVolume,
Item6 = WetBulbTemperature
};
}
}
}
76 changes: 76 additions & 0 deletions Psychrometrics_Engine/Compute/FromWetBulbTemperature.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* 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 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).")]
[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)")]
[PreviousVersion("6.3", "BH.Engine.Psychrometrics.Compute.HumidityRatioWetBulbTemperature(System.Double, System.Double, System.Double)")]
[PreviousVersion("6.3", "BH.Engine.Psychrometrics.Compute.RelativeHumidityWetBulbTemperature(System.Double, System.Double, System.Double)")]
[PreviousVersion("6.3", "BH.Engine.Psychrometrics.Compute.SpecificVolumeWetBulbTemperature(System.Double, System.Double, System.Double)")]
public static Output<double, double, double, double, double, double> FromWetBulbTemperature(
double dryBulbTemperature,
double wetBulbTemperature,
double pressure = 101325)
{
double Density = DensityWetBulbTemperature(dryBulbTemperature, wetBulbTemperature, pressure);
double Enthalpy = EnthalpyWetBulbTemperature(dryBulbTemperature, wetBulbTemperature, pressure);
double DewPoint = DewPointWetBulbTemperature(dryBulbTemperature, wetBulbTemperature, pressure);
double HumidityRatio = HumidityRatioWetBulbTemperature(dryBulbTemperature, wetBulbTemperature, pressure);
double RelativeHumidity = RelativeHumidityWetBulbTemperature(dryBulbTemperature, wetBulbTemperature, pressure);
double SpecificVolume = SpecificVolumeWetBulbTemperature(dryBulbTemperature, wetBulbTemperature, pressure);

return new Output<double, double, double, double, double, double>
{
Item1 = Density,
Item2 = Enthalpy,
Item3 = DewPoint,
Item4 = HumidityRatio,
Item5 = RelativeHumidity,
Item6 = SpecificVolume
};
}
}
}
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);
}
}
}
}
Loading