1 package org.djunits.unit;
2
3 import org.djunits.unit.quantity.Quantity;
4 import org.djunits.unit.scale.IdentityScale;
5 import org.djunits.unit.scale.LinearScale;
6 import org.djunits.unit.si.SIPrefixes;
7 import org.djunits.unit.unitsystem.UnitSystem;
8
9
10
11
12
13
14
15
16
17 public class EnergyUnit extends Unit<EnergyUnit>
18 {
19
20 private static final long serialVersionUID = 20140604L;
21
22
23 public static final Quantity<EnergyUnit> BASE = new Quantity<>("Energy", "kgm2/s2");
24
25
26 public static final EnergyUnit SI =
27 new EnergyUnit().build(new Unit.Builder<EnergyUnit>().setQuantity(BASE).setId("J").setName("joule")
28 .setUnitSystem(UnitSystem.SI_DERIVED).setSiPrefixes(SIPrefixes.UNIT, 1.0).setScale(IdentityScale.SCALE));
29
30
31 public static final EnergyUnit JOULE = SI;
32
33
34 public static final EnergyUnit MICROJOULE = JOULE.deriveSI(SIPrefixes.getUnit("mu"), 1.0);
35
36
37 public static final EnergyUnit MILLIJOULE = JOULE.deriveSI(SIPrefixes.getUnit("m"), 1.0);
38
39
40 public static final EnergyUnit KILOJOULE = JOULE.deriveSI(SIPrefixes.getUnit("k"), 1.0);
41
42
43 public static final EnergyUnit MEGAJOULE = JOULE.deriveSI(SIPrefixes.getUnit("M"), 1.0);
44
45
46 public static final EnergyUnit GIGAJOULE = JOULE.deriveSI(SIPrefixes.getUnit("G"), 1.0);
47
48
49 public static final EnergyUnit TERAJOULE = JOULE.deriveSI(SIPrefixes.getUnit("T"), 1.0);
50
51
52 public static final EnergyUnit PETAJOULE = JOULE.deriveSI(SIPrefixes.getUnit("P"), 1.0);
53
54
55 public static final EnergyUnit FOOT_POUND_FORCE = JOULE.deriveLinear(factorFL(ForceUnit.POUND_FORCE, LengthUnit.FOOT),
56 "ft.lbf", "foot pound-force", UnitSystem.IMPERIAL);
57
58
59 public static final EnergyUnit INCH_POUND_FORCE = JOULE.deriveLinear(factorFL(ForceUnit.POUND_FORCE, LengthUnit.INCH),
60 "in.lbf", "inch pound-force", UnitSystem.IMPERIAL);
61
62
63 public static final EnergyUnit BTU_ISO =
64 JOULE.deriveLinear(1.0545E3, "BTU(ISO)", "British thermal unit (ISO)", UnitSystem.IMPERIAL);
65
66
67 public static final EnergyUnit BTU_IT =
68 JOULE.deriveLinear(1.05505585262E3, "BTU(IT)", "British thermal unit (International Table)", UnitSystem.IMPERIAL);
69
70
71 public static final EnergyUnit CALORIE_IT =
72 JOULE.deriveLinear(4.1868, "cal(IT)", "calorie (International Table)", UnitSystem.IMPERIAL);
73
74
75 public static final EnergyUnit CALORIE = JOULE.deriveLinear(4.184, "cal", "calorie", UnitSystem.OTHER);
76
77
78 public static final EnergyUnit KILOCALORIE = CALORIE.deriveLinear(1000.0, "kcal", "kilocalorie");
79
80
81 public static final EnergyUnityUnit">EnergyUnit WATT_HOUR = new EnergyUnit().build(new Unit.Builder<EnergyUnit>().setQuantity(BASE)
82 .setId("Wh").setName("watt-hour").setUnitSystem(UnitSystem.SI_DERIVED).setSiPrefixes(SIPrefixes.UNIT, 1.0)
83 .setScale(new LinearScale(3600.0)));
84
85
86 public static final EnergyUnit MICROWATT_HOUR = WATT_HOUR.deriveSI(SIPrefixes.getUnit("mu"), 1.0);
87
88
89 public static final EnergyUnit MILLIWATT_HOUR = WATT_HOUR.deriveSI(SIPrefixes.getUnit("m"), 1.0);
90
91
92 public static final EnergyUnit KILOWATT_HOUR = WATT_HOUR.deriveSI(SIPrefixes.getUnit("k"), 1.0);
93
94
95 public static final EnergyUnit MEGAWATT_HOUR = WATT_HOUR.deriveSI(SIPrefixes.getUnit("M"), 1.0);
96
97
98 public static final EnergyUnit GIGAWATT_HOUR = WATT_HOUR.deriveSI(SIPrefixes.getUnit("G"), 1.0);
99
100
101 public static final EnergyUnit TERAWATT_HOUR = WATT_HOUR.deriveSI(SIPrefixes.getUnit("T"), 1.0);
102
103
104 public static final EnergyUnit PETAWATT_HOUR = WATT_HOUR.deriveSI(SIPrefixes.getUnit("P"), 1.0);
105
106
107 public static final EnergyUnitit">EnergyUnit ELECTRONVOLT = new EnergyUnit().build(new Unit.Builder<EnergyUnit>().setQuantity(BASE)
108 .setId("eV").setName("electronvolt").setUnitSystem(UnitSystem.SI_ACCEPTED).setSiPrefixes(SIPrefixes.UNIT, 1.0)
109 .setScale(new LinearScale(1.602176634E-19)));
110
111
112 public static final EnergyUnit MICROELECTRONVOLT = ELECTRONVOLT.deriveSI(SIPrefixes.getUnit("mu"), 1.0);
113
114
115 public static final EnergyUnit MILLIELECTRONVOLT = ELECTRONVOLT.deriveSI(SIPrefixes.getUnit("m"), 1.0);
116
117
118 public static final EnergyUnit KILOELECTRONVOLT = ELECTRONVOLT.deriveSI(SIPrefixes.getUnit("k"), 1.0);
119
120
121 public static final EnergyUnit MEGAELECTRONVOLT = ELECTRONVOLT.deriveSI(SIPrefixes.getUnit("M"), 1.0);
122
123
124 public static final EnergyUnit GIGAELECTRONVOLT = ELECTRONVOLT.deriveSI(SIPrefixes.getUnit("G"), 1.0);
125
126
127 public static final EnergyUnit STHENE_METER = JOULE.deriveLinear(1000.0, "sn.m", "sthene meter", UnitSystem.MTS);
128
129
130 public static final EnergyUnit ERG = JOULE.deriveLinear(1.0E-7, "erg", "erg", UnitSystem.CGS);
131
132
133
134
135
136
137
138 private static double factorFL(final ForceUnit force, final LengthUnit distance)
139 {
140 return force.getScale().toStandardUnit(1.0) * distance.getScale().toStandardUnit(1.0);
141 }
142
143 }