Skip to content
MadsKirkFoged edited this page Sep 2, 2021 · 1 revision

Setting up an equation

//How much Power (Watt) does it take to heat up the water
SpecificEntropy P1 = new SpecificEntropy(1, SpecificEntropyUnit.JoulePerKilogramKelvin);
MassFlow M1 = new MassFlow(1, MassFlowUnit.KilogramPerSecond);
MassFlow M2 = new MassFlow(4, MassFlowUnit.KilogramPerSecond);
Temperature T2 = new Temperature(10, TemperatureUnit.DegreeCelsius);
Temperature T1 = new Temperature(5, TemperatureUnit.DegreeCelsius);

Power Q1 = M1 * P1 * (T2 - T1);

Showing to the user in different ways

Debug.Print($"Result without specifying the unit: {Q1}"); //Result without specifying the unit: 5 W

Debug.Print($"Unit as double: {Q1.As(PowerUnit.BritishThermalUnitPerHour)}"); //Unit as double: 17.06064110098004

Debug.Print($"Unit with limited precision: {Q1.As(PowerUnit.BritishThermalUnitPerHour):g4}"); //Unit with limited precision: 17.06

Debug.Print($"Converting it into new unit: {Q1.ToUnit(PowerUnit.KilocaloriePerHour)}"); //Converting it into new unit: 4.302 kcal/h

Raise to the Power of

Length L1 = new Length(4.3, LengthUnit.Foot);
Area A1 = L1.Pow(2);
Debug.Print($"Area: {A1}"); //Area: 1.718 m²

Absolute value

Power P1 = Power.FromGigawatts(-1);
Debug.Print($"Absolute value is: {P1.Abs()}"); //Absolute value is: 1 GW