## Modelica.SIunits.Conversions

Conversion functions to/from non SI units and type definitions of non SI units

### Information

This package provides conversion functions from the non SI Units defined in package Modelica.SIunits.Conversions.NonSIunits to the corresponding SI Units defined in package Modelica.SIunits and vice versa. It is recommended to use these functions in the following way:

      import SI = Modelica.SIunits;
      import Modelica.SIunits.Conversions.*;
         ...
      parameter SI.Temperature     T   = from_degC(25);   // convert 25 degree Celsius to Kelvin
      parameter SI.Angle           phi = from_deg(180);   // convert 180 degree to radian
      parameter SI.AngularVelocity w   = from_rpm(3600);  // convert 3600 revolutions per minutes
                                                          // to radian per seconds

The following conversion functions are provided. Note, that all of them have one Real input and one Real output argument:

Function | Description
--- | ---
to_degC from_degC | Convert from Kelvin to degree Celsius Convert from degree Celsius to Kelvin
to_degF from_degF | Convert from Kelvin to degree Fahrenheit Convert from degree Fahrenheit to Kelvin
to_degRk from_degRk | Convert from Kelvin to degree Rankine Convert from degree Rankine to Kelvin
to_deg from_deg | Convert from radian to degree Convert from degree to radian
to_rpm from_rpm | Convert from radian per second to revolutions per minute Convert from revolutions per minute to radian per second
to_kmh from_kmh | Convert from metre per second to kilometre per hour Convert from kilometre per hour to metre per second
to_day from_day | Convert from second to day Convert from day to second
to_hour from_hour | Convert from second to hour Convert from hour to second
to_minute from_minute | Convert from second to minute Convert from minute to second
to_litre from_litre | Convert from cubic metre to litre Convert from litre to cubic metre
to_kWh from_kWh | Convert from Joule to kilo Watt hour Convert from kilo Watt hour to Joule
to_bar from_bar | Convert from Pascal to bar Convert from bar to Pascal
to_gps from_gps | Convert from kilogram per second to gram per second Convert from gram per second to kilogram per second

There is the additional partial function ConversionIcon in this package. It contains just the base icon for all the conversion functions.

## Modelica.SIunits.Conversions.to_degC

Convert from Kelvin to °Celsius

### Modelica definition

    function to_degC "Convert from Kelvin to °Celsius"
      extends ConversionIcon;
      input Temperature Kelvin "Kelvin value";
      output NonSIunits.Temperature_degC Celsius "Celsius value";
    algorithm
      Celsius := Kelvin + Modelica.Constants.T_zero;
    end to_degC;

## Modelica.SIunits.Conversions.from_degC

Convert from °Celsius to Kelvin

### Modelica definition

    function from_degC "Convert from °Celsius to Kelvin"
      extends ConversionIcon;
      input NonSIunits.Temperature_degC Celsius "Celsius value";
      output Temperature Kelvin "Kelvin value";
    algorithm
      Kelvin := Celsius - Modelica.Constants.T_zero;
    end from_degC;

## Modelica.SIunits.Conversions.to_degF

Convert from Kelvin to °Fahrenheit

### Modelica definition

    function to_degF "Convert from Kelvin to °Fahrenheit"
      extends ConversionIcon;
      input Temperature Kelvin "Kelvin value";
      output NonSIunits.Temperature_degF Fahrenheit "Fahrenheit value";
    algorithm
      Fahrenheit := (Kelvin + Modelica.Constants.T_zero)*(9/5) + 32;
    end to_degF;

## Modelica.SIunits.Conversions.from_degF

Convert from °Fahrenheit to Kelvin

### Modelica definition

    function from_degF "Convert from °Fahrenheit to Kelvin"
      extends ConversionIcon;
      input NonSIunits.Temperature_degF Fahrenheit "Fahrenheit value";
      output Temperature Kelvin "Kelvin value";
    algorithm
      Kelvin := (Fahrenheit - 32)*(5/9) - Modelica.Constants.T_zero;
    end from_degF;

## Modelica.SIunits.Conversions.to_degRk

Convert from Kelvin to °Rankine

