View Javadoc
1   package org.djunits.unit;
2   
3   import org.djunits.quantity.Quantity;
4   import org.djunits.unit.scale.IdentityScale;
5   import org.djunits.unit.scale.LinearScale;
6   import org.djunits.unit.si.SIPrefixes;
7   import org.djunits.unit.unitsystem.UnitSystem;
8   
9   /**
10   * Standard mass units. Several conversion factors have been taken from
11   * <a href="http://en.wikipedia.org/wiki/Conversion_of_units">http://en.wikipedia.org/wiki/Conversion_of_units</a>.
12   * <p>
13   * Copyright (c) 2015-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved. <br>
14   * BSD-style license. See <a href="https://djunits.org/docs/license.html">DJUNITS License</a>.
15   * </p>
16   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
17   */
18  public class MassUnit extends Unit<MassUnit>
19  {
20      /** */
21      private static final long serialVersionUID = 20140607L;
22  
23      /** The base, with "kg" as the SI signature. */
24      public static final Quantity<MassUnit> BASE = new Quantity<>("Mass", "kg");
25  
26      /** The SI unit for mass is kilogram. */
27      public static final MassUnit SI =
28              new MassUnit().build(new Unit.Builder<MassUnit>().setQuantity(BASE).setId("kg").setName("kilogram")
29                      .setUnitSystem(UnitSystem.SI_DERIVED).setSiPrefixes(SIPrefixes.KILO, 1.0).setScale(IdentityScale.SCALE));
30  
31      /** kilogram. */
32      public static final MassUnit KILOGRAM = SI;
33  
34      /** gram. */
35      public static final MassUnit GRAM = KILOGRAM.deriveLinear(1.0E-3, "g", "gram", UnitSystem.SI_BASE);
36  
37      /** microgram. */
38      public static final MassUnit MICROGRAM = GRAM.deriveSI(SIPrefixes.getUnit("mu"), 1.0);
39  
40      /** milligram. */
41      public static final MassUnit MILLIGRAM = GRAM.deriveSI(SIPrefixes.getUnit("m"), 1.0);
42  
43      /** pound. */
44      public static final MassUnit POUND = KILOGRAM.deriveLinear(0.45359237, "lb", "pound", UnitSystem.IMPERIAL);
45  
46      /** pound. */
47      public static final MassUnit OUNCE = POUND.deriveLinear(1.0 / 16.0, "oz", "ounce");
48  
49      /** long ton = 2240 lb. */
50      public static final MassUnit TON_LONG = POUND.deriveLinear(2240.0, "long tn", "long ton");
51  
52      /** short ton = 2000 lb. */
53      public static final MassUnit TON_SHORT = POUND.deriveLinear(2000.0, "sh tn", "short ton", UnitSystem.US_CUSTOMARY);
54  
55      /** metric ton = 1000 kg. */
56      public static final MassUnit TON_METRIC = KILOGRAM.deriveLinear(1000.0, "t", "metric tonne", UnitSystem.SI_ACCEPTED);
57  
58      /** metric ton = 1000 kg. */
59      public static final MassUnit TONNE = KILOGRAM.deriveLinear(1000.0, "t(mts)", "tonne", UnitSystem.MTS);
60  
61      /** dalton. */
62      public static final MassUnit DALTON = KILOGRAM.deriveLinear(1.6605388628E-27, "Da", "Dalton", UnitSystem.SI_ACCEPTED);
63  
64      /** electronvolt = 1.782661907E-36 kg. See http://physics.nist.gov/cuu/Constants/Table/allascii.txt. */
65      public static final MassUnit ELECTRONVOLT = new MassUnit().build(
66              new Unit.Builder<MassUnit>().setQuantity(BASE).setId("eV").setName("electronvolt").setUnitSystem(UnitSystem.OTHER)
67                      .setSiPrefixes(SIPrefixes.UNIT_POS, 1.0).setScale(new LinearScale(1.782661907E-36)));
68  
69      /** microelectronvolt. */
70      public static final MassUnit MICROELECTRONVOLT = ELECTRONVOLT.deriveSI(SIPrefixes.getUnit("mu"), 1.0);
71  
72      /** millielectronvolt. */
73      public static final MassUnit MILLIELECTRONVOLT = ELECTRONVOLT.deriveSI(SIPrefixes.getUnit("m"), 1.0);
74  
75      /** kiloelectronvolt. */
76      public static final MassUnit KILOELECTRONVOLT = ELECTRONVOLT.deriveSI(SIPrefixes.getUnit("k"), 1.0);
77  
78      /** megaelectronvolt. */
79      public static final MassUnit MEGAELECTRONVOLT = ELECTRONVOLT.deriveSI(SIPrefixes.getUnit("M"), 1.0);
80  
81      /** gigaelectronvolt. */
82      public static final MassUnit GIGAELECTRONVOLT = ELECTRONVOLT.deriveSI(SIPrefixes.getUnit("G"), 1.0);
83  
84  }