# This is a pared down verison of pint's
# https://github.com/hgrecco/pint/blob/master/pint/default_en.txt
# file.
# We have narrowed the units universe to those that occur in the ASHRAE 90.1 standard

# Syntax
# ======
# Units
# -----
# <canonical name> = <relation to another unit or dimension> [= <symbol>] [= <alias>] [ = <alias> ] [...]
#
# The canonical name and aliases should be expressed in singular form.
# Pint automatically deals with plurals built by adding 's' to the singular form; plural
# forms that don't follow this rule should be instead explicitly listed as aliases.
#
# If a unit has no symbol and one wants to define aliases, then the symbol should be
# conventionally set to _.
#
# Example:
#     millennium = 1e3 * year = _ = millennia
#
#
# Prefixes
# --------
# <prefix>- = <amount> [= <symbol>] [= <alias>] [ = <alias> ] [...]
#
# Example:
#     deca- =  1e+1  = da- = deka-
#
#
# Derived dimensions
# ------------------
# [dimension name] = <relation to other dimensions>
#
# Example:
#     [density] = [mass] / [volume]
#
# Note that primary dimensions don't need to be declared; they can be
# defined for the first time in a unit definition.
# E.g. see below `meter = [length]`
#
#
# Additional aliases
# ------------------
# @alias <canonical name or previous alias> = <alias> [ = <alias> ] [...]
#
# Used to add aliases to already existing unit definitions.
# Particularly useful when one wants to enrich definitions
# from defaults_en.txt with custom aliases.
#
# Example:
#     @alias meter = my_meter

# See also: https://pint.readthedocs.io/en/latest/defining.html

@defaults
    group = international
    system = mks
@end


#### PREFIXES ####

# decimal prefixes
yocto- = 1e-24 = y-
zepto- = 1e-21 = z-
atto- =  1e-18 = a-
femto- = 1e-15 = f-
pico- =  1e-12 = p-
nano- =  1e-9  = n-
micro- = 1e-6  = µ- = u-
milli- = 1e-3  = m-
centi- = 1e-2  = c-
deci- =  1e-1  = d-
deca- =  1e+1  = da- = deka-
hecto- = 1e2   = h-
kilo- =  1e3   = k-
mega- =  1e6   = M-
giga- =  1e9   = G-
tera- =  1e12  = T-
peta- =  1e15  = P-
exa- =   1e18  = E-
zetta- = 1e21  = Z-
yotta- = 1e24  = Y-

# extra_prefixes
semi- = 0.5 = _ = demi-
sesqui- = 1.5


#### BASE UNITS ####

meter = [length] = m = metre
second = [time] = s = sec
ampere = [current] = A = amp
candela = [luminosity] = cd = candle
gram = [mass] = g
mole = [substance] = mol
kelvin = [temperature]; offset: 0 = K = degK = °K = degree_Kelvin = degreeK  # older names supported for compatibility
radian = [] = rad
bit = []
count = []


#### CONSTANTS ####

#@import constants_en.txt


#### UNITS ####
# Common and less common, grouped by quantity.
# Conversion factors are exact (except when noted),
# although floating-point conversion may introduce inaccuracies

# Angle
turn = 2 * π * radian = _ = revolution = cycle = circle
degree = π / 180 * radian = deg = arcdeg = arcdegree = angular_degree
arcminute = degree / 60 = arcmin = arc_minute = angular_minute
arcsecond = arcminute / 60 = arcsec = arc_second = angular_second
milliarcsecond = 1e-3 * arcsecond = mas
grade = π / 200 * radian = grad = gon
mil = π / 32000 * radian

# Solid angle
steradian = radian ** 2 = sr
square_degree = (π / 180) ** 2 * sr = sq_deg = sqdeg

# Length

# Mass

# Time
minute = 60 * second = min
hour = 60 * minute = hr = h
day = 24 * hour = d
week = 7 * day
year = 365.25 * day = a = yr = julian_year
month = year / 12

# Temperature
degree_Celsius = kelvin; offset: 273.15 = C = celsius = degC = degreeC
degree_Rankine = 5 / 9 * kelvin; offset: 0 = R = rankine = degR = degreeR = °R
degree_Fahrenheit = 5 / 9 * kelvin; offset: 233.15 + 200 / 9 = F = fahrenheit = degF = degreeF

# Area
[area] = [length] ** 2
m2 = meter ** 2

# Volume
[volume] = [length] ** 3
liter = decimeter ** 3 = l = L = litre
cubic_centimeter = centimeter ** 3 = cc
m3 = meter ** 3
gallon = 3.785 * L

# Volumetric Flow Rate
cfm = ft ** 3 / min
gpm = gallon / min

# Frequency
[frequency] = 1 / [time]

# Acceleration
[acceleration] = [velocity] / [time]

# Force
[force] = [mass] * [acceleration]
newton = kilogram * meter / second ** 2 = N

