Class: Constants::Libraries::Element

Inherits:
Object
  • Object
show all
Includes:
Constants::Library
Defined in:
lib/constants/libraries/element.rb

Overview

Element is a library of elements in the periodic table, and includes mass, isotope, and abundance information.

e = Element::He
e.name                    # => "Helium"
e.symbol                  # => "He"
e.atomic_number           # => 2
e.mass                    # => 4.0026032497
e.isotopes                # => [3, 4]
e.abundances              # => [0.000137, 99.999863]

Constant Summary collapse

Ag =
Element.new("Ag", "Silver", 47, "107:106.905093(6):51.839(8);109:108.904756(3):48.161(8)", "107.8682(2)")
Al =
Element.new("Al", "Aluminum", 13, "27:26.98153844(14):100", "26.981538(2)")
Ar =
Element.new("Ar", "Argon", 18, "36:35.96754628(27):0.3365(30);38:37.9627322(5):0.0632(5);40:39.962383123(3):99.6003(30)", "39.948(1)")
As =
Element.new("As", "Arsenic", 33, "75:74.9215964(18):100", "74.92160(2)")
Au =
Element.new("Au", "Gold", 79, "197:196.966552(3):100", "196.96655(2)")
B =
Element.new("B", "Boron", 5, "10:10.0129370(4):19.9(7);11:11.0093055(5):80.1(7)", "10.811(7)")
Ba =
Element.new("Ba", "Barium", 56, "130:129.906310(7):0.106(1);132:131.905056(3):0.101(1);134:133.904503(3):2.417(18);135:134.905683(3):6.592(12);136:135.904570(3):7.854(24);137:136.905821(3):11.232(24);138:137.905241(3):71.698(42)", "137.327(7)")
Be =
Element.new("Be", "Beryllium", 4, "9:9.0121821(4):100", "9.012182(3)")
Bi =
Element.new("Bi", "Bismuth", 83, "209:208.980383(3):100", "208.98038(2)")
Br =
Element.new("Br", "Bromine", 35, "79:78.9183376(20):50.69(7);81:80.916291(3):49.31(7)", "79.904(1)")
C =
Element.new("C", "Carbon", 6, "12:12.0000000(0):98.93(8);13:13.0033548378(10):1.07(8)", "12.0107(8)")
Ca =
Element.new("Ca", "Calcium", 20, "40:39.9625912(3):96.941(156);42:41.9586183(4):0.647(23);43:42.9587668(5):0.135(10);44:43.9554811(9):2.086(110);46:45.9536928(25):0.004(3);48:47.952534(4):0.187(21)", "40.078(4)")
Cd =
Element.new("Cd", "Cadmium", 48, "106:105.906458(6):1.25(6);108:107.904183(6):0.89(3);110:109.903006(3):12.49(18);111:110.904182(3):12.80(12);112:111.9027572(30):24.13(21);113:112.9044009(30):12.22(12);114:113.9033581(30):28.73(42);116:115.904755(3):7.49(18)", "112.411(8)")
Ce =
Element.new("Ce", "Cerium", 58, "136:135.907140(50):0.185(2);138:137.905986(11):0.251(2);140:139.905434(3):88.450(51);142:141.909240(4):11.114(51)", "140.116(1)")
Cl =
Element.new("Cl", "Chlorine", 17, "35:34.96885271(4):75.78(4);37:36.96590260(5):24.22(4)", "35.453(2)")
Co =
Element.new("Co", "Cobalt", 27, "59:58.9332002(15):100", "58.933200(9)")
Cr =
Element.new("Cr", "Chromium", 24, "50:49.9460496(14):4.345(13);52:51.9405119(15):83.789(18);53:52.9406538(15):9.501(17);54:53.9388849(15):2.365(7)", "51.9961(6)")
Cs =
Element.new("Cs", "Cesium", 55, "133:132.905447(3):100", "132.90545(2)")
Cu =
Element.new("Cu", "Copper", 29, "63:62.9296011(15):69.17(3);65:64.9277937(19):30.83(3)", "63.546(3)")
Dy =
Element.new("Dy", "Dysprosium", 66, "156:155.924278(7):0.06(1);158:157.924405(4):0.10(1);160:159.925194(3):2.34(8);161:160.926930(3):18.91(24);162:161.926795(3):25.51(26);163:162.928728(3):24.90(16);164:163.929171(3):28.18(37)", "162.500(1)")
Er =
Element.new("Er", "Erbium", 68, "162:161.928775(4):0.14(1);164:163.929197(4):1.61(3);166:165.930290(3):33.61(35);167:166.932045(3):22.93(17);168:167.932368(3):26.78(26);170:169.935460(3):14.93(27)", "167.259(3)")
Eu =
Element.new("Eu", "Europium", 63, "151:150.919846(3):47.81(3);153:152.921226(3):52.19(3)", "151.964(1)")
F =
Element.new("F", "Fluorine", 9, "19:18.99840320(7):100", "18.9984032(5)")
Fe =
Element.new("Fe", "Iron", 26, "54:53.9396148(14):5.845(35);56:55.9349421(15):91.754(36);57:56.9353987(15):2.119(10);58:57.9332805(15):0.282(4)", "55.845(2)")
Ga =
Element.new("Ga", "Gallium", 31, "69:68.925581(3):60.108(9);71:70.9247050(19):39.892(9)", "69.723(1)")
Gd =
Element.new("Gd", "Gadolinium", 64, "152:151.919788(3):0.20(1);154:153.920862(3):2.18(3);155:154.922619(3):14.80(12);156:155.922120(3):20.47(9);157:156.923957(3):15.65(2);158:157.924101(3):24.84(7);160:159.927051(3):21.86(19)", "157.25(3)")
Ge =
Element.new("Ge", "Germanium", 32, "70:69.9242504(19):20.84(87);72:71.9220762(16):27.54(34);73:72.9234594(16):7.73(5);74:73.9211782(16):36.28(73);76:75.9214027(16):7.61(38)", "72.64(1)")
H =
Element.new("H", "Hydrogen", 1, "1:1.0078250321(4):99.9885(70);2:2.0141017780(4):0.0115(70)", "1.00794(7)")
He =
Element.new("He", "Helium", 2, "3:3.0160293097(9):0.000137(3);4:4.0026032497(10):99.999863(3)", "4.002602(2)")
Hf =
Element.new("Hf", "Hafnium", 72, "174:173.940040(3):0.16(1);176:175.9414018(29):5.26(7);177:176.9432200(27):18.60(9);178:177.9436977(27):27.28(7);179:178.9458151(27):13.62(2);180:179.9465488(27):35.08(16)", "178.49(2)")
Hg =
Element.new("Hg", "Mercury", 80, "196:195.965815(4):0.15(1);198:197.966752(3):9.97(20);199:198.968262(3):16.87(22);200:199.968309(3):23.10(19);201:200.970285(3):13.18(9);202:201.970626(3):29.86(26);204:203.973476(3):6.87(15)", "200.59(2)")
Ho =
Element.new("Ho", "Holmium", 67, "165:164.930319(3):100", "164.93032(2)")
I =
Element.new("I", "Iodine", 53, "127:126.904468(4):100", "126.90447(3)")
In =
Element.new("In", "Indium", 49, "113:112.904061(4):4.29(5);115:114.903878(5):95.71(5)", "114.818(3)")
Ir =
Element.new("Ir", "Iridium", 77, "191:190.960591(3):37.3(2);193:192.962924(3):62.7(2)", "192.217(3)")
K =
Element.new("K", "Potassium", 19, "39:38.9637069(3):93.2581(44);40:39.96399867(29):0.0117(1);41:40.96182597(28):6.7302(44)", "39.0983(1)")
Kr =
Element.new("Kr", "Krypton", 36, "78:77.920386(7):0.35(1);80:79.916378(4):2.28(6);82:81.9134846(28):11.58(14);83:82.914136(3):11.49(6);84:83.911507(3):57.00(4);86:85.9106103(12):17.30(22)", "83.798(2)")
La =
Element.new("La", "Lanthanum", 57, "138:137.907107(4):0.090(1);139:138.906348(3):99.910(1)", "138.9055(2)")
Li =
Element.new("Li", "Lithium", 3, "6:6.0151223(5):7.59(4);7:7.0160040(5):92.41(4)", "6.941(2)")
Lu =
Element.new("Lu", "Lutetium", 71, "175:174.9407679(28):97.41(2);176:175.9426824(28):2.59(2)", "174.967(1)")
Mg =
Element.new("Mg", "Magnesium", 12, "24:23.98504190(20):78.99(4);25:24.98583702(20):10.00(1);26:25.98259304(21):11.01(3)", "24.3050(6)")
Mn =
Element.new("Mn", "Manganese", 25, "55:54.9380496(14):100", "54.938049(9)")
Mo =
Element.new("Mo", "Molybdenum", 42, "100:99.907477(6):9.63(23);92:91.906810(4):14.84(35);94:93.9050876(20):9.25(12);95:94.9058415(20):15.92(13);96:95.9046789(20):16.68(2);97:96.9060210(20):9.55(8);98:97.9054078(20):24.13(31)", "95.94(2)")
N =
Element.new("N", "Nitrogen", 7, "14:14.0030740052(9):99.632(7);15:15.0001088984(9):0.368(7)", "14.0067(2)")
Na =
Element.new("Na", "Sodium", 11, "23:22.98976967(23):100", "22.989770(2)")
Nb =
Element.new("Nb", "Niobium", 41, "93:92.9063775(24):100", "92.90638(2)")
Nd =
Element.new("Nd", "Neodymium", 60, "142:141.907719(3):27.2(5);143:142.909810(3):12.2(2);144:143.910083(3):23.8(3);145:144.912569(3):8.3(1);146:145.913112(3):17.2(3);148:147.916889(3):5.7(1);150:149.920887(4):5.6(2)", "144.24(3)")
Ne =
Element.new("Ne", "Neon", 10, "20:19.9924401759(20):90.48(3);21:20.99384674(4):0.27(1);22:21.99138551(23):9.25(3)", "20.1797(6)")
Ni =
Element.new("Ni", "Nickel", 28, "58:57.9353479(15):68.0769(89);60:59.9307906(15):26.2231(77);61:60.9310604(15):1.1399(6);62:61.9283488(15):3.6345(17);64:63.9279696(16):0.9256(9)", "58.6934(2)")
O =
Element.new("O", "Oxygen", 8, "16:15.9949146221(15):99.757(16);17:16.99913150(22):0.038(1);18:17.9991604(9):0.205(14)", "15.9994(3)")
Os =
Element.new("Os", "Osmium", 76, "184:183.952491(3):0.02(1);186:185.953838(3):1.59(3);187:186.9557479(30):1.96(2);188:187.9558360(30):13.24(8);189:188.9581449(30):16.15(5);190:189.958445(3):26.26(2);192:191.961479(4):40.78(19)", "190.23(3)")
P =
Element.new("P", "Phosphorus", 15, "31:30.97376151(20):100", "30.973761(2)")
Pa =
Element.new("Pa", "Protactinium", 91, "231:231.0358789(28):100", "231.03588(2)")
Pb =
Element.new("Pb", "Lead", 82, "204:203.973029(3):1.4(1);206:205.974449(3):24.1(1);207:206.975881(3):22.1(1);208:207.976636(3):52.4(1)", "207.2(1)")
Pd =
Element.new("Pd", "Palladium", 46, "102:101.905608(3):1.02(1);104:103.904035(5):11.14(8);105:104.905084(5):22.33(8);106:105.903483(5):27.33(3);108:107.903894(4):26.46(9);110:109.905152(12):11.72(9)", "106.42(1)")
Pr =
Element.new("Pr", "Praseodymium", 59, "141:140.907648(3):100", "140.90765(2)")
Pt =
Element.new("Pt", "Platinum", 78, "190:189.959930(7):0.014(1);192:191.961035(4):0.782(7);194:193.962664(3):32.967(99);195:194.964774(3):33.832(10);196:195.964935(3):25.242(41);198:197.967876(4):7.163(55)", "195.078(2)")
Rb =
Element.new("Rb", "Rubidium", 37, "85:84.9117893(25):72.17(2);87:86.9091835(27):27.83(2)", "85.4678(3)")
Re =
Element.new("Re", "Rhenium", 75, "185:184.9529557(30):37.40(2);187:186.9557508(30):62.60(2)", "186.207(1)")
Rh =
Element.new("Rh", "Rhodium", 45, "103:102.905504(3):100", "102.90550(2)")
Ru =
Element.new("Ru", "Ruthenium", 44, "100:99.9042197(22):12.60(7);101:100.9055822(22):17.06(2);102:101.9043495(22):31.55(14);104:103.905430(4):18.62(27);96:95.907598(8):5.54(14);98:97.905287(7):1.87(3);99:98.9059393(21):12.76(14)", "101.07(2)")
S =
Element.new("S", "Sulfur", 16, "32:31.97207069(12):94.93(31);33:32.97145850(12):0.76(2);34:33.96786683(11):4.29(28);36:35.96708088(25):0.02(1)", "32.065(5)")
Sb =
Element.new("Sb", "Antimony", 51, "121:120.9038180(24):57.21(5);123:122.9042157(22):42.79(5)", "121.760(1)")
Sc =
Element.new("Sc", "Scandium", 21, "45:44.9559102(12):100", "44.955910(8)")
Se =
Element.new("Se", "Selenium", 34, "74:73.9224766(16):0.89(4);76:75.9192141(16):9.37(29);77:76.9199146(16):7.63(16);78:77.9173095(16):23.77(28);80:79.9165218(20):49.61(41);82:81.9167000(22):8.73(22)", "78.96(3)")
Si =
Element.new("Si", "Silicon", 14, "28:27.9769265327(20):92.2297(7);29:28.97649472(3):4.6832(5);30:29.97377022(5):3.0872(5)", "28.0855(3)")
Sm =
Element.new("Sm", "Samarium", 62, "144:143.911995(4):3.07(7);147:146.914893(3):14.99(18);148:147.914818(3):11.24(10);149:148.917180(3):13.82(7);150:149.917271(3):7.38(1);152:151.919728(3):26.75(16);154:153.922205(3):22.75(29)", "150.36(3)")
Sn =
Element.new("Sn", "Tin", 50, "112:111.904821(5):0.97(1);114:113.902782(3):0.66(1);115:114.903346(3):0.34(1);116:115.901744(3):14.54(9);117:116.902954(3):7.68(7);118:117.901606(3):24.22(9);119:118.903309(3):8.59(4);120:119.9021966(27):32.58(9);122:121.9034401(29):4.63(3);124:123.9052746(15):5.79(5)", "118.710(7)")
Sr =
Element.new("Sr", "Strontium", 38, "84:83.913425(4):0.56(1);86:85.9092624(24):9.86(1);87:86.9088793(24):7.00(1);88:87.9056143(24):82.58(1)", "87.62(1)")
Ta =
Element.new("Ta", "Tantalum", 73, "180:179.947466(3):0.012(2);181:180.947996(3):99.988(2)", "180.9479(1)")
Tb =
Element.new("Tb", "Terbium", 65, "159:158.925343(3):100", "158.92534(2)")
Te =
Element.new("Te", "Tellurium", 52, "120:119.904020(11):0.09(1);122:121.9030471(20):2.55(12);123:122.9042730(19):0.89(3);124:123.9028195(16):4.74(14);125:124.9044247(20):7.07(15);126:125.9033055(20):18.84(25);128:127.9044614(19):31.74(8);130:129.9062228(21):34.08(62)", "127.60(3)")
Th =
Element.new("Th", "Thorium", 90, "232:232.0380504(22):100", "232.0381(1)")
Ti =
Element.new("Ti", "Titanium", 22, "46:45.9526295(12):8.25(3);47:46.9517638(10):7.44(2);48:47.9479471(10):73.72(3);49:48.9478708(10):5.41(2);50:49.9447921(11):5.18(2)", "47.867(1)")
Tl =
Element.new("Tl", "Thallium", 81, "203:202.972329(3):29.524(14);205:204.974412(3):70.476(14)", "204.3833(2)")
Tm =
Element.new("Tm", "Thulium", 69, "169:168.934211(3):100", "168.93421(2)")
U =
Element.new("U", "Uranium", 92, "234:234.0409456(21):0.0055(2);235:235.0439231(21):0.7200(51);238:238.0507826(21):99.2745(106)", "238.02891(3)")
V =
Element.new("V", "Vanadium", 23, "50:49.9471628(14):0.250(4);51:50.9439637(14):99.750(4)", "50.9415(1)")
W =
Element.new("W", "Tungsten", 74, "180:179.946706(5):0.12(1);182:181.948206(3):26.50(16);183:182.9502245(29):14.31(4);184:183.9509326(29):30.64(2);186:185.954362(3):28.43(19)", "183.84(1)")
Xe =
Element.new("Xe", "Xenon", 54, "124:123.9058958(21):0.09(1);126:125.904269(7):0.09(1);128:127.9035304(15):1.92(3);129:128.9047795(9):26.44(24);130:129.9035079(10):4.08(2);131:130.9050819(10):21.18(3);132:131.9041545(12):26.89(6);134:133.9053945(9):10.44(10);136:135.907220(8):8.87(16)", "131.293(6)")
Y =
Element.new("Y", "Yttrium", 39, "89:88.9058479(25):100", "88.90585(2)")
Yb =
Element.new("Yb", "Ytterbium", 70, "168:167.933894(5):0.13(1);170:169.934759(3):3.04(15);171:170.936322(3):14.28(57);172:171.9363777(30):21.83(67);173:172.9382068(30):16.13(27);174:173.9388581(30):31.83(92);176:175.942568(3):12.76(41)", "173.04(3)")
Zn =
Element.new("Zn", "Zinc", 30, "64:63.9291466(18):48.63(60);66:65.9260368(16):27.90(27);67:66.9271309(17):4.10(13);68:67.9248476(17):18.75(51);70:69.925325(4):0.62(3)", "65.409(4)")
Zr =
Element.new("Zr", "Zirconium", 40, "90:89.9047037(23):51.45(40);91:90.9056450(23):11.22(5);92:91.9050401(23):17.15(8);94:93.9063158(25):17.38(28);96:95.908276(3):2.80(9)", "91.224(2)")

