-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSI.elm
201 lines (188 loc) · 5.33 KB
/
SI.elm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
module SI where
{-| SI units, metric prefixes, and other common SI-based units.
# SI units
@docs meter, metre, second, kilogram, kilogramme, kelvin, mole, ampere, candela
# Prefixes
@docs yotta, zetta, exa, peta, tera, giga, mega, kilo, hecto, deca, deci,
centi, milli, micro, nano, pico, femto, atto, zepto, yocto
# Utility unit
@docs gram
# Other spellings
@docs metre, kilogramme, gramme
# SI named derived units
@docs hertz, radian, steradian, newton, pascal, joule, watt, coulomb, volt,
farad, ohm, siemens, weber, tesla, henry, degree, lumen, lux, becquerel, gray,
sievert, katal
-}
import Units (..)
import Ratio (..)
-- SI base units.
{-| SI unit of length. -}
meter : Unit
meter = baseLength
{-| SI unit of time. -}
second : Unit
second = baseTime
{-| SI unit of mass. -}
kilogram : Unit
kilogram = baseMass
{-| SI unit of temperature. -}
kelvin : Unit
kelvin = baseTemp
{-| SI unit of amount. -}
mole : Unit
mole = baseAmount
{-| SI unit of electric current. -}
ampere : Unit
ampere = baseCurrent
{-| SI unit of luminous intensity. -}
candela : Unit
candela = baseLumInt
-- Metric prefixes to scale units by some factor.
{-| Scales unit prefix by 10^24 -}
yotta : Unit -> Unit
yotta = scale (10 ^ 24)
{-| Scales unit prefix by 10^21 -}
zetta : Unit -> Unit
zetta = scale (10 ^ 21)
{-| Scales unit prefix by 10^18 -}
exa : Unit -> Unit
exa = scale (10 ^ 18)
{-| Scales unit prefix by 10^15 -}
peta : Unit -> Unit
peta = scale (10 ^ 15)
{-| Scales unit prefix by 10^12 -}
tera : Unit -> Unit
tera = scale (10 ^ 12)
{-| Scales unit prefix by 10^9 -}
giga : Unit -> Unit
giga = scale (10 ^ 9)
{-| Scales unit prefix by 10^6 -}
mega : Unit -> Unit
mega = scale (10 ^ 6)
{-| Scales unit prefix by 10^3 -}
kilo : Unit -> Unit
kilo = scale (10 ^ 3)
{-| Scales unit prefix by 10^2 -}
hecto : Unit -> Unit
hecto = scale (10 ^ 2)
{-| Scales unit prefix by 10 -}
deca : Unit -> Unit
deca = scale 10
{-| Scales unit prefix by 10^-1 -}
deci : Unit -> Unit
deci = scale (10 ^ -1)
{-| Scales unit prefix by 10^-2 -}
centi : Unit -> Unit
centi = scale (10 ^ -2)
{-| Scales unit prefix by 10^-3 -}
milli : Unit -> Unit
milli = scale (10 ^ -3)
{-| Scales unit prefix by 10^-6 -}
micro : Unit -> Unit
micro = scale (10 ^ -6)
{-| Scales unit prefix by 10^-9 -}
nano : Unit -> Unit
nano = scale (10 ^ -9)
{-| Scales unit prefix by 10^-12 -}
pico : Unit -> Unit
pico = scale (10 ^ -12)
{-| Scales unit prefix by 10^-15 -}
femto : Unit -> Unit
femto = scale (10 ^ -15)
{-| Scales unit prefix by 10^-18 -}
atto : Unit -> Unit
atto = scale (10 ^ -18)
{-| Scales unit prefix by 10^-21 -}
zepto : Unit -> Unit
zepto = scale (10 ^ -21)
{-| Scales unit prefix by 10^-24 -}
yocto : Unit -> Unit
yocto = scale (10 ^ -24)
-- Kilogram is the SI unit of mass, but we prefix "gram," not "kilogram."
-- Defining "gram" allows us to say "milli gram," etc.
{-| More commonly prefixed unit of mass. -}
gram : Unit
gram = milli kilogram
-- Some units have more than one spelling.
{-| Alternate spelling of meter. -}
metre : Unit
metre = meter
{-| Alternate spelling of kilogram. -}
kilogramme : Unit
kilogramme = kilogram
{-| Alternate spelling of gram. -}
gramme : Unit
gramme = gram
-- SI named derived units.
{-| Unit for frequency equal to one per second. -}
hertz : Unit
hertz = inv second
{-| Unit for angle measure defined as the angle subtended on a circle of unit
radius by an arc of unit length. Equal to 1/(2 pi) turns around a circle. -}
radian : Unit
radian = unity
{-| Unit for solid angle measure defined as the solid angle subtended on a
sphere of unit radius by a unit area on its surface. 4 pi steradians subtend a
sphere. -}
steradian : Unit
steradian = unity
{-| SI derived unit of force. -}
newton : Unit
newton = (kilogram `mul` meter) `per` (second `pow` (fromInt 2))
{-| SI derived unit of pressure. -}
pascal : Unit
pascal = newton `per` (second `pow` (fromInt 2))
{-| SI derived unit of energy. -}
joule : Unit
joule = newton `mul` meter
{-| SI derived unit of power. -}
watt : Unit
watt = joule `per` second
{-| SI derived unit of charge. -}
coulomb : Unit
coulomb = second `mul` ampere
{-| SI derived unit of voltage. -}
volt : Unit
volt = watt `per` ampere
{-| SI derived unit of capacitance. -}
farad : Unit
farad = coulomb `per` volt
{-| SI derived unit of electric resistance. -}
ohm : Unit
ohm = volt `per` ampere
{-| SI derived unit of electric conductance. -}
siemens : Unit
siemens = inv ohm
{-| SI derived unit of magnetic flux. -}
weber : Unit
weber = joule `per` ampere
{-| SI derived unit of magnetic flux density. -}
tesla : Unit
tesla = weber `per` (meter `pow` (fromInt 2))
{-| SI derived unit of inductance. -}
henry : Unit
henry = volt `mul` second `per` ampere
{-| SI derived unit of temperature, whose units are the same size as Kelvin and
whose zero is 273.15 kelvin above absolute zero. -}
degree : Unit
degree = affineUnit 273.15 kelvin
{-| SI derived unit of luminous intensity. -}
lumen : Unit
lumen = candela `mul` steradian
{-| SI derived unit of luminous flux per area. -}
lux : Unit
lux = lumen `per` (meter `pow` fromInt 2)
{-| SI derived unit of radioactivity. -}
becquerel : Unit
becquerel = inv second
{-| SI derived unit of ionizing radiation dose. -}
gray : Unit
gray = joule `per` kilogram
{-| SI derived unit of ionizing radiation dose, measuring health effects on the
human body. -}
sievert : Unit
sievert = joule `per` kilogram
{-| SI derived unit of catalytic activity. -}
katal : Unit
katal = mole `per` second