# Energy
[energy] = [force] * [length]
joule = newton * meter = J
erg = dyne * centimeter
watt_hour = watt * hour = Wh = watthour
calorie = 4.184 * joule = cal = thermochemical_calorie = cal_th
british_thermal_unit = 1055.056 * joule = Btu = BTU = Btu_iso
therm = 1e5 * Btu = thm = EC_therm

# Power
[power] = [energy] / [time]
watt = joule / second = W
british_thermal_unit_per_hour = Btu / hour = Btu_h = btu_h
volt_ampere = volt * ampere = VA
ton = 3517 * W
hp = 745.7 * W

# Momentum
[momentum] = [length] * [mass] / [time]

# Density (as auxiliary for pressure)
[density] = [mass] / [volume]

# Pressure
[pressure] = [force] / [area]
pascal = newton / meter ** 2 = Pa
bar = 1e5 * pascal
technical_atmosphere = kilogram * g_0 / centimeter ** 2 = at
torr = atm / 760
pound_force_per_square_inch = force_pound / inch ** 2 = psi
ft_WC = 2989.067 * Pa
millimeter_Hg = millimeter * Hg * g_0 = mmHg = mm_Hg = millimeter_Hg_0C
centimeter_Hg = centimeter * Hg * g_0 = cmHg = cm_Hg = centimeter_Hg_0C
inch_Hg = inch * Hg * g_0 = inHg = in_Hg = inch_Hg_32F

# Torque
[torque] = [force] * [length]
foot_pound = foot * force_pound = ft_lb = footpound

# Viscosity
[viscosity] = [pressure] * [time]

# Kinematic viscosity
[kinematic_viscosity] = [area] / [time]

# Fluidity
[fluidity] = 1 / [viscosity]

# Heat transimission
[heat_transmission] = [energy] / [area]

# Luminance
[luminance] = [luminosity] / [area]

# Luminous flux
[luminous_flux] = [luminosity]

# Illuminance
[illuminance] = [luminous_flux] / [area]

# Intensity
[intensity] = [power] / [area]

# Current

# Charge
[charge] = [current] * [time]
coulomb = ampere * second
faraday = e * N_A * mole
conventional_coulomb_90 = K_J90 * R_K90 / (K_J * R_K) * coulomb = C_90
ampere_hour = ampere * hour = Ah

# Electric potential
[electric_potential] = [energy] / [charge]
volt = joule / coulomb = V

# Electric field
[electric_field] = [electric_potential] / [length]

# Electric displacement field
[electric_displacement_field] = [charge] / [area]

# Resistance
[resistance] = [electric_potential] / [current]
ohm = volt / ampere = Ω

# Resistivity
[resistivity] = [resistance] * [length]

# Conductance
[conductance] = [current] / [electric_potential]

# Capacitance
[capacitance] = [charge] / [electric_potential]

# Logaritmic Unit Definition
#  Unit = scale; logbase; logfactor
#  x_dB = [logfactor] * log( x_lin / [scale] ) / log( [logbase] )

# Logaritmic Units of dimensionless quantity: [ https://en.wikipedia.org/wiki/Level_(logarithmic_quantity) ]

decibelmilliwatt = 1e-3 watt; logbase: 10; logfactor: 10 = dBm
decibelmicrowatt = 1e-6 watt; logbase: 10; logfactor: 10 = dBu

decibel = 1 ; logbase: 10; logfactor: 10 = dB
# bell = 1 ; logbase: 10; logfactor: = B
## NOTE: B (Bell) symbol conflicts with byte

decade = 1 ; logbase: 10; logfactor: 1
## NOTE: decade [time] can conflict with decade [dimensionless]

octave = 1 ; logbase: 2; logfactor: 1 = oct

neper = 1 ; logbase: 2.71828182845904523536028747135266249775724709369995; logfactor: 0.5 = Np
# neper = 1 ; logbase: eulers_number; logfactor: 0.5 = Np

#### UNIT GROUPS ####
# Mostly for length, area, volume, mass, force
# (customary or specialized units)

@group USCSLengthInternational
    inch = yard / 36 = in = international_inch = inches = international_inches
    foot = yard / 3 = ft = international_foot = feet = international_feet
    yard = 0.9144 * meter = yd = international_yard  # since Jul 1959
    mile = 1760 * yard = mi = international_mile

    square_inch = inch ** 2 = sq_in = square_inches
    square_foot = foot ** 2 = sq_ft = ft2 = square_feet
    square_yard = yard ** 2 = sq_yd
    square_mile = mile ** 2 = sq_mi

    cubic_inch = in ** 3 = cu_in
    cubic_foot = ft ** 3 = cu_ft = ft3 = cubic_feet
    cubic_yard = yd ** 3 = cu_yd
@end


#### CONVERSION CONTEXTS ####