Instance Attribute Summary collapse

Attributes included from Constants::Library

#library

Instance Method Summary collapse

Methods included from Constants::Library

#[], #collection, extended, included, #index, #reset_library

Constructor Details

#initialize(symbol, name, atomic_number, attributes, std_atomic_weight) ⇒ Element

Returns a new instance of Element.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/constants/libraries/element.rb', line 50

def initialize(symbol, name, atomic_number, attributes, std_atomic_weight)
  @symbol = symbol
  @name = name
  @atomic_number = atomic_number
  @isotopes = []
  @masses = []
  @abundances = []
  @index_max_abundance = 0
  @std_atomic_weight = Constant.parse(std_atomic_weight + 'Da')

  attributes.split(/;/).each_with_index do |attr_str, i|
    isotope, mass, abundance = attr_str.split(/:/)
    @isotopes << isotope.to_i
    @masses << Constant.parse(mass + 'Da')

    abundance = Constant.parse(abundance)
    @abundances << abundance

    if abundance.value > abundances[@index_max_abundance].value
      @index_max_abundance = i
    end
  end
end

Instance Attribute Details

#abundancesObject (readonly)

An array the isotopic abundances of element isotopes in mass order ([98.93, 1.07])



39
40
41
# File 'lib/constants/libraries/element.rb', line 39

