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

Add units to support AGS toolkit #129

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions Units_Engine/Convert/Density/Density.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public static double ToDensity(this double kilogramPerCubicMetres, object unit)
return UNU.DensityUnit.MilligramPerCubicMeter;
case DensityUnit.MilligramPerDeciliter:
return UNU.DensityUnit.MilligramPerDeciliter;
case "mgcaco3/l":
case DensityUnit.MilligramPerLiter:
return UNU.DensityUnit.MilligramPerLiter;
case DensityUnit.MilligramPerMilliliter:
Expand Down
57 changes: 57 additions & 0 deletions Units_Engine/Convert/Molality/MillimolePerKilogram.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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 <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 UN = UnitsNet; //This is to avoid clashes between UnitsNet quantity attributes and BHoM quantity attributes
using UnitsNet.Units;
peterjamesnugent marked this conversation as resolved.
Show resolved Hide resolved
using System.ComponentModel;
using BH.oM.Base.Attributes;
using BH.oM.Quantities.Attributes;

namespace BH.Engine.Units
{
public static partial class Convert
{
[Description("Convert SI units (molePerKilogram) into millimolePerKilogram.")]
[Input("molePerKilograms", "The number of molePerKilogram to convert.", typeof(Molality))]
[Output("millimolePerKilograms", "The number of millimolePerKilogram.")]
public static double ToMillimolePerKilogram(this double molePerKilograms)
{
UN.QuantityValue qv = molePerKilograms;
return UN.UnitConverter.Convert(qv, MolalityUnit.MolePerKilogram, MolalityUnit.MillimolePerKilogram);
}

/***************************************************/

[Description("Convert millimolePerKilogram into SI units (molePerKilogram).")]
[Input("millimolePerKilograms", "The number of millimolePerKilograms to convert.")]
[Output("molePerKilograms", "The number of molePerKilograms.", typeof(Molality))]
public static double FromMillimolePerKilogram(this double millimolePerKilograms)
{
UN.QuantityValue qv = millimolePerKilograms;
return UN.UnitConverter.Convert(qv, MolalityUnit.MillimolePerKilogram, MolalityUnit.MolePerKilogram);
}
}
}
2 changes: 2 additions & 0 deletions Units_Engine/Convert/Molality/Molality.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ public static double ToMolality(this double molePerKilograms, object unit)
return UNU.MolalityUnit.MolePerGram;
case MolalityUnit.MolePerKilogram:
return UNU.MolalityUnit.MolePerKilogram;
case MolalityUnit.MillimolePerKilogram:
return UNU.MolalityUnit.MillimolePerKilogram;
default:
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion Units_Engine/Units_Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</Target>

<ItemGroup>
<PackageReference Include="UnitsNet" Version="5.42.0" />
<PackageReference Include="UnitsNet" Version="5.55.0" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion Units_oM/Enums/Molality.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public enum MolalityUnit
{
Undefined = 0,
MolePerKilogram = 1,
MolePerGram = 2
MolePerGram = 2,
MillimolePerKilogram = 3
}
}