View Javadoc
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   * The units of pressure.
13   * <p>
14   * Copyright (c) 2014 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
15   * BSD-style license. See <a href="http://opentrafficsim.org/node/13">OpenTrafficSim License</a>.
16   * <p>
17   * @version May 15, 2014 <br>
18   * @author <a href="http://www.tbm.tudelft.nl/averbraeck">Alexander Verbraeck</a>
19   */
20  public class PressureUnit extends Unit<PressureUnit>
21  {
22      /** */
23      private static final long serialVersionUID = 20140607L;
24  
25      /** the unit of mass for the pressure unit, e.g., kilogram. */
26      private final MassUnit massUnit;
27  
28      /** the unit of length for the pressure unit, e.g., meter. */
29      private final LengthUnit lengthUnit;
30  
31      /** the unit of time for the pressure unit, e.g., second. */
32      private final TimeUnit timeUnit;
33  
34      /** The SI unit for pressure is Pascal. */
35      public static final PressureUnit SI;
36  
37      /** Pascal. */
38      public static final PressureUnit PASCAL;
39  
40      /** hectoPascal. */
41      public static final PressureUnit HECTOPASCAL;
42  
43      /** kiloPascal. */
44      public static final PressureUnit KILOPASCAL;
45  
46      /** standard atmosphere. */
47      public static final PressureUnit ATMOSPHERE_STANDARD;
48  
49      /** torr. */
50      public static final PressureUnit TORR;
51  
52      /** technical atmosphere. */
53      public static final PressureUnit ATMOSPHERE_TECHNICAL;
54  
55      /** barye. */
56      public static final PressureUnit BARYE;
57  
58      /** bar. */
59      public static final PressureUnit BAR;
60  
61      /** millibar. */
62      public static final PressureUnit MILLIBAR;
63  
64      /** cm Hg. */
65      public static final PressureUnit CENTIMETER_MERCURY;
66  
67      /** mm Hg. */
68      public static final PressureUnit MILLIMETER_MERCURY;
69  
70      /** foot Hg. */
71      public static final PressureUnit FOOT_MERCURY;
72  
73      /** inch Hg. */
74      public static final PressureUnit INCH_MERCURY;
75  
76      /** kilogram-force per square millimeter. */
77      public static final PressureUnit KGF_PER_SQUARE_MM;
78  
79      /** pound per square foot. */
80      public static final PressureUnit POUND_PER_SQUARE_FOOT;
81  
82      /** pound per square inch. */
83      public static final PressureUnit POUND_PER_SQUARE_INCH;
84  
85      /** pieze. */
86      public static final PressureUnit PIEZE;
87  
88      static
89      {
90          SI =
91                  new PressureUnit(MassUnit.KILOGRAM, LengthUnit.METER, TimeUnit.SECOND, "PressureUnit.pascal",
92                          "PressureUnit.Pa", SI_DERIVED);
93          PASCAL = SI;
94          HECTOPASCAL = new PressureUnit("PressureUnit.hectopascal", "PressureUnit.hPa", SI_DERIVED, PASCAL, 100.0);
95          KILOPASCAL = new PressureUnit("PressureUnit.kilopascal", "PressureUnit.kPa", SI_DERIVED, PASCAL, 1000.0);
96          ATMOSPHERE_STANDARD =
97                  new PressureUnit("PressureUnit.atmosphere_(standard)", "PressureUnit.atm", OTHER, PASCAL, 101325.0);
98          TORR = new PressureUnit("PressureUnit.torr", "PressureUnit.Torr", OTHER, ATMOSPHERE_STANDARD, 1.0 / 760.0);
99          ATMOSPHERE_TECHNICAL =
100                 new PressureUnit(ForceUnit.KILOGRAM_FORCE, AreaUnit.SQUARE_CENTIMETER,
101                         "PressureUnit.atmosphere_(technical)", "PressureUnit.at", OTHER);
102         BARYE =
103                 new PressureUnit(ForceUnit.DYNE, AreaUnit.SQUARE_CENTIMETER, "PressureUnit.barye", "PressureUnit.Ba",
104                         CGS);
105         BAR = new PressureUnit("PressureUnit.bar_(full)", "PressureUnit.bar", OTHER, PASCAL, 1E5);
106         MILLIBAR = new PressureUnit("PressureUnit.millibar", "PressureUnit.mbar", OTHER, PressureUnit.BAR, 0.001);
107         CENTIMETER_MERCURY =
108                 new PressureUnit("PressureUnit.centimeter_mercury", "PressureUnit.cmHg", OTHER, PASCAL, 1333.224);
109         MILLIMETER_MERCURY =
110                 new PressureUnit("PressureUnit.millimeter_mercury", "PressureUnit.mmHg", OTHER, PASCAL, 133.3224);
111         FOOT_MERCURY = new PressureUnit("PressureUnit.foot_mercury", "PressureUnit.ftHg", IMPERIAL, PASCAL, 40.63666E3);
112         INCH_MERCURY = new PressureUnit("PressureUnit.inch_mercury", "PressureUnit.inHg", IMPERIAL, PASCAL, 3.386389E3);
113         KGF_PER_SQUARE_MM =
114                 new PressureUnit(ForceUnit.KILOGRAM_FORCE, AreaUnit.SQUARE_MILLIMETER,
115                         "PressureUnit.kilogram-force_per_square_millimeter", "PressureUnit.kgf/mm^2", OTHER);
116         POUND_PER_SQUARE_FOOT =
117                 new PressureUnit(ForceUnit.POUND_FORCE, AreaUnit.SQUARE_FOOT, "PressureUnit.pound_per_square_foot",
118                         "PressureUnit.lbf/ft^2", IMPERIAL);
119         POUND_PER_SQUARE_INCH =
120                 new PressureUnit(ForceUnit.POUND_FORCE, AreaUnit.SQUARE_INCH, "PressureUnit.pound_per_square_inch",
121                         "PressureUnit.lbf/in^2", IMPERIAL);
122         PIEZE =
123                 new PressureUnit(MassUnit.TONNE, LengthUnit.METER, TimeUnit.SECOND, "PressureUnit.pieze",
124                         "PressureUnit.pz", MTS);
125     }
126 
127     /**
128      * Construct a pressure unit from mass, length and time units.
129      * @param massUnit the unit of mass for the pressure unit, e.g., kilogram
130      * @param lengthUnit the unit of length for the pressure unit, e.g., meter
131      * @param timeUnit the unit of time for the pressure unit, e.g., second
132      * @param nameKey the key to the locale file for the long name of the unit
133      * @param abbreviationKey the key to the locale file for the abbreviation of the unit
134      * @param unitSystem the unit system, e.g. SI or Imperial
135      */
136     public PressureUnit(final MassUnit massUnit, final LengthUnit lengthUnit, final TimeUnit timeUnit,
137             final String nameKey, final String abbreviationKey, final UnitSystem unitSystem)
138     {
139         super(nameKey, abbreviationKey, unitSystem, PASCAL,
140                 massUnit.getConversionFactorToStandardUnit()
141                         / (lengthUnit.getConversionFactorToStandardUnit()
142                                 * timeUnit.getConversionFactorToStandardUnit() * timeUnit
143                                     .getConversionFactorToStandardUnit()), true);
144         this.massUnit = massUnit;
145         this.lengthUnit = lengthUnit;
146         this.timeUnit = timeUnit;
147     }
148 
149     /**
150      * Construct a pressure unit from force and area units.
151      * @param forceUnit the unit of force for the pressure unit, e.g., Newton
152      * @param areaUnit the unit of area for the pressure unit, e.g., m^2
153      * @param nameKey the key to the locale file for the long name of the unit
154      * @param abbreviationKey the key to the locale file for the abbreviation of the unit
155      * @param unitSystem the unit system, e.g. SI or Imperial
156      */
157     public PressureUnit(final ForceUnit forceUnit, final AreaUnit areaUnit, final String nameKey,
158             final String abbreviationKey, final UnitSystem unitSystem)
159     {
160         super(nameKey, abbreviationKey, unitSystem, PASCAL, forceUnit.getConversionFactorToStandardUnit()
161                 / areaUnit.getConversionFactorToStandardUnit(), true);
162         this.massUnit = forceUnit.getMassUnit();
163         this.lengthUnit = forceUnit.getLengthUnit();
164         this.timeUnit = forceUnit.getTimeUnit();
165     }
166 
167     /**
168      * Build a unit with a conversion factor to another unit.
169      * @param nameKey the key to the locale file for the long name of the unit
170      * @param abbreviationKey the key to the locale file for the abbreviation of the unit
171      * @param unitSystem the unit system, e.g. SI or Imperial
172      * @param referenceUnit the unit to convert to
173      * @param conversionFactorToReferenceUnit multiply a value in this unit by the factor to convert to the given
174      *            reference unit
175      */
176     public PressureUnit(final String nameKey, final String abbreviationKey, final UnitSystem unitSystem,
177             final PressureUnit referenceUnit, final double conversionFactorToReferenceUnit)
178     {
179         super(nameKey, abbreviationKey, unitSystem, referenceUnit, conversionFactorToReferenceUnit, true);
180         this.massUnit = referenceUnit.getMassUnit();
181         this.lengthUnit = referenceUnit.getLengthUnit();
182         this.timeUnit = referenceUnit.getTimeUnit();
183     }
184 
185     /**
186      * @return massUnit
187      */
188     public final MassUnit getMassUnit()
189     {
190         return this.massUnit;
191     }
192 
193     /**
194      * @return lengthUnit
195      */
196     public final LengthUnit getLengthUnit()
197     {
198         return this.lengthUnit;
199     }
200 
201     /**
202      * @return timeUnit
203      */
204     public final TimeUnit getTimeUnit()
205     {
206         return this.timeUnit;
207     }
208 
209     /** {@inheritDoc} */
210     @Override
211     public final PressureUnit getStandardUnit()
212     {
213         return PASCAL;
214     }
215 
216     /** {@inheritDoc} */
217     @Override
218     public final String getSICoefficientsString()
219     {
220         return "kg/ms2";
221     }
222 
223 }