Quantities
functions related to Quantities, physical units and constants
Functions
Predicates
- acceleration?
- action?
- angle?
- angularVelocity?
- area?
- areaDensity?
- capacitance?
- charge?
- conductance?
- conforms?
- currency?
- current?
- currentDensity?
- dataTransferRate?
- density?
- elastance?
- electricField?
- electricityPrice?
- energy?
- entropy?
- force?
- frequency?
- heatFlux?
- illuminance?
- inductance?
- information?
- jerk?
- kinematicViscosity?
- length?
- luminosity?
- luminousFlux?
- magneticFieldStrength?
- magneticFlux?
- magneticFluxDensity?
- mass?
- massFlowRate?
- molarConcentration?
- moleFlowRate?
- momentofInertia?
- momentum?
- permeability?
- permittivity?
- potential?
- power?
- pressure?
- radiation?
- radiationExposure?
- resistance?
- resistivity?
- salary?
- snap?
- solidAngle?
- specificVolume?
- speed?
- substance?
- surfaceTension?
- temperature?
- thermalConductivity?
- thermalInsulance?
- time?
- unitless?
- viscosity?
- volume?
- volumetricFlow?
- waveNumber?
Constants
- alphaParticleMass
- angstromStar
- atomicMass
- avogadroConstant
- bohrRadius
- boltzmannConstant
- classicalElectronRadius
- conductanceQuantum
- deuteronMass
- electronCharge
- electronMass
- electronMassEnergy
- gravitationalConstant
- hartreeEnergy
- helionMass
- impedanceOfVacuum
- inverseConductanceQuantum
- josephsonConstant
- magneticFluxQuantum
- molarGasConstant
- muonMass
The Quantities module provides comprehensive support for physical quantities and units. It includes a wide range of physical properties, SI units, derived units, and constants, with automatic unit conversion and dimensional analysis.
Key Concepts
- Physical quantities with units (like "5 meters" or "72 kilometers per hour")
- Support for all SI base units and derived units
- Automatic unit conversion and compatibility checking
- Physical constants
- Dimensional analysis
- Support for currency units
Basic Usage
Creating Quantities
; basic quantities
distance: 100`m ; 100 meters
time: 9.5`s ; 9.5 seconds
mass: 75`kg ; 75 kilograms
; derived units
speed: 60`km/h ; 60 kilometers per hour
force: 10`N ; 10 newtons
energy: 50`kWh ; 50 kilowatt-hours
Unit Conversions
dist: 5`km
print convert dist `m ; 5000 m
; or using the infix operator
print dist --> `m ; 5000 m
speed: 90`km/h
print speed --> `m/s ; 25 m/s
temp: 25`degC
print temp --> `degF ; 77°F
Unit Compatibility
length1: 5`m
length2: 3`km
; compatible units can be used in calculations
total: length1 + (length2 --> `m)
print total ; 3005 m
speed: 100`km/h
time: 2.5`h
; dimensional analysis works automatically
distance: speed * time
print distance ; 250 km
Working with Currencies
price: 50`USD
euros: price --> `EUR
print euros ; 47.77 € (depends on the current
; exchange rate, obviously...)
salary: 5000`USD/mo
yearly: salary * 12
print yearly ; 60000 $/mo
Common Patterns
Complex Unit Calculations
; calculating power
voltage: 220`V
current: 5`A
power: voltage * current
print power ; 1100 V·A
; calculating energy cost
time: 2`h
energy: power * time
price: 0.15`USD/kWh
cost: price * (energy --> `kWh)
print cost ; 0.33 $
Using Physical Constants
; gravitational force
G: gravitationalConstant
m1: 5.97e24`kg ; mass of Earth
m2: 75`kg ; mass of a person
r: 6371000`m ; Earth's radius
force: G * m1 * m2 / (r * r)
print to :floating force ; 736.2513565961324
Available Properties
Physical quantities in Arturo are classified by their properties. Here are some key properties and their dimensions:
Property | Dimensions | Example |
---|---|---|
Length | L | 5 m |
Time | T | 10 s |
Mass | M | 75 kg |
Current | I | 5 A |
Temperature | K | 20 degC |
Amount | N | 2 mol |
Luminosity | J | 100 cd |
Speed | L·T⁻¹ | 60 km/h |
Acceleration | L·T⁻² | 9.81 m/s2 |
Force | L·M·T⁻² | 10 N |
Energy | L²·M·T⁻² | 100 J |
Power | L²·M·T⁻³ | 1000 W |
Note
There are many more properties available. Useproperty
to inspect any quantity's dimensional formula.
Prefixes
Metric prefixes are supported for most units:
Prefix | Symbol | Factor |
---|---|---|
atto | a | 10⁻¹⁸ |
femto | f | 10⁻¹⁵ |
pico | p | 10⁻¹² |
nano | n | 10⁻⁹ |
micro | μ | 10⁻⁶ |
milli | m | 10⁻³ |
kilo | k | 10³ |
mega | M | 10⁶ |
giga | G | 10⁹ |
tera | T | 10¹² |
peta | P | 10¹⁵ |
exa | E | 10¹⁸ |
Note
Most units that allow prefixes can use any SI prefix (from atto- to exa-). Prefixes change the unit by the corresponding power of 10.
Supported Units
Base SI Units
Unit | Symbol | Property | Example |
---|---|---|---|
meter | m | Length | 5 m |
second | s | Time | 10 s |
kelvin | K | Temperature | 300 K |
gram | g | Mass | 500 g |
ampere | A | Current | 2 A |
mole | mol | Substance | 1 mol |
candela | cd | Luminosity | 100 cd |
Length Units
Unit | Symbol | Definition | Note |
---|---|---|---|
inch | in | 127/5000 m | |
foot | ft | 12 in | |
yard | yd | 3 ft | |
mile | mi | 5280 ft | |
nautical mile | nmi | 1852 m | |
angstrom | Å | 10⁻¹⁰ m | |
light year | ly | 9.461e15 m | |
astronomical unit | au | 1.496e11 m | |
pixel | px | 1/96 in | |
point | pt | 1/72 in |
Area Units
Unit | Symbol | Definition |
---|---|---|
acre | ac | 4840 yd² |
hectare | ha | 10000 m² |
barn | b | 100 ftm² |
Volume Units
Unit | Symbol | Definition |
---|---|---|
liter | L | 1000 cm³ |
gallon | gal | 231 in³ |
barrel | bbl | 42 gal |
quart | qt | 1/4 gal |
pint | p | 1/2 qt |
cup | cup | 1/2 p |
fluid ounce | floz | 1/8 cup |
bushel | bu | 2150.42 in³ |
cord | cord | 128 ft³ |
Mass Units
Unit | Symbol | Definition |
---|---|---|
pound | lb | 0.45359237 kg |
ounce | oz | 1/16 lb |
stone | st | 14 lb |
ton | ton | 2000 lb |
metric ton | t | 1000 kg |
carat | ct | 0.2 g |
grain | gr | 64.79891 mg |
Time Units
Unit | Symbol | Definition |
---|---|---|
minute | min | 60 s |
hour | h | 60 min |
day | day | 24 h |
week | wk | 7 day |
month | mo | 2629746 s |
year | yr | 31556952 s |
Speed Units
Unit | Symbol | Definition |
---|---|---|
kilometers per hour | km/h | 1000/3600 m/s |
miles per hour | mph | 5280/3600 ft/s |
knot | kn | 1852/3600 m/s |
mach | mach | 340.29 m/s |
Force Units
Unit | Symbol | Definition |
---|---|---|
newton | N | 1 kg·m/s² |
dyne | dyn | 10⁻⁵ N |
pound-force | lbf | 4.44822 N |
Pressure Units
Unit | Symbol | Definition |
---|---|---|
pascal | Pa | 1 N/m² |
bar | bar | 100000 Pa |
atmosphere | atm | 101325 Pa |
torr | Torr | 133.3224 Pa |
psi | psi | 6894.76 Pa |
Energy Units
Unit | Symbol | Definition |
---|---|---|
joule | J | 1 N·m |
watt-hour | Wh | 3600 J |
calorie | cal | 4.184 J |
electron volt | eV | 1.602e-19 J |
BTU | BTU | 1055.06 J |
Power Units
Unit | Symbol | Definition |
---|---|---|
watt | W | 1 J/s |
horsepower | hp | 745.7 W |
Electric Units
Unit | Symbol | Definition |
---|---|---|
volt | V | 1 W/A |
ohm | Ω | 1 V/A |
farad | F | 1 C/V |
henry | H | 1 V·s/A |
weber | Wb | 1 V·s |
tesla | T | 1 Wb/m² |
Angle Units
Unit | Symbol | Definition |
---|---|---|
radian | rad | base unit |
degree | ° | π/180 rad |
arcminute | ' | π/10800 rad |
arcsecond | " | π/648000 rad |
Radiation Units
Unit | Symbol | Definition |
---|---|---|
becquerel | Bq | 1/s |
gray | Gy | 1 J/kg |
sievert | Sv | 1 J/kg |
Information Units
Unit | Symbol | Definition |
---|---|---|
byte | B | base unit |
bit | b | 1/8 B |
kibibyte | KiB | 1024 B |
mebibyte | MiB | 1024 KiB |
gibibyte | GiB | 1024 MiB |
tebibyte | TiB | 1024 GiB |
Tip
Arturo supports many world currencies including: AED, ALL, ARS, AUD, BGN, BHD, BND, BOB, BRL, BWP, CAD, CHF, CLP, CNY, COP, CRC, CZK, DKK, DOP, DZD, EGP, ETB, EUR, FJD, GBP, HKD, HNL, HRK, HUF, IDR, ILS, INR, IRR, ISK, JMD, JOD, JPY, KES, KRW, KWD, KYD, KZT, LBP, LKR, MAD, MDL, MKD, MXN, MUR, MYR, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PYG, QAR, RON, RSD, RUB, SAR, SCR, SEK, SGD, SLL, SOS, SVC, THB, TND, TRY, TTD, TWD, TZS, UAH, UGX, UYU, UZS, VES, VND, XAF, XOF, YER, ZAR, ZMW.Cryptocurrency codes are also supported: BTC (Bitcoin), ETH (Ethereum), BNB (Binance Coin).