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 volume flow rate is the volume of fluid 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 FlowVolumeUnit extends Unit<FlowVolumeUnit>
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<FlowVolumeUnit> BASE = new Quantity<>("FlowVolume", "m3/s");
23  
24      /** The SI unit for volume flow rate is m^3/s. */
25      public static final FlowVolumeUnitl#FlowVolumeUnit">FlowVolumeUnit SI = new FlowVolumeUnit().build(new Unit.Builder<FlowVolumeUnit>().setQuantity(BASE)
26              .setId("m^3/s").setName("cubic meter per second").setUnitSystem(UnitSystem.SI_DERIVED)
27              .setSiPrefixes(SIPrefixes.NONE, 1.0).setScale(IdentityScale.SCALE).setAdditionalAbbreviations("m^3/sec"));
28  
29      /** m^3/s. */
30      public static final FlowVolumeUnit CUBIC_METER_PER_SECOND = SI;
31  
32      /** m^3/min. */
33      public static final FlowVolumeUnit CUBIC_METER_PER_MINUTE = SI.deriveLinear(
34              factorVD(VolumeUnit.CUBIC_METER, DurationUnit.MINUTE), "m^3/min", "cubic meter per minute", UnitSystem.SI_ACCEPTED);
35  
36      /** m^3/hour. */
37      public static final FlowVolumeUnit CUBIC_METER_PER_HOUR =
38              SI.deriveLinear(factorVD(VolumeUnit.CUBIC_METER, DurationUnit.HOUR), "m^3/h", "cubic meter per hour",
39                      UnitSystem.SI_ACCEPTED, "m^3/h", "m^3/h", "m^3/hr", "m^3/hour");
40  
41      /** m^3/day. */
42      public static final FlowVolumeUnit CUBIC_METER_PER_DAY = SI.deriveLinear(factorVD(VolumeUnit.CUBIC_METER, DurationUnit.DAY),
43              "m^3/day", "cubic meter per day", UnitSystem.SI_ACCEPTED);
44  
45      /** L/s. */
46      public static final FlowVolumeUnit LITER_PER_SECOND = SI.deriveLinear(factorVD(VolumeUnit.LITER, DurationUnit.SECOND),
47              "L/s", "liter per second", UnitSystem.SI_ACCEPTED, "L/s", "L/s", "L/sec");
48  
49      /** L/min. */
50      public static final FlowVolumeUnit LITER_PER_MINUTE = SI.deriveLinear(factorVD(VolumeUnit.LITER, DurationUnit.MINUTE),
51              "L/min", "liter per minute", UnitSystem.SI_ACCEPTED);
52  
53      /** L/hour. */
54      public static final FlowVolumeUnit LITER_PER_HOUR = SI.deriveLinear(factorVD(VolumeUnit.LITER, DurationUnit.HOUR), "L/h",
55              "liter per hour", UnitSystem.SI_ACCEPTED, "L/h", "L/h", "L/hr", "L/hour");
56  
57      /** L/day. */
58      public static final FlowVolumeUnit LITER_PER_DAY =
59              SI.deriveLinear(factorVD(VolumeUnit.LITER, DurationUnit.DAY), "L/day", "liter per day", UnitSystem.SI_ACCEPTED);
60  
61      /** ft^3/s. */
62      public static final FlowVolumeUnit CUBIC_FEET_PER_SECOND =
63              SI.deriveLinear(factorVD(VolumeUnit.CUBIC_FOOT, DurationUnit.SECOND), "ft^3/s", "cubic foot per second",
64                      UnitSystem.IMPERIAL, "ft^3/s", "ft^3/s", "ft^3/sec");
65  
66      /** ft^3/min. */
67      public static final FlowVolumeUnit CUBIC_FEET_PER_MINUTE = SI.deriveLinear(
68              factorVD(VolumeUnit.CUBIC_FOOT, DurationUnit.MINUTE), "ft^3/min", "cubic foot per minute", UnitSystem.IMPERIAL);
69  
70      /** in^3/s. */
71      public static final FlowVolumeUnit CUBIC_INCH_PER_SECOND =
72              SI.deriveLinear(factorVD(VolumeUnit.CUBIC_INCH, DurationUnit.SECOND), "in^3/s", "cubic inch per second",
73                      UnitSystem.IMPERIAL, "in^3/s", "in^3/s", "in^3/sec");
74  
75      /** in^3/min. */
76      public static final FlowVolumeUnit CUBIC_INCH_PER_MINUTE = SI.deriveLinear(
77              factorVD(VolumeUnit.CUBIC_INCH, DurationUnit.MINUTE), "in^3/min", "cubic inch per minute", UnitSystem.IMPERIAL);
78  
79      /** gallon/s (US). */
80      public static final FlowVolumeUnit GALLON_US_PER_SECOND =
81              SI.deriveLinear(factorVD(VolumeUnit.GALLON_US, DurationUnit.SECOND), "gal(US)/s", "US gallon per second",
82                      UnitSystem.US_CUSTOMARY, "gal(US)/s", "gal(US)/s", "gal(US)/sec");
83  
84      /** gallon/min (US). */
85      public static final FlowVolumeUnit GALLON_US_PER_MINUTE =
86              SI.deriveLinear(factorVD(VolumeUnit.GALLON_US, DurationUnit.MINUTE), "gal(US)/min", "US gallon per minute",
87                      UnitSystem.US_CUSTOMARY);
88  
89      /** gallon/hour (US). */
90      public static final FlowVolumeUnit GALLON_US_PER_HOUR = SI.deriveLinear(factorVD(VolumeUnit.GALLON_US, DurationUnit.HOUR),
91              "gal(US)/h", "US gallon per hour", UnitSystem.US_CUSTOMARY, "gal(US)/h", "gal(US)/h", "gal(US)/hr", "gal(US)/hour");
92  
93      /** gallon/day (US). */
94      public static final FlowVolumeUnit GALLON_US_PER_DAY = SI.deriveLinear(factorVD(VolumeUnit.GALLON_US, DurationUnit.DAY),
95              "gal(US)/day", "US gallon per day", UnitSystem.US_CUSTOMARY);
96  
97      /**
98       * Determine the conversion factor to the base flow volume unit, given a volume unit and a duration unit.
99       * @param volume VolumeUnit; the used volume unit, e.g. m3
100      * @param duration DurationUnit; the used duration unit, e.g. h
101      * @return double; the conversion factor from the provided units (e.g. m3/h) to the standard unit (e.g., m3/s)
102      */
103     private static double factorVD(final VolumeUnit volume, final DurationUnit duration)
104     {
105         return volume.getScale().toStandardUnit(1.0) / duration.getScale().toStandardUnit(1.0);
106     }
107 
108 }