# A function that given the symbol of an element # returns the relative mass of its most common isotope def label2mass(label): label = str(label) if label.upper() in label_to_mass: return label_to_mass[label.upper()] else: print "Could not find the following element symbol: ",label return 0.0 # A function that given the symbol of an element # returns its atomic number (as an integer) def label2Z(label): label = str(label) if label.upper() in label_to_Z: return label_to_Z[label.upper()] else: print "Could not find the following element symbol: ",label return 0.0 # A dictionary that converts the symbol of an element # to the relative mass of its most common isotope label_to_mass = {'X': 0.000000000, 'H': 1.007825032, 'HE': 4.002603254, 'LI': 7.016004548, 'BE': 9.012182201, 'B': 11.009305406, 'C': 12.000000000, 'N': 14.003074005, 'O': 15.994914620, 'F': 18.998403224, 'NE': 19.992440175, 'NA': 22.989769281, 'MG': 23.985041699, 'AL': 26.981538627, 'SI': 27.976926532, 'P': 30.973761629, 'S': 31.972070999, 'CL': 34.968852682, 'AR': 39.962383123, 'K': 38.963706679, 'CA': 39.962590983, 'SC': 44.955911909, 'TI': 47.947946281, 'V': 50.943959507, 'CR': 51.940507472, 'MN': 54.938045141, 'FE': 55.934937475, 'CO': 58.933195048, 'NI': 57.935342907, 'CU': 62.929597474, 'ZN': 63.929142222, 'GA': 68.925573587, 'GE': 73.921177767, 'AS': 74.921596478, 'SE': 79.916521271, 'BR': 78.918337087, 'KR': 85.910610729, 'RB': 84.911789737, 'SR': 87.905612124, 'Y': 88.905848295, 'ZR': 89.904704416, 'NB': 92.906378058, 'MO': 97.905408169, 'TC': 98.906254747, 'RU': 101.904349312, 'RH': 102.905504292, 'PD': 105.903485715, 'AG': 106.905096820, 'CD': 113.903358540, 'IN': 114.903878484, 'SN': 119.902194676, 'SB': 120.903815686, 'TE': 129.906224399, 'I': 126.904472681, 'XE': 131.904153457, 'CS': 132.905451932, 'BA': 137.905247237, 'LA': 138.906353267, 'CE': 139.905438706, 'PR': 140.907652769, 'ND': 141.907723297, 'PM': 144.912749023, 'SM': 151.919732425, 'EU': 152.921230339, 'GD': 157.924103912, 'TB': 158.925346757, 'DY': 163.929174751, 'HO': 164.930322070, 'ER': 165.930293061, 'TM': 168.934213250, 'YB': 173.938862089, 'LU': 174.940771819, 'HF': 179.946549953, 'TA': 180.947995763, 'W': 183.950931188, 'RE': 186.955753109, 'OS': 191.961480690, 'IR': 192.962926430, 'PT': 194.964791134, 'AU': 196.966568662, 'HG': 201.970643011, 'TL': 204.974427541, 'PB': 207.976652071, 'BI': 208.980398734, 'PO': 208.982430435, 'AT': 210.987496271, 'RN': 222.017577738, 'FR': 222.017551730, 'RA': 228.031070292, 'AC': 227.027752127, 'TH': 232.038055325, 'PA': 231.035883990, 'U': 238.050788247, 'NP': 237.048173444, 'PU': 242.058742611, 'AM': 243.061381080, 'CM': 247.070353540, 'BK': 247.070307080, 'CF': 251.079586788, 'ES': 252.082978512, 'FM': 257.095104724, 'MD': 258.098431319, 'NO': 255.093241131, 'LR': 260.105504000, 'RF': 263.112547000, 'DB': 255.107398000, 'SG': 259.114500000, 'BH': 262.122892000, 'HS': 263.128558000, 'MT': 265.136151000, 'DS': 281.162061000, 'RG': 272.153615000, 'UUB': 283.171792000, 'UUT': 283.176451000, 'UUQ': 285.183698000, 'UUP': 287.191186000, 'UUH': 292.199786000, 'UUS': 291.206564000, 'UUO': 293.214670000} # A dictionary that converts the symbol of an element # to its atomic number label_to_Z = {'X': 0, 'H': 1, 'HE': 2, 'LI': 3, 'BE': 4, 'B': 5, 'C': 6, 'N': 7, 'O': 8, 'F': 9, 'NE': 10, 'NA': 11, 'MG': 12, 'AL': 13, 'SI': 14, 'P': 15, 'S': 16, 'CL': 17, 'AR': 18, 'K': 19, 'CA': 20, 'SC': 21, 'TI': 22, 'V': 23, 'CR': 24, 'MN': 25, 'FE': 26, 'CO': 27, 'NI': 28, 'CU': 29, 'ZN': 30, 'GA': 31, 'GE': 32, 'AS': 33, 'SE': 34, 'BR': 35, 'KR': 36, 'RB': 37, 'SR': 38, 'Y': 39, 'ZR': 40, 'NB': 41, 'MO': 42, 'TC': 43, 'RU': 44, 'RH': 45, 'PD': 46, 'AG': 47, 'CD': 48, 'IN': 49, 'SN': 50, 'SB': 51, 'TE': 52, 'I': 53, 'XE': 54, 'CS': 55, 'BA': 56, 'LA': 57, 'CE': 58, 'PR': 59, 'ND': 60, 'PM': 61, 'SM': 62, 'EU': 63, 'GD': 64, 'TB': 65, 'DY': 66, 'HO': 67, 'ER': 68, 'TM': 69, 'YB': 70, 'LU': 71, 'HF': 72, 'TA': 73, 'W': 74, 'RE': 75, 'OS': 76, 'IR': 77, 'PT': 78, 'AU': 79, 'HG': 80, 'TL': 81, 'PB': 82, 'BI': 83, 'PO': 84, 'AT': 85, 'RN': 86, 'FR': 87, 'RA': 88, 'AC': 89, 'TH': 90, 'PA': 91, 'U': 92, 'NP': 93, 'PU': 94, 'AM': 95, 'CM': 96, 'BK': 97, 'CF': 98, 'ES': 99, 'FM': 100, 'MD': 101, 'NO': 102, 'LR': 103, 'RF': 104, 'DB': 105, 'SG': 106, 'BH': 107, 'HS': 108, 'MT': 109, 'DS': 110, 'RG': 111, 'UUB': 112, 'UUT': 113, 'UUQ': 114, 'UUP': 115, 'UUH': 116, 'UUS': 117, 'UUO': 118}