def abundances
  @abundances
end

#atomic_numberObject (readonly)

The atomic number of the element, ie the number of protons in the element (6)



27
28
29
# File 'lib/constants/libraries/element.rb', line 27

def atomic_number
  @atomic_number
end

#index_max_abundanceObject (readonly)

The index of the most abundant isotope (0)



42
43
44
# File 'lib/constants/libraries/element.rb', line 42

def index_max_abundance
  @index_max_abundance
end

#isotopesObject (readonly)

An array the mass numbers of element isotopes in mass order ([12, 13])



31
32
33
# File 'lib/constants/libraries/element.rb', line 31

def isotopes
  @isotopes
end

#massesObject (readonly)

An array the masses of element isotopes in mass order ([12.0 Da, 13.0033548378 Da])



35
36
37
# File 'lib/constants/libraries/element.rb', line 35

def masses
  @masses
end

#nameObject (readonly)

The name of the element (Carbon)



23
24
25
# File 'lib/constants/libraries/element.rb', line 23

def name
  @name
end

#std_atomic_weightObject (readonly)

The standard atomic weight of the element, ie the mean relative atomic mass of an element in the Earth’s crust and atmosphere as determined by IUPAC (12.0107 Da)



48
49
50
# File 'lib/constants/libraries/element.rb', line 48