### Modelica definition

    function to_degRk "Convert from Kelvin to °Rankine"
      extends ConversionIcon;
      input Temperature Kelvin "Kelvin value";
      output NonSIunits.Temperature_degRk Rankine "Rankine value";
    algorithm
      Rankine := (9/5)*Kelvin;
    end to_degRk;

## Modelica.SIunits.Conversions.from_degRk

Convert from °Rankine to Kelvin

### Modelica definition

    function from_degRk "Convert from °Rankine to Kelvin"
      extends ConversionIcon;
      input NonSIunits.Temperature_degRk Rankine "Rankine value";
      output Temperature Kelvin "Kelvin value";
    algorithm
      Kelvin := (5/9)*Rankine;
    end from_degRk;

## Modelica.SIunits.Conversions.to_deg

Convert from radian to degree

### Modelica definition

    function to_deg "Convert from radian to degree"
      extends ConversionIcon;
      input Angle radian "radian value";
      output NonSIunits.Angle_deg degree "degree value";
    algorithm
      degree := (180.0/Modelica.Constants.pi)*radian;
    end to_deg;

## Modelica.SIunits.Conversions.from_deg

Convert from degree to radian

### Modelica definition

    function from_deg "Convert from degree to radian"
      extends ConversionIcon;
      input NonSIunits.Angle_deg degree "degree value";
      output Angle radian "radian value";
    algorithm
      radian := (Modelica.Constants.pi/180.0)*degree;
    end from_deg;

## Modelica.SIunits.Conversions.to_rpm

Convert from radian per second to revolutions per minute

### Modelica definition

    function to_rpm
      "Convert from radian per second to revolutions per minute"
      extends ConversionIcon;
      input AngularVelocity rs "radian per second value";
      output NonSIunits.AngularVelocity_rpm rpm "revolutions per minute value";
    algorithm
      rpm := (30/Modelica.Constants.pi)*rs;
    end to_rpm;

## Modelica.SIunits.Conversions.from_rpm

Convert from revolutions per minute to radian per second

### Modelica definition

    function from_rpm
      "Convert from revolutions per minute to radian per second"
      extends ConversionIcon;
      input NonSIunits.AngularVelocity_rpm rpm "revolutions per minute value";
      output AngularVelocity rs "radian per second value";
    algorithm
      rs := (Modelica.Constants.pi/30)*rpm;
    end from_rpm;

## Modelica.SIunits.Conversions.to_kmh

Convert from metre per second to kilometre per hour

### Modelica definition

    function to_kmh "Convert from metre per second to kilometre per hour"

      extends ConversionIcon;
      input Velocity ms "metre per second value";
      output NonSIunits.Velocity_kmh kmh "kilometre per hour value";
    algorithm
      kmh := 3.6*ms;
    end to_kmh;

## Modelica.SIunits.Conversions.from_kmh

Convert from kilometre per hour to metre per second

### Modelica definition

    function from_kmh
      "Convert from kilometre per hour to metre per second"
      extends ConversionIcon;
      input NonSIunits.Velocity_kmh kmh "kilometre per hour value";
      output Velocity ms "metre per second value";
    algorithm
      ms := kmh/3.6;
    end from_kmh;

## Modelica.SIunits.Conversions.to_day

Convert from second to day

### Modelica definition

    function to_day "Convert from second to day"
      extends ConversionIcon;
      input Time s "second value";
      output NonSIunits.Time_day day "day value";
    algorithm
      day := s/86400;
    end to_day;

## Modelica.SIunits.Conversions.from_day

Convert from day to second

### Modelica definition

    function from_day "Convert from day to second"
      extends ConversionIcon;
      input NonSIunits.Time_day day "day value";
      output Time s "second value";
    algorithm
      s := 86400*day;
    end from_day;

## Modelica.SIunits.Conversions.to_hour

Convert from second to hour

### Modelica definition

    function to_hour "Convert from second to hour"
      extends ConversionIcon;
      input Time s "second value";
      output NonSIunits.Time_hour hour "hour value";
    algorithm
      hour := s/3600;
    end to_hour;

