1#!/usr/bin/env python
2# Copyright 2014-2020 The PySCF Developers. All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16import numpy
17
18ELEMENTS = [
19    'X',  # Ghost
20    'H' , 'He', 'Li', 'Be', 'B' , 'C' , 'N' , 'O' , 'F' , 'Ne',
21    'Na', 'Mg', 'Al', 'Si', 'P' , 'S' , 'Cl', 'Ar', 'K' , 'Ca',
22    'Sc', 'Ti', 'V' , 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn',
23    'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr', 'Rb', 'Sr', 'Y' , 'Zr',
24    'Nb', 'Mo', 'Tc', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn',
25    'Sb', 'Te', 'I' , 'Xe', 'Cs', 'Ba', 'La', 'Ce', 'Pr', 'Nd',
26    'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb',
27    'Lu', 'Hf', 'Ta', 'W' , 'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg',
28    'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn', 'Fr', 'Ra', 'Ac', 'Th',
29    'Pa', 'U' , 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm',
30    'Md', 'No', 'Lr', 'Rf', 'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds',
31    'Rg', 'Cn', 'Nh', 'Fl', 'Mc', 'Lv', 'Ts', 'Og',
32]
33NUC = dict(((x,i) for i,x in enumerate(ELEMENTS)))
34NUC.update((x.upper(),i) for i,x in enumerate(ELEMENTS))
35NUC['GHOST'] = 0
36ELEMENTS_PROTON = NUC
37
38ATOMIC_NAMES = [
39    'Ghost',
40    # IUPAC version dated 28 November 2016
41    'Hydrogen', 'Helium', 'Lithium', 'Beryllium', 'Boron',
42    'Carbon', 'Nitrogen', 'Oxygen', 'Fluorine', 'Neon',
43    'Sodium', 'Magnesium', 'Aluminium', 'Silicon', 'Phosphorus',
44    'Sulfur', 'Chlorine', 'Argon', 'Potassium', 'Calcium',
45    'Scandium', 'Titanium', 'Vanadium', 'Chromium', 'Manganese',
46    'Iron', 'Cobalt', 'Nickel', 'Copper', 'Zinc',
47    'Gallium', 'Germanium', 'Arsenic', 'Selenium', 'Bromine',
48    'Krypton', 'Rubidium', 'Strontium', 'Yttrium', 'Zirconium',
49    'Niobium', 'Molybdenum', 'Technetium', 'Ruthenium', 'Rhodium',
50    'Palladium', 'Silver', 'Cadmium', 'Indium', 'Tin',
51    'Antimony', 'Tellurium', 'Iodine', 'Xenon', 'Caesium',
52    'Barium', 'Lanthanum', 'Cerium', 'Praseodymium', 'Neodymium',
53    'Promethium', 'Samarium', 'Europium', 'Gadolinium', 'Terbium',
54    'Dysprosium', 'Holmium', 'Erbium', 'Thulium', 'Ytterbium',
55    'Lutetium', 'Hafnium', 'Tantalum', 'Tungsten', 'Rhenium',
56    'Osmium', 'Iridium', 'Platinum', 'Gold', 'Mercury',
57    'Thallium', 'Lead', 'Bismuth', 'Polonium', 'Astatine',
58    'Radon', 'Francium', 'Radium', 'Actinium', 'Thorium',
59    'Protactinium', 'Uranium', 'Neptunium', 'Plutonium', 'Americium',
60    'Curium', 'Berkelium', 'Californium', 'Einsteinium', 'Fermium',
61    'Mendelevium', 'Nobelium', 'Lawrencium', 'Rutherfordium', 'Dubnium',
62    'Seaborgium', 'Bohrium', 'Hassium', 'Meitnerium', 'Darmastadtium',
63    'Roentgenium', 'Copernicium', 'Nihonium', 'Flerovium', 'Moscovium',
64    'Livermorium', 'Tennessine', 'Oganesson'
65]
66
67ISOTOPE_MAIN = [
68    0  ,   # GHOST
69    1  ,   # H
70    4  ,   # He
71    7  ,   # Li
72    9  ,   # Be
73    11 ,   # B
74    12 ,   # C
75    14 ,   # N
76    16 ,   # O
77    19 ,   # F
78    20 ,   # Ne
79    23 ,   # Na
80    24 ,   # Mg
81    27 ,   # Al
82    28 ,   # Si
83    31 ,   # P
84    32 ,   # S
85    35 ,   # Cl
86    40 ,   # Ar
87    39 ,   # K
88    40 ,   # Ca
89    45 ,   # Sc
90    48 ,   # Ti
91    51 ,   # V
92    52 ,   # Cr
93    55 ,   # Mn
94    56 ,   # Fe
95    59 ,   # Co
96    58 ,   # Ni
97    63 ,   # Cu
98    64 ,   # Zn
99    69 ,   # Ga
100    74 ,   # Ge
101    75 ,   # As
102    80 ,   # Se
103    79 ,   # Br
104    84 ,   # Kr
105    85 ,   # Rb
106    88 ,   # Sr
107    89 ,   # Y
108    90 ,   # Zr
109    93 ,   # Nb
110    98 ,   # Mo
111    98 ,   # 98Tc
112    102,   # Ru
113    103,   # Rh
114    106,   # Pd
115    107,   # Ag
116    114,   # Cd
117    115,   # In
118    120,   # Sn
119    121,   # Sb
120    130,   # Te
121    127,   # I
122    132,   # Xe
123    133,   # Cs
124    138,   # Ba
125    139,   # La
126    140,   # Ce
127    141,   # Pr
128    144,   # Nd
129    145,   # Pm
130    152,   # Sm
131    153,   # Eu
132    158,   # Gd
133    159,   # Tb
134    162,   # Dy
135    162,   # Ho
136    168,   # Er
137    169,   # Tm
138    174,   # Yb
139    175,   # Lu
140    180,   # Hf
141    181,   # Ta
142    184,   # W
143    187,   # Re
144    192,   # Os
145    193,   # Ir
146    195,   # Pt
147    197,   # Au
148    202,   # Hg
149    205,   # Tl
150    208,   # Pb
151    209,   # Bi
152    209,   # Po
153    210,   # At
154    222,   # Rn
155    223,   # Fr
156    226,   # Ra
157    227,   # Ac
158    232,   # Th
159    231,   # Pa
160    238,   # U
161    237,   # Np
162    244,   # Pu
163    243,   # Am
164    247,   # Cm
165    247,   # Bk
166    251,   # Cf
167    252,   # Es
168    257,   # Fm
169    258,   # Md
170    259,   # No
171    262,   # Lr
172    261,   # Rf
173    262,   # Db
174    263,   # Sg
175    262,   # Bh
176    265,   # Hs
177    266,   # Mt
178    0  ,   # Ds
179    0  ,   # Rg
180    0  ,   # Cn
181    0  ,   # Nh
182    0  ,   # Fl
183    0  ,   # Mc
184    0  ,   # Lv
185    0  ,   # Ts
186    0  ,   # Og
187]
188
189
190# From ase code
191#
192#    https://wiki.fysik.dtu.dk/ase/index.html
193#
194# Atomic masses are based on:
195#
196#   Meija, J., Coplen, T., Berglund, M., et al. (2016). Atomic weights of
197#   the elements 2013 (IUPAC Technical Report). Pure and Applied Chemistry,
198#   88(3), pp. 265-291. Retrieved 30 Nov. 2016,
199#   from doi:10.1515/pac-2015-0305
200#
201# Standard atomic weights are taken from Table 1: "Standard atomic weights
202# 2013", with the uncertainties ignored.
203# For hydrogen, helium, boron, carbon, nitrogen, oxygen, magnesium, silicon,
204# sulfur, chlorine, bromine and thallium, where the weights are given as a
205# range the "conventional" weights are taken from Table 3 and the ranges are
206# given in the comments.
207# The mass of the most stable isotope (in Table 4) is used for elements
208# where there the element has no stable isotopes (to avoid NaNs): Tc, Pm,
209# Po, At, Rn, Fr, Ra, Ac, everything after Np
210MASSES = [
211    0.,                 # GHOST
212    1.008,              # H [1.00784, 1.00811]
213    4.002602,           # He
214    6.94,               # Li [6.938, 6.997]
215    9.0121831,          # Be
216    10.81,              # B [10.806, 10.821]
217    12.011,             # C [12.0096, 12.0116]
218    14.007,             # N [14.00643, 14.00728]
219    15.999,             # O [15.99903, 15.99977]
220    18.998403163,       # F
221    20.1797,            # Ne
222    22.98976928,        # Na
223    24.305,             # Mg [24.304, 24.307]
224    26.9815385,         # Al
225    28.085,             # Si [28.084, 28.086]
226    30.973761998,       # P
227    32.06,              # S [32.059, 32.076]
228    35.45,              # Cl [35.446, 35.457]
229    39.948,             # Ar
230    39.0983,            # K
231    40.078,             # Ca
232    44.955908,          # Sc
233    47.867,             # Ti
234    50.9415,            # V
235    51.9961,            # Cr
236    54.938044,          # Mn
237    55.845,             # Fe
238    58.933194,          # Co
239    58.6934,            # Ni
240    63.546,             # Cu
241    65.38,              # Zn
242    69.723,             # Ga
243    72.630,             # Ge
244    74.921595,          # As
245    78.971,             # Se
246    79.904,             # Br [79.901, 79.907]
247    83.798,             # Kr
248    85.4678,            # Rb
249    87.62,              # Sr
250    88.90584,           # Y
251    91.224,             # Zr
252    92.90637,           # Nb
253    95.95,              # Mo
254    97.90721,           # 98Tc
255    101.07,             # Ru
256    102.90550,          # Rh
257    106.42,             # Pd
258    107.8682,           # Ag
259    112.414,            # Cd
260    114.818,            # In
261    118.710,            # Sn
262    121.760,            # Sb
263    127.60,             # Te
264    126.90447,          # I
265    131.293,            # Xe
266    132.90545196,       # Cs
267    137.327,            # Ba
268    138.90547,          # La
269    140.116,            # Ce
270    140.90766,          # Pr
271    144.242,            # Nd
272    144.91276,          # 145Pm
273    150.36,             # Sm
274    151.964,            # Eu
275    157.25,             # Gd
276    158.92535,          # Tb
277    162.500,            # Dy
278    164.93033,          # Ho
279    167.259,            # Er
280    168.93422,          # Tm
281    173.054,            # Yb
282    174.9668,           # Lu
283    178.49,             # Hf
284    180.94788,          # Ta
285    183.84,             # W
286    186.207,            # Re
287    190.23,             # Os
288    192.217,            # Ir
289    195.084,            # Pt
290    196.966569,         # Au
291    200.592,            # Hg
292    204.38,             # Tl [204.382, 204.385]
293    207.2,              # Pb
294    208.98040,          # Bi
295    208.98243,          # Po
296    209.98715,          # At
297    222.01758,          # Rn
298    223.01974,          # Fr
299    226.02541,          # Ra
300    227.02775,          # Ac
301    232.0377,           # Th
302    231.03588,          # Pa
303    238.02891,          # U
304    237.04817,          # Np
305    244.06421,          # Pu
306    243.06138,          # Am
307    247.07035,          # Cm
308    247.07031,          # Bk
309    251.07959,          # Cf
310    252.0830,           # Es
311    257.09511,          # Fm
312    258.09843,          # Md
313    259.1010,           # No
314    262.110,            # Lr
315    267.122,            # Rf
316    268.126,            # Db
317    271.134,            # Sg
318    270.133,            # Bh
319    269.1338,           # Hs
320    278.156,            # Mt
321    281.165,            # Ds
322    281.166,            # Rg
323    285.177,            # Cn
324    286.182,            # Nh
325    289.190,            # Fl
326    289.194,            # Mc
327    293.204,            # Lv
328    293.208,            # Ts
329    294.214,            # Og
330]
331
332
333# ground state configuration = (num. electrons for each irrep./angular moment)
334CONFIGURATION = [
335    [ 0, 0, 0, 0],     #  0  GHOST
336    [ 1, 0, 0, 0],     #  1  H
337    [ 2, 0, 0, 0],     #  2  He
338    [ 3, 0, 0, 0],     #  3  Li
339    [ 4, 0, 0, 0],     #  4  Be
340    [ 4, 1, 0, 0],     #  5  B
341    [ 4, 2, 0, 0],     #  6  C
342    [ 4, 3, 0, 0],     #  7  N
343    [ 4, 4, 0, 0],     #  8  O
344    [ 4, 5, 0, 0],     #  9  F
345    [ 4, 6, 0, 0],     # 10  Ne
346    [ 5, 6, 0, 0],     # 11  Na
347    [ 6, 6, 0, 0],     # 12  Mg
348    [ 6, 7, 0, 0],     # 13  Al
349    [ 6, 8, 0, 0],     # 14  Si
350    [ 6, 9, 0, 0],     # 15  P
351    [ 6,10, 0, 0],     # 16  S
352    [ 6,11, 0, 0],     # 17  Cl
353    [ 6,12, 0, 0],     # 18  Ar
354    [ 7,12, 0, 0],     # 19  K
355    [ 8,12, 0, 0],     # 20  Ca
356    [ 8,12, 1, 0],     # 21  Sc
357    [ 8,12, 2, 0],     # 22  Ti
358    [ 8,12, 3, 0],     # 23  V
359    [ 7,12, 5, 0],     # 24  Cr
360    [ 8,12, 5, 0],     # 25  Mn
361    [ 8,12, 6, 0],     # 26  Fe
362    [ 8,12, 7, 0],     # 27  Co
363    [ 8,12, 8, 0],     # 28  Ni
364    [ 7,12,10, 0],     # 29  Cu
365    [ 8,12,10, 0],     # 30  Zn
366    [ 8,13,10, 0],     # 31  Ga
367    [ 8,14,10, 0],     # 32  Ge
368    [ 8,15,10, 0],     # 33  As
369    [ 8,16,10, 0],     # 34  Se
370    [ 8,17,10, 0],     # 35  Br
371    [ 8,18,10, 0],     # 36  Kr
372    [ 9,18,10, 0],     # 37  Rb
373    [10,18,10, 0],     # 38  Sr
374    [10,18,11, 0],     # 39  Y
375    [10,18,12, 0],     # 40  Zr
376    [ 9,18,14, 0],     # 41  Nb
377    [ 9,18,15, 0],     # 42  Mo
378    [10,18,15, 0],     # 43  Tc
379    [ 9,18,17, 0],     # 44  Ru
380    [ 9,18,18, 0],     # 45  Rh
381    [ 8,18,20, 0],     # 46  Pd
382    [ 9,18,20, 0],     # 47  Ag
383    [10,18,20, 0],     # 48  Cd
384    [10,19,20, 0],     # 49  In
385    [10,20,20, 0],     # 50  Sn
386    [10,21,20, 0],     # 51  Sb
387    [10,22,20, 0],     # 52  Te
388    [10,23,20, 0],     # 53  I
389    [10,24,20, 0],     # 54  Xe
390    [11,24,20, 0],     # 55  Cs
391    [12,24,20, 0],     # 56  Ba
392    [12,24,21, 0],     # 57  La
393    [12,24,21, 1],     # 58  Ce
394    [12,24,20, 3],     # 59  Pr
395    [12,24,20, 4],     # 60  Nd
396    [12,24,20, 5],     # 61  Pm
397    [12,24,20, 6],     # 62  Sm
398    [12,24,20, 7],     # 63  Eu
399    [12,24,21, 7],     # 64  Gd
400    [12,24,21, 8],     # 65  Tb
401    [12,24,20,10],     # 66  Dy
402    [12,24,20,11],     # 67  Ho
403    [12,24,20,12],     # 68  Er
404    [12,24,20,13],     # 69  Tm
405    [12,24,20,14],     # 70  Yb
406    [12,24,21,14],     # 71  Lu
407    [12,24,22,14],     # 72  Hf
408    [12,24,23,14],     # 73  Ta
409    [12,24,24,14],     # 74  W
410    [12,24,25,14],     # 75  Re
411    [12,24,26,14],     # 76  Os
412    [12,24,27,14],     # 77  Ir
413    [11,24,29,14],     # 78  Pt
414    [11,24,30,14],     # 79  Au
415    [12,24,30,14],     # 80  Hg
416    [12,25,30,14],     # 81  Tl
417    [12,26,30,14],     # 82  Pb
418    [12,27,30,14],     # 83  Bi
419    [12,28,30,14],     # 84  Po
420    [12,29,30,14],     # 85  At
421    [12,30,30,14],     # 86  Rn
422    [13,30,30,14],     # 87  Fr
423    [14,30,30,14],     # 88  Ra
424    [14,30,31,14],     # 89  Ac
425    [14,30,32,14],     # 90  Th
426    [14,30,31,16],     # 91  Pa
427    [14,30,31,17],     # 92  U
428    [14,30,31,18],     # 93  Np
429    [14,30,30,20],     # 94  Pu
430    [14,30,30,21],     # 95  Am
431    [14,30,31,21],     # 96  Cm
432    [14,30,31,22],     # 97  Bk
433    [14,30,30,24],     # 98  Cf
434    [14,30,30,25],     # 99  Es
435    [14,30,30,26],     #100  Fm
436    [14,30,30,27],     #101  Md
437    [14,30,30,28],     #102  No
438    [14,30,31,28],     #103  Lr
439    [14,30,32,28],     #104  Rf
440    [14,30,33,28],     #105  Db
441    [14,30,34,28],     #106  Sg
442    [14,30,35,28],     #107  Bh
443    [14,30,36,28],     #108  Hs
444    [14,30,37,28],     #109  Mt
445    [14,30,38,28],     #110  Ds
446    [14,30,39,28],     #111  Rg
447    [14,30,40,28],     #112  Cn
448    [14,31,40,28],     #113  Nh
449    [14,32,40,28],     #114  Fl
450    [14,33,40,28],     #115  Mc
451    [14,34,40,28],     #116  Lv
452    [14,35,40,28],     #117  Ts
453    [14,36,40,28],     #118  Og
454]
455
456# Non-relativistic spin-restricted spherically averaged Hartree-Fock
457# configurations for use in atomic SAD calculations. Reference
458# configurations from Phys. Rev. A 101, 012516 (2020).
459NRSRHF_CONFIGURATION = [
460    [ 0, 0, 0, 0],     #  0  GHOST
461    [ 1, 0, 0, 0],     #  1  H
462    [ 2, 0, 0, 0],     #  2  He
463    [ 3, 0, 0, 0],     #  3  Li
464    [ 4, 0, 0, 0],     #  4  Be
465    [ 4, 1, 0, 0],     #  5  B
466    [ 4, 2, 0, 0],     #  6  C
467    [ 4, 3, 0, 0],     #  7  N
468    [ 4, 4, 0, 0],     #  8  O
469    [ 4, 5, 0, 0],     #  9  F
470    [ 4, 6, 0, 0],     # 10  Ne
471    [ 5, 6, 0, 0],     # 11  Na
472    [ 6, 6, 0, 0],     # 12  Mg
473    [ 6, 7, 0, 0],     # 13  Al
474    [ 6, 8, 0, 0],     # 14  Si
475    [ 6, 9, 0, 0],     # 15  P
476    [ 6,10, 0, 0],     # 16  S
477    [ 6,11, 0, 0],     # 17  Cl
478    [ 6,12, 0, 0],     # 18  Ar
479    [ 7,12, 0, 0],     # 19  K
480    [ 8,12, 0, 0],     # 20  Ca
481    [ 8,13, 0, 0],     # 21  Sc
482    [ 8,12, 2, 0],     # 22  Ti
483    [ 8,12, 3, 0],     # 23  V
484    [ 8,12, 4, 0],     # 24  Cr
485    [ 6,12, 7, 0],     # 25  Mn
486    [ 6,12, 8, 0],     # 26  Fe
487    [ 6,12, 9, 0],     # 27  Co
488    [ 6,12,10, 0],     # 28  Ni
489    [ 7,12,10, 0],     # 29  Cu
490    [ 8,12,10, 0],     # 30  Zn
491    [ 8,13,10, 0],     # 31  Ga
492    [ 8,14,10, 0],     # 32  Ge
493    [ 8,15,10, 0],     # 33  As
494    [ 8,16,10, 0],     # 34  Se
495    [ 8,17,10, 0],     # 35  Br
496    [ 8,18,10, 0],     # 36  Kr
497    [ 9,18,10, 0],     # 37  Rb
498    [10,18,10, 0],     # 38  Sr
499    [10,19,10, 0],     # 39  Y
500    [10,18,12, 0],     # 40  Zr
501    [10,18,13, 0],     # 41  Nb
502    [ 8,18,16, 0],     # 42  Mo
503    [ 8,18,17, 0],     # 43  Tc
504    [ 8,18,18, 0],     # 44  Ru
505    [ 8,18,19, 0],     # 45  Rh
506    [ 8,18,20, 0],     # 46  Pd
507    [ 9,18,20, 0],     # 47  Ag
508    [10,18,20, 0],     # 48  Cd
509    [10,19,20, 0],     # 49  In
510    [10,20,20, 0],     # 50  Sn
511    [10,21,20, 0],     # 51  Sb
512    [10,22,20, 0],     # 52  Te
513    [10,23,20, 0],     # 53  I
514    [10,24,20, 0],     # 54  Xe
515    [11,24,20, 0],     # 55  Cs
516    [12,24,20, 0],     # 56  Ba
517    [12,24,21, 0],     # 57  La
518    [12,24,22, 0],     # 58  Ce
519    [12,24,21, 2],     # 59  Pr
520    [12,24,20, 4],     # 60  Nd
521    [12,24,20, 5],     # 61  Pm
522    [12,24,20, 6],     # 62  Sm
523    [12,24,20, 7],     # 63  Eu
524    [11,24,20, 9],     # 64  Gd
525    [10,24,20,11],     # 65  Tb
526    [10,24,20,12],     # 66  Dy
527    [10,24,20,13],     # 67  Ho
528    [10,24,20,14],     # 68  Er
529    [11,24,20,14],     # 69  Tm
530    [12,24,20,14],     # 70  Yb
531    [12,25,20,14],     # 71  Lu
532    [12,24,22,14],     # 72  Hf
533    [12,24,23,14],     # 73  Ta
534    [10,24,26,14],     # 74  W
535    [10,24,27,14],     # 75  Re
536    [10,24,28,14],     # 76  Os
537    [10,24,29,14],     # 77  Ir
538    [10,24,30,14],     # 78  Pt
539    [11,24,30,14],     # 79  Au
540    [12,24,30,14],     # 80  Hg
541    [12,25,30,14],     # 81  Tl
542    [12,26,30,14],     # 82  Pb
543    [12,27,30,14],     # 83  Bi
544    [12,28,30,14],     # 84  Po
545    [12,29,30,14],     # 85  At
546    [12,30,30,14],     # 86  Rn
547    [13,30,30,14],     # 87  Fr
548    [14,30,30,14],     # 88  Ra
549    [14,30,31,14],     # 89  Ac
550    [14,30,32,14],     # 90  Th
551    [14,30,30,17],     # 91  Pa
552    [14,30,30,18],     # 92  U
553    [14,30,30,19],     # 93  Np
554    [13,30,30,21],     # 94  Pu
555    [12,30,30,23],     # 95  Am
556    [12,30,30,24],     # 96  Cm
557    [12,30,30,25],     # 97  Bk
558    [12,30,30,26],     # 98  Cf
559    [12,30,30,27],     # 99  Es
560    [12,30,30,28],     #100  Fm
561    [13,30,30,28],     #101  Md
562    [14,30,30,28],     #102  No
563    [14,30,31,28],     #103  Lr
564    [14,30,32,28],     #104  Rf
565    [14,30,33,28],     #105  Db
566    [12,30,36,28],     #106  Sg
567    [12,30,37,28],     #107  Bh
568    [12,30,38,28],     #108  Hs
569    [12,30,39,28],     #109  Mt
570    [12,30,40,28],     #110  Ds
571    [13,30,40,28],     #111  Rg
572    [14,30,40,28],     #112  Cn
573    [14,31,40,28],     #113  Nh
574    [14,32,40,28],     #114  Fl
575    [14,33,40,28],     #115  Mc
576    [14,34,40,28],     #116  Lv
577    [14,35,40,28],     #117  Ts
578    [14,36,40,28],     #118  Og
579]
580
581
582# This is No. of shells, not the atomic configuations
583#     core       core+valence
584# core+valence = lambda nuc, l: \
585#            int(numpy.ceil(pyscf.lib.parameters.ELEMENTS[nuc][2][l]/(4*l+2.)))
586N_CORE_SHELLS = [
587    '0s0p0d0f',         #  0  GHOST
588    '0s0p0d0f',         #  1  H
589    '0s0p0d0f',         #  2  He
590    '1s0p0d0f',         #  3  Li
591    '1s0p0d0f',         #  4  Be
592    '1s0p0d0f',         #  5  B
593    '1s0p0d0f',         #  6  C
594    '1s0p0d0f',         #  7  N
595    '1s0p0d0f',         #  8  O
596    '1s0p0d0f',         #  9  F
597    '1s0p0d0f',         # 10  Ne
598    '2s1p0d0f',         # 11  Na
599    '2s1p0d0f',         # 12  Mg
600    '2s1p0d0f',         # 13  Al
601    '2s1p0d0f',         # 14  Si
602    '2s1p0d0f',         # 15  P
603    '2s1p0d0f',         # 16  S
604    '2s1p0d0f',         # 17  Cl
605    '2s1p0d0f',         # 18  Ar
606    '3s2p0d0f',         # 19  K
607    '3s2p0d0f',         # 20  Ca
608    '3s2p0d0f',         # 21  Sc
609    '3s2p0d0f',         # 22  Ti
610    '3s2p0d0f',         # 23  V
611    '3s2p0d0f',         # 24  Cr
612    '3s2p0d0f',         # 25  Mn
613    '3s2p0d0f',         # 26  Fe
614    '3s2p0d0f',         # 27  Co
615    '3s2p0d0f',         # 28  Ni
616    '3s2p0d0f',         # 29  Cu
617    '3s2p0d0f',         # 30  Zn
618    '3s2p1d0f',         # 31  Ga
619    '3s2p1d0f',         # 32  Ge
620    '3s2p1d0f',         # 33  As
621    '3s2p1d0f',         # 34  Se
622    '3s2p1d0f',         # 35  Br
623    '3s2p1d0f',         # 36  Kr
624    '4s3p1d0f',         # 37  Rb
625    '4s3p1d0f',         # 38  Sr
626    '4s3p1d0f',         # 39  Y
627    '4s3p1d0f',         # 40  Zr
628    '4s3p1d0f',         # 41  Nb
629    '4s3p1d0f',         # 42  Mo
630    '4s3p1d0f',         # 43  Tc
631    '4s3p1d0f',         # 44  Ru
632    '4s3p1d0f',         # 45  Rh
633    '4s3p1d0f',         # 46  Pd
634    '4s3p1d0f',         # 47  Ag
635    '4s3p1d0f',         # 48  Cd
636    '4s3p2d0f',         # 49  In
637    '4s3p2d0f',         # 50  Sn
638    '4s3p2d0f',         # 51  Sb
639    '4s3p2d0f',         # 52  Te
640    '4s3p2d0f',         # 53  I
641    '4s3p2d0f',         # 54  Xe
642    '5s4p2d0f',         # 55  Cs
643    '5s4p2d0f',         # 56  Ba
644    '5s4p2d0f',         # 57  La
645    '5s4p2d0f',         # 58  Ce
646    '5s4p2d0f',         # 59  Pr
647    '5s4p2d0f',         # 60  Nd
648    '5s4p2d0f',         # 61  Pm
649    '5s4p2d0f',         # 62  Sm
650    '5s4p2d0f',         # 63  Eu
651    '5s4p2d0f',         # 64  Gd
652    '5s4p2d0f',         # 65  Tb
653    '5s4p2d0f',         # 66  Dy
654    '5s4p2d0f',         # 67  Ho
655    '5s4p2d0f',         # 68  Er
656    '5s4p2d0f',         # 69  Tm
657    '5s4p2d0f',         # 70  Yb
658    '5s4p2d1f',         # 71  Lu
659    '5s4p2d1f',         # 72  Hf
660    '5s4p2d1f',         # 73  Ta
661    '5s4p2d1f',         # 74  W
662    '5s4p2d1f',         # 75  Re
663    '5s4p2d1f',         # 76  Os
664    '5s4p2d1f',         # 77  Ir
665    '5s4p2d1f',         # 78  Pt
666    '5s4p2d1f',         # 79  Au
667    '5s4p2d1f',         # 80  Hg
668    '5s4p3d1f',         # 81  Tl
669    '5s4p3d1f',         # 82  Pb
670    '5s4p3d1f',         # 83  Bi
671    '5s4p3d1f',         # 84  Po
672    '5s4p3d1f',         # 85  At
673    '5s4p3d1f',         # 86  Rn
674    '6s5p3d1f',         # 87  Fr
675    '6s5p3d1f',         # 88  Ra
676    '6s5p3d1f',         # 89  Ac
677    '6s5p3d1f',         # 90  Th
678    '6s5p3d1f',         # 91  Pa
679    '6s5p3d1f',         # 92  U
680    '6s5p3d1f',         # 93  Np
681    '6s5p3d1f',         # 94  Pu
682    '6s5p3d1f',         # 95  Am
683    '6s5p3d1f',         # 96  Cm
684    '6s5p3d1f',         # 97  Bk
685    '6s5p3d1f',         # 98  Cf
686    '6s5p3d1f',         # 99  Es
687    '6s5p3d1f',         #100  Fm
688    '6s5p3d1f',         #101  Md
689    '6s5p3d1f',         #102  No
690    '6s5p3d2f',         #103  Lr
691    '6s5p3d2f',         #104  Rf
692    '6s5p3d2f',         #105  Db
693    '6s5p3d2f',         #106  Sg
694    '6s5p3d2f',         #107  Bh
695    '6s5p3d2f',         #108  Hs
696    '6s5p3d2f',         #109  Mt
697    '6s5p3d2f',         #110  Ds
698    '6s5p3d2f',         #111  Rg
699    '6s5p3d2f',         #112  Cn
700    '6s5p4d2f',         #113  Nh
701    '6s5p4d2f',         #114  Fl
702    '6s5p4d2f',         #115  Mc
703    '6s5p4d2f',         #116  Lv
704    '6s3p4d2f',         #117  Ts
705    '6s3p4d2f',         #118  Og
706]
707
708
709N_CORE_VALENCE_SHELLS = [
710    '0s0p0d0f',         #  0  GHOST
711    '1s0p0d0f',         #  1  H
712    '1s0p0d0f',         #  2  He
713    '2s0p0d0f',         #  3  Li
714    '2s0p0d0f',         #  4  Be
715    '2s1p0d0f',         #  5  B
716    '2s1p0d0f',         #  6  C
717    '2s1p0d0f',         #  7  N
718    '2s1p0d0f',         #  8  O
719    '2s1p0d0f',         #  9  F
720    '2s1p0d0f',         # 10  Ne
721    '3s1p0d0f',         # 11  Na
722    '3s1p0d0f',         # 12  Mg
723    '3s2p0d0f',         # 13  Al
724    '3s2p0d0f',         # 14  Si
725    '3s2p0d0f',         # 15  P
726    '3s2p0d0f',         # 16  S
727    '3s2p0d0f',         # 17  Cl
728    '3s2p0d0f',         # 18  Ar
729    '4s2p0d0f',         # 19  K
730    '4s2p0d0f',         # 20  Ca
731    '4s2p1d0f',         # 21  Sc
732    '4s2p1d0f',         # 22  Ti
733    '4s2p1d0f',         # 23  V
734    '4s2p1d0f',         # 24  Cr
735    '4s2p1d0f',         # 25  Mn
736    '4s2p1d0f',         # 26  Fe
737    '4s2p1d0f',         # 27  Co
738    '4s2p1d0f',         # 28  Ni
739    '4s2p1d0f',         # 29  Cu
740    '4s2p1d0f',         # 30  Zn
741    '4s3p1d0f',         # 31  Ga
742    '4s3p1d0f',         # 32  Ge
743    '4s3p1d0f',         # 33  As
744    '4s3p1d0f',         # 34  Se
745    '4s3p1d0f',         # 35  Br
746    '4s3p1d0f',         # 36  Kr
747    '5s3p1d0f',         # 37  Rb
748    '5s3p1d0f',         # 38  Sr
749    '5s3p2d0f',         # 39  Y
750    '5s3p2d0f',         # 40  Zr
751    '5s3p2d0f',         # 41  Nb
752    '5s3p2d0f',         # 42  Mo
753    '5s3p2d0f',         # 43  Tc
754    '5s3p2d0f',         # 44  Ru
755    '5s3p2d0f',         # 45  Rh
756    '4s3p2d0f',         # 46  Pd
757    '5s3p2d0f',         # 47  Ag
758    '5s3p2d0f',         # 48  Cd
759    '5s4p2d0f',         # 49  In
760    '5s4p2d0f',         # 50  Sn
761    '5s4p2d0f',         # 51  Sb
762    '5s4p2d0f',         # 52  Te
763    '5s4p2d0f',         # 53  I
764    '5s4p2d0f',         # 54  Xe
765    '6s4p2d0f',         # 55  Cs
766    '6s4p2d0f',         # 56  Ba
767    '6s4p3d0f',         # 57  La
768    '6s4p3d1f',         # 58  Ce
769    '6s4p2d1f',         # 59  Pr
770    '6s4p2d1f',         # 60  Nd
771    '6s4p2d1f',         # 61  Pm
772    '6s4p2d1f',         # 62  Sm
773    '6s4p2d1f',         # 63  Eu
774    '6s4p3d1f',         # 64  Gd
775    '6s4p3d1f',         # 65  Tb
776    '6s4p2d1f',         # 66  Dy
777    '6s4p2d1f',         # 67  Ho
778    '6s4p2d1f',         # 68  Er
779    '6s4p2d1f',         # 69  Tm
780    '6s4p2d1f',         # 70  Yb
781    '6s4p3d1f',         # 71  Lu
782    '6s4p3d1f',         # 72  Hf
783    '6s4p3d1f',         # 73  Ta
784    '6s4p3d1f',         # 74  W
785    '6s4p3d1f',         # 75  Re
786    '6s4p3d1f',         # 76  Os
787    '6s4p3d1f',         # 77  Ir
788    '6s4p3d1f',         # 78  Pt
789    '6s4p3d1f',         # 79  Au
790    '6s4p3d1f',         # 80  Hg
791    '6s5p3d1f',         # 81  Tl
792    '6s5p3d1f',         # 82  Pb
793    '6s5p3d1f',         # 83  Bi
794    '6s5p3d1f',         # 84  Po
795    '6s5p3d1f',         # 85  At
796    '6s5p3d1f',         # 86  Rn
797    '7s5p3d1f',         # 87  Fr
798    '7s5p3d1f',         # 88  Ra
799    '7s5p4d1f',         # 89  Ac
800    '7s5p4d1f',         # 90  Th
801    '7s5p4d2f',         # 91  Pa
802    '7s5p4d2f',         # 92  U
803    '7s5p4d2f',         # 93  Np
804    '7s5p3d2f',         # 94  Pu
805    '7s5p3d2f',         # 95  Am
806    '7s5p4d2f',         # 96  Cm
807    '7s5p4d2f',         # 97  Bk
808    '7s5p3d2f',         # 98  Cf
809    '7s5p3d2f',         # 99  Es
810    '7s5p3d2f',         #100  Fm
811    '7s5p3d2f',         #101  Md
812    '7s5p3d2f',         #102  No
813    '7s5p4d2f',         #103  Lr
814    '7s5p4d2f',         #104  Rf
815    '7s5p4d2f',         #105  Db
816    '7s5p4d2f',         #106  Sg
817    '7s5p4d2f',         #107  Bh
818    '7s5p4d2f',         #108  Hs
819    '7s5p4d2f',         #109  Mt
820    '7s5p4d2f',         #110  Ds
821    '7s5p4d2f',         #111  Rg
822    '7s5p4d2f',         #112  Cn
823    '7s6p4d2f',         #113  Nh
824    '7s6p4d2f',         #114  Fl
825    '7s6p4d2f',         #115  Mc
826    '7s6p4d2f',         #116  Lv
827    '7s6p4d2f',         #117  Ts
828    '7s6p4d2f',         #118  Og
829]
830
831
832########################################
833#
834# Some functions to format atomic symbol
835#
836########################################
837
838# For code compatiblity in python-2 and python-3
839import sys
840if sys.version_info >= (3,):
841    unicode = str
842del(sys)
843
844def _rm_digit(symb):
845    if symb.isalpha():
846        return symb
847    else:
848        return ''.join([i for i in symb if i.isalpha()])
849
850_ELEMENTS_UPPER = dict((x.upper(),x) for x in ELEMENTS)
851_ELEMENTS_UPPER['GHOST'] = 'Ghost'
852
853def charge(symb_or_chg):
854    if isinstance(symb_or_chg, (str, unicode)):
855        a = str(symb_or_chg.strip().upper())
856        if (a[:5] == 'GHOST' or (a[0] == 'X' and a[:2] != 'XE')):
857            return 0
858        else:
859            return ELEMENTS_PROTON[_rm_digit(a)]
860    else:
861        return symb_or_chg
862
863def _symbol(symb_or_chg):
864    if isinstance(symb_or_chg, (str, unicode)):
865        return str(symb_or_chg)
866    else:
867        return ELEMENTS[symb_or_chg]
868
869def _std_symbol(symb_or_chg):
870    '''For a given atom symbol (lower case or upper case) or charge, return the
871    standardized atom symbol (without the numeric prefix or suffix)
872    '''
873    if isinstance(symb_or_chg, (str, unicode)):
874        symb_or_chg = str(symb_or_chg.upper())
875        rawsymb = _rm_digit(symb_or_chg)
876        if rawsymb in _ELEMENTS_UPPER:
877            return _ELEMENTS_UPPER[rawsymb]
878        elif len(rawsymb) > 1 and symb_or_chg[0] == 'X' and symb_or_chg[:2] != 'XE':
879            rawsymb = rawsymb[1:]  # Remove the prefix X
880            return 'X-' + _ELEMENTS_UPPER[rawsymb]
881        elif len(rawsymb) > 5 and rawsymb[:5] == 'GHOST':
882            rawsymb = rawsymb[5:]  # Remove the prefix GHOST
883            return 'GHOST-' + _ELEMENTS_UPPER[rawsymb]
884        else:
885            raise RuntimeError('Unsupported atom symbol %s' % symb_or_chg)
886    else:
887        return ELEMENTS[symb_or_chg]
888
889def _std_symbol_without_ghost(symb_or_chg):
890    '''For a given atom symbol (lower case or upper case) or charge, return the
891    standardized atom symbol
892    '''
893    if isinstance(symb_or_chg, (str, unicode)):
894        symb_or_chg = str(symb_or_chg.upper())
895        rawsymb = _rm_digit(symb_or_chg)
896        if rawsymb in _ELEMENTS_UPPER:
897            return _ELEMENTS_UPPER[rawsymb]
898        elif len(rawsymb) > 1 and symb_or_chg[0] == 'X' and symb_or_chg[:2] != 'XE':
899            rawsymb = rawsymb[1:]  # Remove the prefix X
900            return _ELEMENTS_UPPER[rawsymb]
901        elif len(rawsymb) > 5 and rawsymb[:5] == 'GHOST':
902            rawsymb = rawsymb[5:]  # Remove the prefix GHOST
903            return _ELEMENTS_UPPER[rawsymb]
904        else:
905            raise RuntimeError('Unsupported atom symbol %s' % symb_or_chg)
906    else:
907        return ELEMENTS[symb_or_chg]
908
909def _atom_symbol(symb_or_chg):
910    '''For a given atom symbol (lower case or upper case) or charge, return the
911    standardized atom symbol (with the numeric prefix or suffix)
912    '''
913    if isinstance(symb_or_chg, (str, unicode)):
914        a = str(symb_or_chg.strip().upper())
915        if a.isdigit():
916            symb = ELEMENTS[int(a)]
917        else:
918            rawsymb = _rm_digit(a)
919            if rawsymb not in _ELEMENTS_UPPER:  # likely a ghost atom
920                if len(rawsymb) > 1 and a[0] == 'X' and a[:2] != 'XE':
921                    rawsymb = rawsymb[1:]  # Remove the prefix X
922                    # put hyphen between X prefix and the atomic symbol
923                    if a[1].isalpha():
924                        a = a[0] + '-' + a[1:]
925                    else:
926                        a = a[0] + '-' + a[2:]
927                elif len(rawsymb) > 5 and rawsymb[:5] == 'GHOST':
928                    rawsymb = rawsymb[5:]  # Remove the prefix GHOST
929                    # put hyphen between Ghost prefix and the atomic symbol
930                    if a[5].isalpha():
931                        a = a[:5] + '-' + a[5:]
932                    elif a[5] != '-':
933                        a = a[:5] + '-' + a[6:]
934                else:
935                    raise RuntimeError('Unsupported atom symbol %s' % a)
936            stdsymb = _ELEMENTS_UPPER[rawsymb]
937            symb = a.replace(rawsymb, stdsymb)
938    else:
939        symb = ELEMENTS[symb_or_chg]
940    return symb
941
942def is_ghost_atom(symb_or_chg):
943    if isinstance(symb_or_chg, (int, numpy.integer)):
944        return symb_or_chg == 0
945    elif 'GHOST' in symb_or_chg.upper():
946        return True
947    else:
948        return symb_or_chg[0] == 'X' and symb_or_chg[:2].upper() != 'XE'
949
950