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.watt", "PowerUnit.W",
92 SI_DERIVED, true);
93 WATT = SI;
94 FEMTOWATT = new PowerUnit("PowerUnit.femtowatt", "PowerUnit.fW", SI_DERIVED, WATT, 1.0E-15, true);
95 PICOWATT = new PowerUnit("PowerUnit.picowatt", "PowerUnit.pW", SI_DERIVED, WATT, 1.0E-12, true);
96 NANOWATT = new PowerUnit("PowerUnit.nanowatt", "PowerUnit.nW", SI_DERIVED, WATT, 1.0E-9, true);
97 MICROWATT = new PowerUnit("PowerUnit.microwatt", "PowerUnit.muW", SI_DERIVED, WATT, 1.0E-6, true);
98 MILLIWATT = new PowerUnit("PowerUnit.milliwatt", "PowerUnit.mW", SI_DERIVED, WATT, 1.0E-3, true);
99 KILOWATT = new PowerUnit("PowerUnit.kilowatt", "PowerUnit.kW", SI_DERIVED, WATT, 1.0E3, true);
100 MEGAWATT = new PowerUnit("PowerUnit.megawatt", "PowerUnit.MW", SI_DERIVED, WATT, 1.0E6, true);
101 GIGAWATT = new PowerUnit("PowerUnit.gigawatt", "PowerUnit.GW", SI_DERIVED, WATT, 1.0E9, true);
102 TERAWATT = new PowerUnit("PowerUnit.terawatt", "PowerUnit.TW", SI_DERIVED, WATT, 1.0E12, true);
103 PETAWATT = new PowerUnit("PowerUnit.petawatt", "PowerUnit.PW", SI_DERIVED, WATT, 1.0E15, true);
104 FOOT_POUND_FORCE_PER_HOUR = new PowerUnit(ForceUnit.POUND_FORCE, LengthUnit.FOOT, DurationUnit.HOUR,
105 "PowerUnit.foot_pound-force_per_hour", "PowerUnit.ft.lbf/h", IMPERIAL, true);
106 FOOT_POUND_FORCE_PER_MINUTE = new PowerUnit(ForceUnit.POUND_FORCE, LengthUnit.FOOT, DurationUnit.MINUTE,
107 "PowerUnit.foot_pound-force_per_minute", "PowerUnit.ft.lbf/min", IMPERIAL, true);
108 FOOT_POUND_FORCE_PER_SECOND = new PowerUnit(ForceUnit.POUND_FORCE, LengthUnit.FOOT, DurationUnit.SECOND,
109 "PowerUnit.foot_pound-force_per_second", "PowerUnit.ft.lbf/s", IMPERIAL, true);
110 HORSEPOWER_METRIC = new PowerUnit("PowerUnit.horsepower_(metric)", "PowerUnit.hp", OTHER, WATT, 735.49875, true);
111 STHENE_METER_PER_SECOND = new PowerUnit(ForceUnit.STHENE, LengthUnit.METER, DurationUnit.SECOND,
112 "PowerUnit.sthene-meter_per_second", "PowerUnit.sn.m/s", MTS, true);
113 ERG_PER_SECOND = new PowerUnit(ForceUnit.DYNE, LengthUnit.CENTIMETER, DurationUnit.SECOND, "PowerUnit.erg_per_second",
114 "PowerUnit.erg/s", CGS, true);
115 }
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130 private PowerUnit(final MassUnit massUnit, final LengthUnit lengthUnit, final DurationUnit durationUnit,
131 final String nameOrNameKey, final String abbreviationOrAbbreviationKey, final UnitSystem unitSystem,
132 final boolean standardUnit)
133 {
134 super(nameOrNameKey, abbreviationOrAbbreviationKey, unitSystem, WATT, massUnit.getScaleFactor()
135 * lengthUnit.getScaleFactor() * lengthUnit.getScaleFactor() / Math.pow(durationUnit.getScaleFactor(), 3.0),
136 standardUnit);
137 this.massUnit = massUnit;
138 this.lengthUnit = lengthUnit;
139 this.durationUnit = durationUnit;
140 }
141
142
143
144
145
146
147
148
149
150
151 public PowerUnit(final MassUnit massUnit, final LengthUnit lengthUnit, final DurationUnit durationUnit, final String name,
152 final String abbreviation, final UnitSystem unitSystem)
153 {
154 this(massUnit, lengthUnit, durationUnit, name, abbreviation, unitSystem, false);
155 }
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170 private PowerUnit(final ForceUnit forceUnit, final LengthUnit lengthUnit, final DurationUnit durationUnit,
171 final String nameOrNameKey, final String abbreviationOrAbbreviationKey, final UnitSystem unitSystem,
172 final boolean standardUnit)
173 {
174 super(nameOrNameKey, abbreviationOrAbbreviationKey, unitSystem, WATT,
175 lengthUnit.getScaleFactor() * forceUnit.getScaleFactor() / durationUnit.getScaleFactor(), standardUnit);
176 this.massUnit = forceUnit.getMassUnit();
177 this.lengthUnit = forceUnit.getLengthUnit();
178 this.durationUnit = forceUnit.getDurationUnit();
179 }
180
181
182
183
184
185
186
187
188
189
190 public PowerUnit(final LengthUnit lengthUnit, final ForceUnit forceUnit, final DurationUnit durationUnit, final String name,
191 final String abbreviation, final UnitSystem unitSystem)
192 {
193 this(forceUnit, lengthUnit, durationUnit, name, abbreviation, unitSystem, false);
194 }
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209 private PowerUnit(final String nameOrNameKey, final String abbreviationOrAbbreviationKey, final UnitSystem unitSystem,
210 final PowerUnit referenceUnit, final double scaleFactorToReferenceUnit, final boolean standardUnit)
211 {
212 super(nameOrNameKey, abbreviationOrAbbreviationKey, unitSystem, referenceUnit, scaleFactorToReferenceUnit,
213 standardUnit);
214 this.massUnit = referenceUnit.getMassUnit();
215 this.lengthUnit = referenceUnit.getLengthUnit();
216 this.durationUnit = referenceUnit.getDurationUnit();
217 }
218
219
220
221
222
223
224
225
226
227
228 public PowerUnit(final String name, final String abbreviation, final UnitSystem unitSystem, final PowerUnit referenceUnit,
229 final double scaleFactorToReferenceUnit)
230 {
231 this(name, abbreviation, unitSystem, referenceUnit, scaleFactorToReferenceUnit, false);
232 }
233
234
235
236
237 public final MassUnit getMassUnit()
238 {
239 return this.massUnit;
240 }
241
242
243
244
245 public final LengthUnit getLengthUnit()
246 {
247 return this.lengthUnit;
248 }
249
250
251
252
253 public final DurationUnit getDurationUnit()
254 {
255 return this.durationUnit;
256 }
257
258
259 @Override
260 public final PowerUnit getStandardUnit()
261 {
262 return WATT;
263 }
264
265
266 @Override
267 public final String getSICoefficientsString()
268 {
269 return "kgm2/s3";
270 }
271
272 }