DHI.Physics.EUM — tiny interop with MIKE EUM¶
What it is: a tiny, internal helper that bridges our DHI.Physics model (Units/Dimensions/Quantities) with MIKE’s EUM (Euro Mouse) type & unit system from Generic.MikeZero. It lets you go to/from EUM ids and quickly validate allowed unit/type pairs.
Available via NuGet (private source or nuget.org, depending on your feed). Add it like any other package and reference
DHI.Physics.EUM.
API (one class)¶
public static class EumConvert
{
// 1) Physics Unit Id (string) -> EUM unit id (int)
public static int UnitToEumUnit(string unitId);
// 2) Unit abbreviation (e.g., "m", "m^3/s") -> EUM unit id (int)
public static int UnitAbbreviationToEumUnit(string unitAbbreviation);
// 3) EUM unit id (int) -> DHI.Physics.Unit
public static Unit EumUnitToUnit(int eumUnitId);
// 4) EUM type id (int) -> quantity type key (string)
public static string EumTypeToQuantityType(int eumTypeId);
// 5) quantity type key (string) -> EUM type id (int)
public static int QuantityTypeToEumType(string quantityType);
// 6) Validate if a unit is allowed for a given EUM type
public static bool IsAllowedUnit(int eumTypeId, int eumUnitId);
}
Notes & behavior¶
- Unit ids:
UnitToEumUnitaccepts either"meter"or"eumUmeter". If theeumUprefix is missing we add it, then match case-sensitively againsteumUnit. - Abbreviations:
UnitAbbreviationToEumUnitmatches exactly (case-sensitive) againstEUMValue(...).EumUnitAbbreviation. - EUM → Unit:
EumUnitToUnitbuilds aDHI.Physics.UnitusingEUMWrapper.eumUnitGetParameters(factor, offset, 7-base dimension powers). If all powers are zero, the unit isDimension.NonDimensional. - Exceptions: If a mapping can’t be found, methods throw
KeyNotFoundExceptionwith a clear message. - Allowed pairs:
IsAllowedUnitwrapsEUMWrapper.GetItemAllowedUnits(eumTypeId)and checks membership.
Quick examples¶
using DHI.Physics;
using DHI.Physics.EUM;
using static DHI.Physics.Units;
// 1) Physics unit id -> EUM unit id
int eumMeter = EumConvert.UnitToEumUnit("meter"); // e.g., 1000
// 2) Abbreviation -> EUM unit id
int eumMps = EumConvert.UnitAbbreviationToEumUnit("m/s");
// 3) EUM unit id -> Physics Unit
Unit u = EumConvert.EumUnitToUnit(eumMps); // Unit with Dimension L T^-1
// 4) EUM type id -> quantity type key (e.g., "Electrical Conductivity")
string qType = EumConvert.EumTypeToQuantityType(100000);
// 5) quantity type key -> EUM type id
int eumType = EumConvert.QuantityTypeToEumType("Electrical Conductivity");
// 6) Validate type/unit
bool ok = EumConvert.IsAllowedUnit(eumType, eumMps);
When to use¶
- Import/export with MIKE files or APIs that are EUM-typed.
- Validate that a selected unit is allowed for a given EUM item type.
- Convert an external EUM unit id into an internal
DHI.Physics.Unitso your domain services stay unit-aware.