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 private PowerUnit(final MassUnit massUnit, final LengthUnit lengthUnit, final DurationUnit durationUnit,
129 final String nameOrNameKey, final String abbreviationOrAbbreviationKey, final UnitSystem unitSystem,
130 final boolean standardUnit)
131 {
132 super(nameOrNameKey, abbreviationOrAbbreviationKey, unitSystem, WATT, massUnit.getScaleFactor()
133 * lengthUnit.getScaleFactor() * lengthUnit.getScaleFactor() / Math.pow(durationUnit.getScaleFactor(), 3.0),
134 standardUnit);
135 this.massUnit = massUnit;
136 this.lengthUnit = lengthUnit;
137 this.durationUnit = durationUnit;
138 }
139
140
141
142
143
144
145
146
147
148
149 public PowerUnit(final MassUnit massUnit, final LengthUnit lengthUnit, final DurationUnit durationUnit, final String name,
150 final String abbreviation, final UnitSystem unitSystem)
151 {
152 this(massUnit, lengthUnit, durationUnit, name, abbreviation, unitSystem, false);
153 }
154
155
156
157
158
159
160
161
162
163
164
165
166 private PowerUnit(final ForceUnit forceUnit, final LengthUnit lengthUnit, final DurationUnit durationUnit,
167 final String nameOrNameKey, final String abbreviationOrAbbreviationKey, final UnitSystem unitSystem,
168 final boolean standardUnit)
169 {
170 super(nameOrNameKey, abbreviationOrAbbreviationKey, unitSystem, WATT,
171 lengthUnit.getScaleFactor() * forceUnit.getScaleFactor() / durationUnit.getScaleFactor(), standardUnit);
172 this.massUnit = forceUnit.getMassUnit();
173 this.lengthUnit = forceUnit.getLengthUnit();
174 this.durationUnit = forceUnit.getDurationUnit();
175 }
176
177
178
179
180
181
182
183
184
185
186 public PowerUnit(final LengthUnit lengthUnit, final ForceUnit forceUnit, final DurationUnit durationUnit, final String name,
187 final String abbreviation, final UnitSystem unitSystem)
188 {
189 this(forceUnit, lengthUnit, durationUnit, name, abbreviation, unitSystem, false);
190 }
191
192
193
194
195
196
197
198
199
200
201
202 private PowerUnit(final String nameOrNameKey, final String abbreviationOrAbbreviationKey, final UnitSystem unitSystem,
203 final PowerUnit referenceUnit, final double scaleFactorToReferenceUnit, final boolean standardUnit)
204 {
205 super(nameOrNameKey, abbreviationOrAbbreviationKey, unitSystem, referenceUnit, scaleFactorToReferenceUnit,
206 standardUnit);
207 this.massUnit = referenceUnit.getMassUnit();
208 this.lengthUnit = referenceUnit.getLengthUnit();
209 this.durationUnit = referenceUnit.getDurationUnit();
210 }
211
212
213
214
215
216
217
218
219
220 public PowerUnit(final String name, final String abbreviation, final UnitSystem unitSystem, final PowerUnit referenceUnit,
221 final double scaleFactorToReferenceUnit)
222 {
223 this(name, abbreviation, unitSystem, referenceUnit, scaleFactorToReferenceUnit, false);
224 }
225
226
227
228
229 public final MassUnit getMassUnit()
230 {
231 return this.massUnit;
232 }
233
234
235
236
237 public final LengthUnit getLengthUnit()
238 {
239 return this.lengthUnit;
240 }
241
242
243
244
245 public final DurationUnit getDurationUnit()
246 {
247 return this.durationUnit;
248 }
249
250
251 @Override
252 public final PowerUnit getStandardUnit()
253 {
254 return WATT;
255 }
256
257
258 @Override
259 public final String getSICoefficientsString()
260 {
261 return "kgm2/s3";
262 }
263
264 }