## Modelica.SIunits.Conversions.from_hour

Convert from hour to second

### Modelica definition

    function from_hour "Convert from hour to second"
      extends ConversionIcon;
      input NonSIunits.Time_hour hour "hour value";
      output Time s "second value";
    algorithm
      s := 3600*hour;
    end from_hour;

## Modelica.SIunits.Conversions.to_minute

Convert from second to minute

### Modelica definition

    function to_minute "Convert from second to minute"
      extends ConversionIcon;
      input Time s "second value";
      output NonSIunits.Time_minute minute "minute value";
    algorithm
      minute := s/60;
    end to_minute;

## Modelica.SIunits.Conversions.from_minute

Convert from minute to second

### Modelica definition

    function from_minute "Convert from minute to second"
      extends ConversionIcon;
      input NonSIunits.Time_minute minute "minute value";
      output Time s "second value";
    algorithm
      s := 60*minute;
    end from_minute;

## Modelica.SIunits.Conversions.to_litre

Convert from cubic metre to litre

### Modelica definition

    function to_litre "Convert from cubic metre to litre"
      extends ConversionIcon;
      input Volume m3 "cubic metre value";
      output NonSIunits.Volume_litre litre "litre value";
    algorithm
      litre := 1000*m3;
    end to_litre;

## Modelica.SIunits.Conversions.from_litre

Convert from litre to cubic metre

### Modelica definition

    function from_litre "Convert from litre to cubic metre"
      extends ConversionIcon;
      input NonSIunits.Volume_litre litre "litre value";
      output Volume m3 "cubic metre value";
    algorithm
      m3 := litre/1000;
    end from_litre;

## Modelica.SIunits.Conversions.to_kWh

Convert from Joule to kilo Watt hour

### Modelica definition

    function to_kWh "Convert from Joule to kilo Watt hour"
      extends ConversionIcon;
      input Energy J "Joule value";
      output NonSIunits.Energy_kWh kWh "kWh value";
    algorithm
      kWh := J/3.6e6;
    end to_kWh;

## Modelica.SIunits.Conversions.from_kWh

Convert from kilo Watt hour to Joule

### Modelica definition

    function from_kWh "Convert from kilo Watt hour to Joule"
      extends ConversionIcon;
      input NonSIunits.Energy_kWh kWh "kWh value";
      output Energy J "Joule value";
    algorithm
      J := 3.6e6*kWh;
    end from_kWh;

## Modelica.SIunits.Conversions.to_bar

Convert from Pascal to bar

### Modelica definition

    function to_bar "Convert from Pascal to bar"
      extends ConversionIcon;
      input Pressure Pa "Pascal value";
      output NonSIunits.Pressure_bar bar "bar value";
    algorithm
      bar := Pa/1e5;
    end to_bar;

## Modelica.SIunits.Conversions.from_bar

Convert from bar to Pascal

### Modelica definition

    function from_bar "Convert from bar to Pascal"
      extends ConversionIcon;
      input NonSIunits.Pressure_bar bar "bar value";
      output Pressure Pa "Pascal value";
    algorithm
      Pa := 1e5*bar;
    end from_bar;

## Modelica.SIunits.Conversions.to_gps

Convert from kilogram per second to gram per second

### Modelica definition

    function to_gps "Convert from kilogram per second to gram per second"

      extends ConversionIcon;
      input MassFlowRate kgps "kg/s value";
      output NonSIunits.MassFlowRate_gps gps "g/s value";
    algorithm
      gps := 1000*kgps;
    end to_gps;

## Modelica.SIunits.Conversions.from_gps

Convert from gram per second to kilogram per second

### Modelica definition

    function from_gps
      "Convert from gram per second to kilogram per second"
      extends ConversionIcon;
      input NonSIunits.MassFlowRate_gps gps "g/s value";
      output MassFlowRate kgps "kg/s value";
    algorithm
      kgps := gps/1000;
    end from_gps;

## Modelica.SIunits.Conversions.ConversionIcon

Base icon for conversion functions

### Modelica definition

    partial function ConversionIcon "Base icon for conversion functions"
    end ConversionIcon;