public static double ToJoule(double srcValue, EnergyRepresentation srcUnit) { switch (srcUnit) { case EnergyRepresentation.Joule: return(srcValue); case EnergyRepresentation.JoulePerMole: return(srcValue / SIConstants.AVOGADROS_CONSTANT); case EnergyRepresentation.CalorieInternational: return(srcValue * SIConstants.CALORIE); case EnergyRepresentation.CalorieInternationalPerMole: return(srcValue * SIConstants.CALORIE / SIConstants.AVOGADROS_CONSTANT); case EnergyRepresentation.ElectronVolt: return(srcValue * SIConstants.ELECTRON_VOLT); case EnergyRepresentation.KilowattHours: return(srcValue * 3600000); case EnergyRepresentation.AsTemperatureKelvin: return(srcValue * SIConstants.BOLTZMANN); default: throw new ArgumentOutOfRangeException("EnergyUnit unknown: " + srcUnit.ToString()); } }
public static double FromTo(double srcValue, EnergyRepresentation srcUnit, EnergyRepresentation destUnit) { if (srcUnit == destUnit) { return(srcValue); } else { return(FromJouleTo(ToJoule(srcValue, srcUnit), destUnit)); } }
public static double ToJoule(double srcValue, EnergyRepresentation srcUnit) { switch (srcUnit) { case EnergyRepresentation.Joule: return srcValue; case EnergyRepresentation.JoulePerMole: return srcValue / SIConstants.AVOGADROS_CONSTANT; case EnergyRepresentation.CalorieInternational: return srcValue * SIConstants.CALORIE; case EnergyRepresentation.CalorieInternationalPerMole: return srcValue * SIConstants.CALORIE / SIConstants.AVOGADROS_CONSTANT; case EnergyRepresentation.ElectronVolt: return srcValue * SIConstants.ELECTRON_VOLT; case EnergyRepresentation.KilowattHours: return srcValue * 3600000; case EnergyRepresentation.AsTemperatureKelvin: return srcValue * SIConstants.BOLTZMANN; default: throw new ArgumentOutOfRangeException("EnergyUnit unknown: " + srcUnit.ToString()); } }
public Energy ConvertTo(EnergyRepresentation destUnit) { return new Energy(FromTo(_value, _unit, destUnit), destUnit); }
public double InUnitsOf(EnergyRepresentation destUnit) { return FromTo(_value, _unit, destUnit); }
public Energy(double value, EnergyRepresentation unit) { _unit = unit; _value = value; }
/// <summary> /// Returns the temperature (in Kelvin) corresponding to the provided energy. /// </summary> /// <param name="srcValue">Energy value.</param> /// <param name="srcUnit">Energy unit.</param> /// <returns>Temperature E/kB in Kelvin, where kB is the BOLTZMANN constant and E the energy in Joule.</returns> public static double ToTemperatureSI(double srcValue, EnergyRepresentation srcUnit) { return ToJoule(srcValue, srcUnit) / SIConstants.BOLTZMANN; }
public static double FromTo(double srcValue, EnergyRepresentation srcUnit, EnergyRepresentation destUnit) { if (srcUnit == destUnit) return srcValue; else return FromJouleTo(ToJoule(srcValue, srcUnit), destUnit); }
public Energy ConvertTo(EnergyRepresentation destUnit) { return(new Energy(FromTo(_value, _unit, destUnit), destUnit)); }
public double InUnitsOf(EnergyRepresentation destUnit) { return(FromTo(_value, _unit, destUnit)); }
public Energy(double value, EnergyRepresentation unit) { _unit = unit; _value = value; }
/// <summary> /// Returns the temperature (in Kelvin) corresponding to the provided energy. /// </summary> /// <param name="srcValue">Energy value.</param> /// <param name="srcUnit">Energy unit.</param> /// <returns>Temperature E/kB in Kelvin, where kB is the BOLTZMANN constant and E the energy in Joule.</returns> public static double ToTemperatureSI(double srcValue, EnergyRepresentation srcUnit) { return(ToJoule(srcValue, srcUnit) / SIConstants.BOLTZMANN); }