diff --git a/Common/UnitDefinitions/Energy.json b/Common/UnitDefinitions/Energy.json index 033355792c..18f2a85f37 100644 --- a/Common/UnitDefinitions/Energy.json +++ b/Common/UnitDefinitions/Energy.json @@ -88,7 +88,7 @@ "PluralName": "WattHours", "FromUnitToBaseFunc": "x*3600d", "FromBaseToUnitFunc": "x/3600d", - "Prefixes": [ "Kilo", "Mega", "Giga" ], + "Prefixes": [ "Kilo", "Mega", "Giga", "Tera" ], "Localization": [ { "Culture": "en-US", diff --git a/UnitsNet.Tests/CustomCode/EnergyTests.cs b/UnitsNet.Tests/CustomCode/EnergyTests.cs index 3febc639e3..09807e8df2 100644 --- a/UnitsNet.Tests/CustomCode/EnergyTests.cs +++ b/UnitsNet.Tests/CustomCode/EnergyTests.cs @@ -49,6 +49,8 @@ public class EnergyTests : EnergyTestsBase protected override double ErgsInOneJoule => 10000000; + protected override double TerawattHoursInOneJoule => 2.77777778e-16; + protected override double ThermsEcInOneJoule => 9.4781712031331720001278504447561e-9; protected override double FootPoundsInOneJoule => 0.737562149; diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.NetFramework.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.NetFramework.g.cs index 45b185b837..e0fff37867 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.NetFramework.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.NetFramework.g.cs @@ -248,6 +248,11 @@ public Energy(double numericValue, EnergyUnit unit) /// public double MegawattHours => As(EnergyUnit.MegawattHour); + /// + /// Get Energy in TerawattHours. + /// + public double TerawattHours => As(EnergyUnit.TerawattHour); + /// /// Get Energy in ThermsEc. /// @@ -460,6 +465,15 @@ public static Energy FromMegawattHours(QuantityValue megawatthours) return new Energy(value, EnergyUnit.MegawattHour); } /// + /// Get Energy from TerawattHours. + /// + /// If value is NaN or Infinity. + public static Energy FromTerawattHours(QuantityValue terawatthours) + { + double value = (double) terawatthours; + return new Energy(value, EnergyUnit.TerawattHour); + } + /// /// Get Energy from ThermsEc. /// /// If value is NaN or Infinity. @@ -871,6 +885,7 @@ private double AsBaseUnit() case EnergyUnit.MegabritishThermalUnit: return (_value*1055.05585262) * 1e6d; case EnergyUnit.Megajoule: return (_value) * 1e6d; case EnergyUnit.MegawattHour: return (_value*3600d) * 1e6d; + case EnergyUnit.TerawattHour: return (_value*3600d) * 1e12d; case EnergyUnit.ThermEc: return _value*1.05505585262e8; case EnergyUnit.ThermImperial: return _value*1.05505585257348e8; case EnergyUnit.ThermUs: return _value*1.054804e8; @@ -907,6 +922,7 @@ private double AsBaseNumericType(EnergyUnit unit) case EnergyUnit.MegabritishThermalUnit: return (baseUnitValue/1055.05585262) / 1e6d; case EnergyUnit.Megajoule: return (baseUnitValue) / 1e6d; case EnergyUnit.MegawattHour: return (baseUnitValue/3600d) / 1e6d; + case EnergyUnit.TerawattHour: return (baseUnitValue/3600d) / 1e12d; case EnergyUnit.ThermEc: return baseUnitValue/1.05505585262e8; case EnergyUnit.ThermImperial: return baseUnitValue/1.05505585257348e8; case EnergyUnit.ThermUs: return baseUnitValue/1.054804e8; diff --git a/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs b/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs index f550255ca2..0c153614e5 100644 --- a/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs +++ b/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs @@ -339,6 +339,8 @@ private static readonly (string CultureName, Type UnitType, int UnitValue, strin ("en-US", typeof(EnergyUnit), (int)EnergyUnit.Megajoule, new string[]{"MJ"}), ("en-US", typeof(EnergyUnit), (int)EnergyUnit.MegawattHour, new string[]{"MWh"}), ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.MegawattHour, new string[]{"MВт/ч"}), + ("en-US", typeof(EnergyUnit), (int)EnergyUnit.TerawattHour, new string[]{"TWh"}), + ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.TerawattHour, new string[]{"TВт/ч"}), ("en-US", typeof(EnergyUnit), (int)EnergyUnit.ThermEc, new string[]{"th (E.C.)"}), ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.ThermEc, new string[]{"Европейский терм"}), ("en-US", typeof(EnergyUnit), (int)EnergyUnit.ThermImperial, new string[]{"th (imp.)"}), diff --git a/UnitsNet/GeneratedCode/Units/EnergyUnit.g.cs b/UnitsNet/GeneratedCode/Units/EnergyUnit.g.cs index d29480b5e8..a54293d2ea 100644 --- a/UnitsNet/GeneratedCode/Units/EnergyUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/EnergyUnit.g.cs @@ -62,6 +62,7 @@ public enum EnergyUnit MegabritishThermalUnit, Megajoule, MegawattHour, + TerawattHour, ThermEc, ThermImperial, ThermUs,