1 package org.djunits.unit;
2
3 import static org.djunits.unit.unitsystem.UnitSystem.CGS;
4 import static org.djunits.unit.unitsystem.UnitSystem.IMPERIAL;
5 import static org.djunits.unit.unitsystem.UnitSystem.MTS;
6 import static org.djunits.unit.unitsystem.UnitSystem.OTHER;
7 import static org.djunits.unit.unitsystem.UnitSystem.SI_ACCEPTED;
8 import static org.djunits.unit.unitsystem.UnitSystem.SI_BASE;
9 import static org.djunits.unit.unitsystem.UnitSystem.SI_DERIVED;
10
11 import org.djunits.unit.unitsystem.UnitSystem;
12
13
14
15
16
17
18
19
20
21
22
23 public class EnergyUnit extends LinearUnit<EnergyUnit>
24 {
25
26 private static final long serialVersionUID = 20140604L;
27
28
29 private final MassUnit massUnit;
30
31
32 private final LengthUnit lengthUnit;
33
34
35 private final DurationUnit durationUnit;
36
37
38 public static final EnergyUnit SI;
39
40
41 public static final EnergyUnit PICOJOULE;
42
43
44 public static final EnergyUnit NANOJOULE;
45
46
47 public static final EnergyUnit MICROJOULE;
48
49
50 public static final EnergyUnit MILLIJOULE;
51
52
53 public static final EnergyUnit JOULE;
54
55
56 public static final EnergyUnit KILOJOULE;
57
58
59 public static final EnergyUnit MEGAJOULE;
60
61
62 public static final EnergyUnit GIGAJOULE;
63
64
65 public static final EnergyUnit TERAJOULE;
66
67
68 public static final EnergyUnit PETAJOULE;
69
70
71 public static final EnergyUnit FOOT_POUND_FORCE;
72
73
74 public static final EnergyUnit INCH_POUND_FORCE;
75
76
77 public static final EnergyUnit BTU_ISO;
78
79
80 public static final EnergyUnit BTU_IT;
81
82
83 public static final EnergyUnit CALORIE_IT;
84
85
86 public static final EnergyUnit CALORIE;
87
88
89 public static final EnergyUnit KILOCALORIE;
90
91
92 public static final EnergyUnit FEMTOWATT_HOUR;
93
94
95 public static final EnergyUnit PICOWATT_HOUR;
96
97
98 public static final EnergyUnit NANOWATT_HOUR;
99
100
101 public static final EnergyUnit MICROWATT_HOUR;
102
103
104 public static final EnergyUnit MILLIWATT_HOUR;
105
106
107 public static final EnergyUnit WATT_HOUR;
108
109
110 public static final EnergyUnit KILOWATT_HOUR;
111
112
113 public static final EnergyUnit MEGAWATT_HOUR;
114
115
116 public static final EnergyUnit GIGAWATT_HOUR;
117
118
119 public static final EnergyUnit TERAWATT_HOUR;
120
121
122 public static final EnergyUnit PETAWATT_HOUR;
123
124
125 public static final EnergyUnit ELECTRONVOLT;
126
127
128 public static final EnergyUnit MICROELECTRONVOLT;
129
130
131 public static final EnergyUnit MILLIELECTRONVOLT;
132
133
134 public static final EnergyUnit KILOELECTRONVOLT;
135
136
137 public static final EnergyUnit MEGAELECTRONVOLT;
138
139
140 public static final EnergyUnit GIGAELECTRONVOLT;
141
142
143 public static final EnergyUnit TERAELECTRONVOLT;
144
145
146 public static final EnergyUnit PETAELECTRONVOLT;
147
148
149 public static final EnergyUnit EXAELECTRONVOLT;
150
151
152 public static final EnergyUnit STHENE_METER;
153
154
155 public static final EnergyUnit ERG;
156
157 static
158 {
159 SI = new EnergyUnit(MassUnit.KILOGRAM, LengthUnit.METER, DurationUnit.SECOND, "EnergyUnit.J", SI_DERIVED);
160 JOULE = SI;
161 PICOJOULE = new EnergyUnit("EnergyUnit.pJ", SI_BASE, JOULE, 1E-12);
162 NANOJOULE = new EnergyUnit("EnergyUnit.nJ", SI_BASE, JOULE, 1E-9);
163 MICROJOULE = new EnergyUnit("EnergyUnit.muJ", SI_BASE, JOULE, 1E-6);
164 MILLIJOULE = new EnergyUnit("EnergyUnit.mJ", SI_BASE, JOULE, 1E-3);
165 KILOJOULE = new EnergyUnit("EnergyUnit.kJ", SI_BASE, JOULE, 1000.0);
166 MEGAJOULE = new EnergyUnit("EnergyUnit.MJ", SI_BASE, JOULE, 1E9);
167 GIGAJOULE = new EnergyUnit("EnergyUnit.GJ", SI_BASE, JOULE, 1E12);
168 TERAJOULE = new EnergyUnit("EnergyUnit.TJ", SI_BASE, JOULE, 1E15);
169 PETAJOULE = new EnergyUnit("EnergyUnit.PJ", SI_BASE, JOULE, 1E18);
170 FOOT_POUND_FORCE = new EnergyUnit(ForceUnit.POUND_FORCE, LengthUnit.FOOT, "EnergyUnit.ft.lbf", IMPERIAL);
171 INCH_POUND_FORCE = new EnergyUnit(ForceUnit.POUND_FORCE, LengthUnit.INCH, "EnergyUnit.in.lbf", IMPERIAL);
172 BTU_ISO = new EnergyUnit("EnergyUnit.BTU(ISO)", IMPERIAL, JOULE, 1.0545E3);
173 BTU_IT = new EnergyUnit("EnergyUnit.BTU(IT)", IMPERIAL, JOULE, 1.05505585262E3);
174 CALORIE_IT = new EnergyUnit("EnergyUnit.cal(IT)", OTHER, JOULE, 4.1868);
175 CALORIE = new EnergyUnit("EnergyUnit.cal", OTHER, JOULE, 4.184);
176 KILOCALORIE = new EnergyUnit("EnergyUnit.kcal", OTHER, CALORIE, 1000.0);
177 WATT_HOUR = new EnergyUnit("EnergyUnit.Wh", SI_DERIVED, JOULE, 3600.0);
178 FEMTOWATT_HOUR = new EnergyUnit("EnergyUnit.fWh", SI_DERIVED, WATT_HOUR, 1.0E-15);
179 PICOWATT_HOUR = new EnergyUnit("EnergyUnit.pWh", SI_DERIVED, WATT_HOUR, 1.0E-12);
180 NANOWATT_HOUR = new EnergyUnit("EnergyUnit.nWh", SI_DERIVED, WATT_HOUR, 1.0E-9);
181 MICROWATT_HOUR = new EnergyUnit("EnergyUnit.muWh", SI_DERIVED, WATT_HOUR, 1.0E-6);
182 MILLIWATT_HOUR = new EnergyUnit("EnergyUnit.mWh", SI_DERIVED, WATT_HOUR, 1.0E-3);
183 KILOWATT_HOUR = new EnergyUnit("EnergyUnit.kWh", SI_DERIVED, WATT_HOUR, 1000.0);
184 MEGAWATT_HOUR = new EnergyUnit("EnergyUnit.MWh", SI_DERIVED, WATT_HOUR, 1.0E6);
185 GIGAWATT_HOUR = new EnergyUnit("EnergyUnit.GWh", SI_DERIVED, WATT_HOUR, 1.0E9);
186 TERAWATT_HOUR = new EnergyUnit("EnergyUnit.TWh", SI_DERIVED, WATT_HOUR, 1.0E12);
187 PETAWATT_HOUR = new EnergyUnit("EnergyUnit.PWh", SI_DERIVED, WATT_HOUR, 1.0E15);
188 ELECTRONVOLT = new EnergyUnit("EnergyUnit.eV", SI_ACCEPTED, JOULE, 1.602176565314E-19);
189 MICROELECTRONVOLT = new EnergyUnit("EnergyUnit.mueV", SI_ACCEPTED, ELECTRONVOLT, 1.0E-6);
190 MILLIELECTRONVOLT = new EnergyUnit("EnergyUnit.meV", SI_ACCEPTED, ELECTRONVOLT, 1.0E-3);
191 KILOELECTRONVOLT = new EnergyUnit("EnergyUnit.keV", SI_ACCEPTED, ELECTRONVOLT, 1.0E3);
192 MEGAELECTRONVOLT = new EnergyUnit("EnergyUnit.MeV", SI_ACCEPTED, ELECTRONVOLT, 1.0E6);
193 GIGAELECTRONVOLT = new EnergyUnit("EnergyUnit.GeV", SI_ACCEPTED, ELECTRONVOLT, 1.0E9);
194 TERAELECTRONVOLT = new EnergyUnit("EnergyUnit.TeV", SI_ACCEPTED, ELECTRONVOLT, 1.0E12);
195 PETAELECTRONVOLT = new EnergyUnit("EnergyUnit.PeV", SI_ACCEPTED, ELECTRONVOLT, 1.0E15);
196 EXAELECTRONVOLT = new EnergyUnit("EnergyUnit.EeV", SI_ACCEPTED, ELECTRONVOLT, 1.0E18);
197 STHENE_METER = new EnergyUnit("EnergyUnit.sn.m", MTS, JOULE, 1000.0);
198 ERG = new EnergyUnit("EnergyUnit.erg", CGS, JOULE, 1.0E-7);
199 }
200
201
202
203
204
205
206
207
208
209 private EnergyUnit(final MassUnit massUnit, final LengthUnit lengthUnit, final DurationUnit durationUnit,
210 final String abbreviationKey, final UnitSystem unitSystem)
211 {
212 super(abbreviationKey, unitSystem, JOULE, massUnit.getScaleFactor() * lengthUnit.getScaleFactor()
213 * lengthUnit.getScaleFactor() / (durationUnit.getScaleFactor() * durationUnit.getScaleFactor()));
214 this.massUnit = massUnit;
215 this.lengthUnit = lengthUnit;
216 this.durationUnit = durationUnit;
217 }
218
219
220
221
222
223
224
225
226
227
228 public EnergyUnit(final MassUnit massUnit, final LengthUnit lengthUnit, final DurationUnit durationUnit, final String name,
229 final String abbreviation, final UnitSystem unitSystem)
230 {
231 super(name, abbreviation, unitSystem, JOULE, massUnit.getScaleFactor() * lengthUnit.getScaleFactor()
232 * lengthUnit.getScaleFactor() / (durationUnit.getScaleFactor() * durationUnit.getScaleFactor()));
233 this.massUnit = massUnit;
234 this.lengthUnit = lengthUnit;
235 this.durationUnit = durationUnit;
236 }
237
238
239
240
241
242
243
244
245 private EnergyUnit(final ForceUnit forceUnit, final LengthUnit lengthUnit, final String abbreviationKey,
246 final UnitSystem unitSystem)
247 {
248 super(abbreviationKey, unitSystem, JOULE, forceUnit.getScaleFactor() * lengthUnit.getScaleFactor());
249 this.massUnit = forceUnit.getMassUnit();
250 this.lengthUnit = forceUnit.getLengthUnit();
251 this.durationUnit = forceUnit.getDurationUnit();
252 }
253
254
255
256
257
258
259
260
261
262 public EnergyUnit(final ForceUnit forceUnit, final LengthUnit lengthUnit, final String name, final String abbreviation,
263 final UnitSystem unitSystem)
264 {
265 super(name, abbreviation, unitSystem, JOULE, forceUnit.getScaleFactor() * lengthUnit.getScaleFactor());
266 this.massUnit = forceUnit.getMassUnit();
267 this.lengthUnit = forceUnit.getLengthUnit();
268 this.durationUnit = forceUnit.getDurationUnit();
269 }
270
271
272
273
274
275
276
277
278
279 private EnergyUnit(final String abbreviationKey, final UnitSystem unitSystem, final EnergyUnit referenceUnit,
280 final double scaleFactorToReferenceUnit)
281 {
282 super(abbreviationKey, unitSystem, referenceUnit, scaleFactorToReferenceUnit);
283 this.massUnit = referenceUnit.getMassUnit();
284 this.lengthUnit = referenceUnit.getLengthUnit();
285 this.durationUnit = referenceUnit.getDurationUnit();
286 }
287
288
289
290
291
292
293
294
295
296
297 public EnergyUnit(final String name, final String abbreviation, final UnitSystem unitSystem, final EnergyUnit referenceUnit,
298 final double scaleFactorToReferenceUnit)
299 {
300 super(name, abbreviation, unitSystem, referenceUnit, scaleFactorToReferenceUnit);
301 this.massUnit = referenceUnit.getMassUnit();
302 this.lengthUnit = referenceUnit.getLengthUnit();
303 this.durationUnit = referenceUnit.getDurationUnit();
304 }
305
306
307
308
309 public final MassUnit getMassUnit()
310 {
311 return this.massUnit;
312 }
313
314
315
316
317 public final LengthUnit getLengthUnit()
318 {
319 return this.lengthUnit;
320 }
321
322
323
324
325 public final DurationUnit getDurationUnit()
326 {
327 return this.durationUnit;
328 }
329
330
331 @Override
332 public final EnergyUnit getStandardUnit()
333 {
334 return JOULE;
335 }
336
337
338 @Override
339 public final String getSICoefficientsString()
340 {
341 return "kgm2/s2";
342 }
343
344 }