<commit_before>/* Copyright 2002-2021 CS GROUP
 * Licensed to CS GROUP (CS) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * CS licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.orekit.utils.units;

import org.hipparchus.fraction.Fraction;
import org.hipparchus.util.FastMath;

/** Basic handling of multiplicative units.
 * <p>
 * This class is by no means a complete handling of units. For complete
 * support, look at libraries like {@code UOM}. This class handles only
 * time, length, mass and current dimensions, as well as angles (which are
 * dimensionless).
 * </p>
 * <p>
 * Instances of this class are immutable.
 * </p>
 * @see <a href="https://github.com/netomi/uom">UOM</a>
 * @author <NAME>
 * @since 11.0
 */
public class Unit {

    /** No unit. */
    public static final Unit NONE = new Unit("n/a", 1.0, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO);

    /** Dimensionless unit. */
    public static final Unit ONE = new Unit("1", 1.0, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO);

    /** Percentage unit. */
    public static final Unit PERCENT = new Unit("%", 1.0e-2, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO);

    /** Second unit. */
    public static final Unit SECOND = new Unit("s", 1.0, Fraction.ZERO, Fraction.ZERO, Fraction.ONE, Fraction.ZERO, Fraction.ZERO);

    /** Minute unit. */
    public static final Unit MINUTE = SECOND.scale("min", 60.0);

    /** Hour unit. */
    public static final Unit HOUR = MINUTE.scale("h", 60);

    /** Day unit. */
    public static final Unit DAY = HOUR.scale("d", 24.0);

    /** Julian year unit.
     * @see <a href="https://www.iau.org/publications/proceedings_rules/units/">SI Units</a> at IAU
     */
    public static final Unit YEAR = DAY.scale("a", 365.25);

    /** Hertz unit. */
    public static final Unit HERTZ = SECOND.power("Hz", Fraction.MINUS_ONE);

    /** Metre unit. */
    public static final Unit METRE = new Unit("m", 1.0, Fraction.ZERO, Fraction.ONE, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO);

    /** Kilometre unit. */
    public static final Unit KILOMETRE = METRE.scale("km", 1000.0);

    /** Kilogram unit. */
    public static final Unit KILOGRAM = new Unit("kg", 1.0, Fraction.ONE, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO);

    /** Gram unit. */
    public static final Unit GRAM = KILOGRAM.scale("g", 1.0e-3);

    /** Ampere unit. */
    public static final Unit AMPERE = new Unit("A", 1.0, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ONE, Fraction.ZERO);

    /** Radian unit. */
    public static final Unit RADIAN = new Unit("rad", 1.0, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ONE);

    /** Degree unit. */
    public static final Unit DEGREE = RADIAN.scale("°", FastMath.toRadians(1.0));

    /** Arc minute unit. */
    public static final Unit ARC_MINUTE = DEGREE.scale("′", 1.0 / 60.0);

    /** Arc second unit. */
    public static final Unit ARC_SECOND = ARC_MINUTE.scale("″", 1.0 / 60.0);

    /** Revolution unit. */
    public static final Unit REVOLUTION = RADIAN.scale("rev", 2.0 * FastMath.PI);

    /** Newton unit. */
    public static final Unit NEWTON = KILOGRAM.multiply(null, METRE).divide("N", SECOND.power(null, Fraction.TWO));

    /** Pascal unit. */
    public static final Unit PASCAL = NEWTON.divide("Pa", METRE.power(null, Fraction.TWO));

    /** Bar unit. */
    public static final Unit BAR = PASCAL.scale("bar", 100000.0);

    /** Joule unit. */
    public static final Unit JOULE = NEWTON.multiply("J", METRE);

    /** Watt unit. */
    public static final Unit WATT = JOULE.divide("W", SECOND);

    /** Coulomb unit. */
    public static final Unit COULOMB = SECOND.multiply("C", AMPERE);

    /** Volt unit. */
    public static final Unit VOLT = WATT.divide("V", AMPERE);

    /** Ohm unit. */
    public static final Unit OHM = VOLT.divide("Ω", AMPERE);

    /** tesla unit. */
    public static final Unit TESLA = VOLT.multiply(null, SECOND).divide("T", METRE.power(null, Fraction.TWO));

    /** Solar Flux Unit. */
    public static final Unit SOLAR_FLUX_UNIT = WATT.divide(null, METRE.power(null, Fraction.TWO).multiply(null, HERTZ)).scale("sfu", 1.0e-22);

    /** Total Electron Content Unit. */
    public static final Unit TOTAL_ELECTRON_CONTENT_UNIT = METRE.power(null, new Fraction(-2)).scale("TECU", 1.0e+16);

    /** Name name of the unit. */
    private final String name;

    /** Scaling factor to SI units. */
    private final double scale;

