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_DERIVED;
8
9 import org.djunits.unit.unitsystem.UnitSystem;
10
11
12
13
14
15
16
17
18
19
20
21 public class PowerUnit extends LinearUnit<PowerUnit>
22 {
23
24 private static final long serialVersionUID = 20140607L;
25
26
27 private final MassUnit massUnit;
28
29
30 private final LengthUnit lengthUnit;
31
32
33 private final DurationUnit durationUnit;
34
35
36 public static final PowerUnit SI;
37
38
39 public static final PowerUnit FEMTOWATT;
40
41
42 public static final PowerUnit PICOWATT;
43
44
45 public static final PowerUnit NANOWATT;
46
47
48 public static final PowerUnit MICROWATT;
49
50
51 public static final PowerUnit MILLIWATT;
52
53
54 public static final PowerUnit WATT;
55
56
57 public static final PowerUnit KILOWATT;
58
59
60 public static final PowerUnit MEGAWATT;
61
62
63 public static final PowerUnit GIGAWATT;
64
65
66 public static final PowerUnit TERAWATT;
67
68
69 public static final PowerUnit PETAWATT;
70
71
72 public static final PowerUnit FOOT_POUND_FORCE_PER_HOUR;
73
74
75 public static final PowerUnit FOOT_POUND_FORCE_PER_MINUTE;
76
77
78 public static final PowerUnit FOOT_POUND_FORCE_PER_SECOND;
79
80
81 public static final PowerUnit HORSEPOWER_METRIC;
82
83
84 public static final PowerUnit STHENE_METER_PER_SECOND;
85
86
87 public static final PowerUnit ERG_PER_SECOND;
88
89 static
90 {
91 SI = new PowerUnit(MassUnit.KILOGRAM, LengthUnit.METER, DurationUnit.SECOND, "PowerUnit.W", SI_DERIVED);
92 WATT = SI;
93 FEMTOWATT = new PowerUnit("PowerUnit.fW", SI_DERIVED, WATT, 1.0E-15);
94 PICOWATT = new PowerUnit("PowerUnit.pW", SI_DERIVED, WATT, 1.0E-12);
95 NANOWATT = new PowerUnit("PowerUnit.nW", SI_DERIVED, WATT, 1.0E-9);
96 MICROWATT = new PowerUnit("PowerUnit.muW", SI_DERIVED, WATT, 1.0E-6);
97 MILLIWATT = new PowerUnit("PowerUnit.mW", SI_DERIVED, WATT, 1.0E-3);
98 KILOWATT = new PowerUnit("PowerUnit.kW", SI_DERIVED, WATT, 1.0E3);
99 MEGAWATT = new PowerUnit("PowerUnit.MW", SI_DERIVED, WATT, 1.0E6);
100 GIGAWATT = new PowerUnit("PowerUnit.GW", SI_DERIVED, WATT, 1.0E9);
101 TERAWATT = new PowerUnit("PowerUnit.TW", SI_DERIVED, WATT, 1.0E12);
102 PETAWATT = new PowerUnit("PowerUnit.PW", SI_DERIVED, WATT, 1.0E15);
103 FOOT_POUND_FORCE_PER_HOUR =
104 new PowerUnit(ForceUnit.POUND_FORCE, LengthUnit.FOOT, DurationUnit.HOUR, "PowerUnit.ft.lbf/h", IMPERIAL);
105 FOOT_POUND_FORCE_PER_MINUTE =
106 new PowerUnit(ForceUnit.POUND_FORCE, LengthUnit.FOOT, DurationUnit.MINUTE, "PowerUnit.ft.lbf/min", IMPERIAL);
107 FOOT_POUND_FORCE_PER_SECOND =
108 new PowerUnit(ForceUnit.POUND_FORCE, LengthUnit.FOOT, DurationUnit.SECOND, "PowerUnit.ft.lbf/s", IMPERIAL);
109 HORSEPOWER_METRIC = new PowerUnit("PowerUnit.hp", OTHER, WATT, 735.49875);
110 STHENE_METER_PER_SECOND =
111 new PowerUnit(ForceUnit.STHENE, LengthUnit.METER, DurationUnit.SECOND, "PowerUnit.sn.m/s", MTS);
112 ERG_PER_SECOND = new PowerUnit(ForceUnit.DYNE, LengthUnit.CENTIMETER, DurationUnit.SECOND, "PowerUnit.erg/s", CGS);
113 }
114
115
116
117
118
119
120
121
122
123 private PowerUnit(final MassUnit massUnit, final LengthUnit lengthUnit, final DurationUnit durationUnit,
124 final String abbreviationKey, final UnitSystem unitSystem)
125 {
126 super(abbreviationKey, unitSystem, WATT, massUnit.getScaleFactor() * lengthUnit.getScaleFactor()
127 * lengthUnit.getScaleFactor() / Math.pow(durationUnit.getScaleFactor(), 3.0));
128 this.massUnit = massUnit;
129 this.lengthUnit = lengthUnit;
130 this.durationUnit = durationUnit;
131 }
132
133
134
135
136
137
138
139
140
141
142 public PowerUnit(final MassUnit massUnit, final LengthUnit lengthUnit, final DurationUnit durationUnit, final String name,
143 final String abbreviation, final UnitSystem unitSystem)
144 {
145 super(name, abbreviation, unitSystem, WATT, massUnit.getScaleFactor() * lengthUnit.getScaleFactor()
146 * lengthUnit.getScaleFactor() / Math.pow(durationUnit.getScaleFactor(), 3.0));
147 this.massUnit = massUnit;
148 this.lengthUnit = lengthUnit;
149 this.durationUnit = durationUnit;
150 }
151
152
153
154
155
156
157
158
159
160 private PowerUnit(final ForceUnit forceUnit, final LengthUnit lengthUnit, final DurationUnit durationUnit,
161 final String abbreviationKey, final UnitSystem unitSystem)
162 {
163 super(abbreviationKey, unitSystem, WATT,
164 lengthUnit.getScaleFactor() * forceUnit.getScaleFactor() / durationUnit.getScaleFactor());
165 this.massUnit = forceUnit.getMassUnit();
166 this.lengthUnit = forceUnit.getLengthUnit();
167 this.durationUnit = forceUnit.getDurationUnit();
168 }
169
170
171
172
173
174
175
176
177
178
179 public PowerUnit(final LengthUnit lengthUnit, final ForceUnit forceUnit, final DurationUnit durationUnit, final String name,
180 final String abbreviation, final UnitSystem unitSystem)
181 {
182 super(name, abbreviation, unitSystem, WATT,
183 lengthUnit.getScaleFactor() * forceUnit.getScaleFactor() / durationUnit.getScaleFactor());
184 this.massUnit = forceUnit.getMassUnit();
185 this.lengthUnit = forceUnit.getLengthUnit();
186 this.durationUnit = forceUnit.getDurationUnit();
187 }
188
189
190
191
192
193
194
195
196
197 private PowerUnit(final String abbreviationKey, final UnitSystem unitSystem, final PowerUnit referenceUnit,
198 final double scaleFactorToReferenceUnit)
199 {
200 super(abbreviationKey, unitSystem, referenceUnit, scaleFactorToReferenceUnit);
201 this.massUnit = referenceUnit.getMassUnit();
202 this.lengthUnit = referenceUnit.getLengthUnit();
203 this.durationUnit = referenceUnit.getDurationUnit();
204 }
205
206
207
208
209
210
211
212
213
214
215 public PowerUnit(final String name, final String abbreviation, final UnitSystem unitSystem, final PowerUnit referenceUnit,
216 final double scaleFactorToReferenceUnit)
217 {
218 super(name, abbreviation, unitSystem, referenceUnit, scaleFactorToReferenceUnit);
219 this.massUnit = referenceUnit.getMassUnit();
220 this.lengthUnit = referenceUnit.getLengthUnit();
221 this.durationUnit = referenceUnit.getDurationUnit();
222 }
223
224
225
226
227 public final MassUnit getMassUnit()
228 {
229 return this.massUnit;
230 }
231
232
233
234
235 public final LengthUnit getLengthUnit()
236 {
237 return this.lengthUnit;
238 }
239
240
241
242
243 public final DurationUnit getDurationUnit()
244 {
245 return this.durationUnit;
246 }
247
248
249 @Override
250 public final PowerUnit getStandardUnit()
251 {
252 return WATT;
253 }
254
255
256 @Override
257 public final String getSICoefficientsString()
258 {
259 return "kgm2/s3";
260 }
261
262 }