1 package org.opentrafficsim.core.unit;
2
3 import static org.opentrafficsim.core.unit.unitsystem.UnitSystem.CGS;
4 import static org.opentrafficsim.core.unit.unitsystem.UnitSystem.IMPERIAL;
5 import static org.opentrafficsim.core.unit.unitsystem.UnitSystem.MTS;
6 import static org.opentrafficsim.core.unit.unitsystem.UnitSystem.OTHER;
7 import static org.opentrafficsim.core.unit.unitsystem.UnitSystem.SI_DERIVED;
8
9 import org.opentrafficsim.core.unit.unitsystem.UnitSystem;
10
11
12
13
14
15
16
17
18
19
20 public class PowerUnit extends Unit<PowerUnit>
21 {
22
23 private static final long serialVersionUID = 20140607L;
24
25
26 private final MassUnit massUnit;
27
28
29 private final LengthUnit lengthUnit;
30
31
32 private final TimeUnit timeUnit;
33
34
35 public static final PowerUnit SI;
36
37
38 public static final PowerUnit WATT;
39
40
41 public static final PowerUnit KILOWATT;
42
43
44 public static final PowerUnit MEGAWATT;
45
46
47 public static final PowerUnit GIGAWATT;
48
49
50 public static final PowerUnit FOOT_POUND_FORCE_PER_HOUR;
51
52
53 public static final PowerUnit FOOT_POUND_FORCE_PER_MINUTE;
54
55
56 public static final PowerUnit FOOT_POUND_FORCE_PER_SECOND;
57
58
59 public static final PowerUnit HORSEPOWER_METRIC;
60
61
62 public static final PowerUnit STHENE_METER_PER_SECOND;
63
64
65 public static final PowerUnit ERG_PER_SECOND;
66
67 static
68 {
69 SI =
70 new PowerUnit(MassUnit.KILOGRAM, LengthUnit.METER, TimeUnit.SECOND, "PowerUnit.watt", "PowerUnit.W",
71 SI_DERIVED);
72 WATT = SI;
73 KILOWATT = new PowerUnit("PowerUnit.kilowatt", "PowerUnit.kW", SI_DERIVED, WATT, 1000.0);
74 MEGAWATT = new PowerUnit("PowerUnit.megawatt", "PowerUnit.MW", SI_DERIVED, WATT, 1.0E6);
75 GIGAWATT = new PowerUnit("PowerUnit.gigawatt", "PowerUnit.GW", SI_DERIVED, WATT, 1.0E9);
76 FOOT_POUND_FORCE_PER_HOUR =
77 new PowerUnit(LengthUnit.FOOT, ForceUnit.POUND_FORCE, TimeUnit.HOUR,
78 "PowerUnit.foot_pound-force_per_hour", "PowerUnit.ft.lbf/h", IMPERIAL);
79 FOOT_POUND_FORCE_PER_MINUTE =
80 new PowerUnit(LengthUnit.FOOT, ForceUnit.POUND_FORCE, TimeUnit.MINUTE,
81 "PowerUnit.foot_pound-force_per_minute", "PowerUnit.ft.lbf/min", IMPERIAL);
82 FOOT_POUND_FORCE_PER_SECOND =
83 new PowerUnit(LengthUnit.FOOT, ForceUnit.POUND_FORCE, TimeUnit.SECOND,
84 "PowerUnit.foot_pound-force_per_second", "PowerUnit.ft.lbf/s", IMPERIAL);
85 HORSEPOWER_METRIC = new PowerUnit("PowerUnit.horsepower_(metric)", "PowerUnit.hp", OTHER, WATT, 735.49875);
86 STHENE_METER_PER_SECOND =
87 new PowerUnit(LengthUnit.METER, ForceUnit.STHENE, TimeUnit.SECOND, "PowerUnit.sthene-meter_per_second",
88 "PowerUnit.sn.m/s", MTS);
89 ERG_PER_SECOND =
90 new PowerUnit(LengthUnit.CENTIMETER, ForceUnit.DYNE, TimeUnit.SECOND, "PowerUnit.erg_per_second",
91 "PowerUnit.erg/s", CGS);
92 }
93
94
95
96
97
98
99
100
101
102 public PowerUnit(final MassUnit massUnit, final LengthUnit lengthUnit, final TimeUnit timeUnit,
103 final String nameKey, final String abbreviationKey, final UnitSystem unitSystem)
104 {
105 super(nameKey, abbreviationKey, unitSystem, WATT, massUnit.getConversionFactorToStandardUnit()
106 * lengthUnit.getConversionFactorToStandardUnit() * lengthUnit.getConversionFactorToStandardUnit()
107 / Math.pow(timeUnit.getConversionFactorToStandardUnit(), 3.0), true);
108 this.massUnit = massUnit;
109 this.lengthUnit = lengthUnit;
110 this.timeUnit = timeUnit;
111 }
112
113
114
115
116
117
118
119
120
121 public PowerUnit(final LengthUnit lengthUnit, final ForceUnit forceUnit, final TimeUnit timeUnit,
122 final String nameKey, final String abbreviationKey, final UnitSystem unitSystem)
123 {
124 super(nameKey, abbreviationKey, unitSystem, WATT, lengthUnit.getConversionFactorToStandardUnit()
125 * forceUnit.getConversionFactorToStandardUnit() / timeUnit.getConversionFactorToStandardUnit(), true);
126 this.massUnit = forceUnit.getMassUnit();
127 this.lengthUnit = forceUnit.getLengthUnit();
128 this.timeUnit = forceUnit.getTimeUnit();
129 }
130
131
132
133
134
135
136
137
138
139 public PowerUnit(final String nameKey, final String abbreviationKey, final UnitSystem unitSystem,
140 final PowerUnit referenceUnit, final double conversionFactorToReferenceUnit)
141 {
142 super(nameKey, abbreviationKey, unitSystem, referenceUnit, conversionFactorToReferenceUnit, true);
143 this.massUnit = referenceUnit.getMassUnit();
144 this.lengthUnit = referenceUnit.getLengthUnit();
145 this.timeUnit = referenceUnit.getTimeUnit();
146 }
147
148
149
150
151 public final MassUnit getMassUnit()
152 {
153 return this.massUnit;
154 }
155
156
157
158
159 public final LengthUnit getLengthUnit()
160 {
161 return this.lengthUnit;
162 }
163
164
165
166
167 public final TimeUnit getTimeUnit()
168 {
169 return this.timeUnit;
170 }
171
172
173 @Override
174 public final PowerUnit getStandardUnit()
175 {
176 return WATT;
177 }
178
179
180 @Override
181 public final String getSICoefficientsString()
182 {
183 return "kgm2/s3";
184 }
185
186 }