#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Create energy tables for periodic table elements ; sqlite3 database
"""

# data from NIST :
# J.E. Sansonetti, W.C. Martin, and S.L. Young (2013),
# Handbook of Basic Atomic Spectroscopic Data (version 1.1.3)
from scipy import constants
from mypython.database.table.shared_tool import connection
from mypython.database.table.shared_tool import reset_all
from mypython.database.table.shared_tool import init_all
from mypython.database.table.shared_tool import store_all
from mypython.database.table.shared_tool import cursor
from mypython.utility.order import ordered_unique_list


ryd=2*constants.Rydberg/100

class EnergyData(object):
    def __init__(self):
        self.classname="""energy"""
        self.values={}
        self.kind={}
        name="label"
        (self.values[name],self.kind[name])=(None,"VARCHAR(3)")
        name="charge"
        (self.values[name],self.kind[name])=(None,"INTEGER")
        name="energy"
        (self.values[name],self.kind[name])=(None,"REAL")
        name="method"
        (self.values[name],self.kind[name])=(None,"VARCHAR(10)")
        name="ionization"
        (self.values[name],self.kind[name])=(None,"REAL")
        name="configuration"
        (self.values[name],self.kind[name])=(None,"VARCHAR(30)")
        name="totalSpin"
        (self.values[name],self.kind[name])=(None,"INTEGER")
        name="totalOrbital"
        (self.values[name],self.kind[name])=(None,"INTEGER")
        name="totalJ"
        (self.values[name],self.kind[name])=(None,"INTEGER")

    def reset(self):
        global ion
        ion=None
        for keys in self.values:
            self.values[keys]=None

def add_representation(table_input):
    # compute center of gravity of J-lines
    if(table_input[0][4]>=0):
        output=list(table_input)
        config=[]
        for val in table_input:
            key = [val[1],val[2],val[3]]
            config.append(key)
        ordered_config = ordered_unique_list(config)
        for valkey in ordered_config:
            total=0.
            average=0.
            key = [valkey[0],valkey[1],valkey[2]]
            for val in table_input:
                if([val[1],val[2],val[3]] == key):
                    total+=val[4]+1
                    average+=val[0]*(val[4]+1)
            if(total==0.): continue
            average=average/total
            output.append([average,valkey[0],valkey[1],valkey[2],-2])
        return output
#   try to add all possible J-lines assuming zero SO coupling
    else:
        output=list(table_input)
        for val in table_input:
            i_min=abs(val[3]-val[2])
            i_max=val[3]+val[2]+2
            for j in range(i_min,i_max,2):
                output.append([val[0],val[1],val[2],val[3],j])
        return output

def copy_method():
    elements=["Be","Sr","Ba"]
    for name in elements:
        cursor.execute("""SELECT label,charge,energy,method,ionization,configuration,totalSpin,totalOrbital,totalJ
               FROM energy WHERE label = ? AND method = ?
               """,(name,"cipsi"))
        result = cursor.fetchall()
        for val in result:
            val_list = list(val)
            val_list[3] = 'cipsi-nof'
            cursor.execute("""INSERT INTO energy (label,charge,energy,method,ionization,configuration,totalSpin,totalOrbital,totalJ)
                  VALUES (?,?,?,?,?,?,?,?,?)
               """,(val_list))

    elements=["Li","Na","K","Rb","Cs"]
    for name in elements:
        cursor.execute("""SELECT label,charge,energy,method,ionization,configuration,totalSpin,totalOrbital,totalJ
               FROM energy WHERE label = ? AND method = ? AND charge= ?
               """,(name,"cipsi",1))
        result = cursor.fetchall()
        for val in result:
            val_list = list(val)
            val_list[3] = 'cipsi-nof'
            cursor.execute("""INSERT INTO energy (label,charge,energy,method,ionization,configuration,totalSpin,totalOrbital,totalJ)
                  VALUES (?,?,?,?,?,?,?,?,?)
               """,(val_list))

    elements=["Ca"]
    for name in elements:
        cursor.execute("""SELECT label,charge,energy,method,ionization,configuration,totalSpin,totalOrbital,totalJ
               FROM energy WHERE label = ? AND method = ? AND charge= ?
               """,(name,"cipsi",2))
        result = cursor.fetchall()
        for val in result:
            val_list = list(val)
            val_list[3] = 'cipsi-nof'
            cursor.execute("""INSERT INTO energy (label,charge,energy,method,ionization,configuration,totalSpin,totalOrbital,totalJ)
                  VALUES (?,?,?,?,?,?,?,?,?)
               """,(val_list))

database=[]
ion=[]
energy=EnergyData()

database.append(energy)

init_all(database)
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Hydrogen 1
reset_all(database)
energy.values["label"]="H"
ion=[109678.7717]
energy.values["charge"]=0
energy.values["method"]="nist"
energy.values["ionization"]=ion[0]
ener=[]
ener.append([0.0,"1s",1,0,1])
ener.append([82259.2850,"2p",1,2,3])
ener.append([82258.9191,"2p",1,2,1])
ener.append([82258.9544,"2s",1,0,1])
ener.append([97492.2112,"3p",1,2,1])
ener.append([97492.3196,"3p",1,2,3])
ener.append([97492.2217,"3s",1,0,1])
ener.append([97492.3195,"3d",1,4,3])
ener.append([97492.3556,"3d",1,4,5])
ener.append([102823.8486,"4p",1,2,1])
ener.append([102823.8943,"4p",1,2,3])
ener.append([102823.8530,"4s",1,0,1])
ener.append([102823.8942,"4d",1,4,3])
ener.append([102823.9095,"4d",1,4,5])
ener.append([102823.9095,"4f",1,6,5])
ener.append([102823.9171,"4f",1,6,7])
ener.append([105291.6287,"5p",1,2,1])
ener.append([105291.6521,"5p",1,2,3])
ener.append([105291.6309,"5s",1,0,1])
ener.append([105291.6520,"5d",1,4,3])
ener.append([105291.6599,"5d",1,4,5])
ener.append([105291.6598,"5f",1,6,5])
ener.append([105291.6637,"5f",1,6,7])
ener.append([105291.6637,"5g",1,8,7])
ener.append([105291.6661,"5g",1,8,9])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Helium 2
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Lithium 3
reset_all(database)
energy.values["label"]="Li"
ion=[43487.150,610078.]
energy.values["charge"]=0
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([-0.198142289321,"2s",1,0,-2])
ener.append([-0.130235293968,"2p",1,2,-2])
ener.append([-0.074150426059,"3s",1,0,-2])
ener.append([-0.057232490963,"3p",1,2,-2])
ener.append([-0.055541278003,"3d",1,4,-2])
ener.append([-0.030940673018,"4s",1,0,-2])
ener.append([-0.029703272593,"4p",1,2,-2])
ener.append([-0.027954010106,"4f",1,6,-2])
ener.append([-0.021607421107,"4d",1,4,-2])
ener.append([0.013595302951,"5p",1,2,-2])
ener.append([0.066621184718,"5s",1,0,-2])
ener.append([0.102039173595,"5d",1,4,-2])
ener.append([0.142070786686,"6p",1,2,-2])
ener.append([0.469264339871,"6s",1,0,-2])
ener.append([0.518068666392,"6d",1,4,-2])
ener.append([0.532881207368,"7p",1,2,-2])
ener.append([1.64315034277,"8p",1,2,-2])
ener.append([2.23032389901,"7s",1,0,-2])
ener.append([8.31920967215,"8s",1,0,-2])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["method"]="cipsi-nof"
energy.values["ionization"]=None
ener=[]
ener.append([-0.198142289294,"2s",1,0,-2])
ener.append([-0.130235294009,"2p",1,2,-2])
ener.append([-0.074150426049,"3s",1,0,-2])
ener.append([-0.057232490995,"3p",1,2,-2])
ener.append([-0.055541277992,"3d",1,4,-2])
ener.append([-0.03094067305,"4s",1,0,-2])
ener.append([-0.029703272599,"4p",1,2,-2])
ener.append([-0.021607421082,"4d",1,4,-2])
ener.append([0.013595302954,"5p",1,2,-2])
ener.append([0.066621184738,"5s",1,0,-2])
ener.append([0.102039173626,"5d",1,4,-2])
ener.append([0.142070786655,"6p",1,2,-2])
ener.append([0.469264339825,"6s",1,0,-2])
ener.append([0.518068666392,"6d",1,4,-2])
ener.append([0.532881207383,"7p",1,2,-2])
ener.append([1.64315034279,"8p",1,2,-2])
ener.append([2.23032389901,"7s",1,0,-2])
ener.append([8.31920967219,"8s",1,0,-2])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=0
energy.values["method"]="nist"
energy.values["ionization"]=ion[0]
ener=[]
ener.append([0.0,"2s",1,0,1])
ener.append([42118.27,"9p",1,2,3])
ener.append([42118.27,"9p",1,2,1])
ener.append([41751.63,"8p",1,2,3])
ener.append([41751.63,"8p",1,2,1])
ener.append([41217.35,"7p",1,2,1])
ener.append([41217.35,"7p",1,2,3])
ener.append([40390.84,"6p",1,2,3])
ener.append([40390.84,"6p",1,2,1])
ener.append([39015.56,"5p",1,2,3])
ener.append([39015.56,"5p",1,2,1])
ener.append([36469.55,"4p",1,2,1])
ener.append([36469.55,"4p",1,2,3])
ener.append([30925.38,"3p",1,2,3])
ener.append([30925.38,"3p",1,2,1])
ener.append([14903.66,"2p",1,2,1])
ener.append([42131.3,"9d",1,4,3])
ener.append([14904.0,"2p",1,2,3])
ener.append([42131.3,"9d",1,4,5])
ener.append([41771.3,"8d",1,4,3])
ener.append([41771.3,"8d",1,4,5])
ener.append([41587.1,"8s",1,0,1])
ener.append([41246.5,"7d",1,4,3])
ener.append([41246.5,"7d",1,4,5])
ener.append([40967.9,"7s",1,0,1])
ener.append([40437.31,"6d",1,4,3])
ener.append([40437.32,"6d",1,4,5])
ener.append([39987.64,"6s",1,0,1])
ener.append([39094.93,"5d",1,4,3])
ener.append([39094.94,"5d",1,4,5])
ener.append([38299.5,"5s",1,0,1])
ener.append([36623.38,"4d",1,4,3])
ener.append([36623.4,"4d",1,4,5])
ener.append([35012.06,"4s",1,0,1])
ener.append([31283.08,"3d",1,4,3])
ener.append([31283.12,"3d",1,4,5])
ener.append([27206.12,"3s",1,0,1])
ener.append([39104.5,"5f",1,6,5])
ener.append([39104.5,"5f",1,6,7])
ener.append([36630.2,"4f",1,6,7])
ener.append([36630.2,"4f",1,6,5])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=0
energy.values["method"]="nist-c"
energy.values["ionization"]=ion[0]
ener=[]
ener.append([0.0,"2s",1,0,1])
ener.append([42832.92,"13p",1,2,3])
ener.append([42832.92,"13p",1,2,1])
ener.append([42719.14,"12p",1,2,3])
ener.append([42719.14,"12p",1,2,1])
ener.append([42569.1,"11p",1,2,1])
ener.append([42569.1,"11p",1,2,3])
ener.append([42379.16,"10p",1,2,3])
ener.append([42379.16,"10p",1,2,1])
ener.append([27206.12,"3s",1,0,1])
ener.append([41751.63,"8p",1,2,1])
ener.append([41751.63,"8p",1,2,3])
ener.append([41217.35,"7p",1,2,1])
ener.append([41217.35,"7p",1,2,3])
ener.append([40390.84,"6p",1,2,3])
ener.append([40390.84,"6p",1,2,1])
ener.append([39015.56,"5p",1,2,1])
ener.append([39015.56,"5p",1,2,3])
ener.append([30925.38,"3p",1,2,1])
ener.append([41587.1,"8s",1,0,1])
ener.append([30925.38,"3p",1,2,3])
ener.append([31283.08,"3d",1,4,3])
ener.append([31283.12,"3d",1,4,5])
ener.append([40967.9,"7s",1,0,1])
ener.append([35012.06,"4s",1,0,1])
ener.append([36630.2,"4f",1,6,5])
ener.append([40437.32,"6d",1,4,5])
ener.append([40437.31,"6d",1,4,3])
ener.append([36630.2,"4f",1,6,7])
ener.append([38299.5,"5s",1,0,1])
ener.append([36623.38,"4d",1,4,3])
ener.append([39104.5,"5f",1,6,5])
ener.append([36623.4,"4d",1,4,5])
ener.append([39104.5,"5f",1,6,7])
ener.append([39094.94,"5d",1,4,5])
ener.append([39094.93,"5d",1,4,3])
ener.append([41246.5,"7d",1,4,3])
ener.append([41246.5,"7d",1,4,5])
ener.append([41771.3,"8d",1,4,3])
ener.append([41771.3,"8d",1,4,5])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([0.0,"1s2",0,0,0])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="nist"
energy.values["ionization"]=ion[1]
ener=[]
ener.append([0.0,"1s2",0,0,0])
ener.append([600998.0,"1s.7p",0,2,2])
ener.append([597836.0,"1s.6p",0,2,2])
ener.append([592634.91,"1s.5p",0,2,2])
ener.append([582830.11,"1s.4p",0,2,2])
ener.append([561752.82,"1s.3p",0,2,2])
ener.append([501808.59,"1s.2p",0,2,2])
ener.append([476034.98,"1s.2s",2,0,2])
ener.append([597663.4,"1s.6p",2,2,4])
ener.append([597662.73,"1s.6p",2,2,2])
ener.append([597662.35,"1s.6p",2,2,0])
ener.append([592134.7,"1s.5p",2,2,4])
ener.append([592134.03,"1s.5p",2,2,2])
ener.append([592133.65,"1s.5p",2,2,0])
ener.append([491374.6,"1s.2s",0,0,0])
ener.append([494261.17,"1s.2p",2,2,2])
ener.append([601114.45,"1s.7d",2,4,4])
ener.append([601114.06,"1s.7d",2,4,2])
ener.append([494263.44,"1s.2p",2,2,4])
ener.append([601115.11,"1s.7d",2,4,6])
ener.append([494266.57,"1s.2p",2,2,0])
ener.append([600643.9,"1s.7s",2,0,2])
ener.append([581886.7,"1s.4p",2,2,4])
ener.append([581885.98,"1s.4p",2,2,2])
ener.append([581885.58,"1s.4p",2,2,0])
ener.append([597875.94,"1s.6d",2,4,4])
ener.append([597875.55,"1s.6d",2,4,2])
ener.append([597876.6,"1s.6d",2,4,6])
ener.append([597121.95,"1s.6s",2,0,2])
ener.append([601119.02,"1s.7d",0,4,4])
ener.append([600930.0,"1s.7s",0,0,0])
ener.append([592514.43,"1s.5d",0,4,4])
ener.append([592504.09,"1s.5d",2,4,4])
ener.append([592503.7,"1s.5d",2,4,2])
ener.append([592504.75,"1s.5d",2,4,6])
ener.append([591184.26,"1s.5s",2,0,2])
ener.append([597882.52,"1s.6d",0,4,4])
ener.append([597580.53,"1s.6s",0,0,0])
ener.append([591989.55,"1s.5s",0,0,0])
ener.append([582613.41,"1s.4d",2,4,4])
ener.append([582613.02,"1s.4d",2,4,2])
ener.append([582614.07,"1s.4d",2,4,6])
ener.append([579981.33,"1s.4s",2,0,2])
ener.append([559502.32,"1s.3p",2,2,0])
ener.append([559501.42,"1s.3p",2,2,4])
ener.append([559500.35,"1s.3p",2,2,2])
ener.append([582630.95,"1s.4d",0,4,4])
ener.append([581596.77,"1s.4s",0,0,0])
ener.append([561273.62,"1s.3d",0,4,4])
ener.append([561244.3,"1s.3d",2,4,2])
ener.append([561243.15,"1s.3d",2,4,4])
ener.append([561243.77,"1s.3d",2,4,6])
ener.append([554754.45,"1s.3s",2,0,2])
ener.append([558777.88,"1s.3s",0,0,0])
ener.append([601121.55,"1s.7f",0,6,6])
ener.append([601120.4,"1s.7f",2,6,4])
ener.append([601120.4,"1s.7f",2,6,6])
ener.append([601120.4,"1s.7f",2,6,8])
ener.append([597886.48,"1s.6f",0,6,6])
ener.append([597885.43,"1s.6f",2,6,6])
ener.append([597885.43,"1s.6f",2,6,4])
ener.append([597885.43,"1s.6f",2,6,8])
ener.append([592521.11,"1s.5f",0,6,6])
ener.append([592520.11,"1s.5f",2,6,6])
ener.append([592520.11,"1s.5f",2,6,4])
ener.append([592520.11,"1s.5f",2,6,8])
ener.append([582644.04,"1s.4f",0,6,6])
ener.append([582642.97,"1s.4f",2,6,6])
ener.append([582642.97,"1s.4f",2,6,4])
ener.append([582642.97,"1s.4f",2,6,8])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Beryllium 4
reset_all(database)
energy.values["label"]="Be"
ion=[75192.64,146882.8]
energy.values["charge"]=0
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([-1.01325639187,"2s2",0,0,-2])
ener.append([-0.815333565009,"2s.2p",0,2,-2])
ener.append([-0.752641234326,"2p2",0,4,-2])
ener.append([-0.737005502336,"2s.3p",0,2,-2])
ener.append([-0.732200041982,"2s.3s",0,0,-2])
ener.append([-0.717367129921,"2s.3d",0,4,-2])
ener.append([-0.70564001848,"2s.4p",0,2,-2])
ener.append([-0.694232799456,"2s.4d",0,4,-2])
ener.append([-0.91324893518,"2s.2p",2,2,-2])
ener.append([-0.757791408087,"2s.3s",2,0,-2])
ener.append([-0.74338926252,"2s.3p",2,2,-2])
ener.append([-0.739655100816,"2p2",2,2,-2])
ener.append([-0.727536954227,"2s.3d",2,4,-2])
ener.append([-0.706997201851,"2s.4p",2,2,-2])
ener.append([-0.700058485037,"2s.4d",2,4,-2])
ener.append([-0.675152845211,"2s.5p",2,2,-2])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=0
energy.values["method"]="nist"
energy.values["ionization"]=ion[0]
ener=[]
ener.append([0.0,"2s2",0,0,0])
ener.append([60187.34,"2s.3p",0,2,2])
ener.append([42565.35,"2s.2p",0,2,2])
ener.append([21978.28,"2s.2p",2,2,0])
ener.append([62053.72,"2s.3d",2,4,2])
ener.append([21978.925,"2s.2p",2,2,2])
ener.append([62053.72,"2s.3d",2,4,4])
ener.append([21981.27,"2s.2p",2,2,4])
ener.append([62053.72,"2s.3d",2,4,6])
ener.append([59697.08,"2p2",2,2,4])
ener.append([59695.07,"2p2",2,2,2])
ener.append([59693.65,"2p2",2,2,0])
ener.append([72931.6,"2s.7f",2,6,6])
ener.append([72931.6,"2s.7f",2,6,4])
ener.append([68241.02,"2s.4f",2,6,6])
ener.append([68241.02,"2s.4f",2,6,4])
ener.append([66811.88,"2s.4p",2,2,4])
ener.append([66811.88,"2s.4p",2,2,2])
ener.append([66811.88,"2s.4p",2,2,0])
ener.append([64428.31,"2s.3d",0,4,4])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0]-ion[1])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=0
energy.values["method"]="nist-c"
ener=[]
ener.append([0.0,"2s2",0,0,0])
ener.append([73709.4,"2s.9p",0,2,2])
ener.append([73309.7,"2s.8p",0,2,2])
ener.append([72701.8,"2s.7p",0,2,2])
ener.append([71746.09,"2s.6p",0,2,2])
ener.append([70120.49,"2s.5p",0,2,2])
ener.append([21978.28,"2s.2p",2,2,0])
ener.append([73802.6,"2s.9d",2,4,2])
ener.append([21978.925,"2s.2p",2,2,2])
ener.append([73802.6,"2s.9d",2,4,4])
ener.append([21981.27,"2s.2p",2,2,4])
ener.append([73802.6,"2s.9d",2,4,6])
ener.append([73429.33,"2s.8d",2,4,2])
ener.append([73429.33,"2s.8d",2,4,4])
ener.append([73429.33,"2s.8d",2,4,6])
ener.append([73088.5,"2s.8s",2,0,2])
ener.append([72880.9,"2s.7d",2,4,2])
ener.append([72880.9,"2s.7d",2,4,4])
ener.append([72880.9,"2s.7d",2,4,6])
ener.append([72354.7,"2s.7s",2,0,2])
ener.append([72029.5,"2s.6d",2,4,2])
ener.append([72029.5,"2s.6d",2,4,4])
ener.append([72029.5,"2s.6d",2,4,6])
ener.append([71160.52,"2s.6s",2,0,2])
ener.append([70603.76,"2s.5d",2,4,2])
ener.append([70603.76,"2s.5d",2,4,4])
ener.append([70603.76,"2s.5d",2,4,6])
ener.append([69010.2,"2s.5s",2,0,2])
ener.append([67941.66,"2s.4d",2,4,2])
ener.append([67941.66,"2s.4d",2,4,4])
ener.append([67941.66,"2s.4d",2,4,6])
ener.append([64506.45,"2s.4s",2,0,2])
ener.append([42565.35,"2s.2p",0,2,2])
ener.append([73866.67,"2s.9d",0,4,4])
ener.append([73608.5,"2s.9s",0,0,0])
ener.append([73519.81,"2s.8d",0,4,4])
ener.append([73146.57,"2s.8s",0,0,0])
ener.append([73017.42,"2s.7d",0,4,4])
ener.append([52080.94,"2s.3s",2,0,2])
ener.append([72448.28,"2s.7s",0,0,0])
ener.append([72251.27,"2s.6d",0,4,4])
ener.append([71321.15,"2s.6s",0,0,0])
ener.append([71002.34,"2s.5d",0,4,4])
ener.append([69322.2,"2s.5s",0,0,0])
ener.append([68780.86,"2s.4d",0,4,4])
ener.append([65245.33,"2s.4s",0,0,0])
ener.append([64428.31,"2s.3d",0,4,4])
ener.append([54677.26,"2s.3s",0,0,0])
ener.append([56882.43,"2p2",0,4,4])
ener.append([72931.65,"2s.7f",0,6,6])
ener.append([72111.62,"2s.6f",0,6,6])
ener.append([58907.45,"2s.3p",2,2,2])
ener.append([58907.45,"2s.3p",2,2,0])
ener.append([58907.83,"2s.3p",2,2,4])
ener.append([70749.9,"2s.5f",0,6,6])
ener.append([70749.72,"2s.5f",2,6,6])
ener.append([60187.34,"2s.3p",0,2,2])
ener.append([67034.7,"2s.4p",0,2,2])
ener.append([68241.18,"2s.4f",0,6,6])
ener.append([62053.72,"2s.3d",2,4,4])
ener.append([62053.72,"2s.3d",2,4,2])
ener.append([73309.15,"2s.8p",2,2,4])
ener.append([62053.72,"2s.3d",2,4,6])
ener.append([73309.15,"2s.8p",2,2,0])
ener.append([73309.15,"2s.8p",2,2,2])
ener.append([72697.32,"2s.7p",2,2,0])
ener.append([72697.32,"2s.7p",2,2,2])
ener.append([72697.32,"2s.7p",2,2,4])
ener.append([72111.55,"2s.6f",2,6,4])
ener.append([72111.55,"2s.6f",2,6,6])
ener.append([71730.62,"2s.6p",2,2,2])
ener.append([71730.62,"2s.6p",2,2,0])
ener.append([71730.62,"2s.6p",2,2,4])
ener.append([70749.72,"2s.5f",2,6,4])
ener.append([70065.4,"2s.5p",2,2,2])
ener.append([70065.4,"2s.5p",2,2,4])
ener.append([70065.4,"2s.5p",2,2,0])
ener.append([66811.88,"2s.4p",2,2,0])
ener.append([66811.88,"2s.4p",2,2,2])
ener.append([66811.88,"2s.4p",2,2,4])
ener.append([68241.02,"2s.4f",2,6,4])
ener.append([68241.02,"2s.4f",2,6,6])
ener.append([72931.6,"2s.7f",2,6,6])
ener.append([72931.6,"2s.7f",2,6,4])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0]-ion[1])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([-0.669247973312,"2s",1,0,-2])
ener.append([-0.523750055823,"2p",1,2,-2])
ener.append([-0.266772778555,"3s",1,0,-2])
ener.append([-0.229423387731,"3p",1,2,-2])
ener.append([-0.222451803011,"3d",1,4,-2])
ener.append([-0.128020159478,"4p",1,2,-2])
ener.append([-0.125096434193,"4d",1,4,-2])
ener.append([-0.081491844469,"5p",1,2,-2])
ener.append([-0.079872296711,"5d",1,4,-2])
ener.append([-0.044364028359,"6d",1,4,-2])
ener.append([-0.039773212306,"6p",1,2,-2])
ener.append([0.040402309538,"7d",1,4,-2])
ener.append([0.152677462775,"7p",1,2,-2])
ener.append([0.243659209818,"8d",1,4,-2])
ener.append([0.297452799006,"4s",1,0,-2])
ener.append([0.750840570804,"9d",1,4,-2])
ener.append([1.05828814927,"8p",1,2,-2])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="nist"
energy.values["ionization"]=ion[1]
ener=[]
ener.append([0.0,"2s",1,0,1])
ener.append([141403.24,"9p",1,2,1])
ener.append([141403.31,"9p",1,2,3])
ener.append([139938.18,"8p",1,2,3])
ener.append([139938.08,"8p",1,2,1])
ener.append([137796.12,"7p",1,2,3])
ener.append([137795.97,"7p",1,2,1])
ener.append([134485.61,"6p",1,2,3])
ener.append([134485.37,"6p",1,2,1])
ener.append([128972.05,"5p",1,2,3])
ener.append([128971.62,"5p",1,2,1])
ener.append([118761.32,"4p",1,2,3])
ener.append([118760.51,"4p",1,2,1])
ener.append([31928.744,"2p",1,2,1])
ener.append([141461.15,"9d",1,4,3])
ener.append([31935.32,"2p",1,2,3])
ener.append([141461.15,"9d",1,4,5])
ener.append([140020.58,"8d",1,4,3])
ener.append([140020.58,"8d",1,4,5])
ener.append([137919.17,"7d",1,4,3])
ener.append([137919.17,"7d",1,4,5])
ener.append([137218.78,"7s",1,0,1])
ener.append([134681.15,"6d",1,4,3])
ener.append([134681.15,"6d",1,4,5])
ener.append([133556.44,"6s",1,0,1])
ener.append([129310.13,"5d",1,4,3])
ener.append([129310.25,"5d",1,4,5])
ener.append([96497.288,"3p",1,2,3])
ener.append([96495.36,"3p",1,2,1])
ener.append([127335.12,"5s",1,0,1])
ener.append([119421.2,"4d",1,4,3])
ener.append([119421.44,"4d",1,4,5])
ener.append([115464.44,"4s",1,0,1])
ener.append([98054.57,"3d",1,4,3])
ener.append([98055.1,"3d",1,4,5])
ener.append([88231.915,"3s",1,0,1])
ener.append([141463.65,"9f",1,6,5])
ener.append([141463.65,"9f",1,6,7])
ener.append([140024.12,"8f",1,6,5])
ener.append([140024.12,"8f",1,6,7])
ener.append([137924.31,"7f",1,6,5])
ener.append([137924.31,"7f",1,6,7])
ener.append([134689.2,"6f",1,6,5])
ener.append([134689.23,"6f",1,6,7])
ener.append([129323.85,"5f",1,6,5])
ener.append([129323.92,"5f",1,6,7])
ener.append([119446.59,"4f",1,6,5])
ener.append([119446.72,"4f",1,6,7])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[1])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=2
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([0.,"1s2",0,0,0])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=2
energy.values["method"]="nist"
energy.values["ionization"]=None
ener=[]
ener.append([0.0,"1s2",0,0,0])
ener.append([1221135.0,"1s.7p",0,2,2])
ener.append([1213931.0,"1s.6p",0,2,2])
ener.append([1201894.0,"1s.5p",0,2,2])
ener.append([1179830.0,"1s.4p",0,2,2])
ener.append([1132390.0,"1s.3p",0,2,2])
ener.append([997454.0,"1s.2p",0,2,2])
ener.append([956502.0,"1s.2s",2,0,2])
ener.append([1201060.0,"1s.5p",2,2,0])
ener.append([1201060.0,"1s.5p",2,2,4])
ener.append([1201060.0,"1s.5p",2,2,2])
ener.append([981178.0,"1s.2s",0,0,0])
ener.append([1178174.0,"1s.4p",2,2,0])
ener.append([1178174.0,"1s.4p",2,2,4])
ener.append([1178174.0,"1s.4p",2,2,2])
ener.append([983355.0,"1s.2p",2,2,2])
ener.append([1201702.0,"1s.5d",2,4,4])
ener.append([1201702.0,"1s.5d",2,4,2])
ener.append([983366.0,"1s.2p",2,2,0])
ener.append([983370.0,"1s.2p",2,2,4])
ener.append([1201702.0,"1s.5d",2,4,6])
ener.append([1199650.0,"1s.5s",2,0,2])
ener.append([1201800.0,"1s.5d",0,4,4])
ener.append([1179451.0,"1s.4d",2,4,4])
ener.append([1179451.0,"1s.4d",2,4,2])
ener.append([1179451.0,"1s.4d",2,4,6])
ener.append([1175295.0,"1s.4s",2,0,2])
ener.append([1179495.0,"1s.4d",0,4,4])
ener.append([1178005.0,"1s.4s",0,0,0])
ener.append([1128300.0,"1s.3p",2,2,2])
ener.append([1128300.0,"1s.3p",2,2,4])
ener.append([1128300.0,"1s.3p",2,2,0])
ener.append([1131462.0,"1s.3d",0,4,4])
ener.append([1131383.0,"1s.3d",2,4,2])
ener.append([1131383.0,"1s.3d",2,4,4])
ener.append([1131383.0,"1s.3d",2,4,6])
ener.append([1121184.0,"1s.3s",2,0,2])
ener.append([1127705.0,"1s.3s",0,0,0])
ener.append([1221090.0,"1s.7f",2,6,6])
ener.append([1221090.0,"1s.7f",2,6,4])
ener.append([1221090.0,"1s.7f",2,6,8])
ener.append([1213815.0,"1s.6f",2,6,8])
ener.append([1213815.0,"1s.6f",2,6,4])
ener.append([1213815.0,"1s.6f",2,6,6])
ener.append([1213813.0,"1s.6f",0,6,6])
ener.append([1201730.0,"1s.5f",2,6,4])
ener.append([1201730.0,"1s.5f",2,6,6])
ener.append([1201730.0,"1s.5f",2,6,8])
ener.append([1201742.0,"1s.5f",0,6,6])
ener.append([1179515.0,"1s.4f",2,6,4])
ener.append([1179515.0,"1s.4f",2,6,6])
ener.append([1179515.0,"1s.4f",2,6,8])
ener.append([1179514.0,"1s.4f",0,6,6])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=2
energy.values["method"]="nist-c"
energy.values["ionization"]=None
ener=[]
ener.append([1131462.0,"1s.3d",0,4,4])
ener.append([1132390.0,"1s.3p",0,2,2])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Boron 5
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Carbon 6
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Nitrogen 7
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Oxygen 8
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Fluorine 9
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Neon 10
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Sodium 11
reset_all(database)
energy.values["label"]="Na"
ion=[41449.451,381390.2]
energy.values["charge"]=0
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([-0.188858513716,"3s",1,0,-2])
ener.append([-0.111545088773,"3p",1,2,-2])
ener.append([-0.071570839503,"4s",1,0,-2])
ener.append([-0.055937151245,"3d",1,4,-2])
ener.append([-0.050924007438,"4p",1,2,-2])
ener.append([-0.037556415262,"5s",1,0,-2])
ener.append([-0.031381769244,"4d",1,4,-2])
ener.append([-0.03099953028,"4f",1,6,-2])
ener.append([-0.016852587785,"5p",1,2,-2])
ener.append([-0.013241595936,"6p",1,2,-2])
ener.append([-0.009483928725,"5d",1,4,-2])
ener.append([-0.009278940512,"6s",1,0,-2])
ener.append([-0.008025195354,"5f",1,6,-2])
ener.append([0.085932651749,"6d",1,4,-2])
ener.append([0.119101445779,"7s",1,0,-2])
ener.append([0.128116728901,"7p",1,2,-2])
ener.append([0.606668704568,"7d",1,4,-2])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["method"]="cipsi-nof"
energy.values["ionization"]=None
ener=[]
ener.append([-0.188858513741,"3s",1,0,-2])
ener.append([-0.11154508881,"3p",1,2,-2])
ener.append([-0.071570839541,"4s",1,0,-2])
ener.append([-0.055937151215,"3d",1,4,-2])
ener.append([-0.050924007404,"4p",1,2,-2])
ener.append([-0.037556415309,"5s",1,0,-2])
ener.append([-0.031381769226,"4d",1,4,-2])
ener.append([-0.016852587815,"5p",1,2,-2])
ener.append([-0.013241595962,"6p",1,2,-2])
ener.append([-0.009483928704,"5d",1,4,-2])
ener.append([-0.009278940576,"6s",1,0,-2])
ener.append([0.085932651728,"6d",1,4,-2])
ener.append([0.119101445853,"7s",1,0,-2])
ener.append([0.1281167289,"7p",1,2,-2])
ener.append([0.606668704608,"7d",1,4,-2])
ener.append([1.18598329551,"8p",1,2,-2])
ener.append([2.35455631224,"8s",1,0,-2])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=0
energy.values["method"]="nist"
energy.values["ionization"]=ion[0]
ener=[]
ener.append([0.0,"3s",1,0,1])
ener.append([30272.58,"4p",1,2,3])
ener.append([16973.36619,"3p",1,2,3])
ener.append([38387.255,"6d",1,4,5])
ener.append([16956.17025,"3p",1,2,1])
ener.append([37036.772,"5d",1,4,3])
ener.append([37036.752,"5d",1,4,5])
ener.append([34548.764,"4d",1,4,3])
ener.append([34548.729,"4d",1,4,5])
ener.append([33200.673,"5s",1,0,1])
ener.append([29172.887,"3d",1,4,3])
ener.append([29172.837,"3d",1,4,5])
ener.append([39208.98,"7f",1,6,7])
ener.append([25739.999,"4s",1,0,1])
ener.append([35042.85,"5p",1,2,3])
ener.append([35040.38,"5p",1,2,1])
ener.append([38399.79,"6f",1,6,7])
ener.append([38399.79,"6f",1,6,5])
ener.append([30266.99,"4p",1,2,1])
ener.append([38387.268,"6d",1,4,3])
ener.append([37057.65,"5f",1,6,5])
ener.append([37057.65,"5f",1,6,7])
ener.append([36372.618,"6s",1,0,1])
ener.append([34586.92,"4f",1,6,5])
ener.append([34586.92,"4f",1,6,7])
ener.append([39734.16,"8f",1,6,7])
ener.append([39734.16,"8f",1,6,5])
ener.append([39728.7,"8d",1,4,3])
ener.append([39728.7,"8d",1,4,5])
ener.append([39208.98,"7f",1,6,5])
ener.append([39200.93,"7d",1,4,3])
ener.append([39200.93,"7d",1,4,5])
ener.append([37297.61,"6p",1,2,3])
ener.append([37296.32,"6p",1,2,1])
ener.append([38012.042,"7s",1,0,1])
ener.append([38540.93,"7p",1,2,3])
ener.append([38540.18,"7p",1,2,1])
ener.append([38968.51,"8s",1,0,1])
ener.append([39298.84,"8p",1,2,3])
ener.append([39298.35,"8p",1,2,1])
ener.append([39574.85,"9s",1,0,1])
ener.append([39794.81,"9p",1,2,3])
ener.append([39794.479,"9p",1,2,1])
ener.append([39983.27,"10s",1,0,1])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=0
energy.values["method"]="nist-c"
energy.values["ionization"]=ion[0]
ener=[]
ener.append([0.0,"3s",1,0,1])
ener.append([39794.479,"9p",1,2,1])
ener.append([39298.84,"8p",1,2,3])
ener.append([39298.35,"8p",1,2,1])
ener.append([38540.93,"7p",1,2,3])
ener.append([38540.18,"7p",1,2,1])
ener.append([37297.61,"6p",1,2,3])
ener.append([37296.32,"6p",1,2,1])
ener.append([35042.85,"5p",1,2,3])
ener.append([35040.38,"5p",1,2,1])
ener.append([30266.99,"4p",1,2,1])
ener.append([16973.36619,"3p",1,2,3])
ener.append([41174.705,"20d",1,4,5])
ener.append([41174.705,"20d",1,4,3])
ener.append([41145.0,"19d",1,4,3])
ener.append([41144.999,"19d",1,4,5])
ener.append([41134.023,"20s",1,0,1])
ener.append([41110.202,"18d",1,4,3])
ener.append([41110.202,"18d",1,4,5])
ener.append([41097.271,"19s",1,0,1])
ener.append([41069.08,"17d",1,4,3])
ener.append([41069.079,"17d",1,4,5])
ener.append([41053.701,"18s",1,0,1])
ener.append([41020.001,"16d",1,4,3])
ener.append([41020.0,"16d",1,4,5])
ener.append([41001.515,"17s",1,0,1])
ener.append([40960.771,"15d",1,4,5])
ener.append([40960.771,"15d",1,4,3])
ener.append([40938.281,"16s",1,0,1])
ener.append([40888.387,"14d",1,4,3])
ener.append([40888.386,"14d",1,4,5])
ener.append([40860.648,"15s",1,0,1])
ener.append([40798.644,"13d",1,4,3])
ener.append([40798.642,"13d",1,4,5])
ener.append([40763.884,"14s",1,0,1])
ener.append([40685.509,"12d",1,4,5])
ener.append([40685.509,"12d",1,4,3])
ener.append([40641.148,"13s",1,0,1])
ener.append([40540.095,"11d",1,4,3])
ener.append([40540.093,"11d",1,4,5])
ener.append([40482.236,"12s",1,0,1])
ener.append([16956.17025,"3p",1,2,1])
ener.append([40348.918,"10d",1,4,3])
ener.append([40348.915,"10d",1,4,5])
ener.append([40271.396,"11s",1,0,1])
ener.append([40090.31,"9d",1,4,3])
ener.append([40090.31,"9d",1,4,5])
ener.append([39983.27,"10s",1,0,1])
ener.append([39728.7,"8d",1,4,3])
ener.append([39728.7,"8d",1,4,5])
ener.append([39574.85,"9s",1,0,1])
ener.append([39200.93,"7d",1,4,3])
ener.append([39200.93,"7d",1,4,5])
ener.append([38968.51,"8s",1,0,1])
ener.append([38387.268,"6d",1,4,3])
ener.append([38012.042,"7s",1,0,1])
ener.append([36372.618,"6s",1,0,1])
ener.append([25739.999,"4s",1,0,1])
ener.append([40814.352,"14p",1,2,3])
ener.append([40814.273,"14p",1,2,1])
ener.append([40705.444,"13p",1,2,3])
ener.append([40705.344,"13p",1,2,1])
ener.append([40565.913,"12p",1,2,3])
ener.append([40565.783,"12p",1,2,1])
ener.append([40383.097,"11p",1,2,3])
ener.append([40382.925,"11p",1,2,1])
ener.append([40137.043,"10p",1,2,3])
ener.append([40136.81,"10p",1,2,1])
ener.append([39794.81,"9p",1,2,3])
ener.append([29172.837,"3d",1,4,5])
ener.append([40542.293,"11f",1,6,5])
ener.append([40542.293,"11f",1,6,7])
ener.append([29172.887,"3d",1,4,3])
ener.append([40351.761,"10f",1,6,5])
ener.append([40351.761,"10f",1,6,7])
ener.append([40094.19,"9f",1,6,7])
ener.append([40094.19,"9f",1,6,5])
ener.append([39734.16,"8f",1,6,7])
ener.append([39734.16,"8f",1,6,5])
ener.append([30272.58,"4p",1,2,3])
ener.append([39208.98,"7f",1,6,5])
ener.append([33200.673,"5s",1,0,1])
ener.append([41076.141,"18p",1,2,3])
ener.append([41076.106,"18p",1,2,1])
ener.append([41028.462,"17p",1,2,3])
ener.append([41028.419,"17p",1,2,1])
ener.append([40971.028,"16p",1,2,3])
ener.append([40970.976,"16p",1,2,1])
ener.append([40900.985,"15p",1,2,3])
ener.append([40900.922,"15p",1,2,1])
ener.append([34548.729,"4d",1,4,5])
ener.append([34548.764,"4d",1,4,3])
ener.append([34586.92,"4f",1,6,5])
ener.append([34586.92,"4f",1,6,7])
ener.append([38387.255,"6d",1,4,5])
ener.append([37036.752,"5d",1,4,5])
ener.append([37036.772,"5d",1,4,3])
ener.append([37057.65,"5f",1,6,5])
ener.append([37057.65,"5f",1,6,7])
ener.append([38399.79,"6f",1,6,5])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([0.0,"2s2.2p6",0,0,0])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="nist"
energy.values["ionization"]=ion[1]
ener=[]
ener.append([0.,"2s2.2p6",0,0,0])
ener.append([268762.96,"2s2.2p5.3s",0,2,2])
ener.append([308860.8,"2s2.2p5.3p",0,0,0])
ener.append([264924.32,"2s2.2p5.3s",2,2,4])
ener.append([300507.11,"2s2.2p5.3p",2,2,2])
ener.append([300103.92,"2s2.2p5.3p",2,2,4])
ener.append([265689.62,"2s2.2p5.3s",2,2,2])
ener.append([300387.82,"2s2.2p5.3p",2,2,0])
ener.append([266281.62,"2s2.2p5.3s",2,2,0])
ener.append([297248.82,"2s2.2p5.3p",2,4,6])
ener.append([331123.04,"2s2.2p5.(2P*<3/2>).3d",1,7,8])
ener.append([297635.61,"2s2.2p5.3p",2,4,4])
ener.append([298165.44,"2s2.2p5.3p",2,4,2])
ener.append([299885.37,"2s2.2p5.3p",0,2,2])
ener.append([299189.96,"2s2.2p5.3p",0,4,4])
ener.append([293220.33,"2s2.2p5.3p",2,0,2])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="nist-c"
energy.values["ionization"]=ion[1]
ener=[]
ener.append([0.0,"2s2.2p6",0,0,0])
ener.append([330636.75,"2s2.2p5.(2P*<3/2>).3d",1,1,2])
ener.append([268762.96,"2s2.2p5.3s",0,2,2])
ener.append([265689.62,"2s2.2p5.3s",2,2,2])
ener.append([308860.8,"2s2.2p5.3p",0,0,0])
ener.append([293220.33,"2s2.2p5.3p",2,0,2])
ener.append([333107.74,"2s2.2p5.(2P*<1/2>).4s",1,1,2])
ener.append([332962.57,"2s2.2p5.(2P*<1/2>).3d",1,3,4])
ener.append([332710.11,"2s2.2p5.(2P*<1/2>).4s",1,1,0])
ener.append([331873.93,"2s2.2p5.(2P*<3/2>).4s",1,3,2])
ener.append([331745.06,"2s2.2p5.(2P*<3/2>).3d",1,3,2])
ener.append([330789.05,"2s2.2p5.(2P*<3/2>).3d",1,3,4])
ener.append([330549.35,"2s2.2p5.(2P*<3/2>).3d",1,1,0])
ener.append([297635.61,"2s2.2p5.3p",2,4,4])
ener.append([264924.32,"2s2.2p5.3s",2,2,4])
ener.append([299885.37,"2s2.2p5.3p",0,2,2])
ener.append([300507.11,"2s2.2p5.3p",2,2,2])
ener.append([298165.44,"2s2.2p5.3p",2,4,2])
ener.append([332802.21,"2s2.2p5.(2P*<1/2>).3d",1,5,4])
ener.append([299189.96,"2s2.2p5.3p",0,4,4])
ener.append([332841.93,"2s2.2p5.(2P*<1/2>).3d",1,5,6])
ener.append([266281.62,"2s2.2p5.3s",2,2,0])
ener.append([300103.92,"2s2.2p5.3p",2,2,4])
ener.append([331665.59,"2s2.2p5.(2P*<3/2>).3d",1,5,4])
ener.append([300387.82,"2s2.2p5.3p",2,2,0])
ener.append([331186.7,"2s2.2p5.(2P*<3/2>).3d",1,7,6])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="nist-z"
energy.values["ionization"]=ion[1]
ener=[]
ener.append([0.0,"2s2.2p6",0,0,0])
ener.append([564200.0,"2s.2p6.3p",0,2,2])
ener.append([333162.94,"2s2.2p5.(2P*<1/2>).3d",1,3,2])
ener.append([333107.74,"2s2.2p5.(2P*<1/2>).4s",1,1,2])
ener.append([331873.93,"2s2.2p5.(2P*<3/2>).4s",1,3,2])
ener.append([331745.06,"2s2.2p5.(2P*<3/2>).3d",1,3,2])
ener.append([293220.33,"2s2.2p5.3p",2,0,2])
ener.append([332802.21,"2s2.2p5.(2P*<1/2>).3d",1,5,4])
ener.append([331665.59,"2s2.2p5.(2P*<3/2>).3d",1,5,4])
ener.append([331496.51,"2s2.2p5.(2P*<3/2>).4s",1,3,4])
ener.append([297248.82,"2s2.2p5.3p",2,4,6])
ener.append([332962.57,"2s2.2p5.(2P*<1/2>).3d",1,3,4])
ener.append([332841.93,"2s2.2p5.(2P*<1/2>).3d",1,5,6])
ener.append([297635.61,"2s2.2p5.3p",2,4,4])
ener.append([298165.44,"2s2.2p5.3p",2,4,2])
ener.append([331707.9,"2s2.2p5.(2P*<3/2>).3d",1,5,6])
ener.append([299189.96,"2s2.2p5.3p",0,4,4])
ener.append([331186.7,"2s2.2p5.(2P*<3/2>).3d",1,7,6])
ener.append([330789.05,"2s2.2p5.(2P*<3/2>).3d",1,3,4])
ener.append([299885.37,"2s2.2p5.3p",0,2,2])
ener.append([300103.92,"2s2.2p5.3p",2,2,4])
ener.append([300387.82,"2s2.2p5.3p",2,2,0])
ener.append([300507.11,"2s2.2p5.3p",2,2,2])
ener.append([330636.75,"2s2.2p5.(2P*<3/2>).3d",1,1,2])
ener.append([308860.8,"2s2.2p5.3p",0,0,0])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

# Cation Na+ : extracted by fit from Derevianko data
energy.values["method"]="divers"
energy.values["ionization"]=None
ener=[[0.,'2s2.2p6',0,0,-2]]
ener.append([310646.663514/ryd,"core1",0,-99,-2])
ener.append([677213.681821/ryd,"core2",0,-99,-2])
ener.append([2227012.69749/ryd,"core3",0,-99,-2])
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Magnesium 12
reset_all(database)
energy.values["label"]="Mg"
ion=[61671.05,121267.64]
energy.values["charge"]=0
energy.values["method"]="nist"
energy.values["ionization"]=ion[0]
ener=[]
ener.append([0.0,"3s2",0,0,0])
ener.append([35051.264,"3s.3p",0,2,2])
ener.append([21911.178,"3s.3p",2,2,4])
ener.append([41197.403,"3s.4s",2,0,2])
ener.append([46403.065,"3s.3d",0,4,4])
ener.append([43503.333,"3s.4s",0,0,0])
ener.append([54676.438,"3s.4f",0,6,6])
ener.append([47851.162,"3s.4p",2,2,4])
ener.append([47844.414,"3s.4p",2,2,2])
ener.append([49346.729,"3s.4p",0,2,2])
ener.append([53134.642,"3s.4d",0,4,4])
ener.append([57204.163,"3s.5f",0,6,6])
ener.append([52556.206,"3s.5s",0,0,0])
ener.append([54706.536,"3s.5p",0,2,2])
ener.append([56308.381,"3s.5d",0,4,4])
ener.append([56186.873,"3s.6s",0,0,0])
ener.append([47841.119,"3s.4p",2,2,0])
ener.append([47957.058,"3s.3d",2,4,2])
ener.append([47957.027,"3s.3d",2,4,4])
ener.append([47957.045,"3s.3d",2,4,6])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0]-ion[1])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=0
energy.values["method"]="nist-c"
ener=[]
ener.append([0.0,"3s2",0,0,0])
ener.append([57214.992,"3s.6p",0,2,2])
ener.append([54706.536,"3s.5p",0,2,2])
ener.append([49346.729,"3s.4p",0,2,2])
ener.append([21911.178,"3s.3p",2,2,4])
ener.append([58442.843,"3s.6d",2,4,6])
ener.append([21870.464,"3s.3p",2,2,2])
ener.append([57873.94,"3p2",2,2,4])
ener.append([21850.405,"3s.3p",2,2,0])
ener.append([57833.4,"3p2",2,2,2])
ener.append([57812.77,"3p2",2,2,0])
ener.append([47957.027,"3s.3d",2,4,4])
ener.append([83536.84,"3p.3d",2,4,6])
ener.append([47957.045,"3s.3d",2,4,6])
ener.append([83520.47,"3p.3d",2,4,4])
ener.append([47957.058,"3s.3d",2,4,2])
ener.append([83511.25,"3p.3d",2,4,2])
ener.append([56968.248,"3s.5d",2,4,4])
ener.append([56968.218,"3s.5d",2,4,6])
ener.append([46403.065,"3s.3d",0,4,4])
ener.append([80693.01,"3p.3d",0,4,4])
ener.append([54192.335,"3s.4d",2,4,2])
ener.append([54192.294,"3s.4d",2,4,4])
ener.append([54192.256,"3s.4d",2,4,6])
ener.append([51872.526,"3s.5s",2,0,2])
ener.append([53134.642,"3s.4d",0,4,4])
ener.append([35051.264,"3s.3p",0,2,2])
ener.append([59689.991,"3s.8d",0,4,4])
ener.append([59041.019,"3s.7d",0,4,4])
ener.append([58023.246,"3s.6d",0,4,4])
ener.append([56308.381,"3s.5d",0,4,4])
ener.append([56186.873,"3s.6s",0,0,0])
ener.append([41197.403,"3s.4s",2,0,2])
ener.append([52556.206,"3s.5s",0,0,0])
ener.append([43503.333,"3s.4s",0,0,0])
ener.append([59935.37,"3s.8f",0,6,6])
ener.append([54252.726,"3s.5p",2,2,4])
ener.append([54250.086,"3s.5p",2,2,2])
ener.append([59400.763,"3s.7f",0,6,6])
ener.append([58580.23,"3s.7p",0,2,2])
ener.append([58575.477,"3s.6f",0,6,6])
ener.append([47844.414,"3s.4p",2,2,2])
ener.append([59881.181,"3s.8d",2,4,4])
ener.append([59400.763,"3s.7f",2,6,8])
ener.append([57204.163,"3s.5f",0,6,6])
ener.append([58575.527,"3s.6f",2,6,4])
ener.append([58575.527,"3s.6f",2,6,6])
ener.append([58575.527,"3s.6f",2,6,8])
ener.append([47841.119,"3s.4p",2,2,0])
ener.append([58442.874,"3s.6d",2,4,2])
ener.append([58442.853,"3s.6d",2,4,4])
ener.append([47851.162,"3s.4p",2,2,4])
ener.append([59053.52,"3s.8s",0,0,0])
ener.append([57204.305,"3s.5f",2,6,8])
ener.append([57204.267,"3s.5f",2,6,6])
ener.append([57204.228,"3s.5f",2,6,4])
ener.append([56968.271,"3s.5d",2,4,2])
ener.append([57019.025,"3s.6p",2,2,4])
ener.append([58009.41,"3s.7s",0,0,0])
ener.append([55891.8,"3s.6s",2,0,2])
ener.append([59403.18,"3s.8p",0,2,2])
ener.append([54676.755,"3s.4f",2,6,8])
ener.append([54676.701,"3s.4f",2,6,6])
ener.append([54676.654,"3s.4f",2,6,4])
ener.append([60562.637,"3s.10f",2,6,8])
ener.append([54248.809,"3s.5p",2,2,0])
ener.append([60301.283,"3s.9f",2,6,8])
ener.append([60301.283,"3s.9f",2,6,6])
ener.append([59935.37,"3s.8f",2,6,8])
ener.append([59935.37,"3s.8f",2,6,6])
ener.append([59935.37,"3s.8f",2,6,4])
ener.append([59881.168,"3s.8d",2,4,6])
ener.append([54676.438,"3s.4f",0,6,6])
ener.append([59950.87,"3s.8g",0,8,8])
ener.append([59950.87,"3s.8g",2,8,8])
ener.append([59950.87,"3s.8g",2,8,10])
ener.append([59400.763,"3s.7f",2,6,6])
ener.append([59400.763,"3s.7f",2,6,4])
ener.append([57017.724,"3s.6p",2,2,2])
ener.append([57017.078,"3s.6p",2,2,0])
ener.append([59318.775,"3s.7d",2,4,4])
ener.append([59318.764,"3s.7d",2,4,6])
ener.append([59423.537,"3s.7g",0,8,8])
ener.append([59423.537,"3s.7g",2,8,6])
ener.append([59423.537,"3s.7g",2,8,8])
ener.append([59423.537,"3s.7g",2,8,10])
ener.append([60563.35,"3s.11p",0,2,2])
ener.append([58610.795,"3s.6g",0,8,8])
ener.append([58610.795,"3s.6g",2,8,6])
ener.append([58610.795,"3s.6g",2,8,8])
ener.append([58610.795,"3s.6g",2,8,10])
ener.append([57855.214,"3s.7s",2,0,2])
ener.append([60562.637,"3s.10f",2,6,4])
ener.append([60562.637,"3s.10f",2,6,6])
ener.append([60535.34,"3s.10d",2,4,4])
ener.append([60535.34,"3s.10d",2,4,6])
ener.append([60420.87,"3s.11s",2,0,2])
ener.append([60301.283,"3s.9f",2,6,4])
ener.append([60263.583,"3s.9d",2,4,4])
ener.append([60263.583,"3s.9d",2,4,6])
ener.append([59881.196,"3s.8d",2,4,2])
ener.append([59649.15,"3s.9s",2,0,2])
ener.append([57262.76,"3s.5g",0,8,8])
ener.append([57262.76,"3s.5g",2,8,8])
ener.append([57262.76,"3s.5g",2,8,6])
ener.append([58477.76,"3s.7p",2,2,4])
ener.append([58477.02,"3s.7p",2,2,2])
ener.append([59707.11,"3s.9s",0,0,0])
ener.append([59342.51,"3s.8p",2,2,4])
ener.append([59318.793,"3s.7d",2,4,2])
ener.append([58476.689,"3s.7p",2,2,0])
ener.append([60535.34,"3s.10d",2,4,2])
ener.append([59897.86,"3s.9p",2,2,4])
ener.append([58962.739,"3s.8s",2,0,2])
ener.append([59936.63,"3s.9p",0,2,2])
ener.append([60435.099,"3s.10d",0,4,4])
ener.append([60263.583,"3s.9d",2,4,2])
ener.append([60104.0,"3s.10s",2,0,2])
ener.append([60143.23,"3s.10s",0,0,0])
ener.append([60127.239,"3s.9d",0,4,4])
ener.append([59342.51,"3s.8p",2,2,2])
ener.append([59342.51,"3s.8p",2,2,0])
ener.append([59897.86,"3s.9p",2,2,2])
ener.append([60302.3,"3s.10p",0,2,2])
ener.append([60562.637,"3s.10f",0,6,6])
ener.append([59897.86,"3s.9p",2,2,0])
ener.append([60301.283,"3s.9f",0,6,6])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0]-ion[1])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="nist"
energy.values["ionization"]=ion[1]
ener=[]
ener.append([35669.31,"3p",1,2,1])
ener.append([93311.11,"4d",1,4,3])
ener.append([35760.88,"3p",1,2,3])
ener.append([93310.59,"4d",1,4,5])
ener.append([92790.51,"5s",1,0,1])
ener.append([71490.19,"3d",1,4,5])
ener.append([109062.35,"6f",1,6,7])
ener.append([71491.06,"3d",1,4,3])
ener.append([109062.32,"6f",1,6,5])
ener.append([0.0,"3s",1,0,1])
ener.append([69804.95,"4s",1,0,1])
ener.append([103689.92,"5f",1,6,7])
ener.append([103689.86,"5f",1,6,5])
ener.append([80650.02,"4p",1,2,3])
ener.append([108900.02,"6d",1,4,5])
ener.append([97468.92,"5p",1,2,3])
ener.append([97455.12,"5p",1,2,1])
ener.append([80619.5,"4p",1,2,1])
ener.append([103420.0,"5d",1,4,3])
ener.append([103419.7,"5d",1,4,5])
ener.append([103196.75,"6s",1,0,1])
ener.append([93799.75,"4f",1,6,7])
ener.append([93799.63,"4f",1,6,5])
ener.append([105629.72,"6p",1,2,3])
ener.append([105622.34,"6p",1,2,1])
ener.append([108900.2,"6d",1,4,3])
ener.append([115764.99,"10s",1,0,1])
ener.append([112301.47,"7f",1,6,7])
ener.append([112301.47,"7f",1,6,5])
ener.append([115844.6,"9f",1,6,7])
ener.append([112197.05,"7d",1,4,5])
ener.append([114403.55,"8f",1,6,7])
ener.append([114403.55,"8f",1,6,5])
ener.append([110203.58,"7p",1,2,1])
ener.append([114332.74,"8d",1,4,3])
ener.append([110207.99,"7p",1,2,3])
ener.append([114332.68,"8d",1,4,5])
ener.append([112197.17,"7d",1,4,3])
ener.append([115844.6,"9f",1,6,5])
ener.append([108784.33,"7s",1,0,1])
ener.append([113030.25,"8p",1,2,1])
ener.append([115794.44,"9d",1,4,3])
ener.append([113033.09,"8p",1,2,3])
ener.append([115794.39,"9d",1,4,5])
ener.append([112129.2,"8s",1,0,1])
ener.append([114289.36,"9s",1,0,1])
ener.append([114896.79,"9p",1,2,1])
ener.append([114898.72,"9p",1,2,3])
ener.append([116195.1,"10p",1,2,3])
ener.append([116838.45,"10d",1,4,5])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[1])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="nist-c"
energy.values["ionization"]=ion[1]
ener=[]
ener.append([0.0,"3s",1,0,1])
ener.append([114898.72,"9p",1,2,3])
ener.append([114896.79,"9p",1,2,1])
ener.append([113033.09,"8p",1,2,3])
ener.append([113030.25,"8p",1,2,1])
ener.append([110207.99,"7p",1,2,3])
ener.append([110203.58,"7p",1,2,1])
ener.append([105629.72,"6p",1,2,3])
ener.append([105622.34,"6p",1,2,1])
ener.append([97468.92,"5p",1,2,3])
ener.append([97455.12,"5p",1,2,1])
ener.append([80650.02,"4p",1,2,3])
ener.append([80619.5,"4p",1,2,1])
ener.append([35669.31,"3p",1,2,1])
ener.append([115794.44,"9d",1,4,3])
ener.append([115764.99,"10s",1,0,1])
ener.append([35760.88,"3p",1,2,3])
ener.append([115794.39,"9d",1,4,5])
ener.append([114332.74,"8d",1,4,3])
ener.append([114289.36,"9s",1,0,1])
ener.append([114332.68,"8d",1,4,5])
ener.append([112197.17,"7d",1,4,3])
ener.append([112129.2,"8s",1,0,1])
ener.append([112197.05,"7d",1,4,5])
ener.append([108900.2,"6d",1,4,3])
ener.append([108900.02,"6d",1,4,5])
ener.append([108784.33,"7s",1,0,1])
ener.append([103420.0,"5d",1,4,3])
ener.append([103419.7,"5d",1,4,5])
ener.append([103196.75,"6s",1,0,1])
ener.append([93311.11,"4d",1,4,3])
ener.append([69804.95,"4s",1,0,1])
ener.append([71490.19,"3d",1,4,5])
ener.append([115844.6,"9f",1,6,7])
ener.append([115844.6,"9f",1,6,5])
ener.append([71491.06,"3d",1,4,3])
ener.append([114403.55,"8f",1,6,5])
ener.append([114403.55,"8f",1,6,7])
ener.append([112301.47,"7f",1,6,5])
ener.append([112301.47,"7f",1,6,7])
ener.append([109062.32,"6f",1,6,5])
ener.append([103689.86,"5f",1,6,5])
ener.append([93310.59,"4d",1,4,5])
ener.append([92790.51,"5s",1,0,1])
ener.append([93799.63,"4f",1,6,5])
ener.append([93799.75,"4f",1,6,7])
ener.append([103689.92,"5f",1,6,7])
ener.append([109062.35,"6f",1,6,7])
ener.append([116838.45,"10d",1,4,5])
ener.append([116838.48,"10d",1,4,3])
ener.append([116195.1,"10p",1,2,3])
ener.append([116193.7,"10p",1,2,1])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[1])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=2
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([0.,"2s2.2p6",0,0,0])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=2
energy.values["method"]="nist"
energy.values["ionization"]=None
ener=[]
ener.append([0.,"2s2.2p6",0,0,0])
ener.append([474053.2,"2s2.2p5.3p",2,4,6])
ener.append([531563.0,"2s2.2p5.3d",2,6,8])
ener.append([474655.0,"2s2.2p5.3p",2,4,4])
ener.append([531833.1,"2s2.2p5.3d",2,6,6])
ener.append([478374.5,"2s2.2p5.3p",0,2,2])
ener.append([534776.9,"2s2.2p5.3d",0,4,4])
ener.append([478846.1,"2s2.2p5.3p",2,2,4])
ener.append([534923.6,"2s2.2p5.3d",2,4,6])
ener.append([479456.0,"2s2.2p5.3p",2,2,2])
ener.append([535179.6,"2s2.2p5.3d",2,4,4])
ener.append([477435.7,"2s2.2p5.3p",0,4,4])
ener.append([532971.2,"2s2.2p5.3d",0,6,6])
ener.append([425640.3,"2s2.2p5.3s",2,2,4])
ener.append([426868.1,"2s2.2p5.3s",2,2,2])
ener.append([475502.9,"2s2.2p5.3p",2,4,2])
ener.append([427852.1,"2s2.2p5.3s",2,2,0])
ener.append([467378.5,"2s2.2p5.3p",2,0,2])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=2
energy.values["method"]="nist-c"
energy.values["ionization"]=None
ener=[]
ener.append([0.0,"2s2.2p6",0,0,0])
ener.append([536152.0,"2s2.2p5.3d",0,2,2])
ener.append([534197.7,"2s2.2p5.3d",2,4,2])
ener.append([431530.0,"2s2.2p5.3s",0,2,2])
ener.append([426868.1,"2s2.2p5.3s",2,2,2])
ener.append([467378.5,"2s2.2p5.3p",2,0,2])
ener.append([548034.4,"2s2.2p5.(2P*<1/2>).4s",1,1,0])
ener.append([545820.4,"2s2.2p5.(2P*<3/2>).4s",1,3,4])
ener.append([475502.9,"2s2.2p5.3p",2,4,2])
ener.append([474053.2,"2s2.2p5.3p",2,4,6])
ener.append([474655.0,"2s2.2p5.3p",2,4,4])
ener.append([478846.1,"2s2.2p5.3p",2,2,4])
ener.append([548720.7,"2s2.2p5.(2P*<1/2>).4s",1,1,2])
ener.append([478374.5,"2s2.2p5.3p",0,2,2])
ener.append([479456.0,"2s2.2p5.3p",2,2,2])
ener.append([496012.1,"2s2.2p5.3p",0,0,0])
ener.append([477435.7,"2s2.2p5.3p",0,4,4])
ener.append([546531.6,"2s2.2p5.(2P*<3/2>).4s",1,3,2])
ener.append([530962.9,"2s2.2p5.3d",2,2,4])
ener.append([530420.6,"2s2.2p5.3d",2,2,2])
ener.append([530178.2,"2s2.2p5.3d",2,2,0])
ener.append([535179.6,"2s2.2p5.3d",2,4,4])
ener.append([534923.6,"2s2.2p5.3d",2,4,6])
ener.append([534776.9,"2s2.2p5.3d",0,4,4])
ener.append([532971.2,"2s2.2p5.3d",0,6,6])
ener.append([532725.7,"2s2.2p5.3d",2,6,4])
ener.append([531833.1,"2s2.2p5.3d",2,6,6])
ener.append([479265.3,"2s2.2p5.3p",2,2,0])
ener.append([425640.3,"2s2.2p5.3s",2,2,4])
ener.append([427852.1,"2s2.2p5.3s",2,2,0])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=2
energy.values["method"]="nist-z"
energy.values["ionization"]=None
ener=[]
ener.append([0.0,"2s2.2p6",0,0,0])
ener.append([530420.6,"2s2.2p5.3d",2,2,2])
ener.append([467378.5,"2s2.2p5.3p",2,0,2])
ener.append([548720.7,"2s2.2p5.(2P*<1/2>).4s",1,1,2])
ener.append([474655.0,"2s2.2p5.3p",2,4,4])
ener.append([475502.9,"2s2.2p5.3p",2,4,2])
ener.append([479265.3,"2s2.2p5.3p",2,2,0])
ener.append([536152.0,"2s2.2p5.3d",0,2,2])
ener.append([478374.5,"2s2.2p5.3p",0,2,2])
ener.append([545820.4,"2s2.2p5.(2P*<3/2>).4s",1,3,4])
ener.append([534776.9,"2s2.2p5.3d",0,4,4])
ener.append([474053.2,"2s2.2p5.3p",2,4,6])
ener.append([477435.7,"2s2.2p5.3p",0,4,4])
ener.append([534923.6,"2s2.2p5.3d",2,4,6])
ener.append([478846.1,"2s2.2p5.3p",2,2,4])
ener.append([535179.6,"2s2.2p5.3d",2,4,4])
ener.append([534197.7,"2s2.2p5.3d",2,4,2])
ener.append([532725.7,"2s2.2p5.3d",2,6,4])
ener.append([496012.1,"2s2.2p5.3p",0,0,0])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Aluminum 13
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Silicon 14
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Phosphorus 15
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Sulfur 16
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Chlorine 17
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Argon 18
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Potassium 19
reset_all(database)
energy.values["label"]="K"
ion=[35009.8140,255100.]
energy.values["charge"]=0
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([-0.159524447561,"4s",1,0,-2])
ener.append([-0.100176167772,"4p",1,2,-2])
ener.append([-0.063717946358,"5s",1,0,-2])
ener.append([-0.061387353601,"3d",1,4,-2])
ener.append([-0.046733558673,"5p",1,2,-2])
ener.append([-0.034626390034,"4d",1,4,-2])
ener.append([-0.034407375532,"6s",1,0,-2])
ener.append([-0.031146089228,"4f",1,6,-2])
ener.append([-0.027143013021,"6p",1,2,-2])
ener.append([-0.021891102308,"5d",1,4,-2])
ener.append([-0.009748449617,"5f",1,6,-2])
ener.append([-0.008359123554,"7s",1,0,-2])
ener.append([-0.00822086149,"6d",1,4,-2])
ener.append([0.012580221971,"7p",1,2,-2])
ener.append([0.072227635818,"7d",1,4,-2])
ener.append([0.105341718941,"8s",1,0,-2])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["method"]="cipsi-nof"
energy.values["ionization"]=None
ener=[]
ener.append([-0.159524447527,"4s",1,0,-2])
ener.append([-0.10017616779,"4p",1,2,-2])
ener.append([-0.063717946373,"5s",1,0,-2])
ener.append([-0.061387353651,"3d",1,4,-2])
ener.append([-0.046733558642,"5p",1,2,-2])
ener.append([-0.034626389993,"4d",1,4,-2])
ener.append([-0.034407375546,"6s",1,0,-2])
ener.append([-0.027143012999,"6p",1,2,-2])
ener.append([-0.021891102276,"5d",1,4,-2])
ener.append([-0.008359123605,"7s",1,0,-2])
ener.append([-0.008220861507,"6d",1,4,-2])
ener.append([0.012580221941,"7p",1,2,-2])
ener.append([0.072227635822,"7d",1,4,-2])
ener.append([0.105341718915,"8s",1,0,-2])
ener.append([0.406963783456,"8d",1,4,-2])
ener.append([0.428447276432,"8p",1,2,-2])
ener.append([1.37090369105,"9s",1,0,-2])
ener.append([2.0815085835,"9d",1,4,-2])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=0
energy.values["method"]="nist"
energy.values["ionization"]=ion[0]
ener=[]
ener.append([0.0,"4s",1,0,1])
ener.append([24720.139,"5p",1,2,3])
ener.append([24701.382,"5p",1,2,1])
ener.append([13042.896027,"4p",1,2,3])
ener.append([12985.185724,"4p",1,2,1])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=0
energy.values["method"]="nist-c"
energy.values["ionization"]=ion[0]
ener=[]
ener.append([12985.185724,"4p",1,2,1])
ener.append([34072.2393,"13s",1,0,1])
ener.append([13042.896027,"4p",1,2,3])
ener.append([33871.4788,"12s",1,0,1])
ener.append([33598.5597,"11s",1,0,1])
ener.append([33214.2267,"10s",1,0,1])
ener.append([32648.3511,"9s",1,0,1])
ener.append([31765.3767,"8s",1,0,1])
ener.append([30274.2487,"7s",1,0,1])
ener.append([27450.7104,"6s",1,0,1])
ener.append([21536.988,"3d",1,4,3])
ener.append([21534.68,"3d",1,4,5])
ener.append([21026.551,"5s",1,0,1])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="nist-z"
energy.values["ionization"]=ion[1]
ener=[]
ener.append([0.0,"3p6",0,0,0])
ener.append([246600.0,"3p5.7d",-1,-99,2])
ener.append([242900.0,"3p5.6d",-1,-99,2])
ener.append([241000.0,"3p5.7s",-1,-99,2])
ener.append([237000.0,"3p5.5d",-1,-99,2])
ener.append([215014.6,"3p5.(2P*<1/2>).5s",1,1,2])
ener.append([201957.6,"3p5.3d",0,2,2])
ener.append([180448.9,"3p5.3d",2,4,2])
ener.append([166457.3,"3p5.4s",0,2,2])
ener.append([164492.0,"3p5.3d",2,2,2])
ener.append([163232.2,"3p5.4s",2,2,2])
ener.append([162502.7,"3p5.4s",2,2,4])
ener.append([242692.6,"3p5.(2P*<3/2>).6f",1,3,2])
ener.append([242700.3,"3p5.(2P*<3/2>).6f",1,3,4])
ener.append([163432.1,"3p5.3d",2,2,0])
ener.append([164927.9,"3p5.3d",2,2,4])
ener.append([242771.2,"3p5.(2P*<3/2>).6f",1,5,6])
ener.append([239503.3,"3p5.(2P*<1/2>).5f",1,5,4])
ener.append([237220.4,"3p5.(2P*<3/2>).5f",1,3,4])
ener.append([239486.7,"3p5.(2P*<1/2>).5f",1,5,6])
ener.append([237356.7,"3p5.(2P*<3/2>).5f",1,5,4])
ener.append([237204.7,"3p5.(2P*<3/2>).5f",1,3,2])
ener.append([170049.2,"3p5.3d",2,6,8])
ener.append([242728.7,"3p5.(2P*<3/2>).6f",1,9,10])
ener.append([237339.0,"3p5.(2P*<3/2>).5f",1,5,6])
ener.append([165145.4,"3p5.4s",2,2,0])
ener.append([170831.1,"3p5.3d",2,6,6])
ener.append([242811.1,"3p5.(2P*<3/2>).6f",1,7,8])
ener.append([242810.6,"3p5.(2P*<3/2>).6f",1,7,6])
ener.append([242774.8,"3p5.(2P*<3/2>).6f",1,5,4])
ener.append([242732.2,"3p5.(2P*<3/2>).6f",1,9,8])
ener.append([171522.6,"3p5.3d",2,6,4])
ener.append([239487.7,"3p5.(2P*<1/2>).5f",1,7,8])
ener.append([239485.4,"3p5.(2P*<1/2>).5f",1,7,6])
ener.append([237408.5,"3p5.(2P*<3/2>).5f",1,7,6])
ener.append([237271.2,"3p5.(2P*<3/2>).5f",1,9,10])
ener.append([229524.9,"3p5.(2P*<1/2>).4f",1,5,4])
ener.append([229507.0,"3p5.(2P*<1/2>).4f",1,5,6])
ener.append([237275.3,"3p5.(2P*<3/2>).5f",1,9,8])
ener.append([227100.9,"3p5.(2P*<3/2>).4f",1,3,2])
ener.append([179349.2,"3p5.3d",0,4,4])
ener.append([179395.8,"3p5.3d",2,4,6])
ener.append([227367.2,"3p5.(2P*<3/2>).4f",1,5,4])
ener.append([227123.2,"3p5.(2P*<3/2>).4f",1,3,4])
ener.append([227343.9,"3p5.(2P*<3/2>).4f",1,5,6])
ener.append([180392.7,"3p5.3d",2,4,4])
ener.append([180618.7,"3p5.3d",0,6,6])
ener.append([229495.9,"3p5.(2P*<1/2>).4f",1,7,8])
ener.append([237407.2,"3p5.(2P*<3/2>).5f",1,7,8])
ener.append([227487.5,"3p5.(2P*<3/2>).4f",1,7,8])
ener.append([227230.6,"3p5.(2P*<3/2>).4f",1,9,8])
ener.append([227226.0,"3p5.(2P*<3/2>).4f",1,9,10])
ener.append([227484.8,"3p5.(2P*<3/2>).4f",1,7,6])
ener.append([229492.5,"3p5.(2P*<1/2>).4f",1,7,6])
ener.append([183204.1,"3p5.4p",2,0,2])
ener.append([219192.1,"3p5.4d",2,4,4])
ener.append([186383.8,"3p5.4p",2,4,6])
ener.append([215851.5,"3p5.4d",2,2,4])
ener.append([186681.4,"3p5.4p",2,4,4])
ener.append([215400.9,"3p5.4d",2,2,2])
ener.append([187527.0,"3p5.4p",2,4,2])
ener.append([214722.7,"3p5.(2P*<1/2>).5s",1,1,0])
ener.append([217722.3,"3p5.4d",2,4,6])
ener.append([188150.3,"3p5.4p",0,4,4])
ener.append([217061.9,"3p5.4d",2,6,4])
ener.append([194772.2,"3p5.4p",0,0,0])
ener.append([189239.5,"3p5.4p",0,2,2])
ener.append([212988.6,"3p5.(2P*<3/2>).5s",1,3,2])
ener.append([189657.4,"3p5.4p",2,2,4])
ener.append([212571.2,"3p5.(2P*<3/2>).5s",1,3,4])
ener.append([190130.7,"3p5.4p",2,2,2])
ener.append([189768.0,"3p5.4p",2,2,0])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="nist"
energy.values["ionization"]=ion[1]
ener=[]
ener.append([0.0,"3p6",0,0,0])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([0.0,"3p6",0,0,0])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

# Cation K+ : extracted by fit from Derevianko data
energy.values["method"]="divers"
energy.values["ionization"]=None
ener=[[0.,'3p6',0,0,-2]]
ener.append([178100.003571/ryd,"core1",0,-99,-2])
ener.append([309969.445078/ryd,"core2",0,-99,-2])
#ener.append([157105/ryd,"core1",0,-99,-2])
#ener.append([199440/ryd,"core2",0,-99,-2])
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Calcium 20
reset_all(database)
energy.values["label"]="Ca"
ion=[49305.95,95751.87]
energy.values["charge"]=0
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([-0.660787491482,"4s2",0,0,-2])
ener.append([-0.561678057276,"3d.4s",0,4,-2])
ener.append([-0.555316186516,"4s.4p",0,2,-2])
ener.append([-0.50927336394,"4s.5s",0,0,-2])
ener.append([-0.49940668255,"3d.4p",0,4,-2])
ener.append([-0.491072361071,"4s.5p",0,2,-2])
ener.append([-0.489144394296,"4s.4d",0,4,-2])
ener.append([-0.592095723171,"4s.4p",2,2,-2])
ener.append([-0.567919404064,"3d.4s",2,4,-2])
ener.append([-0.517434862011,"4s.5s",2,0,-2])
ener.append([-0.500357792828,"3d.4p",2,6,-2])
ener.append([-0.491567752447,"4s.5p",2,2,-2])
ener.append([-0.487503218902,"4p2",2,2,-2])
ener.append([-0.486742808534,"4s.4d",2,4,-2])
ener.append([-0.486446868213,"3d.4p",2,4,-2])
ener.append([-0.4793577308,"4s.6p",2,2,-2])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=0
energy.values["method"]="nist-c"
energy.values["ionization"]=ion[0]
ener=[]
ener.append([0.0,"4s2",0,0,0])
ener.append([46479.813,"4s.8p",0,2,2])
ener.append([45425.358,"4s.7p",0,2,2])
ener.append([43933.477,"4s.np",0,2,2])
ener.append([41679.008,"4s.6p",0,2,2])
ener.append([15157.901,"4s.4p",2,2,0])
ener.append([48537.623,"3d2",2,2,2])
ener.append([15210.063,"4s.4p",2,2,2])
ener.append([48563.522,"3d2",2,2,4])
ener.append([48524.093,"3d2",2,2,0])
ener.append([15315.943,"4s.4p",2,2,4])
ener.append([45049.073,"4s.6d",2,4,2])
ener.append([45050.419,"4s.6d",2,4,4])
ener.append([45052.374,"4s.6d",2,4,6])
ener.append([42743.002,"4s.5d",2,4,2])
ener.append([42744.716,"4s.5d",2,4,4])
ener.append([42747.387,"4s.5d",2,4,6])
ener.append([40474.241,"4s.6s",2,0,2])
ener.append([23652.304,"4s.4p",0,2,2])
ener.append([38551.558,"4p2",2,2,4])
ener.append([38464.808,"4p2",2,2,2])
ener.append([38417.543,"4p2",2,2,0])
ener.append([37748.197,"4s.4d",2,4,2])
ener.append([37751.867,"4s.4d",2,4,4])
ener.append([37757.449,"4s.4d",2,4,6])
ener.append([20335.36,"3d.4s",2,4,2])
ener.append([42170.214,"4s.4f",2,6,4])
ener.append([20349.26,"3d.4s",2,4,4])
ener.append([42170.558,"4s.4f",2,6,6])
ener.append([20371.0,"3d.4s",2,4,6])
ener.append([42171.026,"4s.4f",2,6,8])
ener.append([21849.634,"3d.4s",0,4,4])
ener.append([42343.587,"4s.4f",0,6,6])
ener.append([31539.495,"4s.5s",2,0,2])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0]-ion[1])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([-0.436283624278,"4s",1,0,-2])
ener.append([-0.373921965845,"3d",1,4,-2])
ener.append([-0.320823910542,"4p",1,2,-2])
ener.append([-0.199305468816,"5s",1,0,-2])
ener.append([-0.177309313767,"4d",1,4,-2])
ener.append([-0.160076378381,"5p",1,2,-2])
ener.append([-0.123737347505,"4f",1,6,-2])
ener.append([-0.114553835606,"6s",1,0,-2])
ener.append([-0.101159845541,"5d",1,4,-2])
ener.append([-0.074958861287,"6p",1,2,-2])
ener.append([-0.072040465718,"7s",1,0,-2])
ener.append([0.026378270164,"6d",1,4,-2])
ener.append([0.028983458056,"5f",1,6,-2])
ener.append([0.065183410406,"8s",1,0,-2])
ener.append([0.161752160071,"7p",1,2,-2])
ener.append([0.445589545031,"7d",1,4,-2])
ener.append([0.777646858617,"9s",1,0,-2])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="nist-c"
energy.values["ionization"]=ion[1]
ener=[]
ener.append([13650.19,"3d",1,4,3])
ener.append([91338.0,"10f",1,6,5])
ener.append([13710.88,"3d",1,4,5])
ener.append([91338.0,"10f",1,6,7])
ener.append([90300.0,"9f",1,6,5])
ener.append([90300.0,"9f",1,6,7])
ener.append([88847.31,"8f",1,6,5])
ener.append([88847.31,"8f",1,6,7])
ener.append([86727.06,"7f",1,6,5])
ener.append([86727.06,"7f",1,6,7])
ener.append([83458.08,"6f",1,6,5])
ener.append([83458.08,"6f",1,6,7])
ener.append([25191.51,"4p",1,2,1])
ener.append([93894.5,"16d",1,4,3])
ener.append([25414.4,"4p",1,2,3])
ener.append([93894.5,"16d",1,4,5])
ener.append([93626.9,"15d",1,4,3])
ener.append([93626.9,"15d",1,4,5])
ener.append([93297.6,"14d",1,4,3])
ener.append([93297.6,"14d",1,4,5])
ener.append([92883.0,"13d",1,4,3])
ener.append([92883.0,"13d",1,4,5])
ener.append([92359.0,"12d",1,4,3])
ener.append([92359.0,"12d",1,4,5])
ener.append([91672.0,"11d",1,4,3])
ener.append([91672.0,"11d",1,4,5])
ener.append([90753.92,"10d",1,4,3])
ener.append([90754.8,"10d",1,4,5])
ener.append([78034.39,"5f",1,6,5])
ener.append([78034.39,"5f",1,6,7])
ener.append([89487.93,"9d",1,4,3])
ener.append([89489.13,"9d",1,4,5])
ener.append([87671.93,"8d",1,4,3])
ener.append([87673.72,"8d",1,4,5])
ener.append([84933.65,"7d",1,4,3])
ener.append([84936.41,"7d",1,4,5])
ener.append([84300.89,"8s",1,0,1])
ener.append([80521.53,"6d",1,4,3])
ener.append([80526.16,"6d",1,4,5])
ener.append([68056.91,"4f",1,6,5])
ener.append([68056.91,"4f",1,6,7])
ener.append([79448.28,"7s",1,0,1])
ener.append([72722.23,"5d",1,4,3])
ener.append([72730.93,"5d",1,4,5])
ener.append([70677.62,"6s",1,0,1])
ener.append([56839.25,"4d",1,4,3])
ener.append([56858.46,"4d",1,4,5])
ener.append([52166.93,"5s",1,0,1])
ener.append([0.0,"4s",1,0,1])
ener.append([60533.02,"5p",1,2,1])
ener.append([60611.28,"5p",1,2,3])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[1])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=2
energy.values["method"]="nist-c"
energy.values["ionization"]=None
ener=[]
ener.append([0.0,"3s2.3p6",0,0,0])
ener.append([402680.0,"3s2.3p5.(2P*<1/2>).10d",1,3,2])
ener.append([399910.0,"3s2.3p5.(2P*<1/2>).10s",1,1,2])
ener.append([399650.0,"3s2.3p5.(2P*<3/2>).10d",1,3,2])
ener.append([396860.0,"3s2.3p5.(2P*<3/2>).10s",1,3,2])
ener.append([396660.0,"3s2.3p5.(2P*<3/2>).9d",1,1,2])
ener.append([395930.0,"3s2.3p5.(2P*<1/2>).8d",1,3,2])
ener.append([392960.0,"3s2.3p5.(2P*<3/2>).9s",1,3,2])
ener.append([392610.0,"3s2.3p5.(2P*<3/2>).8d",1,1,2])
ener.append([380770.0,"3s2.3p5.(2P*<1/2>).7s",1,1,2])
ener.append([377790.0,"3s2.3p5.(2P*<3/2>).7s",1,3,2])
ener.append([376660.0,"3s2.3p5.(2P*<3/2>).6d",1,1,2])
ener.append([365363.88,"3s2.3p5.(2P*<1/2>).5d",1,3,2])
ener.append([364343.85,"3s2.3p5.(2P*<1/2>).6s",1,1,2])
ener.append([336749.11,"3s2.3p5.(2P*<1/2>).4d",1,3,2])
ener.append([331403.2,"3s2.3p5.(2P*<1/2>).5s",1,1,2])
ener.append([328582.45,"3s2.3p5.(2P*<3/2>).5s",1,3,2])
ener.append([327962.11,"3s2.3p5.(2P*<3/2>).4d",1,3,2])
ener.append([323003.56,"3s2.3p5.(2P*<3/2>).4d",1,1,2])
ener.append([279353.64,"3s2.3p5.3d",0,2,2])
ener.append([247696.39,"3s2.3p5.4s",0,2,2])
ener.append([243930.44,"3s2.3p5.4s",2,2,2])
ener.append([227432.11,"3s2.3p5.3d",2,4,2])
ener.append([203851.95,"3s2.3p5.3d",2,2,2])
ener.append([204842.64,"3s2.3p5.3d",2,2,4])
ener.append([385867.0,"3s2.3p5.(2P*<1/2>).6f",1,5,6])
ener.append([382791.5,"3s2.3p5.(2P*<3/2>).6f",1,5,6])
ener.append([212310.0,"3s2.3p5.3d",2,6,8])
ener.append([390054.0,"3s2.3p5.(2P*<3/2>).7f",1,9,10])
ener.append([213379.4,"3s2.3p5.3d",2,6,6])
ener.append([385775.5,"3s2.3p5.(2P*<1/2>).6f",1,7,8])
ener.append([214334.06,"3s2.3p5.3d",2,6,4])
ener.append([385757.6,"3s2.3p5.(2P*<1/2>).6f",1,7,6])
ener.append([382798.5,"3s2.3p5.(2P*<3/2>).6f",1,7,8])
ener.append([382565.1,"3s2.3p5.(2P*<3/2>).6f",1,9,10])
ener.append([373626.9,"3s2.3p5.(2P*<1/2>).5f",1,5,4])
ener.append([382587.9,"3s2.3p5.(2P*<3/2>).6f",1,9,8])
ener.append([373880.37,"3s2.3p5.(2P*<1/2>).5f",1,5,6])
ener.append([382784.7,"3s2.3p5.(2P*<3/2>).6f",1,7,6])
ener.append([203373.22,"3s2.3p5.3d",2,2,0])
ener.append([371447.58,"3s2.3p5.(2P*<3/2>).5f",1,3,2])
ener.append([371274.48,"3s2.3p5.(2P*<3/2>).5f",1,3,4])
ener.append([228413.95,"3s2.3p5.3d",0,6,6])
ener.append([393224.9,"3s2.3p5.(2P*<1/2>).7f",1,7,8])
ener.append([226333.56,"3s2.3p5.3d",2,4,6])
ener.append([390207.6,"3s2.3p5.(2P*<3/2>).7f",1,7,8])
ener.append([373425.5,"3s2.3p5.(2P*<1/2>).5f",1,7,8])
ener.append([225826.22,"3s2.3p5.3d",0,4,4])
ener.append([373401.9,"3s2.3p5.(2P*<1/2>).5f",1,7,6])
ener.append([385906.9,"3s2.3p5.(2P*<1/2>).6f",1,5,4])
ener.append([370533.1,"3s2.3p5.(2P*<3/2>).5f",1,7,8])
ener.append([370172.43,"3s2.3p5.(2P*<3/2>).5f",1,9,8])
ener.append([370141.77,"3s2.3p5.(2P*<3/2>).5f",1,9,10])
ener.append([370515.4,"3s2.3p5.(2P*<3/2>).5f",1,7,6])
ener.append([370454.0,"3s2.3p5.(2P*<1/2>).6p",1,3,4])
ener.append([382853.4,"3s2.3p5.(2P*<3/2>).6f",1,5,4])
ener.append([227388.56,"3s2.3p5.3d",2,4,4])
ener.append([350900.04,"3s2.3p5.(2P*<1/2>).4f",1,5,4])
ener.append([350741.19,"3s2.3p5.(2P*<1/2>).4f",1,5,6])
ener.append([371060.0,"3s2.3p5.(2P*<3/2>).5f",1,5,6])
ener.append([370304.5,"3s2.3p5.(2P*<3/2>).5f",1,5,4])
ener.append([347758.22,"3s2.3p5.(2P*<3/2>).4f",1,5,4])
ener.append([346732.19,"3s2.3p5.(2P*<3/2>).4f",1,3,2])
ener.append([346896.26,"3s2.3p5.(2P*<3/2>).4f",1,3,4])
ener.append([347417.05,"3s2.3p5.(2P*<3/2>).4f",1,5,6])
ener.append([367472.91,"3s.3p6.3d",2,4,6])
ener.append([343784.96,"3s2.3p5.(2P*<1/2>).5p",1,3,2])
ener.append([344257.92,"3s2.3p5.(2P*<1/2>).5p",1,1,2])
ener.append([344149.81,"3s2.3p5.(2P*<1/2>).5p",1,3,4])
ener.append([341349.19,"3s2.3p5.(2P*<3/2>).5p",1,3,2])
ener.append([341601.46,"3s2.3p5.(2P*<3/2>).5p",1,3,4])
ener.append([350805.32,"3s2.3p5.(2P*<1/2>).4f",1,7,8])
ener.append([340748.72,"3s2.3p5.(2P*<3/2>).5p",1,5,4])
ener.append([350779.47,"3s2.3p5.(2P*<1/2>).4f",1,7,6])
ener.append([339198.09,"3s2.3p5.(2P*<3/2>).5p",1,1,2])
ener.append([348051.86,"3s2.3p5.(2P*<3/2>).4f",1,7,8])
ener.append([348028.13,"3s2.3p5.(2P*<3/2>).4f",1,7,6])
ener.append([347383.51,"3s2.3p5.(2P*<3/2>).4f",1,9,8])
ener.append([347344.37,"3s2.3p5.(2P*<3/2>).4f",1,9,10])
ener.append([340580.15,"3s2.3p5.(2P*<3/2>).5p",1,5,6])
ener.append([242547.19,"3s2.3p5.4s",2,2,4])
ener.append([367026.65,"3s2.3p5.(2P*<3/2>).6p",1,5,6])
ener.append([346692.34,"3s2.3p5.(2P*<1/2>).5p",1,1,0])
ener.append([343110.24,"3s2.3p5.(2P*<3/2>).5p",1,1,0])
ener.append([277022.4,"3s2.3p5.4p",2,4,6])
ener.append([376808.6,"3s2.3p5.(2P*<3/2>).6d",1,7,8])
ener.append([277380.86,"3s2.3p5.4p",2,4,4])
ener.append([376883.4,"3s2.3p5.(2P*<3/2>).6d",1,7,6])
ener.append([245611.88,"3s2.3p5.4s",2,2,0])
ener.append([272188.7,"3s2.3p5.4p",2,0,2])
ener.append([361154.07,"3s2.3p5.(2P*<3/2>).6s",1,3,4])
ener.append([359520.6,"3s2.3p5.(2P*<3/2>).5d",1,3,4])
ener.append([290934.3,"3s2.3p5.4p",0,0,0])
ener.append([359156.83,"3s2.3p5.(2P*<3/2>).5d",1,1,2])
ener.append([358940.91,"3s2.3p5.(2P*<3/2>).5d",1,1,0])
ener.append([279741.8,"3s2.3p5.4p",0,4,4])
ener.append([281139.55,"3s2.3p5.4p",0,2,2])
ener.append([361353.31,"3s2.3p5.(2P*<3/2>).6s",1,3,2])
ener.append([363021.27,"3s2.3p5.(2P*<1/2>).5d",1,3,4])
ener.append([278621.01,"3s2.3p5.4p",2,4,2])
ener.append([361794.08,"3s2.3p5.(2P*<3/2>).5d",1,3,2])
ener.append([364229.89,"3s2.3p5.(2P*<1/2>).6s",1,1,0])
ener.append([360207.16,"3s2.3p5.(2P*<3/2>).5d",1,5,4])
ener.append([282571.43,"3s2.3p5.4p",2,2,2])
ener.append([359800.57,"3s2.3p5.(2P*<3/2>).5d",1,7,6])
ener.append([359543.08,"3s2.3p5.(2P*<3/2>).5d",1,7,8])
ener.append([281882.24,"3s2.3p5.4p",2,2,4])
ener.append([362893.47,"3s2.3p5.(2P*<1/2>).5d",1,5,4])
ener.append([363118.75,"3s2.3p5.(2P*<1/2>).5d",1,5,6])
ener.append([360388.68,"3s2.3p5.(2P*<3/2>).5d",1,5,6])
ener.append([282075.15,"3s2.3p5.4p",2,2,0])
ener.append([331048.86,"3s2.3p5.(2P*<1/2>).5s",1,1,0])
ener.append([327922.87,"3s2.3p5.(2P*<3/2>).5s",1,3,4])
ener.append([323655.06,"3s2.3p5.(2P*<3/2>).4d",1,3,4])
ener.append([328090.99,"3s2.3p5.(2P*<1/2>).4d",1,5,4])
ener.append([322663.28,"3s2.3p5.(2P*<3/2>).4d",1,1,0])
ener.append([326186.32,"3s2.3p5.(2P*<3/2>).4d",1,5,6])
ener.append([328606.78,"3s2.3p5.(2P*<1/2>).4d",1,3,4])
ener.append([325467.67,"3s2.3p5.(2P*<3/2>).4d",1,5,4])
ener.append([324660.47,"3s2.3p5.(2P*<3/2>).4d",1,7,6])
ener.append([324110.24,"3s2.3p5.(2P*<3/2>).4d",1,7,8])
ener.append([328588.76,"3s2.3p5.(2P*<1/2>).4d",1,5,6])
ener.append([366778.85,"3s.3p6.3d",2,4,2])
ener.append([366926.33,"3s.3p6.3d",2,4,4])
ener.append([390392.62,"3s2.3p5.(2P*<3/2>).7g",1,5,6])
ener.append([390411.58,"3s2.3p5.(2P*<3/2>).7g",1,11,12])
ener.append([390411.99,"3s2.3p5.(2P*<3/2>).7g",1,11,10])
ener.append([393552.31,"3s2.3p5.(2P*<1/2>).7g",1,7,8])
ener.append([393551.86,"3s2.3p5.(2P*<1/2>).7g",1,9,10])
ener.append([390452.0,"3s2.3p5.(2P*<3/2>).7g",1,7,6])
ener.append([393552.8,"3s2.3p5.(2P*<1/2>).7g",1,7,6])
ener.append([390471.79,"3s2.3p5.(2P*<3/2>).7g",1,9,8])
ener.append([390472.32,"3s2.3p5.(2P*<3/2>).7g",1,9,10])
ener.append([383061.33,"3s2.3p5.(2P*<3/2>).6g",1,5,4])
ener.append([383063.78,"3s2.3p5.(2P*<3/2>).6g",1,5,6])
ener.append([383094.79,"3s2.3p5.(2P*<3/2>).6g",1,11,12])
ener.append([383156.51,"3s2.3p5.(2P*<3/2>).6g",1,7,8])
ener.append([383095.1,"3s2.3p5.(2P*<3/2>).6g",1,11,10])
ener.append([386249.78,"3s2.3p5.(2P*<1/2>).6g",1,7,8])
ener.append([386248.39,"3s2.3p5.(2P*<1/2>).6g",1,9,8])
ener.append([386248.68,"3s2.3p5.(2P*<1/2>).6g",1,9,10])
ener.append([383157.11,"3s2.3p5.(2P*<3/2>).6g",1,7,6])
ener.append([386250.31,"3s2.3p5.(2P*<1/2>).6g",1,7,6])
ener.append([383189.82,"3s2.3p5.(2P*<3/2>).6g",1,9,8])
ener.append([383190.2,"3s2.3p5.(2P*<3/2>).6g",1,9,10])
ener.append([370901.88,"3s2.3p5.(2P*<3/2>).5g",1,5,4])
ener.append([371061.3,"3s2.3p5.(2P*<3/2>).5g",1,7,6])
ener.append([370903.12,"3s2.3p5.(2P*<3/2>).5g",1,5,6])
ener.append([371121.06,"3s2.3p5.(2P*<3/2>).5g",1,9,10])
ener.append([371120.69,"3s2.3p5.(2P*<3/2>).5g",1,9,8])
ener.append([371061.37,"3s2.3p5.(2P*<3/2>).5g",1,7,8])
ener.append([370957.52,"3s2.3p5.(2P*<3/2>).5g",1,11,12])
ener.append([370957.65,"3s2.3p5.(2P*<3/2>).5g",1,11,10])
ener.append([374143.44,"3s2.3p5.(2P*<1/2>).5g",1,7,8])
ener.append([374143.84,"3s2.3p5.(2P*<1/2>).5g",1,7,6])
ener.append([374138.9,"3s2.3p5.(2P*<1/2>).5g",1,9,8])
ener.append([374139.31,"3s2.3p5.(2P*<1/2>).5g",1,9,10])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=2
energy.values["method"]="nist"
energy.values["ionization"]=None
ener=[]
ener.append([0.0,"3s2.3p6",0,0,0])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=2
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([0.0,"3s2.3p6",0,0,0])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

# Cation Ca2+ : extracted by fit from Derevianko data
energy.values["charge"]=2
energy.values["method"]="divers"
energy.values["ionization"]=None
ener=[[0.,'3s2.3p6',0,0,-2]]
ener.append([220852.627414/ryd,"core1",0,-99,-2])
ener.append([371639.292563/ryd,"core2",0,-99,-2])
ener.append([2725817.2086/ryd,"core3",0,-99,-2])
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Scandium 21
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Titanium 22
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Vanadium 23
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Chromium 24
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Manganese 25
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Iron 27
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Cobalt 28
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Nickel 29
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Copper 30
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Zinc 31
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Gallium 32
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Germanium 33
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Arsenic 34
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Selenium 35
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Bromine 36
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Krypton 37
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Rubidium 38
reset_all(database)
ion=[33690.81,220105.0]
energy.values["label"]="Rb"
energy.values["charge"]=0
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([-0.153507732592,"5s",1,0,-2])
ener.append([-0.095471900952,"5p",1,2,-2])
ener.append([-0.06531858928,"4d",1,4,-2])
ener.append([-0.061934292703,"6s",1,0,-2])
ener.append([-0.045069013296,"6p",1,2,-2])
ener.append([-0.03638827352,"5d",1,4,-2])
ener.append([-0.033682178489,"7s",1,0,-2])
ener.append([-0.01733517429,"6d",1,4,-2])
ener.append([-0.005453598314,"8s",1,0,-2])
ener.append([-0.001626511,"7p",1,2,-2])
ener.append([0.054941413765,"7d",1,4,-2])
ener.append([0.202975370874,"4f",1,6,-2])
ener.append([0.456049133702,"8p",1,2,-2])
ener.append([0.515869432166,"8d",1,4,-2])
ener.append([0.812639956835,"9s",1,0,-2])
ener.append([3.70731548675,"10s",1,0,-2])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["method"]="cipsi-nof"
energy.values["ionization"]=None
ener=[]
ener.append([-0.153507732626,"5s",1,0,-2])
ener.append([-0.095471900938,"5p",1,2,-2])
ener.append([-0.065318589267,"4d",1,4,-2])
ener.append([-0.061934292663,"6s",1,0,-2])
ener.append([-0.045069013324,"6p",1,2,-2])
ener.append([-0.036388273527,"5d",1,4,-2])
ener.append([-0.033682178528,"7s",1,0,-2])
ener.append([-0.017335174284,"6d",1,4,-2])
ener.append([-0.005453598305,"8s",1,0,-2])
ener.append([-0.001626510993,"7p",1,2,-2])
ener.append([0.054941413746,"7d",1,4,-2])
ener.append([0.456049133733,"8p",1,2,-2])
ener.append([0.515869432179,"8d",1,4,-2])
ener.append([0.812639956791,"9s",1,0,-2])
ener.append([3.70731548673,"10s",1,0,-2])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["method"]="nist"
energy.values["ionization"]=ion[0]/ryd
ener=[]
ener.append([0.0,"5s",1,0,1])
ener.append([23792.591,"6p",1,2,3])
ener.append([23715.081,"6p",1,2,1])
ener.append([12816.545,"5p",1,2,3])
ener.append([12578.95,"5p",1,2,1])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

# Cation Rb+ : extracted by fit from Derevianko data
energy.values["charge"]=1
energy.values["method"]="divers"
energy.values["ionization"]=None
ener=[[0.,'4p6',0,0,-2]]
ener.append([165912/ryd,"core1",0,-99,-2])
ener.append([362918/ryd,"core2",0,-99,-2])
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[[0.,'4p6',0,0,0]]
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="nist"
energy.values["ionization"]=None
ener=[[0.,'4p6',0,0,0]]
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="nist-z"
energy.values["ionization"]=ion[1]/ryd
ener=[]
ener.append([0.0,"4p6",0,0,0])
ener.append([169658.536,"4p5.4d",0,2,2])
ener.append([155308.82,"4p5.4d",2,4,2])
ener.append([143461.977,"4p5.4d",2,2,2])
ener.append([140610.047,"4p5.(2P*<1/2>).5s",1,1,2])
ener.append([134869.751,"4p5.(2P*<3/2>).5s",1,3,2])
ener.append([167632.436,"4p5.(2P*<1/2>).5p",1,1,0])
ener.append([133341.607,"4p5.(2P*<3/2>).5s",1,3,4])
ener.append([165089.58,"4p5.(2P*<1/2>).5p",1,1,2])
ener.append([164968.007,"4p5.(2P*<1/2>).5p",1,3,4])
ener.append([163924.55,"4p5.(2P*<1/2>).5p",1,3,2])
ener.append([161200.171,"4p5.(2P*<3/2>).5p",1,1,0])
ener.append([138794.38,"4p5.(2P*<1/2>).5s",1,1,0])
ener.append([154273.98,"4p5.(2P*<3/2>).5p",1,1,2])
ener.append([180168.372,"4p5.(2P*<3/2>).6s",1,3,2])
ener.append([158151.666,"4p5.(2P*<3/2>).5p",1,3,2])
ener.append([156895.486,"4p5.(2P*<3/2>).5p",1,5,6])
ener.append([156737.011,"4p5.(2P*<3/2>).5p",1,5,4])
ener.append([143022.335,"4p5.4d",2,2,0])
ener.append([158711.854,"4p5.(2P*<3/2>).5p",1,3,4])
ener.append([143955.871,"4p5.4d",2,2,4])
ener.append([146832.593,"4p5.4d",2,6,6])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=10
energy.values["method"]="nist"
energy.values["ionization"]=None
ener=[[0.,'3d10',0,0,-2]]
ener.append([1008264.,"3d94p",2,2,-2])
ener.append([1023519.,"3d94p",0,2,-2])
ener.append([1031186.,"3d94p",2,4,-2])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Strontium 39
reset_all(database)
energy.values["label"]="Sr"
ion=[45932.09,88964.0]
energy.values["charge"]=0
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([-0.615276171121,"5s2",0,0,-2])
ener.append([-0.520635929285,"5s.4d",0,4,-2])
ener.append([-0.517653559858,"5s.5p",0,2,-2])
ener.append([-0.473190747956,"5s.6s",0,0,-2])
ener.append([-0.462223938906,"4d.5p",0,4,-2])
ener.append([-0.459379393456,"5s.6p",0,2,-2])
ener.append([-0.452046471847,"5s.5d",0,4,-2])
ener.append([-0.445921793779,"5s.7s",0,0,-2])
ener.append([-0.548793716582,"5s.5p",2,2,-2])
ener.append([-0.529764040902,"5s.4d",2,4,-2])
ener.append([-0.480913573295,"5s.6s",2,0,-2])
ener.append([-0.462694905973,"4d.5p",2,6,-2])
ener.append([-0.459863149162,"5s.6p",2,2,-2])
ener.append([-0.455327459847,"5p2",2,2,-2])
ener.append([-0.446899795551,"5s.5d",2,4,-2])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=0
energy.values["method"]="nist"
energy.values["ionization"]=ion[0]
ener=[]
ener.append([0.0,"5s2",0,0,0])
ener.append([21698.452,"5s.5p",0,2,2])
ener.append([14898.545,"5s.5p",2,2,4])
ener.append([35045.019,"5s.5d",2,4,6])
ener.append([14504.334,"5s.5p",2,2,2])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0]-ion[1])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=0
energy.values["method"]="nist-c"
ener=[]
ener.append([0.0,"5s2",0,0,0])
ener.append([45518.64,"5s.19p",0,2,2])
ener.append([45463.02,"5s.18p",0,2,2])
ener.append([45395.34,"5s.17p",0,2,2])
ener.append([45311.99,"5s.16p",0,2,2])
ener.append([45207.83,"5s.15p",0,2,2])
ener.append([45075.29,"5s.14p",0,2,2])
ener.append([44903.5,"5s.13p",0,2,2])
ener.append([44675.737,"5s.12p",0,2,2])
ener.append([44366.42,"5s.11p",0,2,2])
ener.append([43938.201,"5s.10p",0,2,2])
ener.append([43328.04,"5s.9p",0,2,2])
ener.append([42462.136,"5s.8p",0,2,2])
ener.append([41172.054,"4d.5p",0,2,2])
ener.append([38906.858,"5s.7p",0,2,2])
ener.append([34098.404,"5s.6p",0,2,2])
ener.append([14317.507,"5s.5p",2,2,0])
ener.append([44595.92,"4d2",2,2,2])
ener.append([20149.685,"5s.4d",0,4,4])
ener.append([43656.219,"5s.7f",0,6,6])
ener.append([14504.334,"5s.5p",2,2,2])
ener.append([37424.675,"5s.7s",2,0,2])
ener.append([42839.589,"5s.6f",0,6,6])
ener.append([14898.545,"5s.5p",2,2,4])
ener.append([41519.04,"5s.5f",0,6,6])
ener.append([35674.637,"5p2",2,2,4])
ener.append([35400.105,"5p2",2,2,2])
ener.append([18159.04,"5s.4d",2,4,2])
ener.append([38750.42,"5s.4f",2,6,4])
ener.append([18218.784,"5s.4d",2,4,4])
ener.append([35006.908,"5s.5d",2,4,2])
ener.append([18319.261,"5s.4d",2,4,6])
ener.append([38755.175,"5s.4f",2,6,8])
ener.append([38752.41,"5s.4f",2,6,6])
ener.append([35021.989,"5s.5d",2,4,4])
ener.append([39539.013,"5s.4f",0,6,6])
ener.append([37336.591,"4d.5p",2,2,4])
ener.append([37302.731,"4d.5p",2,2,2])
ener.append([36559.492,"4d.5p",2,4,6])
ener.append([36381.746,"4d.5p",2,4,4])
ener.append([36264.151,"4d.5p",2,4,2])
ener.append([38007.742,"4d.5p",0,6,6])
ener.append([33973.065,"5s.6p",2,2,4])
ener.append([33826.899,"4d.5p",0,4,4])
ener.append([33868.317,"5s.6p",2,2,2])
ener.append([33919.315,"4d.5p",2,6,8])
ener.append([33589.709,"4d.5p",2,6,6])
ener.append([21698.452,"5s.5p",0,2,2])
ener.append([36960.842,"5p2",0,4,4])
ener.append([33266.851,"4d.5p",2,6,4])
ener.append([29038.773,"5s.6s",2,0,2])
ener.append([34727.447,"5s.5d",0,4,4])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0]-ion[1])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([-0.405204475915,"5s",1,0,-2])
ener.append([-0.338269312485,"4d",1,4,-2])
ener.append([-0.294868280522,"5p",1,2,-2])
ener.append([-0.187471159842,"6s",1,0,-2])
ener.append([-0.160856082615,"5d",1,4,-2])
ener.append([-0.1502342477,"6p",1,2,-2])
ener.append([-0.089816061528,"7s",1,0,-2])
ener.append([-0.08933998388,"7p",1,2,-2])
ener.append([-0.078484531581,"6d",1,4,-2])
ener.append([0.04198349781,"8p",1,2,-2])
ener.append([0.275654091825,"7d",1,4,-2])
ener.append([1.16371271127,"9p",1,2,-2])
ener.append([1.64892984582,"8s",1,0,-2])
ener.append([2.05802093429,"8d",1,4,-2])
ener.append([8.22138578952,"9s",1,0,-2])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="nist"
energy.values["ionization"]=ion[1]
ener=[]
ener.append([0.0,"5s",1,0,1])
ener.append([24516.65,"5p",1,2,3])
ener.append([23715.19,"5p",1,2,1])
ener.append([14555.9,"4d",1,4,3])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[1])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="nist-c"
ener=[]
ener.append([0.0,"5s",1,0,1])
ener.append([55769.7,"6p",1,2,1])
ener.append([14555.9,"4d",1,4,3])
ener.append([60991.34,"4f",1,6,5])
ener.append([14836.24,"4d",1,4,5])
ener.append([60990.04,"4f",1,6,7])
ener.append([24516.65,"5p",1,2,3])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[1])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=2
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([0.0,"4p6",0,0,0])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=2
energy.values["method"]="nist"
energy.values["ionization"]=None
ener=[]
ener.append([0.0,"4p6",0,0,0])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

# Cation Sr2+ : extracted by fit from Derevianko data
energy.values["charge"]=2
energy.values["method"]="divers"
energy.values["ionization"]=None
ener=[[0.,'4p6',0,0,-2]]
ener.append([202756.787566/ryd,"core1",0,-99,-2])
ener.append([305459.988908/ryd,"core2",0,-99,-2])
ener.append([1670937.8241/ryd,"core3",0,-99,-2])
ener.append([4575119.00509/ryd,"core4",0,-99,-2])
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Yttrium 40
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Zirconium 41
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Niobium 42
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Molybdenum 43
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Technetium 44
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Ruthenium 45
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Rhodium 46
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Palladium 47
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Silver 48
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Cadmium 49
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Indium 50
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Tin 51
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Antimony 52
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Tellurium 53
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Iodine 54
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Xenon 55
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Cesium 56
reset_all(database)
energy.values["label"]="Cs"
ion=[31406.46769,186777.4]
energy.values["charge"]=0
energy.values["method"]="cipsi"
ener=[]
ener.append([-0.143099414445,"6s",1,0,-2])
ener.append([-0.090484534383,"6p",1,2,-2])
ener.append([-0.076768138371,"5d",1,4,-2])
ener.append([-0.058600396544,"7s",1,0,-2])
ener.append([-0.043299992412,"7p",1,2,-2])
ener.append([-0.039118091997,"6d",1,4,-2])
ener.append([-0.032113443776,"8s",1,0,-2])
ener.append([-0.031175284247,"4f",1,6,-2])
ener.append([-0.022149734514,"7d",1,4,-2])
ener.append([-0.011301760721,"5f",1,6,-2])
ener.append([-0.003328491831,"9s",1,0,-2])
ener.append([0.009352984265,"8p",1,2,-2])
ener.append([0.04495517545,"8d",1,4,-2])
ener.append([0.069474510705,"6f",1,6,-2])
ener.append([0.12594603484,"10s",1,0,-2])
ener.append([0.300209665145,"9p",1,2,-2])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["method"]="cipsi-nof"
ener=[]
ener.append([-0.143099414455,"6s",1,0,-2])
ener.append([-0.090484534379,"6p",1,2,-2])
ener.append([-0.076768138363,"5d",1,4,-2])
ener.append([-0.058600396552,"7s",1,0,-2])
ener.append([-0.043299992431,"7p",1,2,-2])
ener.append([-0.039118091973,"6d",1,4,-2])
ener.append([-0.032113443793,"8s",1,0,-2])
ener.append([-0.022149734497,"7d",1,4,-2])
ener.append([-0.003328491802,"9s",1,0,-2])
ener.append([0.009352984278,"8p",1,2,-2])
ener.append([0.044955175475,"8d",1,4,-2])
ener.append([0.125946034818,"10s",1,0,-2])
ener.append([0.300209665177,"9p",1,2,-2])
ener.append([0.340179201618,"9d",1,4,-2])
ener.append([1.11641642832,"11s",1,0,-2])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=0
energy.values["method"]="nist"
energy.values["ionization"]=ion[0]
ener=[]
ener.append([0.0,"6s",1,0,1])
ener.append([21946.397,"7p",1,2,3])
ener.append([21765.348,"7p",1,2,1])
ener.append([11732.3071041,"6p",1,2,3])
ener.append([11178.2681587,"6p",1,2,1])
ener.append([14499.2568,"5d",1,4,3])
ener.append([14596.84232,"5d",1,4,5])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=0
energy.values["method"]="nist-c"
energy.values["ionization"]=ion[0]
ener=[]
ener.append([0.0,"6s",1,0,1])
ener.append([31167.74257,"25p",1,2,3])
ener.append([31143.84,"24p",1,2,3])
ener.append([31116.0904,"23p",1,2,3])
ener.append([31083.77,"22p",1,2,3])
ener.append([31045.664,"21p",1,2,3])
ener.append([31044.31315,"21p",1,2,1])
ener.append([31000.4,"20p",1,2,3])
ener.append([30998.79,"20p",1,2,1])
ener.append([30946.113,"19p",1,2,3])
ener.append([30944.16859,"19p",1,2,1])
ener.append([30880.1228,"18p",1,2,3])
ener.append([30877.74761,"18p",1,2,1])
ener.append([30798.852,"17p",1,2,3])
ener.append([30795.90702,"17p",1,2,1])
ener.append([30697.191,"16p",1,2,3])
ener.append([30693.47416,"16p",1,2,1])
ener.append([30567.688,"15p",1,2,3])
ener.append([30562.90893,"15p",1,2,1])
ener.append([30392.87183,"14p",1,2,1])
ener.append([30174.178,"13p",1,2,3])
ener.append([30165.66826,"13p",1,2,1])
ener.append([29864.345,"12p",1,2,3])
ener.append([29852.43153,"12p",1,2,1])
ener.append([29420.824,"11p",1,2,3])
ener.append([29403.4231,"11p",1,2,1])
ener.append([28753.6769,"10p",1,2,3])
ener.append([28726.8123,"10p",1,2,1])
ener.append([27681.6782,"9p",1,2,3])
ener.append([27636.9966,"9p",1,2,1])
ener.append([25791.508,"8p",1,2,3])
ener.append([25708.83548,"8p",1,2,1])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="nist-z"
energy.values["ionization"]=ion[1]
ener=[]
ener.append([0.0,"5p6",0,0,0])
ener.append([123645.5813,"5p5.(2P*<3/2>).5d",1,3,2])
ener.append([107914.1587,"5p5.(2P*<3/2>).5d",1,1,2])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="nist"
energy.values["ionization"]=ion[1]
ener=[]
ener.append([0.0,"5p6",0,0,0])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([0.0,"5p6",0,0,0])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

# Cation Cs+ : extracted by fit from Derevianko data
energy.values["charge"]=1
energy.values["method"]="divers"
energy.values["ionization"]=None
ener=[[0.,'5p6',0,0,-2]]
ener.append([142044/ryd,"core1",0,-99,-2])
ener.append([553515/ryd,"core2",0,-99,-2])
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Barium 57
reset_all(database)
ion=[42034.91,80686.30]
energy.values["label"]="Ba"
energy.values["charge"]=0
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([-0.559978562311,"6s2",0,0,-2])
ener.append([-0.505324472553,"6s.5d",0,4,-2])
ener.append([-0.480171542318,"6s.6p",0,2,-2])
ener.append([-0.456729710681,"5d2",0,4,-2])
ener.append([-0.452185557509,"5d.6p",0,4,-2])
ener.append([-0.444800590753,"6s.7s",0,0,-2])
ener.append([-0.515866054837,"6s.5d",2,4,-2])
ener.append([-0.500092090949,"6s.6p",2,2,-2])
ener.append([-0.459838552635,"5d.6p",2,6,-2])
ener.append([-0.455152192165,"6s.4f",2,6,-2])
ener.append([-0.450139646539,"5d.6p",2,2,-2])
ener.append([-0.444422527471,"5d.6p",2,4,-2])
ener.append([-0.439800645487,"6s.7s",2,0,-2])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=0
energy.values["method"]="nist"
energy.values["ionization"]=ion[0]/ryd
ener=[]
ener.append([0.0,"6s2",0,0,0])
ener.append([18060.261,"6s.6p",0,2,2])
ener=add_representation(ener)
for val in ener:
    val[0]=(val[0]-ion[0]-ion[1])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=0
energy.values["method"]="nist-c"
ener=[]
ener.append([0.0,"6s2",0,0,0])
ener.append([41494.39,"6s.18p",0,2,2])
ener.append([41411.04,"6s.17p",0,2,2])
ener.append([41307.88,"6s.16p",0,2,2])
ener.append([41183.6,"6s.15p",0,2,2])
ener.append([40991.23,"6s.14p",0,2,2])
ener.append([40765.23,"6s.13p",0,2,2])
ener.append([40428.68,"6s.12p",0,2,2])
ener.append([32547.033,"6s.7p",0,2,2])
ener.append([28554.221,"5d.6p",0,2,2])
ener.append([25704.11,"5d.6p",2,2,2])
ener.append([24192.033,"5d.6p",2,4,2])
ener.append([12636.623,"6s.6p",2,2,2])
ener.append([35762.187,"6s.7d",0,4,4])
ener.append([35344.413,"6p2",2,2,4])
ener.append([13514.745,"6s.6p",2,2,4])
ener.append([35785.273,"6s.7d",2,4,6])
ener.append([34493.904,"6p2",2,2,0])
ener.append([34371.002,"6s.8s",0,0,0])
ener.append([12266.024,"6s.6p",2,2,0])
ener.append([33905.358,"6s.8s",2,0,2])
ener.append([11395.35,"6s.5d",0,4,4])
ener.append([30750.672,"6s.6d",2,4,4])
ener.append([30818.115,"6s.6d",2,4,6])
ener.append([18060.261,"6s.6p",0,2,2])
ener.append([9215.501,"6s.5d",2,4,4])
ener.append([25956.519,"5d.6p",2,2,4])
ener.append([9033.966,"6s.5d",2,4,2])
ener.append([25642.126,"5d.6p",2,2,0])
ener.append([24979.834,"5d.6p",2,4,6])
ener.append([24531.513,"5d.6p",2,4,4])
ener.append([9596.533,"6s.5d",2,4,6])
ener.append([23757.049,"5d.6p",2,6,8])
ener.append([23074.387,"5d.6p",0,4,4])
ener.append([26160.293,"6s.7s",2,0,2])
ener.append([22947.423,"5d.6p",2,6,6])
ener.append([22064.645,"5d.6p",2,6,4])
ener.append([23062.051,"5d2",0,4,4])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[0]-ion[1])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=1
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([-0.367634965634,"6s",1,0,-2])
ener.append([-0.343238909911,"5d",1,4,-2])
ener.append([-0.270180249796,"6p",1,2,-2])
ener.append([-0.173704219073,"7s",1,0,-2])
ener.append([-0.155707521527,"6d",1,4,-2])
ener.append([-0.140243707376,"7p",1,2,-2])
ener.append([-0.102604803731,"8s",1,0,-2])
ener.append([-0.083231538725,"8p",1,2,-2])
ener.append([-0.067926317158,"9s",1,0,-2])
ener.append([-0.029893698844,"7d",1,4,-2])
ener.append([0.007601368945,"10s",1,0,-2])
ener.append([0.009379270217,"9p",1,2,-2])
ener.append([0.612147224068,"8d",1,4,-2])
ener.append([1.3179184565,"10p",1,2,-2])
ener.append([2.40966952844,"9d",1,4,-2])
ener.append([2.65926435464,"11s",1,0,-2])
ener.append([3.90760188475,"11p",1,2,-2])
ener.append([6.24520946524,"10d",1,4,-2])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["method"]="nist-c"
energy.values["ionization"]=ion[1]/ryd
ener=[]
ener.append([0.0,"6s",1,0,1])
ener.append([61339.5,"8p",1,2,1])
ener.append([20261.561,"6p",1,2,1])
ener.append([70014.584,"10s",1,0,1])
ener.append([49389.822,"7p",1,2,1])
ener.append([21952.404,"6p",1,2,3])
ener.append([66673.651,"8d",1,4,3])
ener.append([65683.646,"9s",1,0,1])
ener.append([66725.591,"8d",1,4,5])
ener.append([59800.254,"7d",1,4,3])
ener.append([59894.928,"7d",1,4,5])
ener.append([58025.211,"8s",1,0,1])
ener.append([45949.472,"6d",1,4,3])
ener.append([74091.05,"9f",1,6,5])
ener.append([46154.847,"6d",1,4,5])
ener.append([74108.92,"9f",1,6,7])
ener.append([73101.58,"10d",1,4,3])
ener.append([50011.34,"7p",1,2,3])
ener.append([73122.35,"10d",1,4,5])
ener.append([42355.175,"7s",1,0,1])
ener.append([70620.247,"9d",1,4,3])
ener.append([70651.905,"9d",1,4,5])
ener.append([48258.617,"4f",1,6,5])
ener.append([68426.095,"6g",1,8,7])
ener.append([48483.332,"4f",1,6,7])
ener.append([68426.095,"6g",1,8,9])
ener.append([64596.33,"6f",1,6,5])
ener.append([64697.08,"6f",1,6,7])
ener.append([4873.852,"5d",1,4,3])
ener.append([5674.807,"5d",1,4,5])
ener.append([63026.725,"5g",1,8,7])
ener.append([63026.725,"5g",1,8,9])
ener.append([57631.739,"5f",1,6,7])
ener.append([57390.922,"5f",1,6,5])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0]-ion[1])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=2
energy.values["method"]="nist-z"
energy.values["ionization"]=None
ener=[]
ener.append([0.0,"5p6",0,0,0])
ener.append([180026.71,"5p5.(2P*<1/2>).5d",1,3,2])
ener.append([170192.53,"5p5.(2P*<1/2>).6s",1,1,2])
ener.append([154494.21,"5p5.(2P*<3/2>).6s",1,3,2])
ener.append([153054.62,"5p5.(2P*<3/2>).5d",1,3,2])
ener.append([134568.12,"5p5.(2P*<3/2>).5d",1,1,2])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=2
energy.values["method"]="nist"
energy.values["ionization"]=None
ener=[]
ener.append([0.0,"5p6",0,0,0])
ener=add_representation(ener)
for val in ener:
  val[0]=(val[0])/ryd
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

energy.values["charge"]=2
energy.values["method"]="cipsi"
energy.values["ionization"]=None
ener=[]
ener.append([0.0,"5p6",0,0,0])
ener=add_representation(ener)
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

# Cation Sr2+ : extracted by fit from Derevianko data
energy.values["charge"]=2
energy.values["method"]="divers"
energy.values["ionization"]=None
ener=[[0.,'5p6',0,0,-2]]
ener.append([130372.811962/ryd,"core1",0,-99,-2])
ener.append([268459.047872/ryd,"core2",0,-99,-2])
for val in ener:
    energy.values["energy"]=val[0]
    energy.values["configuration"]=val[1]
    energy.values["totalSpin"]=val[2]
    energy.values["totalOrbital"]=val[3]
    energy.values["totalJ"]=val[4]
    store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Lanthanum 58
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Cerium 59
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Praseodymium 60
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Neodymium 61
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Promethium 62
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Samarium 63
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Europium 64
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Gadolinium 65
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Terbium 66
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Dysprosium 67
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Holmium 68
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Erbium 69
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Thulium 70
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Ytterbium 71
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Lutetium 72
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Hafnium 73
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Tantalum 74
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Tungsten 75
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Rhenium 76
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Osmium 77
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Iridium 78
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Platinum 79
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Gold 80
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Mercury 81
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Thallium 82
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Lead 83
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Bismuth 84
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Polonium 85
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Astatine 86
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Radon 87
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Francium 88
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Radium 89
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Actinium 90
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Thorium 91
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Protactinium 92
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Uranium 93
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Neptunium 94
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Plutonium 95
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Americium 96
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Curium 97
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Berkelium 98
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Californium 99
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Einsteinium 100
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Fermium 101
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Mendelevium 102
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Nobelium 103
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Lawrencium 104
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Rutherfordium 105
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Dubnium 106
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Seaborgium 107
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Bohrium 108
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Hassium 109
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Meitnerium 110
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Darmstadtium 111
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Roentgenium 112
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Copernicium 113
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Ununtrium 114
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Flerovium 115
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Ununpentium 116
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Livermorium 117
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Ununseptium 118
reset_all(database)
store_all(database)

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Ununoctium 119
reset_all(database)
store_all(database)

connection.commit()
copy_method()# copy cipsi into cipsi-nof for atoms with no f orbitals in the basis

connection.commit()
connection.close()
