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    * Standard frequency unit based on time.
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 FrequencyUnit extends Unit<FrequencyUnit>
17  {
18      /** */
19      private static final long serialVersionUID = 20140607L;
20  
21      /** The SI unit for frequency is Hertz or 1/s. */
22      public static final Quantity<FrequencyUnit> BASE = new Quantity<>("Frequency", "/s");
23  
24      /** The SI unit for frequency is Hertz. */
25      public static final FrequencyUnit SI =
26              new FrequencyUnit().build(new Unit.Builder<FrequencyUnit>().setQuantity(BASE).setId("Hz").setName("hertz")
27                      .setUnitSystem(UnitSystem.SI_DERIVED).setSiPrefixes(SIPrefixes.UNIT, 1.0).setScale(IdentityScale.SCALE));
28  
29      /** Hertz. */
30      public static final FrequencyUnit HERTZ = SI;
31  
32      /** kiloHertz. */
33      public static final FrequencyUnit KILOHERTZ = HERTZ.deriveSI(SIPrefixes.getUnit("k"), 1.0);
34  
35      /** megaHertz. */
36      public static final FrequencyUnit MEGAHERTZ = HERTZ.deriveSI(SIPrefixes.getUnit("M"), 1.0);
37  
38      /** gigaHertz. */
39      public static final FrequencyUnit GIGAHERTZ = HERTZ.deriveSI(SIPrefixes.getUnit("G"), 1.0);
40  
41      /** teraHertz. */
42      public static final FrequencyUnit TERAHERTZ = HERTZ.deriveSI(SIPrefixes.getUnit("T"), 1.0);
43  
44      /** Revolutions per minute = 1/60 Hz. */
45      public static final FrequencyUnit RPM = HERTZ.deriveLinear(1.0 / 60.0, "rpm", "revolutions per minute", UnitSystem.OTHER);
46  
47      /** 1/s and all derived units. */
48      public static final FrequencyUnit PER_SECOND = new FrequencyUnit().build(new Unit.Builder<FrequencyUnit>().setQuantity(BASE)
49              .setId("/s").setName("per second").setUnitSystem(UnitSystem.SI_DERIVED).setSiPrefixes(SIPrefixes.PER_UNIT, 1.0)
50              .setScale(IdentityScale.SCALE).setAdditionalAbbreviations("/s", "1/s", "/sec", "1/sec"));
51  
52      /** 1/microsecond. */
53      public static final FrequencyUnit PER_MICROSECOND = PER_SECOND.deriveLinear(1.0E6, "/mus", "per microsecond",
54              UnitSystem.SI_DERIVED, "/\u03BCs", "/mus", "1/mus", "1/\u03BCs", "/musec", "1/musec", "/\u03BCsec", "1/\u03BCsec");
55  
56      /** 1/millisecond. */
57      public static final FrequencyUnit PER_MILLISECOND = PER_SECOND.deriveLinear(1.0E3, "/ms", "per millisecond",
58              UnitSystem.SI_DERIVED, "/ms", "/ms", "1/ms", "/msec", "1/msec");
59  
60      /** 1/min. */
61      public static final FrequencyUnit PER_MINUTE =
62              PER_SECOND.deriveLinear(1.0 / 60.0, "/min", "per minute", UnitSystem.SI_ACCEPTED, "/min", "1/min");
63  
64      /** 1/hour. */
65      public static final FrequencyUnit PER_HOUR = PER_SECOND.deriveLinear(1.0 / 3600.0, "/h", "per hour", UnitSystem.SI_ACCEPTED,
66              "/h", "/h", "1/h", "/hr", "1/hr", "/hour", "1/hour");
67  
68      /** 1/day. */
69      public static final FrequencyUnit PER_DAY =
70              PER_HOUR.deriveLinear(1.0 / 24.0, "/day", "per day", UnitSystem.SI_ACCEPTED, "/day", "/day", "1/day");
71  
72      /** 1/week. */
73      public static final FrequencyUnit PER_WEEK =
74              PER_DAY.deriveLinear(1.0 / 7.0, "/wk", "per week", UnitSystem.OTHER, "/wk", "/wk", "1/wk", "/week", "1/week");
75  
76  }