1 from __future__
import division
2 from collections
import defaultdict, OrderedDict
8 BondEnergies = defaultdict(
lambda:defaultdict(dict))
13 1.28, 0.96, 0.84, 0.76, 0.71, 0.66, 0.57, 0.58,
14 0.0, 1.41, 1.21, 1.11, 1.07, 1.05, 1.02, 1.06,
15 2.03, 1.76, 1.70, 1.60, 1.53, 1.39, 1.61, 1.52, 1.50,
16 1.24, 1.32, 1.22, 1.22, 1.20, 1.19, 1.20, 1.20, 1.16,
17 2.20, 1.95, 1.90, 1.75, 1.64, 1.54, 1.47, 1.46, 1.42,
18 1.39, 1.45, 1.44, 1.42, 1.39, 1.39, 1.38, 1.39, 1.40,
19 2.44, 2.15, 2.07, 2.04, 2.03, 2.01, 1.99, 1.98,
20 1.98, 1.96, 1.94, 1.92, 1.92, 1.89, 1.90, 1.87,
21 1.87, 1.75, 1.70, 1.62, 1.51, 1.44, 1.41, 1.36,
22 1.36, 1.32, 1.45, 1.46, 1.48, 1.40, 1.50, 1.50,
23 2.60, 2.21, 2.15, 2.06, 2.00, 1.96, 1.90, 1.87, 1.80, 1.69]
27 PeriodicTable = OrderedDict([(
'H',1.0079),(
'He',4.0026),
28 (
'Li',6.941),(
'Be',9.0122),(
'B',10.811),(
'C',12.0107),(
'N',14.0067),(
'O',15.9994),(
'F',18.9984),(
'Ne',20.1797),
29 (
'Na',22.9897),(
'Mg',24.305),(
'Al',26.9815),(
'Si',28.0855),(
'P',30.9738),(
'S',32.065),(
'Cl',35.453),(
'Ar',39.948),
30 (
'K',39.0983),(
'Ca',40.078),(
'Sc',44.9559),(
'Ti',47.867),(
'V',50.9415),(
'Cr',51.9961),(
'Mn',54.938),(
'Fe',55.845),(
'Co',58.9332),
31 (
'Ni',58.6934),(
'Cu',63.546),(
'Zn',65.39),(
'Ga',69.723),(
'Ge',72.64),(
'As',74.9216),(
'Se',78.96),(
'Br',79.904),(
'Kr',83.8),
32 (
'Rb',85.4678),(
'Sr',87.62),(
'Y',88.9059),(
'Zr',91.224),(
'Nb',92.9064),(
'Mo',95.94),(
'Tc',98),(
'Ru',101.07),(
'Rh',102.9055),
33 (
'Pd',106.42),(
'Ag',107.8682),(
'Cd',112.411),(
'In',114.818),(
'Sn',118.71),(
'Sb',121.76),(
'Te',127.6),(
'I',126.9045),(
'Xe',131.293),
34 (
'Cs',132.9055),(
'Ba',137.327),(
'La',138.9055),(
'Ce',140.116),(
'Pr',140.9077),(
'Nd',144.24),(
'Pm',145),(
'Sm',150.36),
35 (
'Eu',151.964),(
'Gd',157.25),(
'Tb',158.9253),(
'Dy',162.5),(
'Ho',164.9303),(
'Er',167.259),(
'Tm',168.9342),(
'Yb',173.04),
36 (
'Lu',174.967),(
'Hf',178.49),(
'Ta',180.9479),(
'W',183.84),(
'Re',186.207),(
'Os',190.23),(
'Ir',192.217),(
'Pt',195.078),
37 (
'Au',196.9665),(
'Hg',200.59),(
'Tl',204.3833),(
'Pb',207.2),(
'Bi',208.9804),(
'Po',209),(
'At',210),(
'Rn',222),
38 (
'Fr',223),(
'Ra',226),(
'Ac',227),(
'Th',232.0381),(
'Pa',231.0359),(
'U',238.0289),('Np',237),('Pu',244),
39 (
'Am',243),(
'Cm',247),(
'Bk',247),(
'Cf',251),(
'Es',252),(
'Fm',257),(
'Md',258),(
'No',259),
40 (
'Lr',262),(
'Rf',261),(
'Db',262),(
'Sg',266),(
'Bh',264),(
'Hs',277),(
'Mt',268)])
42 Elements = [
"None",
'H',
'He',
43 'Li',
'Be',
'B',
'C',
'N',
'O',
'F',
'Ne',
44 'Na',
'Mg',
'Al',
'Si',
'P',
'S',
'Cl',
'Ar',
45 'K',
'Ca',
'Sc',
'Ti',
'V',
'Cr',
'Mn',
'Fe',
'Co',
'Ni',
'Cu',
'Zn',
'Ga',
'Ge',
'As',
'Se',
'Br',
'Kr',
46 'Rb',
'Sr',
'Y',
'Zr',
'Nb',
'Mo',
'Tc',
'Ru',
'Rh',
'Pd',
'Ag',
'Cd',
'In',
'Sn',
'Sb',
'Te',
'I',
'Xe',
47 'Cs',
'Ba',
'La',
'Ce',
'Pr',
'Nd',
'Pm',
'Sm',
'Eu',
'Gd',
'Tb',
'Dy',
'Ho',
'Er',
'Tm',
'Yb',
48 'Lu',
'Hf',
'Ta',
'W',
'Re',
'Os',
'Ir',
'Pt',
'Au',
'Hg',
'Tl',
'Pb',
'Bi',
'Po',
'At',
'Rn',
49 'Fr',
'Ra',
'Ac',
'Th',
'Pa',
'U','Np','Pu','Am','Cm','Bk','Cf','Es','Fm','Md','No','Lr','Rf','Db','Sg','Bh','Hs','Mt']
51 BondChars = [
'-',
'=',
'3']
56 data_from_web=
"""H-H 432 74 149 for line
in data_from_web.split(
'\n'):
150 line = line.expandtabs()
151 BE = float(line.split()[1])
152 L = float(line.split()[2]) * 0.01
153 atoms = re.split(
'[-=3]', line.split()[0])
156 bo = BondChars.index(re.findall(
'[-=3]', line.split()[0])[0]) + 1
157 BondEnergies[A][B][bo] = (BE, L)
158 BondEnergies[B][A][bo] = (BE, L)
163 for e, m
in PeriodicTable.items():
164 if np.abs(mass - m) < Deviation:
166 Deviation = np.abs(mass - m)
183 for BO, Vals
in BondEnergies[A][B].items():
186 Devs[BO] = np.abs(length-L)
187 if np.abs(length-L) < Deviation:
190 Deviation = np.abs(length-L)
191 if len(Devs.items()) >= 2:
192 Spac = Devs[1] + Devs[2]
195 if Frac1 > artol
and Frac2 > artol:
198 Strength = 0.5 * (BondEnergies[A][B][1][0] + BondEnergies[A][B][2][0])
199 return Strength, BOMatch
def BondStrengthByLength(A, B, length, artol=0.33, bias=0.0)