make_radii_dict.py 2.71 KB
Newer Older
1 2 3 4
import numpy as np
import pandas as pd
import json

Luigi's avatar
Luigi committed
5
df = pd.read_csv('./data/perovskites_tolerance_factor/Shannon_Effective_Ionic_Radii.csv')
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

df = df.rename(columns = {'OX. State': 'ox',
                          'Coord. #': 'coord',
                          'Crystal Radius': 'rcryst',
                          'Ionic Radius': 'rion',
                          'Spin State' : 'spin'})
    
df['spin'] = [spin if spin in ['HS', 'LS'] else 'only_spin' for spin in df.spin.values]

def get_el(row):
    ION = row['ION']
    if ' ' in ION:
        return ION.split(' ')[0]
    elif '+' in ION:
        return ION.split('+')[0]
    elif '-' in ION:
        return ION.split('-')[0]

df['el'] = df.apply(lambda row: get_el(row), axis = 1)

el_to_ox = {}
for el in df.el.values:
    el_to_ox[el] = list(set(df.ox.get((df['el'] == el)).tolist()))
 
ionic_radii_dict = {}
for el in el_to_ox:
    oxs = el_to_ox[el]
    ox_to_coord = {}
    for ox in oxs:
        coords = df.coord.get((df['el'] == el) & (df['ox'] == ox)).tolist()
        ox_to_coord[ox] = coords
        coord_to_spin = {}
        for coord in ox_to_coord[ox]:
            spin = df.spin.get((df['el'] == el) & (df['ox'] == ox) & (df['coord'] == coord)).tolist()
            coord_to_spin[coord] = spin
            spin_to_rad = {}
            for spin in coord_to_spin[coord]:
                rad = df.rion.get((df['el'] == el) & (df['ox'] == ox) & (df['coord'] == coord) & (df['spin'] == spin)).tolist()[0]
                spin_to_rad[spin] = rad  
                coord_to_spin[coord] = spin_to_rad
                ox_to_coord[ox] = coord_to_spin
    ionic_radii_dict[el] = ox_to_coord

spin_els = ['Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu']
starting_d = [4, 5, 6, 7, 8, 9]
d_dict = dict(zip(spin_els, starting_d))
for el in spin_els:
    for ox in ionic_radii_dict[el].keys():
        for coord in ionic_radii_dict[el][ox].keys():
            if len(ionic_radii_dict[el][ox][coord].keys()) > 1:
                num_d = d_dict[el] + 2 - ox
                if num_d in [4, 5, 6, 7]:
                    ionic_radii_dict[el][ox][coord]['only_spin'] = ionic_radii_dict[el][ox][coord]['HS']
                else:
                    ionic_radii_dict[el][ox][coord]['only_spin'] = ionic_radii_dict[el][ox][coord]['LS']
            elif 'HS' in ionic_radii_dict[el][ox][coord].keys():
                ionic_radii_dict[el][ox][coord]['only_spin'] = ionic_radii_dict[el][ox][coord]['HS']
            elif 'LS' in ionic_radii_dict[el][ox][coord].keys():
                ionic_radii_dict[el][ox][coord]['only_spin'] = ionic_radii_dict[el][ox][coord]['LS']
                
with open('Shannon_radii_dict.json', 'w') as f:
    json.dump(ionic_radii_dict, f)