def std_atomic_weight
  @std_atomic_weight
end

#symbolObject (readonly)

The symbol of the element ©



20
21
22
# File 'lib/constants/libraries/element.rb', line 20

def symbol
  @symbol
end

Instance Method Details

#abundance(n = nil) ⇒ Object

Gets the abundance of the isotope with the given mass number.

By default, returns the abundance of the most abundant isotope.



106
107
108
109
110
111
# File 'lib/constants/libraries/element.rb', line 106

def abundance(n=nil)
  return abundances[index_max_abundance].value if n == nil

  i = index_isotope(n)
  i == nil ? nil : abundances[i].value
end

#abundance_uncertainty(n = nil) ⇒ Object

Returns the uncertainty of the abundance of the isotope with the given mass number. By default, returns the abundance uncertainty of the most abundant isotope.



116
117
118
119
120
121
# File 'lib/constants/libraries/element.rb', line 116

def abundance_uncertainty(n=nil)
  return abundances[index_max_abundance].uncertainty if n == nil

  i = index_isotope(n)
  i == nil ? nil : abundances[i].uncertainty
end

#has_isotope?(n) ⇒ Boolean

True if the element contains an isotope of the given mass number.

Returns:

  • (Boolean)


75
76
77
# File 'lib/constants/libraries/element.rb', line 75

def has_isotope?(n)
  !index_isotope(n).nil?
end

#index_isotope(n) ⇒ Object

Index of the isotope in isotopes, masses, and abundance of the given mass number.



81
82
83
# File 'lib/constants/libraries/element.rb', line 81

def index_isotope(n)
  isotopes.index(n)
end

#mass(n = nil) ⇒ Object

Returns the mass of the isotope with the given mass number.

By default, returns the mass of the most abundant isotope.



87
88
89
90
91
92
# File 'lib/constants/libraries/element.rb', line 87

def mass(n=nil)
  return masses[index_max_abundance].value if n == nil

  i = index_isotope(n)
  i == nil ? nil : masses[i].value
end

#mass_uncertainty(n = nil) ⇒ Object

Returns the uncertainty of the mass of the isotope with the given mass number. By default, returns the mass uncertainty of the most abundant isotope.



97
98
99
100
101
102
# File 'lib/constants/libraries/element.rb', line 97

def mass_uncertainty(n=nil)
  return masses[index_max_abundance].uncertainty if n == nil

  i = index_isotope(n)
  i == nil ? nil : masses[i].uncertainty
end