Skip to content

Conversion from "F" to "mK" erroneous #264

Open

Description

@martinsw

To get correct values for the conversion from "F" to "mK" I have to change this line in the UnitSystem.xml from
<UnitOfMeasure domainID="mK" scale="0.001" baseOffset="-0.27315">
to
<UnitOfMeasure domainID="mK" scale="0.001" baseOffset="-273.15">

Sample code to reproduce:
using RepresentationUnitSystem = AgGateway.ADAPT.Representation.UnitSystem;
...
private void erroneousConversion()
{
RepresentationUnitSystem.UnitOfMeasure sourceUOM = RepresentationUnitSystem.InternalUnitSystemManager.Instance.UnitOfMeasures["F"]; // Fahrenheit
// RepresentationUnitSystem.UnitOfMeasure targetUOM = RepresentationUnitSystem.InternalUnitSystemManager.Instance.UnitOfMeasures["K"]; // Kelvin
RepresentationUnitSystem.UnitOfMeasure targetUOM = RepresentationUnitSystem.InternalUnitSystemManager.Instance.UnitOfMeasures["mK"]; // Millikelvin
RepresentationUnitSystem.UnitOfMeasureConverter converter = new RepresentationUnitSystem.UnitOfMeasureConverter();
double convertedValue = converter.Convert(sourceUOM, targetUOM, 0); // 0° F == 255.4 K
System.Diagnostics.Debug.Print($"{convertedValue}");
convertedValue = converter.Convert(sourceUOM, targetUOM, 98.6); // 98.6° F == 310.1 K
System.Diagnostics.Debug.Print($"{convertedValue}");
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions