vanunits 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/HISTORY +16 -0
  2. data/HOWITWORKS.rdoc +72 -0
  3. data/LICENSE +23 -0
  4. data/README.rdoc +68 -0
  5. data/lib/van/units.rb +116 -0
  6. data/lib/van/units/base.rb +991 -0
  7. data/lib/van/units/constants.rb +2 -0
  8. data/lib/van/units/constants/cgs.rb +122 -0
  9. data/lib/van/units/constants/math.rb +3 -0
  10. data/lib/van/units/constants/math/cgs.rb +125 -0
  11. data/lib/van/units/constants/math/mks.rb +126 -0
  12. data/lib/van/units/constants/math/natural.rb +33 -0
  13. data/lib/van/units/constants/mks.rb +122 -0
  14. data/lib/van/units/currency.rb +160 -0
  15. data/lib/van/units/data/binary/base.rb +4 -0
  16. data/lib/van/units/data/cex.rb +5 -0
  17. data/lib/van/units/data/currency-default.rb +5 -0
  18. data/lib/van/units/data/currency-standard.rb +2 -0
  19. data/lib/van/units/data/currency/base.rb +89 -0
  20. data/lib/van/units/data/iec.rb +5 -0
  21. data/lib/van/units/data/iec_binary/base.rb +6 -0
  22. data/lib/van/units/data/si.rb +8 -0
  23. data/lib/van/units/data/si/base.rb +11 -0
  24. data/lib/van/units/data/si/constants.rb +88 -0
  25. data/lib/van/units/data/si/derived.rb +33 -0
  26. data/lib/van/units/data/si/extra.rb +35 -0
  27. data/lib/van/units/data/si/misc.rb +10 -0
  28. data/lib/van/units/data/uk.rb +10 -0
  29. data/lib/van/units/data/uk/base.rb +25 -0
  30. data/lib/van/units/data/units-default.rb +12 -0
  31. data/lib/van/units/data/units-standard.rb +5 -0
  32. data/lib/van/units/data/us.rb +10 -0
  33. data/lib/van/units/data/us/base.rb +47 -0
  34. data/lib/van/units/data/xmethods.rb +5 -0
  35. data/lib/van/units/data/xmethods/cached.rb +84 -0
  36. data/lib/van/units/data/xmethods/mapping.rb +87 -0
  37. data/lib/van/units/loaders.rb +100 -0
  38. data/lib/van/units/units.rb +111 -0
  39. data/lib/van/units_currency.rb +12 -0
  40. data/meta/author +1 -0
  41. data/meta/collection +1 -0
  42. data/meta/contact +1 -0
  43. data/meta/created +1 -0
  44. data/meta/description +5 -0
  45. data/meta/homepage +1 -0
  46. data/meta/name +1 -0
  47. data/meta/summary +1 -0
  48. data/meta/title +1 -0
  49. data/meta/version +1 -0
  50. data/qed/conversion.rdoc +14 -0
  51. data/qed/equality.rdoc +150 -0
  52. data/qed/operations.rdoc +74 -0
  53. data/test/test_constants.rb +12 -0
  54. data/test/test_currency.rb +26 -0
  55. data/test/test_units.rb +205 -0
  56. metadata +123 -0
@@ -0,0 +1,2 @@
1
+ require 'van/units/constants/cgs'
2
+ require 'van/units/constants/mks'
@@ -0,0 +1,122 @@
1
+ require 'van/units'
2
+ require 'van/units/constants/math/cgs'
3
+
4
+ module Van::Units #:nodoc:
5
+ module Constants
6
+
7
+ # = Constants in the CGS system (cm, g, s)
8
+ #
9
+ # Large assortment of real world contants in c g s units.
10
+ #
11
+ # == Synopsis
12
+ #
13
+ # include Van::Units::Constants
14
+ #
15
+ # CGS::SPEED_OF_LIGHT #=> 2.99792458e10 cm/s
16
+ #
17
+ module CGS
18
+ include Van::Units
19
+
20
+ SPEED_OF_LIGHT = Math::Constants::CGS::SPEED_OF_LIGHT.cm/s # cm / s
21
+ GRAVITATIONAL_CONSTANT = Math::Constants::CGS::GRAVITATIONAL_CONSTANT.cm**3/g*s**2 # cm^3 / g s^2
22
+ PLANCKS_CONSTANT_H = Math::Constants::CGS::PLANCKS_CONSTANT_H.g*cm*82/s # g cm^2 / s
23
+ PLANCKS_CONSTANT_HBAR = Math::Constants::CGS::PLANCKS_CONSTANT_HBAR.g*cm**2/s # g cm^2 / s
24
+ VACUUM_PERMEABILITY = Math::Constants::CGS::VACUUM_PERMEABILITY.cm*g/A**2*s**2 # cm g / A^2 s^2
25
+ ASTRONOMICAL_UNIT = Math::Constants::CGS::ASTRONOMICAL_UNIT.cm # cm
26
+ LIGHT_YEAR = Math::Constants::CGS::LIGHT_YEAR.cm # cm
27
+ PARSEC = Math::Constants::CGS::PARSEC.cm # cm
28
+ GRAV_ACCEL = Math::Constants::CGS::GRAV_ACCEL.cm/s**2 # cm / s^2
29
+ ELECTRON_VOLT = Math::Constants::CGS::ELECTRON_VOLT.g*cm**2/s**2 # g cm^2 / s^2
30
+ MASS_ELECTRON = Math::Constants::CGS::MASS_ELECTRON.g # g
31
+ MASS_MUON = Math::Constants::CGS::MASS_MUON.g # g
32
+ MASS_PROTON = Math::Constants::CGS::MASS_PROTON.g # g
33
+ MASS_NEUTRON = Math::Constants::CGS::MASS_NEUTRON.g # g
34
+ RYDBERG = Math::Constants::CGS::RYDBERG.g*cm**2/s**2 # g cm^2 / s^2
35
+ BOLTZMANN = Math::Constants::CGS::BOLTZMANN.g*cm**2/K*s**2 # g cm^2 / K s^2
36
+ BOHR_MAGNETON = Math::Constants::CGS::BOHR_MAGNETON.A*cm**2 # A cm^2
37
+ NUCLEAR_MAGNETON = Math::Constants::CGS::NUCLEAR_MAGNETON.A*cm**2 # A cm^2
38
+ ELECTRON_MAGNETIC_MOMENT = Math::Constants::CGS::ELECTRON_MAGNETIC_MOMENT.A*cm**2 # A cm^2
39
+ PROTON_MAGNETIC_MOMENT = Math::Constants::CGS::PROTON_MAGNETIC_MOMENT.A*cm**2 # A cm^2
40
+ MOLAR_GAS = Math::Constants::CGS::MOLAR_GAS.g*cm**2/K*mol*s**2 # g cm^2 / K mol s^2
41
+ STANDARD_GAS_VOLUME = Math::Constants::CGS::STANDARD_GAS_VOLUME.cm**3/mol # cm^3 / mol
42
+ MINUTE = Math::Constants::CGS::MINUTE.s # s
43
+ HOUR = Math::Constants::CGS::HOUR.s # s
44
+ DAY = Math::Constants::CGS::DAY.s # s
45
+ WEEK = Math::Constants::CGS::WEEK.s # s
46
+ INCH = Math::Constants::CGS::INCH.cm # cm
47
+ FOOT = Math::Constants::CGS::FOOT.cm # cm
48
+ YARD = Math::Constants::CGS::YARD.cm # cm
49
+ MILE = Math::Constants::CGS::MILE.cm # cm
50
+ NAUTICAL_MILE = Math::Constants::CGS::NAUTICAL_MILE.cm # cm
51
+ FATHOM = Math::Constants::CGS::FATHOM.cm # cm
52
+ MIL = Math::Constants::CGS::MIL.cm # cm
53
+ POINT = Math::Constants::CGS::POINT.cm # cm
54
+ TEXPOINT = Math::Constants::CGS::TEXPOINT.cm # cm
55
+ MICRON = Math::Constants::CGS::MICRON.cm # cm
56
+ ANGSTROM = Math::Constants::CGS::ANGSTROM.cm # cm
57
+ HECTARE = Math::Constants::CGS::HECTARE.cm**2 # cm^2
58
+ ACRE = Math::Constants::CGS::ACRE.cm**2 # cm^2
59
+ BARN = Math::Constants::CGS::BARN.cm**2 # cm^2
60
+ LITER = Math::Constants::CGS::LITER.cm**3 # cm^3
61
+ US_GALLON = Math::Constants::CGS::US_GALLON.cm**3 # cm^3
62
+ QUART = Math::Constants::CGS::QUART.cm**3 # cm^3
63
+ PINT = Math::Constants::CGS::PINT.cm**3 # cm^3
64
+ CUP = Math::Constants::CGS::CUP.cm**3 # cm^3
65
+ FLUID_OUNCE = Math::Constants::CGS::FLUID_OUNCE.cm**3 # cm^3
66
+ TABLESPOON = Math::Constants::CGS::TABLESPOON.cm**3 # cm^3
67
+ TEASPOON = Math::Constants::CGS::TEASPOON.cm**3 # cm^3
68
+ CANADIAN_GALLON = Math::Constants::CGS::CANADIAN_GALLON.cm**3 # cm^3
69
+ UK_GALLON = Math::Constants::CGS::UK_GALLON.cm**3 # cm^3
70
+ MILES_PER_HOUR = Math::Constants::CGS::MILES_PER_HOUR.cm/s # cm / s
71
+ KILOMETERS_PER_HOUR = Math::Constants::CGS::KILOMETERS_PER_HOUR.cm/s # cm / s
72
+ KNOT = Math::Constants::CGS::KNOT.cm/s # cm / s
73
+ POUND_MASS = Math::Constants::CGS::POUND_MASS.g # g
74
+ OUNCE_MASS = Math::Constants::CGS::OUNCE_MASS.g # g
75
+ TON = Math::Constants::CGS::TON.g # g
76
+ METRIC_TON = Math::Constants::CGS::METRIC_TON.g # g
77
+ UK_TON = Math::Constants::CGS::UK_TON.g # g
78
+ TROY_OUNCE = Math::Constants::CGS::TROY_OUNCE.g # g
79
+ CARAT = Math::Constants::CGS::CARAT.g # g
80
+ UNIFIED_ATOMIC_MASS = Math::Constants::CGS::UNIFIED_ATOMIC_MASS.g # g
81
+ GRAM_FORCE = Math::Constants::CGS::GRAM_FORCE.cm*g/s**2 # cm g / s^2
82
+ POUND_FORCE = Math::Constants::CGS::POUND_FORCE.cm*g/s**2 # cm g / s^2
83
+ KILOPOUND_FORCE = Math::Constants::CGS::KILOPOUND_FORCE.cm*g/s**2 # cm g / s^2
84
+ POUNDAL = Math::Constants::CGS::POUNDAL.cm*g/s**2 # cm g / s^2
85
+ CALORIE = Math::Constants::CGS::CALORIE.g*cm**2/s**2 # g cm^2 / s^2
86
+ BTU = Math::Constants::CGS::BTU.g*cm**2/s**2 # g cm^2 / s^2
87
+ THERM = Math::Constants::CGS::THERM.g*cm**2/s**2 # g cm^2 / s^2
88
+ HORSEPOWER = Math::Constants::CGS::HORSEPOWER.g*cm**2/s**3 # g cm^2 / s^3
89
+ BAR = Math::Constants::CGS::BAR.g/cm*s**2 # g / cm s^2
90
+ STD_ATMOSPHERE = Math::Constants::CGS::STD_ATMOSPHERE.g/cm*s**2 # g / cm s^2
91
+ TORR = Math::Constants::CGS::TORR.g/cm*s**2 # g / cm s^2
92
+ METER_OF_MERCURY = Math::Constants::CGS::METER_OF_MERCURY.g/cm*s**2 # g / cm s^2
93
+ INCH_OF_MERCURY = Math::Constants::CGS::INCH_OF_MERCURY.g/cm*s**2 # g / cm s^2
94
+ INCH_OF_WATER = Math::Constants::CGS::INCH_OF_WATER.g/cm*s**2 # g / cm s^2
95
+ PSI = Math::Constants::CGS::PSI.g/cm*s**2 # g / cm s^2
96
+ POISE = Math::Constants::CGS::POISE.g/cm*s # g / cm s
97
+ STOKES = Math::Constants::CGS::STOKES.cm**2/s # cm^2 / s
98
+ FARADAY = Math::Constants::CGS::FARADAY.A*s/mol # A s / mol
99
+ ELECTRON_CHARGE = Math::Constants::CGS::ELECTRON_CHARGE.A*s # A s
100
+ GAUSS = Math::Constants::CGS::GAUSS.g/A*s**2 # g / A s^2
101
+ STILB = Math::Constants::CGS::STILB.cd/cm**2 # cd / cm^2
102
+ LUMEN = Math::Constants::CGS::LUMEN.cd*sr # cd sr
103
+ LUX = Math::Constants::CGS::LUX.cd*sr/cm*2 # cd sr / cm^2
104
+ PHOT = Math::Constants::CGS::PHOT.cd*sr/cm*2 # cd sr / cm^2
105
+ FOOTCANDLE = Math::Constants::CGS::FOOTCANDLE.cd*sr/cm*2 # cd sr / cm^2
106
+ LAMBERT = Math::Constants::CGS::LAMBERT.cd*sr/cm*2 # cd sr / cm^2
107
+ FOOTLAMBERT = Math::Constants::CGS::FOOTLAMBERT.cd*sr/cm*2 # cd sr / cm^2
108
+ CURIE = Math::Constants::CGS::CURIE*1/1.s # 1 / s
109
+ ROENTGEN = Math::Constants::CGS::ROENTGEN.A*s/g # A s / g
110
+ RAD = Math::Constants::CGS::RAD.cm**2/s**2 # cm^2 / s^2
111
+ SOLAR_MASS = Math::Constants::CGS::SOLAR_MASS.g # g
112
+ BOHR_RADIUS = Math::Constants::CGS::BOHR_RADIUS.cm # cm
113
+ VACUUM_PERMITTIVITY = Math::Constants::CGS::VACUUM_PERMITTIVITY.A**2*s**4/g*cm*83 # A^2 s^4 / g cm^3
114
+ NEWTON = Math::Constants::CGS::NEWTON.cm*g/s**2 # cm g / s^2
115
+ DYNE = Math::Constants::CGS::DYNE.cm*g/s**2 # cm g / s^2
116
+ JOULE = Math::Constants::CGS::JOULE.g*cm**2/s**2 # g cm^2 / s^2
117
+ ERG = Math::Constants::CGS::ERG.g*cm**2/s**2 # g cm^2 / s^2
118
+ end
119
+
120
+ end
121
+ end
122
+
@@ -0,0 +1,3 @@
1
+ require 'van/units/constants/math/mks'
2
+ require 'van/units/constants/math/cgs'
3
+ require 'van/units/constants/math/natural'
@@ -0,0 +1,125 @@
1
+ # Title:
2
+ #
3
+ # Unitless CGS Constants
4
+ #
5
+ # Copyright:
6
+ #
7
+ # Copyright (C) 2003 Daniel Carrera, Brian Gough
8
+ #
9
+ # MIT License
10
+ #
11
+ # Authors:
12
+ #
13
+ # - Daniel Carrera
14
+ # - Brian Gough
15
+ # - Thomas Sawyer
16
+
17
+ module Math #:nodoc:
18
+ module Constants
19
+
20
+ # Unitless Constants in the CGS system (cm, g, s).
21
+ #
22
+ module CGS
23
+ SPEED_OF_LIGHT = 2.99792458e10 # cm / s
24
+ GRAVITATIONAL_CONSTANT = 6.673e-8 # cm^3 / g s^2
25
+ PLANCKS_CONSTANT_H = 6.62606876e-27 # g cm^2 / s
26
+ PLANCKS_CONSTANT_HBAR = 1.05457159642e-27 # g cm^2 / s
27
+ VACUUM_PERMEABILITY = 1.25663706144e-1 # cm g / A^2 s^2
28
+ ASTRONOMICAL_UNIT = 1.49597870691e13 # cm
29
+ LIGHT_YEAR = 9.46053620707e17 # cm
30
+ PARSEC = 3.08567758135e18 # cm
31
+ GRAV_ACCEL = 9.80665e2 # cm / s^2
32
+ ELECTRON_VOLT = 1.602176462e-12 # g cm^2 / s^2
33
+ MASS_ELECTRON = 9.10938188e-28 # g
34
+ MASS_MUON = 1.88353109e-25 # g
35
+ MASS_PROTON = 1.67262158e-24 # g
36
+ MASS_NEUTRON = 1.67492716e-24 # g
37
+ RYDBERG = 2.17987190389e-11 # g cm^2 / s^2
38
+ BOLTZMANN = 1.3806503e-16 # g cm^2 / K s^2
39
+ BOHR_MAGNETON = 9.27400899e-20 # A cm^2
40
+ NUCLEAR_MAGNETON = 5.05078317e-23 # A cm^2
41
+ ELECTRON_MAGNETIC_MOMENT = 9.28476362e-20 # A cm^2
42
+ PROTON_MAGNETIC_MOMENT = 1.410606633e-22 # A cm^2
43
+ MOLAR_GAS = 8.314472e7 # g cm^2 / K mol s^2
44
+ STANDARD_GAS_VOLUME = 2.2710981e4 # cm^3 / mol
45
+ MINUTE = 6e1 # s
46
+ HOUR = 3.6e3 # s
47
+ DAY = 8.64e4 # s
48
+ WEEK = 6.048e5 # s
49
+ INCH = 2.54e0 # cm
50
+ FOOT = 3.048e1 # cm
51
+ YARD = 9.144e1 # cm
52
+ MILE = 1.609344e5 # cm
53
+ NAUTICAL_MILE = 1.852e5 # cm
54
+ FATHOM = 1.8288e2 # cm
55
+ MIL = 2.54e-3 # cm
56
+ POINT = 3.52777777778e-2 # cm
57
+ TEXPOINT = 3.51459803515e-2 # cm
58
+ MICRON = 1e-4 # cm
59
+ ANGSTROM = 1e-8 # cm
60
+ HECTARE = 1e8 # cm^2
61
+ ACRE = 4.04685642241e7 # cm^2
62
+ BARN = 1e-24 # cm^2
63
+ LITER = 1e3 # cm^3
64
+ US_GALLON = 3.78541178402e3 # cm^3
65
+ QUART = 9.46352946004e2 # cm^3
66
+ PINT = 4.73176473002e2 # cm^3
67
+ CUP = 2.36588236501e2 # cm^3
68
+ FLUID_OUNCE = 2.95735295626e1 # cm^3
69
+ TABLESPOON = 1.47867647813e1 # cm^3
70
+ TEASPOON = 4.92892159375e0 # cm^3
71
+ CANADIAN_GALLON = 4.54609e3 # cm^3
72
+ UK_GALLON = 4.546092e3 # cm^3
73
+ MILES_PER_HOUR = 4.4704e1 # cm / s
74
+ KILOMETERS_PER_HOUR = 2.77777777778e1 # cm / s
75
+ KNOT = 5.14444444444e1 # cm / s
76
+ POUND_MASS = 4.5359237e2 # g
77
+ OUNCE_MASS = 2.8349523125e1 # g
78
+ TON = 9.0718474e5 # g
79
+ METRIC_TON = 1e6 # g
80
+ UK_TON = 1.0160469088e6 # g
81
+ TROY_OUNCE = 3.1103475e1 # g
82
+ CARAT = 2e-1 # g
83
+ UNIFIED_ATOMIC_MASS = 1.66053873e-24 # g
84
+ GRAM_FORCE = 9.80665e2 # cm g / s^2
85
+ POUND_FORCE = 4.44822161526e5 # cm g / s^2
86
+ KILOPOUND_FORCE = 4.44822161526e8 # cm g / s^2
87
+ POUNDAL = 1.38255e4 # cm g / s^2
88
+ CALORIE = 4.1868e7 # g cm^2 / s^2
89
+ BTU = 1.05505585262e10 # g cm^2 / s^2
90
+ THERM = 1.05506e15 # g cm^2 / s^2
91
+ HORSEPOWER = 7.457e9 # g cm^2 / s^3
92
+ BAR = 1e6 # g / cm s^2
93
+ STD_ATMOSPHERE = 1.01325e6 # g / cm s^2
94
+ TORR = 1.33322368421e3 # g / cm s^2
95
+ METER_OF_MERCURY = 1.33322368421e6 # g / cm s^2
96
+ INCH_OF_MERCURY = 3.38638815789e4 # g / cm s^2
97
+ INCH_OF_WATER = 2.490889e3 # g / cm s^2
98
+ PSI = 6.89475729317e4 # g / cm s^2
99
+ POISE = 1e0 # g / cm s
100
+ STOKES = 1e0 # cm^2 / s
101
+ FARADAY = 9.6485341472e4 # A s / mol
102
+ ELECTRON_CHARGE = 1.602176462e-19 # A s
103
+ GAUSS = 1e-1 # g / A s^2
104
+ STILB = 1e0 # cd / cm^2
105
+ LUMEN = 1e0 # cd sr
106
+ LUX = 1e-4 # cd sr / cm^2
107
+ PHOT = 1e0 # cd sr / cm^2
108
+ FOOTCANDLE = 1.076e-3 # cd sr / cm^2
109
+ LAMBERT = 1e0 # cd sr / cm^2
110
+ FOOTLAMBERT = 1.07639104e-3 # cd sr / cm^2
111
+ CURIE = 3.7e10 # 1 / s
112
+ ROENTGEN = 2.58e-7 # A s / g
113
+ RAD = 1e2 # cm^2 / s^2
114
+ SOLAR_MASS = 1.98892e33 # g
115
+ BOHR_RADIUS = 5.291772083e-9 # cm
116
+ VACUUM_PERMITTIVITY = 8.854187817e-21 # A^2 s^4 / g cm^3
117
+ NEWTON = 1e5 # cm g / s^2
118
+ DYNE = 1e0 # cm g / s^2
119
+ JOULE = 1e7 # g cm^2 / s^2
120
+ ERG = 1e0 # g cm^2 / s^2
121
+ end
122
+
123
+ end
124
+ end
125
+
@@ -0,0 +1,126 @@
1
+ # Title:
2
+ #
3
+ # Unitless MKS Constants
4
+ #
5
+ # Copyright:
6
+ #
7
+ # Copyright (C) 2003 Daniel Carrera, Brian Gough
8
+ #
9
+ # MIT License
10
+ #
11
+ # Authors:
12
+ #
13
+ # - Daniel Carrera
14
+ # - Brian Gough
15
+ # - Thomas Sawyer
16
+
17
+ module Math #:nodoc:
18
+ module Constants
19
+
20
+ # Unitless constants in the MKS system (meters, kg, sec)
21
+ #
22
+ module MKS
23
+ SPEED_OF_LIGHT = 2.99792458e8 # m / s
24
+ GRAVITATIONAL_CONSTANT = 6.673e-11 # m^3 / kg s^2
25
+ PLANCKS_CONSTANT_H = 6.62606876e-34 # kg m^2 / s
26
+ PLANCKS_CONSTANT_HBAR = 1.05457159642e-34 # kg m^2 / s
27
+ VACUUM_PERMEABILITY = 1.25663706144e-6 # kg m / A^2 s^2
28
+ ASTRONOMICAL_UNIT = 1.49597870691e11 # m
29
+ LIGHT_YEAR = 9.46053620707e15 # m
30
+ PARSEC = 3.08567758135e16 # m
31
+ GRAV_ACCEL = 9.80665e0 # m / s^2
32
+ ELECTRON_VOLT = 1.602176462e-19 # kg m^2 / s^2
33
+ MASS_ELECTRON = 9.10938188e-31 # kg
34
+ MASS_MUON = 1.88353109e-28 # kg
35
+ MASS_PROTON = 1.67262158e-27 # kg
36
+ MASS_NEUTRON = 1.67492716e-27 # kg
37
+ RYDBERG = 2.17987190389e-18 # kg m^2 / s^2
38
+ BOLTZMANN = 1.3806503e-23 # kg m^2 / K s^2
39
+ BOHR_MAGNETON = 9.27400899e-24 # A m^2
40
+ NUCLEAR_MAGNETON = 5.05078317e-27 # A m^2
41
+ ELECTRON_MAGNETIC_MOMENT = 9.28476362e-24 # A m^2
42
+ PROTON_MAGNETIC_MOMENT = 1.410606633e-26 # A m^2
43
+ MOLAR_GAS = 8.314472e0 # kg m^2 / K mol s^2
44
+ STANDARD_GAS_VOLUME = 2.2710981e-2 # m^3 / mol
45
+ MINUTE = 6e1 # s
46
+ HOUR = 3.6e3 # s
47
+ DAY = 8.64e4 # s
48
+ WEEK = 6.048e5 # s
49
+ INCH = 2.54e-2 # m
50
+ FOOT = 3.048e-1 # m
51
+ YARD = 9.144e-1 # m
52
+ MILE = 1.609344e3 # m
53
+ NAUTICAL_MILE = 1.852e3 # m
54
+ FATHOM = 1.8288e0 # m
55
+ MIL = 2.54e-5 # m
56
+ POINT = 3.52777777778e-4 # m
57
+ TEXPOINT = 3.51459803515e-4 # m
58
+ MICRON = 1e-6 # m
59
+ ANGSTROM = 1e-10 # m
60
+ HECTARE = 1e4 # m^2
61
+ ACRE = 4.04685642241e3 # m^2
62
+ BARN = 1e-28 # m^2
63
+ LITER = 1e-3 # m^3
64
+ US_GALLON = 3.78541178402e-3 # m^3
65
+ QUART = 9.46352946004e-4 # m^3
66
+ PINT = 4.73176473002e-4 # m^3
67
+ CUP = 2.36588236501e-4 # m^3
68
+ FLUID_OUNCE = 2.95735295626e-5 # m^3
69
+ TABLESPOON = 1.47867647813e-5 # m^3
70
+ TEASPOON = 4.92892159375e-6 # m^3
71
+ CANADIAN_GALLON = 4.54609e-3 # m^3
72
+ UK_GALLON = 4.546092e-3 # m^3
73
+ MILES_PER_HOUR = 4.4704e-1 # m / s
74
+ KILOMETERS_PER_HOUR = 2.77777777778e-1 # m / s
75
+ KNOT = 5.14444444444e-1 # m / s
76
+ POUND_MASS = 4.5359237e-1 # kg
77
+ OUNCE_MASS = 2.8349523125e-2 # kg
78
+ TON = 9.0718474e2 # kg
79
+ METRIC_TON = 1e3 # kg
80
+ UK_TON = 1.0160469088e3 # kg
81
+ TROY_OUNCE = 3.1103475e-2 # kg
82
+ CARAT = 2e-4 # kg
83
+ UNIFIED_ATOMIC_MASS = 1.66053873e-27 # kg
84
+ ATOMIC_MASS = 1.66053873e-27 # kg
85
+ GRAM_FORCE = 9.80665e-3 # kg m / s^2
86
+ POUND_FORCE = 4.44822161526e0 # kg m / s^2
87
+ KILOPOUND_FORCE = 4.44822161526e3 # kg m / s^2
88
+ POUNDAL = 1.38255e-1 # kg m / s^2
89
+ CALORIE = 4.1868e0 # kg m^2 / s^2
90
+ BTU = 1.05505585262e3 # kg m^2 / s^2
91
+ THERM = 1.05506e8 # kg m^2 / s^2
92
+ HORSEPOWER = 7.457e2 # kg m^2 / s^3
93
+ BAR = 1e5 # kg / m s^2
94
+ STD_ATMOSPHERE = 1.01325e5 # kg / m s^2
95
+ TORR = 1.33322368421e2 # kg / m s^2
96
+ METER_OF_MERCURY = 1.33322368421e5 # kg / m s^2
97
+ INCH_OF_MERCURY = 3.38638815789e3 # kg / m s^2
98
+ INCH_OF_WATER = 2.490889e2 # kg / m s^2
99
+ PSI = 6.89475729317e3 # kg / m s^2
100
+ POISE = 1e-1 # kg m^-1 s^-1
101
+ STOKES = 1e-4 # m^2 / s
102
+ FARADAY = 9.6485341472e4 # A s / mol
103
+ ELECTRON_CHARGE = 1.602176462e-19 # A s
104
+ GAUSS = 1e-4 # kg / A s^2
105
+ STILB = 1e4 # cd / m^2
106
+ LUMEN = 1e0 # cd sr
107
+ LUX = 1e0 # cd sr / m^2
108
+ PHOT = 1e4 # cd sr / m^2
109
+ FOOTCANDLE = 1.076e1 # cd sr / m^2
110
+ LAMBERT = 1e4 # cd sr / m^2
111
+ FOOTLAMBERT = 1.07639104e1 # cd sr / m^2
112
+ CURIE = 3.7e10 # 1 / s
113
+ ROENTGEN = 2.58e-4 # A s / kg
114
+ RAD = 1e-2 # m^2 / s^2
115
+ SOLAR_MASS = 1.98892e30 # kg
116
+ BOHR_RADIUS = 5.291772083e-11 # m
117
+ VACUUM_PERMITTIVITY = 8.854187817e-12 # A^2 s^4 / kg m^3
118
+ NEWTON = 1e0 # kg m / s^2
119
+ DYNE = 1e-5 # kg m / s^2
120
+ JOULE = 1e0 # kg m^2 / s^2
121
+ ERG = 1e-7 # kg m^2 / s^2
122
+ end
123
+
124
+ end
125
+ end
126
+
@@ -0,0 +1,33 @@
1
+ module Math
2
+ module Constants
3
+
4
+ # = Unitless Constants
5
+ #
6
+ # Van::Units::Contants::Natural::FINE_STRUCTURE #=> 7.297352533e-3
7
+ #
8
+ module Natural
9
+ FINE_STRUCTURE = 7.297352533e-3 # 1
10
+ AVOGADRO = 6.02214199e23 # 1
11
+ YOTTA = 1e24 # 1
12
+ ZETTA = 1e21 # 1
13
+ EXA = 1e18 # 1
14
+ PETA = 1e15 # 1
15
+ TERA = 1e12 # 1
16
+ GIGA = 1e9 # 1
17
+ MEGA = 1e6 # 1
18
+ KILO = 1e3 # 1
19
+ MILLI = 1e-3 # 1
20
+ MICRO = 1e-6 # 1
21
+ NANO = 1e-9 # 1
22
+ PICO = 1e-12 # 1
23
+ FEMTO = 1e-15 # 1
24
+ ATTO = 1e-18 # 1
25
+ ZEPTO = 1e-21 # 1
26
+ YOCTO = 1e-24 # 1
27
+ end
28
+
29
+ include Natural
30
+
31
+ end
32
+ end
33
+
@@ -0,0 +1,122 @@
1
+ require 'van/units'
2
+ require 'van/units/constants/math'
3
+
4
+ module Van::Units #:nodoc:
5
+ module Constants
6
+
7
+ # = Constants in the MKS system (meters, kg, sec)
8
+ #
9
+ # Large assortment of real world contants in standard m kg s types.
10
+ #
11
+ # == Synopsis
12
+ #
13
+ # include Van::Units::Constants
14
+ #
15
+ # MKS::SPEED_OF_LIGHT #=> 2.99792458e8 m/s
16
+ #
17
+ module MKS
18
+ include Van::Units
19
+
20
+ SPEED_OF_LIGHT = Math::Constants::MKS::SPEED_OF_LIGHT.m/s # m / s
21
+ GRAVITATIONAL_CONSTANT = Math::Constants::MKS::GRAVITATIONAL_CONSTANT.m**3/kg*s**2 # m^3 / kg s^2
22
+ PLANCKS_CONSTANT_H = Math::Constants::MKS::PLANCKS_CONSTANT_H.kg*m**2/s # kg m^2 / s
23
+ PLANCKS_CONSTANT_HBAR = Math::Constants::MKS::PLANCKS_CONSTANT_HBAR.kg*m**2/s # kg m^2 / s
24
+ VACUUM_PERMEABILITY = Math::Constants::MKS::VACUUM_PERMEABILITY.kg*m/A**2*s**2 # kg m / A^2 s^2
25
+ ASTRONOMICAL_UNIT = Math::Constants::MKS::ASTRONOMICAL_UNIT.m # m
26
+ LIGHT_YEAR = Math::Constants::MKS::LIGHT_YEAR.m # m
27
+ PARSEC = Math::Constants::MKS::PARSEC.m # m
28
+ GRAV_ACCEL = Math::Constants::MKS::GRAV_ACCEL.m/s**2 # m / s^2
29
+ ELECTRON_VOLT = Math::Constants::MKS::ELECTRON_VOLT.kg*m**2/s**2 # kg m^2 / s^2
30
+ MASS_ELECTRON = Math::Constants::MKS::MASS_ELECTRON.kg # kg
31
+ MASS_MUON = Math::Constants::MKS::MASS_MUON.kg # kg
32
+ MASS_PROTON = Math::Constants::MKS::MASS_PROTON.kg # kg
33
+ MASS_NEUTRON = Math::Constants::MKS::MASS_NEUTRON.kg # kg
34
+ RYDBERG = Math::Constants::MKS::RYDBERG.kg*m**2/s**2 # kg m^2 / s^2
35
+ BOLTZMANN = Math::Constants::MKS::BOLTZMANN.kg*m**2/K*s**2 # kg m^2 / K s^2
36
+ BOHR_MAGNETON = Math::Constants::MKS::BOHR_MAGNETON.A*m**2 # A m^2
37
+ NUCLEAR_MAGNETON = Math::Constants::MKS::NUCLEAR_MAGNETON.A*m**2 # A m^2
38
+ ELECTRON_MAGNETIC_MOMENT = Math::Constants::MKS::ELECTRON_MAGNETIC_MOMENT.A*m**2 # A m^2
39
+ PROTON_MAGNETIC_MOMENT = Math::Constants::MKS::PROTON_MAGNETIC_MOMENT.A*m**2 # A m^2
40
+ MOLAR_GAS = Math::Constants::MKS::MOLAR_GAS.kg*m**2/K*mol*s**2 # kg m^2 / K mol s^2
41
+ STANDARD_GAS_VOLUME = Math::Constants::MKS::STANDARD_GAS_VOLUME.m**3/mol # m^3 / mol
42
+ MINUTE = Math::Constants::MKS::MINUTE.s # s
43
+ HOUR = Math::Constants::MKS::HOUR.s # s
44
+ DAY = Math::Constants::MKS::DAY.s # s
45
+ WEEK = Math::Constants::MKS::WEEK.s # s
46
+ INCH = Math::Constants::MKS::INCH.m # m
47
+ FOOT = Math::Constants::MKS::FOOT.m # m
48
+ YARD = Math::Constants::MKS::YARD.m # m
49
+ MILE = Math::Constants::MKS::MILE.m # m
50
+ NAUTICAL_MILE = Math::Constants::MKS::NAUTICAL_MILE.m # m
51
+ FATHOM = Math::Constants::MKS::FATHOM.m # m
52
+ MIL = Math::Constants::MKS::MIL.m # m
53
+ POINT = Math::Constants::MKS::POINT.m # m
54
+ TEXPOINT = Math::Constants::MKS::TEXPOINT.m # m
55
+ MICRON = Math::Constants::MKS::MICRON.m # m
56
+ ANGSTROM = Math::Constants::MKS::ANGSTROM.m # m
57
+ HECTARE = Math::Constants::MKS::HECTARE.m**2 # m^2
58
+ ACRE = Math::Constants::MKS::ACRE.m**2 # m^2
59
+ BARN = Math::Constants::MKS::BARN.m**2 # m^2
60
+ LITER = Math::Constants::MKS::LITER.m**3 # m^3
61
+ US_GALLON = Math::Constants::MKS::US_GALLON.m**3 # m^3
62
+ QUART = Math::Constants::MKS::QUART.m**3 # m^3
63
+ PINT = Math::Constants::MKS::PINT.m**3 # m^3
64
+ CUP = Math::Constants::MKS::CUP.m**3 # m^3
65
+ FLUID_OUNCE = Math::Constants::MKS::FLUID_OUNCE.m**3 # m^3
66
+ TABLESPOON = Math::Constants::MKS::TABLESPOON.m**3 # m^3
67
+ TEASPOON = Math::Constants::MKS::TEASPOON.m**3 # m^3
68
+ CANADIAN_GALLON = Math::Constants::MKS::CANADIAN_GALLON.m**3 # m^3
69
+ UK_GALLON = Math::Constants::MKS::UK_GALLON.m**3 # m^3
70
+ MILES_PER_HOUR = Math::Constants::MKS::MILES_PER_HOUR.m/s # m / s
71
+ KILOMETERS_PER_HOUR = Math::Constants::MKS::KILOMETERS_PER_HOUR.m/s # m / s
72
+ KNOT = Math::Constants::MKS::KNOT.m/s # m / s
73
+ POUND_MASS = Math::Constants::MKS::POUND_MASS.kg # kg
74
+ OUNCE_MASS = Math::Constants::MKS::OUNCE_MASS.kg # kg
75
+ TON = Math::Constants::MKS::TON.kg # kg
76
+ METRIC_TON = Math::Constants::MKS::METRIC_TON.kg # kg
77
+ UK_TON = Math::Constants::MKS::UK_TON.kg # kg
78
+ TROY_OUNCE = Math::Constants::MKS::TROY_OUNCE.kg # kg
79
+ CARAT = Math::Constants::MKS::CARAT.kg # kg
80
+ UNIFIED_ATOMIC_MASS = Math::Constants::MKS::UNIFIED_ATOMIC_MASS.kg # kg
81
+ ATOMIC_MASS = Math::Constants::MKS::ATOMIC_MASS.kg # kg
82
+ GRAM_FORCE = Math::Constants::MKS::GRAM_FORCE.kg*m/s**2 # kg m / s^2
83
+ POUND_FORCE = Math::Constants::MKS::POUND_FORCE.kg*m/s**2 # kg m / s^2
84
+ KILOPOUND_FORCE = Math::Constants::MKS::KILOPOUND_FORCE.kg*m/s**2 # kg m / s^2
85
+ POUNDAL = Math::Constants::MKS::POUNDAL.kg*m/s**2 # kg m / s^2
86
+ CALORIE = Math::Constants::MKS::CALORIE.kg*m**2/s**2 # kg m^2 / s^2
87
+ BTU = Math::Constants::MKS::BTU.kg*m**2/s**2 # kg m^2 / s^2
88
+ THERM = Math::Constants::MKS::THERM.kg*m**2/s**2 # kg m^2 / s^2
89
+ HORSEPOWER = Math::Constants::MKS::HORSEPOWER.kg*m**2/s**3 # kg m^2 / s^3
90
+ BAR = Math::Constants::MKS::BAR.kg/m*s**2 # kg / m s^2
91
+ STD_ATMOSPHERE = Math::Constants::MKS::STD_ATMOSPHERE.kg/m*s**2 # kg / m s^2
92
+ TORR = Math::Constants::MKS::TORR.kg/m*s**2 # kg / m s^2
93
+ METER_OF_MERCURY = Math::Constants::MKS::METER_OF_MERCURY.kg/m*s**2 # kg / m s^2
94
+ INCH_OF_MERCURY = Math::Constants::MKS::INCH_OF_MERCURY.kg/m*s**2 # kg / m s^2
95
+ INCH_OF_WATER = Math::Constants::MKS::INCH_OF_WATER.kg/m*s**2 # kg / m s^2
96
+ PSI = Math::Constants::MKS::PSI.kg/m*s**2 # kg / m s^2
97
+ POISE = Math::Constants::MKS::POISE.kg*m**-1*s**-1 # kg m^-1 s^-1
98
+ STOKES = Math::Constants::MKS::STOKES.m**2/s # m^2 / s
99
+ FARADAY = Math::Constants::MKS::FARADAY.A*s/mol # A s / mol
100
+ ELECTRON_CHARGE = Math::Constants::MKS::ELECTRON_CHARGE.A*s # A s
101
+ GAUSS = Math::Constants::MKS::GAUSS.kg/A*s**2 # kg / A s^2
102
+ STILB = Math::Constants::MKS::STILB.cd/m**2 # cd / m^2
103
+ LUMEN = Math::Constants::MKS::LUMEN.cd*sr # cd sr
104
+ LUX = Math::Constants::MKS::LUX.cd*sr/m**2 # cd sr / m^2
105
+ PHOT = Math::Constants::MKS::PHOT.cd*sr/m**2 # cd sr / m^2
106
+ FOOTCANDLE = Math::Constants::MKS::FOOTCANDLE.cd*sr/m**2 # cd sr / m^2
107
+ LAMBERT = Math::Constants::MKS::LAMBERT.cd*sr/m**2 # cd sr / m^2
108
+ FOOTLAMBERT = Math::Constants::MKS::FOOTLAMBERT.cd*sr/m**2 # cd sr / m^2
109
+ CURIE = Math::Constants::MKS::CURIE*1/1.s # 1 / s
110
+ ROENTGEN = Math::Constants::MKS::ROENTGEN.A*s/kg # A s / kg
111
+ RAD = Math::Constants::MKS::RAD.m**2/s**2 # m^2 / s^2
112
+ SOLAR_MASS = Math::Constants::MKS::SOLAR_MASS.kg # kg
113
+ BOHR_RADIUS = Math::Constants::MKS::BOHR_RADIUS.m # m
114
+ VACUUM_PERMITTIVITY = Math::Constants::MKS::VACUUM_PERMITTIVITY.A**2*s**4/kg*m**3 # A^2 s^4 / kg m^3
115
+ NEWTON = Math::Constants::MKS::NEWTON.kg*m/s**2 # kg m / s^2
116
+ DYNE = Math::Constants::MKS::DYNE.kg*m/s**2 # kg m / s^2
117
+ JOULE = Math::Constants::MKS::JOULE.kg*m**2/s**2 # kg m^2 / s^2
118
+ ERG = Math::Constants::MKS::ERG.kg*m**2/s**2 # kg m^2 / s^2
119
+ end
120
+
121
+ end
122
+ end