    /** Mass exponent. */
    private final Fraction mass;
<commit_msg>Fixed missing serialization.<commit_after>/* Copyright 2002-2021 CS GROUP
 * Licensed to CS GROUP (CS) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * CS licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.orekit.utils.units;

import java.io.Serializable;

import org.hipparchus.fraction.Fraction;
import org.hipparchus.util.FastMath;

/** Basic handling of multiplicative units.
 * <p>
 * This class is by no means a complete handling of units. For complete
 * support, look at libraries like {@code UOM}. This class handles only
 * time, length, mass and current dimensions, as well as angles (which are
 * dimensionless).
 * </p>
 * <p>
 * Instances of this class are immutable.
 * </p>
 * @see <a href="https://github.com/netomi/uom">UOM</a>
 * @author <NAME>
 * @since 11.0
 */
public class Unit implements Serializable {

    /** No unit. */
    public static final Unit NONE = new Unit("n/a", 1.0, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO);

    /** Dimensionless unit. */
    public static final Unit ONE = new Unit("1", 1.0, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO);

    /** Percentage unit. */
    public static final Unit PERCENT = new Unit("%", 1.0e-2, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO);

    /** Second unit. */
    public static final Unit SECOND = new Unit("s", 1.0, Fraction.ZERO, Fraction.ZERO, Fraction.ONE, Fraction.ZERO, Fraction.ZERO);

    /** Minute unit. */
    public static final Unit MINUTE = SECOND.scale("min", 60.0);

    /** Hour unit. */
    public static final Unit HOUR = MINUTE.scale("h", 60);

    /** Day unit. */
    public static final Unit DAY = HOUR.scale("d", 24.0);

    /** Julian year unit.
     * @see <a href="https://www.iau.org/publications/proceedings_rules/units/">SI Units</a> at IAU
     */
    public static final Unit YEAR = DAY.scale("a", 365.25);

    /** Hertz unit. */
    public static final Unit HERTZ = SECOND.power("Hz", Fraction.MINUS_ONE);

    /** Metre unit. */
    public static final Unit METRE = new Unit("m", 1.0, Fraction.ZERO, Fraction.ONE, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO);

    /** Kilometre unit. */
    public static final Unit KILOMETRE = METRE.scale("km", 1000.0);

    /** Kilogram unit. */
    public static final Unit KILOGRAM = new Unit("kg", 1.0, Fraction.ONE, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO);

    /** Gram unit. */
    public static final Unit GRAM = KILOGRAM.scale("g", 1.0e-3);

    /** Ampere unit. */
    public static final Unit AMPERE = new Unit("A", 1.0, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ONE, Fraction.ZERO);

    /** Radian unit. */
    public static final Unit RADIAN = new Unit("rad", 1.0, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ZERO, Fraction.ONE);

    /** Degree unit. */
    public static final Unit DEGREE = RADIAN.scale("°", FastMath.toRadians(1.0));

    /** Arc minute unit. */
    public static final Unit ARC_MINUTE = DEGREE.scale("′", 1.0 / 60.0);

    /** Arc second unit. */
    public static final Unit ARC_SECOND = ARC_MINUTE.scale("″", 1.0 / 60.0);

    /** Revolution unit. */
    public static final Unit REVOLUTION = RADIAN.scale("rev", 2.0 * FastMath.PI);

    /** Newton unit. */
    public static final Unit NEWTON = KILOGRAM.multiply(null, METRE).divide("N", SECOND.power(null, Fraction.TWO));

    /** Pascal unit. */
    public static final Unit PASCAL = NEWTON.divide("Pa", METRE.power(null, Fraction.TWO));

    /** Bar unit. */
    public static final Unit BAR = PASCAL.scale("bar", 100000.0);

    /** Joule unit. */
    public static final Unit JOULE = NEWTON.multiply("J", METRE);

    /** Watt unit. */
    public static final Unit WATT = JOULE.divide("W", SECOND);

    /** Coulomb unit. */
    public static final Unit COULOMB = SECOND.multiply("C", AMPERE);

    /** Volt unit. */
    public static final Unit VOLT = WATT.divide("V", AMPERE);

    /** Ohm unit. */
    public static final Unit OHM = VOLT.divide("Ω", AMPERE);

    /** tesla unit. */
    public static final Unit TESLA = VOLT.multiply(null, SECOND).divide("T", METRE.power(null, Fraction.TWO));

    /** Solar Flux Unit. */
    public static final Unit SOLAR_FLUX_UNIT = WATT.divide(null, METRE.power(null, Fraction.TWO).multiply(null, HERTZ)).scale("sfu", 1.0e-22);

    /** Total Electron Content Unit. */
    public static final Unit TOTAL_ELECTRON_CONTENT_UNIT = METRE.power(null, new Fraction(-2)).scale("TECU", 1.0e+16);

    /** Serializable UID. */
    private static final long serialVersionUID = 20210402L;

    /** Name name of the unit. */
    private final String name;

    /** Scaling factor to SI units. */
    private final double scale;

    /** Mass exponent. */
    private final Fraction mass;

{'fraction_non_alphanumeric': 0.13863784589583528, 'fraction_numerical': 0.016398024783378366, 'mean_word_length': 3.1476043276661514, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6880304', 'n_tokens_mistral': 3594, 'n_tokens_neox': 3406, 'n_words': 1112}