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 mass flow rate is the mass of a substance which passes through a given surface per unit of time (wikipedia).
10   * <p>
11   * Copyright (c) 2015-2020 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 FlowMassUnit extends Unit<FlowMassUnit>
17  {
18      /** */
19      private static final long serialVersionUID = 20140607L;
20  
21      /** The base, with "kg/s" as the SI signature. */
22      public static final Quantity<FlowMassUnit> BASE = new Quantity<>("FlowMass", "kg/s");
23  
24      /** The SI unit for mass flow rate is kg/s. */
25      public static final FlowMassUnitl#FlowMassUnit">FlowMassUnit SI = new FlowMassUnit().build(new Unit.Builder<FlowMassUnit>().setQuantity(BASE)
26              .setId("kg/s").setName("kilogram per second").setUnitSystem(UnitSystem.SI_BASE).setSiPrefixes(SIPrefixes.NONE, 1.0)
27              .setScale(IdentityScale.SCALE).setAdditionalAbbreviations("kg/sec"));
28  
29      /** kg/s. */
30      public static final FlowMassUnit KILOGRAM_PER_SECOND = SI;
31  
32      /** lb/s. */
33      public static final FlowMassUnit POUND_PER_SECOND =
34              KILOGRAM_PER_SECOND.deriveLinear(factorMD(MassUnit.POUND, DurationUnit.SECOND), "lb/s", "pound per second",
35                      UnitSystem.IMPERIAL, "lb/s", "lb/s", "lb/sec");
36  
37      /**
38       * Determine the conversion factor to the base flow mass unit, given a mass unit and a duration unit.
39       * @param mass MassUnit; the used mass unit, e.g. lb
40       * @param duration DurationUnit; the used duration unit, e.g. h
41       * @return double; the conversion factor from the provided units (e.g. lb/h) to the standard unit (e.g., kg/s)
42       */
43      private static double factorMD(final MassUnit mass, final DurationUnit duration)
44      {
45          return mass.getScale().toStandardUnit(1.0) / duration.getScale().toStandardUnit(1.0);
46      }
47  
48  }