All Downloads are FREE. Search and download functionalities are using the official Maven repository.

si.uom.NonSI Maven / Gradle / Ivy

There is a newer version: 1.3.1
Show newest version
/*
 * SI Units for Java
 * Copyright (c) 2005-2017, Jean-Marie Dautelle, Werner Keil and others.
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
 *
 * 3. Neither the name of JSR-363, Units of Measurement nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package si.uom;

import static tec.uom.se.unit.MetricPrefix.CENTI;
import static tec.uom.se.unit.Units.*;

import javax.measure.Unit;
import javax.measure.quantity.*;

import si.uom.quantity.DynamicViscosity;
import si.uom.quantity.IonizingRadiation;
import si.uom.quantity.KinematicViscosity;
import si.uom.quantity.Luminance;
import tec.uom.se.AbstractSystemOfUnits;
import tec.uom.se.AbstractUnit;
import tec.uom.se.format.SimpleUnitFormat;
import tec.uom.se.function.LogConverter;
import tec.uom.se.function.MultiplyConverter;
import tec.uom.se.function.PiMultiplierConverter;
import tec.uom.se.function.RationalConverter;
import tec.uom.se.unit.ProductUnit;
import tec.uom.se.unit.TransformedUnit;
import tec.uom.se.unit.Units;

/**
 * 

* This class contains units that are not part of the International System of * Units, that is, they are outside the SI, but are important and widely used. *

* *

* This class is not intended to be implemented by clients. *

* * @noimplement This class is not intended to be implemented by clients. * @noextend This class is not intended to be extended by clients. * * @author Jean-Marie Dautelle * @author Werner Keil * @version 1.0.4, $Date: 2017-04-16$ */ public class NonSI extends AbstractSystemOfUnits { private static final String SYSTEM_NAME = "Non-SI Units"; /** * Holds the standard gravity constant: 9.80665 m/s² exact. */ private static final int STANDARD_GRAVITY_DIVIDEND = 980665; private static final int STANDARD_GRAVITY_DIVISOR = 100000; /** * Holds the avoirdupois pound: 0.45359237 kg exact */ private static final int AVOIRDUPOIS_POUND_DIVIDEND = 45359237; private static final int AVOIRDUPOIS_POUND_DIVISOR = 100000000; /** * Holds the Avogadro constant. */ private static final double AVOGADRO_CONSTANT = 6.02214199e23; // (1/mol). /** * Holds the electric charge of one electron. */ private static final double ELEMENTARY_CHARGE = 1.602176462e-19; // (C). private static final NonSI INSTANCE = new NonSI(); ///////////////////////////////////////////////////////////////// // Units outside the SI that are accepted for use with the SI. // ///////////////////////////////////////////////////////////////// /** * An angle unit accepted for use with SI units (standard name * deg). */ public static final Unit DEGREE_ANGLE = addUnit( new TransformedUnit(RADIAN, new PiMultiplierConverter().concatenate(new RationalConverter(1, 180))), "Degree Angle", "deg"); /** * An angle unit accepted for use with SI units (standard name * '). */ public static final Unit MINUTE_ANGLE = addUnit(new TransformedUnit(RADIAN, new PiMultiplierConverter().concatenate(new RationalConverter(1, 180 * 60))), "Minute Angle", "'"); /** * An angle unit accepted for use with SI units (standard name * ''). */ public static final Unit SECOND_ANGLE = addUnit( new TransformedUnit(RADIAN, new PiMultiplierConverter().concatenate(new RationalConverter(1, 180 * 60 * 60))), "Second Angle", "''"); /** * A mass unit accepted for use with SI units (standard name * t). */ public static final Unit TONNE = AbstractSystemOfUnits.Helper.addUnit(INSTANCE.units, new TransformedUnit(KILOGRAM, new RationalConverter(1000, 1)), "Tonne", "t"); /** * An energy unit accepted for use with SI units (standard name * eV). The electronvolt is the kinetic energy acquired by an * electron passing through a potential difference of 1 V in vacuum. The * value must be obtained by experiment, and is therefore not known exactly. */ public static final Unit ELECTRON_VOLT = addUnit( new TransformedUnit(JOULE, new MultiplyConverter(1.602176487E-19)), "Electron Volt", "eV"); // CODATA 2006 - http://physics.nist.gov/cuu/Constants/codata.pdf /** * A mass unit accepted for use with SI units (standard name * u). The unified atomic mass unit is equal to 1/12 of the * mass of an unbound atom of the nuclide 12C, at rest and in its ground * state. The value must be obtained by experiment, and is therefore not * known exactly. */ public static final Unit UNIFIED_ATOMIC_MASS = addUnit( new TransformedUnit(KILOGRAM, new MultiplyConverter(1.660538782E-27)), "Unified atomic mass", "u", true); // CODATA 2006 - http://physics.nist.gov/cuu/Constants/codata.pdf /** * A length unit accepted for use with SI units (standard name * UA). The astronomical unit is a unit of length. Its value is * such that, when used to describe the motion of bodies in the solar * system, the heliocentric gravitation constant is (0.017 202 098 95)2 * ua3·d-2. The value must be obtained by experiment, and is therefore not * known exactly. */ public static final Unit ASTRONOMICAL_UNIT = addUnit( new TransformedUnit(METRE, new MultiplyConverter(149597871000.0)), "Astronomical Unit", "UA"); // Best estimate source: http://maia.usno.navy.mil/NSFA/CBE.html /** * An angle unit accepted for use with SI units (standard name * ha). */ public static final Unit HECTARE = addUnit( new TransformedUnit(SQUARE_METRE, new RationalConverter(10000, 1)), "Hectare", "ha"); /////////////////// // Dimensionless // /////////////////// /** * A dimensionless unit equals to pi (standard name * Ï€). */ public static final Unit PI = addUnit(AbstractUnit.ONE.multiply(StrictMath.PI)); /** * A logarithmic unit used to describe a ratio (standard name * dB). */ protected static final Unit DECIBEL = AbstractUnit.ONE .transform(new LogConverter(10).inverse().concatenate(RationalConverter.of(1d, 10d))); ///////////////////////// // Amount of substance // ///////////////////////// /** * A unit of amount of substance equals to one atom (standard name * atom). */ public static final Unit ATOM = addUnit(MOLE.divide(AVOGADRO_CONSTANT)); //////////// // Length // //////////// /** * A unit of length equal to 1E-10 m (standard name * \u00C5ngstr\u00F6m). */ public static final Unit ANGSTROM = addUnit(METRE.divide(10000000000L)); /** * A unit of length equal to the distance that light travels in one year * through a vacuum (standard name ly). */ protected static final Unit LIGHT_YEAR = addUnit(METRE.multiply(9.460528405e15)); /** * A unit of length equal to the distance at which a star would appear to * shift its position by one arcsecond over the course the time (about 3 * months) in which the Earth moves a distance of {@link #ASTRONOMICAL_UNIT} * in the direction perpendicular to the direction to the star (standard * name pc). */ public static final Unit PARSEC = addUnit(METRE.multiply(30856770e9)); ////////////// // Duration // ////////////// /** * A unit of duration equal to the time required for a complete rotation of * the earth in reference to any star or to the vernal equinox at the * meridian, equal to 23 hours, 56 minutes, 4.09 seconds (standard name * day_sidereal). */ public static final Unit