def test_element_data(Z): # Cycle through the elements and check that # the info returned from the functions is consistent data = lut.element_data_from_Z(Z) assert data[1] == int(Z) assert data == lut.element_data_from_sym(data[0]) assert data == lut.element_data_from_name(data[2]) assert data[0] == lut.element_sym_from_Z(Z) assert data[2] == lut.element_name_from_Z(Z) nsym = lut.element_sym_from_Z(Z, True) nname = lut.element_name_from_Z(Z, True) assert int(Z) == lut.element_Z_from_sym(nsym.upper()) # Check capitalization assert nsym[0] == data[0][0].upper() assert nname[0] == data[2][0].upper()
split_lines = f.readlines() all_names = [ 'ANO-RCC-MB', 'ANO-RCC-VDZ', 'ANO-RCC-VDZP', 'ANO-RCC-VTZP', 'ANO-RCC-VQZP', 'ANO-RCC-VTZ' ] split_data = {n: {} for n in all_names} for l in split_lines: name, cont = l.split() el1, name1 = name.split('.') el2, name2, _, _, cont, _ = cont.split('.') assert el1 == el2 assert name2 == 'ANO-RCC' assert name1 in all_names el = lut.element_Z_from_sym(el1, as_str=True) assert el not in split_data[name1] cont = re.findall(r'\d+[a-z]+', cont) split_data[name1][el] = cont for name, el_cont_data in split_data.items(): print() print(name) new_basis = copy.deepcopy(base_data) missing_el = [] for el, eldata in new_basis['elements'].items(): if not el in el_cont_data: missing_el.append(el)
def get_element_number(element): return lut.element_Z_from_sym(element)
import re import sys import copy from basis_set_exchange import fileio, lut from basis_set_exchange.readers.helpers import partition_lines, parse_fixed_matrix with open('ano-r.1.molcas', 'r') as f: base_data = [x.strip() for x in f.readlines()] with open('splitmap-ano-r.txt', 'r') as f: split_data = f.readlines()[2:] split_data = [x.strip().split() for x in split_data] split_data = { lut.element_Z_from_sym(x[0], as_str=True): (x[1], x[2], x[3], x[4]) for x in split_data } element_blocks = partition_lines(base_data, lambda x: x.startswith('/')) names = ['ANO-R0', 'ANO-R1', 'ANO-R2', 'ANO-R3'] for idx, name in enumerate(names): out_lines = [] print(name) element_blocks_copy = copy.deepcopy(element_blocks) for block in element_blocks_copy: el = re.match(r'/([A-Za-z]+)\..*', block[0]).group(1) el = lut.element_Z_from_sym(el, as_str=True)
print("basis {} already has element {}. Overwriting...".format( bn, el), file=sys.stderr) all_basis[bn][el] = el_bas_data if not desired_basis in all_basis: raise RuntimeError("basis '{}' not found".format(desired_basis)) bas = all_basis[desired_basis] for el, v in bas.items(): while len(v['links']) > 0: linkstmp = v['links'].copy() v['links'] = [] for l in linkstmp: el2, b2 = l.split(maxsplit=1) if el2 != el: raise RuntimeError("bad link") ldata = all_basis[b2][el2] v['shells'].extend(ldata['shells']) v['links'].extend(ldata['links']) allel = sorted(bas.keys(), key=lambda x: lut.element_Z_from_sym(x)) s = '*\n' for el in allel: s += '{} {}\n*\n'.format(el, desired_basis) s += '\n'.join(bas[el]['shells']) s += '\n*\n' print(s)
#!/usr/bin/env python3 import re import sys import copy from basis_set_exchange import fileio, lut base_data = fileio.read_json_basis('ANO-R.1.json') with open('splitmap-ano-r.txt', 'r') as f: split_data = f.readlines()[2:] split_data = [x.strip().split() for x in split_data] split_data = {lut.element_Z_from_sym(x[0], as_str=True): (x[1], x[2], x[3], x[4]) for x in split_data} names = ['ANO-R0', 'ANO-R1', 'ANO-R2', 'ANO-R3'] for idx,name in enumerate(names): print(name) new_basis = copy.deepcopy(base_data) for el,eldata in new_basis['elements'].items(): el_split = split_data[el][idx] el_split = re.findall(r'\d+[a-z]+', el_split) print(' -> ', el, el_split) new_shells = [] # Double and triple check am = [sh['angular_momentum'] for sh in eldata['electron_shells']] for a in am: assert len(a) == 1