Skip to content

Commit

Permalink
59: Add missing UCUM units
Browse files Browse the repository at this point in the history
Task-Url: #59
  • Loading branch information
keilw committed Sep 6, 2020
1 parent 80e63d5 commit e8af2ca
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 25 deletions.
59 changes: 35 additions & 24 deletions ucum/src/main/java/systems/uom/ucum/UCUM.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@
* <p>
* Compatibility with {@link SI} units has been given priority over strict
* adherence to the standard. We have attempted to note every place where the
* definitions in this class deviate from the UCUM standard, but such notes are
* likely to be incomplete.
* definitions in this class deviate from the UCUM standard, but such notes
* could be incomplete.
* </p>
*
* @author <a href="mailto:eric-r@northwestern.edu">Eric Russell</a>
* @author <a href="mailto:werner@uom.systems">Werner Keil</a>
* @see <a href="http://www.unitsofmeasure.org">UCUM</a>
* @version 2.3, $Date: 2020-09-05 $
* @version 2.4, $Date: 2020-09-06 $
*/
public final class UCUM extends AbstractSystemOfUnits {

Expand Down Expand Up @@ -560,7 +560,7 @@ public static UCUM getInstance() {
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
public static final Unit<Volume> MINIM_BRITISH = addUnit(FLUID_DRAM_BRITISH.divide(60));
////////////////////////////////////////////
// AVOIRDUPOIS WIEGHT UNITS: UCUM 4.4 §39 //
// AVOIRDUPOIS WEIGHT UNITS: UCUM 4.4 §39 //
////////////////////////////////////////////
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
public static final Unit<Mass> GRAIN = addUnit(MILLI(GRAM).multiply(6479891).divide(100000));
Expand All @@ -584,15 +584,9 @@ public static UCUM getInstance() {
// contains a forward reference to POUND, so we had to move it here, below
// section §39
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
// public static final Unit<Force> POUND_FORCE = addUnit(new
// ProductUnit<Force>(
// POUND.multiply(ACCELERATION_OF_FREEFALL)));
public static final Unit<Force> POUND_FORCE = addUnit(
POUND.multiply(ACCELERATION_OF_FREEFALL).asType(Force.class));

// public static final Unit<InformationRate> POUND_FORCE2 =
// addUnit(POUND.multiply(ACCELERATION_OF_FREEFALL).asType(InformationRate.class));

/////////////////////////////////////
// TROY WEIGHT UNITS: UCUM 4.4 §40 //
/////////////////////////////////////
Expand Down Expand Up @@ -639,6 +633,7 @@ public static UCUM getInstance() {
public static final Unit<Length> DIDOT = addUnit(LIGNE.divide(6));
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
public static final Unit<Length> CICERO = addUnit(DIDOT.multiply(12));

//////////////////////////////////////
// OTHER LEGACY UNITS: UCUM 4.5 §43 //
//////////////////////////////////////
Expand Down Expand Up @@ -745,37 +740,59 @@ public static UCUM getInstance() {
//////////////////////////////////////////////////
/**
* amount of substance
* @since 2.4
*/
public static final Unit<AmountOfSubstance> EQUIVALENTS = addUnit(new AlternateUnit<AmountOfSubstance>(MOLE, "eq"));
/**
* amount of substance (dissolved particles)
* @since 2.4
*/
public static final Unit<AmountOfSubstance> OSMOLE = addUnit(new AlternateUnit<AmountOfSubstance>(MOLE, "osm"));
public static final Unit<AmountOfSubstance> OSMOLE = addUnit(new AlternateUnit<AmountOfSubstance>(MOLE, "osm"));

public static final Unit<Acidity> PH = addUnit(
MOLE.divide(LITER).transform(new LogConverter(10)).multiply(-1).asType(Acidity.class));

// @SuppressWarnings("unchecked")
@SuppressWarnings("unchecked")
public static final Unit<Concentration<Mass>> GRAM_PERCENT = addUnit(
GRAM.divide(DECI(LITER)).asType(Concentration.class));

// public static final Unit SVEDBERG = addUnit(SECOND.multiply(1E-13));
/**
* sedimentation coefficient
* @since 2.4
*/
public static final Unit<Time> SVEDBERG = addUnit(SECOND.multiply(1E-13));

public static final Unit<Dimensionless> HIGH_POWER_FIELD = addUnit(ONE);
public static final Unit<Dimensionless> LOW_POWER_FIELD = addUnit(ONE.multiply(100));

/**
* The SI unit for catalytic activity (standard name <code>kat</code>).
* @since 2.3
*/
public static final Unit<CatalyticActivity> KATAL = addUnit(Units.KATAL);

/**
* catalytic activity
* @since 2.3
*/
public static final Unit<CatalyticActivity> UNIT = addUnit(MICRO(MOLE).divide(MINUTE).asType(CatalyticActivity.class));

/**
* arbitrary
* @since 2.3
*/
public static final Unit<Dimensionless> INTERNATIONAL_UNIT = addUnit(new AlternateUnit<Dimensionless>(ONE, "IU"), "International Unit", "IU");

/**
* arbitrary
* @since 2.3
*/
public static final Unit<Dimensionless> INTERNATIONAL_UNIT_ALT = addUnit(new AlternateUnit<Dimensionless>(INTERNATIONAL_UNIT, "i.U."), "International Unit", "i.U.");

/**
* arbitrary
* @since 2.3
*/
public static final Unit<Dimensionless> ARBITRARY_UNIT = addUnit(new AlternateUnit<Dimensionless>(ONE, "arb. U"), "Arbitrary Unit", "arb. U");
// public static final Unit US_PHARMACOPEIA = UNDEFINED;
// public static final Unit GPL = UNDEFINED;
Expand Down Expand Up @@ -865,16 +882,13 @@ public static UCUM getInstance() {
/** temporary helper for MHO */
private static final Unit<? extends Quantity<?>> TMP_MHO = SIEMENS.alternate("mho");

/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
//public static final Unit<Volume> STERE = addUnit(new ProductUnit<Volume>(METER.pow(3)));
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
public static final Unit<Volume> STERE = addUnit(new TransformedUnit<Volume>("st", Units.CUBIC_METRE, Units.CUBIC_METRE, MultiplyConverter.identity()));
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
public static final Unit<Length> ANGSTROM = addUnit(NANO(METER).divide(10));
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
public static final Unit<Area> BARN = addUnit(new ProductUnit<Area>(FEMTO(METER).pow(2)).multiply(100));
// public static final Unit<Area> BARN = addUnit(new
// ProductUnit<Area>(FEMTO(
// METER).pow(2).multiply(100)));

/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
public static final Unit<Pressure> ATMOSPHERE_TECHNICAL = addUnit(
new ProductUnit<Pressure>(KILO(GRAM_FORCE).divide(CENTI(METER).pow(2))));
Expand All @@ -886,15 +900,11 @@ public static UCUM getInstance() {
new ProductUnit<Pressure>(POUND_FORCE.divide(INCH_INTERNATIONAL.pow(2))));
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
public static final Unit<Angle> CIRCLE = addUnit(new ProductUnit<Angle>(PI.multiply(RADIAN.multiply(2))));
// public static final Unit<Angle> CIRCLE = addUnit(new
// ProductUnit<Angle>(PI
// .multiply(RADIAN).multiply(2)));

/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
public static final Unit<SolidAngle> SPHERE = addUnit(
new ProductUnit<SolidAngle>(PI.multiply(STERADIAN.multiply(4))));
// public static final Unit<SolidAngle> SPHERE = addUnit(new
// ProductUnit<SolidAngle>(
// PI.multiply(STERADIAN).multiply(4)));

/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
public static final Unit<Mass> CARAT_METRIC = addUnit(GRAM.divide(5));
/** As per <a href="http://unitsofmeasure.org/">UCUM</a> standard. */
Expand All @@ -913,6 +923,7 @@ public static UCUM getInstance() {

/**
* The bit is defined twice. One definition with a subscript letter ‘s‘ is defined as the logarithmus dualis of the number of distinct signals. However this unit can not practically be used to express more than 1000 bits. Especially when the bit is used to express transmission rate or memory capacities, floating point registers would quickly overflow. Therefore we define a second symbol for bit, without the suffix, to be the dimensionless unit 1.
* @since 2.3
*/
public static final Unit<Information> BIT_S = addUnit(new AlternateUnit<Information>(BIT, "bit\\u2082"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ systems.uom.ucum.UCUM.INTERNATIONAL_UNIT=[IU]
systems.uom.ucum.UCUM.INTERNATIONAL_UNIT_ALT=[IU]
systems.uom.ucum.UCUM.NEPER=NEP
systems.uom.ucum.UCUM.BEL=B
systems.uom.ucum.UCUM.SVEDBERG=[S]

# Common Units (defined by implementation)
tech.units.indriya.unit.Units.KILOMETRE_PER_HOUR = [KPH]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ systems.uom.ucum.UCUM.INTERNATIONAL_UNIT=[iU]
systems.uom.ucum.UCUM.INTERNATIONAL_UNIT_ALT=[IU]
systems.uom.ucum.UCUM.NEPER=Np
systems.uom.ucum.UCUM.BEL=B
systems.uom.ucum.UCUM.SVEDBERG=[S]

# Common Units (defined by implementation)
tech.units.indriya.unit.Units.KILOMETRE_PER_HOUR = [kph]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ systems.uom.ucum.UCUM.INTERNATIONAL_UNIT=IU
systems.uom.ucum.UCUM.INTERNATIONAL_UNIT_ALT=i.U.
systems.uom.ucum.UCUM.NEPER=Np
systems.uom.ucum.UCUM.BEL=B
systems.uom.ucum.UCUM.SVEDBERG=S

# Common Units (defined by implementation)
tech.units.indriya.unit.Units.KILOMETRE_PER_HOUR = kph
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

public class SystemOfUnitsServiceTest {
private static final String EXPECTED_SYSTEM_NAME = "Unified Code for Units of Measure";
private static final int NUM_OF_UNITS = 251;
private static final int NUM_OF_UNITS = 252;

private static SystemOfUnitsService defaultService;

Expand Down

0 comments on commit e8af2ca

Please sign in to comment.