View Javadoc
1   package org.djunits.unit;
2   
3   import org.djunits.unit.quantity.Quantity;
4   import org.djunits.unit.scale.IdentityScale;
5   import org.djunits.unit.si.SIPrefixes;
6   import org.djunits.unit.unitsystem.UnitSystem;
7   
8   /**
9    * The units of pressure.
10   * <p>
11   * Copyright (c) 2015-2023 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
12   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
13   * <p>
14   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
15   */
16  public class PressureUnit extends Unit<PressureUnit>
17  {
18      /** */
19      private static final long serialVersionUID = 20140607L;
20  
21      /** The base, with "kg/ms2" as the SI signature. */
22      public static final Quantity<PressureUnit> BASE = new Quantity<>("Pressure", "kg/ms2");
23  
24      /** The SI unit for pressure is Pascal = kgm/s2. */
25      public static final PressureUnit SI =
26              new PressureUnit().build(new Unit.Builder<PressureUnit>().setQuantity(BASE).setId("Pa").setName("pascal")
27                      .setUnitSystem(UnitSystem.SI_DERIVED).setSiPrefixes(SIPrefixes.UNIT, 1.0).setScale(IdentityScale.SCALE));
28  
29      /** Pascal. */
30      public static final PressureUnit PASCAL = SI;
31  
32      /** hectoPascal. */
33      public static final PressureUnit HECTOPASCAL = PASCAL.deriveLinear(100.0, "hPa", "hectopascal");
34  
35      /** kiloPascal. */
36      public static final PressureUnit KILOPASCAL = PASCAL.deriveLinear(1000.0, "kPa", "kilopascal");
37  
38      /** standard atmosphere. */
39      public static final PressureUnit ATMOSPHERE_STANDARD =
40              PASCAL.deriveLinear(101325.0, "atm", "atmosphere (standard)", UnitSystem.OTHER);
41  
42      /** torr. */
43      public static final PressureUnit TORR = ATMOSPHERE_STANDARD.deriveLinear(1.0 / 760.0, "torr", "Torr");
44  
45      /** technical atmosphere. */
46      public static final PressureUnit ATMOSPHERE_TECHNICAL = SI.deriveLinear(
47              factorFA(ForceUnit.KILOGRAM_FORCE, AreaUnit.SQUARE_CENTIMETER), "at", "atmosphere (technical)", UnitSystem.OTHER);
48  
49      /** barye. */
50      public static final PressureUnit BARYE =
51              SI.deriveLinear(factorFA(ForceUnit.DYNE, AreaUnit.SQUARE_CENTIMETER), "Ba", "barye", UnitSystem.CGS);
52  
53      /** bar. */
54      public static final PressureUnit BAR = SI.deriveLinear(1.0E5, "bar", "bar", UnitSystem.OTHER);
55  
56      /** millibar. */
57      public static final PressureUnit MILLIBAR = BAR.deriveLinear(1.0E-3, "mbar", "millibar");
58  
59      /** cm Hg. */
60      public static final PressureUnit CENTIMETER_MERCURY =
61              PASCAL.deriveLinear(1333.224, "cmHg", "centimeter mercury", UnitSystem.OTHER);
62  
63      /** mm Hg. */
64      public static final PressureUnit MILLIMETER_MERCURY =
65              PASCAL.deriveLinear(133.3224, "mmHg", "millimeter mercury", UnitSystem.OTHER);
66  
67      /** foot Hg. */
68      public static final PressureUnit FOOT_MERCURY =
69              PASCAL.deriveLinear(40.63666E3, "ftHg", "foot mercury", UnitSystem.IMPERIAL);
70  
71      /** inch Hg. */
72      public static final PressureUnit INCH_MERCURY =
73              PASCAL.deriveLinear(3.386389E3, "inHg", "inch mercury", UnitSystem.IMPERIAL);
74  
75      /** kilogram-force per square millimeter. */
76      public static final PressureUnit KGF_PER_SQUARE_MM =
77              SI.deriveLinear(factorFA(ForceUnit.KILOGRAM_FORCE, AreaUnit.SQUARE_MILLIMETER), "kgf/mm^2",
78                      "kilogram-force per square millimeter", UnitSystem.OTHER);
79  
80      /** pound per square foot. */
81      public static final PressureUnit POUND_PER_SQUARE_FOOT =
82              SI.deriveLinear(factorFA(ForceUnit.POUND_FORCE, AreaUnit.SQUARE_FOOT), "lbf/ft^2", "pound-force per square foot",
83                      UnitSystem.IMPERIAL);
84  
85      /** pound per square inch. */
86      public static final PressureUnit POUND_PER_SQUARE_INCH =
87              SI.deriveLinear(factorFA(ForceUnit.POUND_FORCE, AreaUnit.SQUARE_INCH), "lbf/in^2", "pound-force per square inch",
88                      UnitSystem.IMPERIAL);
89  
90      /** pieze. */
91      public static final PressureUnit PIEZE =
92              SI.deriveLinear(factorFA(ForceUnit.STHENE, AreaUnit.SQUARE_METER), "pz", "pi\u00E8ze", UnitSystem.MTS);
93  
94      /**
95       * Determine the conversion factor to the base pressure unit, given a force unit and an area unit.
96       * @param force ForceUnit; the used force unit, e.g. kgf
97       * @param area AreaUnit; the used area unit, e.g. mm2
98       * @return double; the conversion factor from the provided units (e.g. kgf/mm2) to the standard unit (Pa)
99       */
100     private static double factorFA(final ForceUnit force, final AreaUnit area)
101     {
102         return force.getScale().toStandardUnit(1.0) / area.getScale().toStandardUnit(1.0);
103     }
104 
105 }