Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
makes_sense = True
for i, ox_i in enumerate(ox):
for j, ox_j in enumerate(ox[i+1:]):
#!print ox_i, ox_j, paul[i], paul[i+1+j]
if ox_i < ox_j:
if paul[i] < paul[i+1+j]:
makes_sense = False
if ox_i > ox_j:
if paul[i] > paul[i+1+j]:
makes_sense = False
if ox_i == ox_j:
if paul[i] != paul[i+1+j]:
makes_sense = False
return makes_sense
with open(path.join(smact.data_directory, 'element.txt'),'r') as f:
data = f.readlines()
list_of_elements = []
list_of_elements = smact.ordered_elements(1,16)
#for line in data:
# if not line.startswith('#'):
# species = line.split()
# if int(species[0]) > 0 and int(species[0]) < 81:
# #if len(smact.Element(species[1]).oxidation_states) > 0:
# if smact.Element(species[1]).oxidation_states:
# list_of_elements.append(species[1])
print(list_of_elements)
list_of_elements=tuple(smact.ordered_elements(1,16))
makes_sense = True
for i, ox_i in enumerate(ox):
for j, ox_j in enumerate(ox[i+1:]):
#!print ox_i, ox_j, paul[i], paul[i+1+j]
if ox_i < ox_j:
if paul[i] < paul[i+1+j]:
makes_sense = False
if ox_i > ox_j:
if paul[i] > paul[i+1+j]:
makes_sense = False
if ox_i == ox_j:
if paul[i] != paul[i+1+j]:
makes_sense = False
return makes_sense
with open(path.join(smact.data_directory, 'element.txt'), 'r') as f:
data = f.readlines()
list_of_elements = []
for line in data:
if not line.startswith('#'):
species = line.split()
if int(species[0]) > 0 and int(species[0]) < 81:
#if len(smact.Element(species[1]).oxidation_states) > 0:
if smact.Element(species[1]).oxidation_states:
list_of_elements.append(species[1])
count_of_ternary = 0
count_raw_ternary = 0
element_count = 0
ion_count = 0
makes_sense = True
for i, ox_i in enumerate(ox):
for j, ox_j in enumerate(ox[i+1:]):
#!print ox_i, ox_j, paul[i], paul[i+1+j]
if ox_i < ox_j:
if paul[i] < paul[i+1+j]:
makes_sense = False
if ox_i > ox_j:
if paul[i] > paul[i+1+j]:
makes_sense = False
if ox_i == ox_j:
if paul[i] != paul[i+1+j]:
makes_sense = False
return makes_sense
with open(path.join(smact.data_directory, 'element.txt'),'r') as f:
data = f.readlines()
list_of_elements = []
for line in data:
if not line.startswith('#'):
species = line.split()
if int(species[0]) > 0 and int(species[0]) < 101:
#if len(smact.Element(species[1]).oxidation_states) > 0:
if smact.Element(species[1]).oxidation_states:
list_of_elements.append(species[1])
count_of_ternary = 0
count_raw_ternary = 0
element_count = 0
ion_count = 0
def __init__(self):
r"""Parse Shannon radii data file.
Also calculates "spring constant", _k_, based on maximum
difference in Shannon radii:
.. math::
k = \Delta r_\mathrm{max}^{-2}.
"""
shannon_file = os.path.join(data_directory, "shannon_radii.csv")
self.shannon_data = pd.read_csv(shannon_file, index_col=0)
self.k = (
self.shannon_data["ionic_radius"].max() - self.shannon_data["ionic_radius"].min()
)**-2
def __init__(self, probability_table=None):
'''
Args:
probability_table (dict): Lookup table to get probabilities for anion-cation pairs.
Must be of the format {(anion,cation): probability, ...} e.g. {('F-1', 'Li1'): 1.0,...}.
If none, the default table is loaded from the data directory.
'''
if probability_table == None:
with open(path.join(data_directory,'oxidation_state_probability_table.json'), 'r') as f:
probability_data = json.load(f)
# Put data into the required format
probability_table = {}
for i in probability_data:
probability_table[(i[0],i[1])] = i[2]
self._probability_table = probability_table
# Define set of species for which we have data
included_anions = set([i[0] for i in self._probability_table.keys()])
included_cations = set([i[1] for i in self._probability_table.keys()])
included_species = list(included_anions) + list(included_cations)
self._included_species = included_species
self._included_cations = included_cations
self._included_anions = included_anions
Default values used from Faraday Discussions paper (DOI: 10.1039/C8FD00032H) if none supplied.
scoring (str): Can be either:
overall_score - Mean species-anion score for each species of interest
in the composition.
limiting_score - As above but minimum species-anion score.
probability - Product of scores.
probability_simple - Product of scores for different species only (set(comp))
verbose (bool): Explicitly print any compounds that were skipped over due to the elements
they contain.
edit_struc_dict (bool): Add the probability to the dicts in the structures list.
Returns:
probabilities_list (list): Score for each structure in structures.
"""
if not list_scores:
# Import default list_scores from data directory
with open(os.path.join(data_directory,
'oxidation_states/oxidationstates_prob_table.csv'), 'r') as f:
reader = csv.reader(f)
list_scores = {eval(rows[0]): eval(rows[1]) for rows in reader}
print('INFO: Using default list_scores.')
if not species_list:
# Import species_list from data directory
with open(os.path.join(data_directory,'oxidation_states/species_list.txt'), 'r') as f:
species_list = eval(f.readline())
print('INFO: Using default species_list.')
scores_dict = {}
for key in list_scores.keys():
an = {}
for spec, val in zip(species_list, list_scores[key]):
an[spec] = val
scores_dict[key] = an
return a, b, c, space, alpha, beta, gamma
e_lattices = [E2_1]
i = 0
a_sym = []
a_cood = []
a_shannon = []
b_sym = []
b_cood = []
b_shannon = []
c_sym = ['O']
c_cood = [2]
c_shannon = [1.21]
with open(path.join(smact.data_directory, 'shannon_radii.csv'), 'rU') as f:
reader = csv.reader(f)
reader.next() # Skip the first row which is titles
for row in reader:
# print row
if i <= 1000: # "Safety valve"
if row[1] == '2' and row[2] == '6_n'or'8_n':
a_sym.append(row[0])
# a_cood.append(row[2])
a_shannon.append(row[3])
if row[1] == '4' and '6_n':
b_sym.append(row[0])
b_cood.append(row[2])
b_shannon.append(row[3])
i += 1
for j, bsymbol in enumerate(b_sym):
they contain.
edit_struc_dict (bool): Add the probability to the dicts in the structures list.
Returns:
probabilities_list (list): Score for each structure in structures.
"""
if not list_scores:
# Import default list_scores from data directory
with open(os.path.join(data_directory,
'oxidation_states/oxidationstates_prob_table.csv'), 'r') as f:
reader = csv.reader(f)
list_scores = {eval(rows[0]): eval(rows[1]) for rows in reader}
print('INFO: Using default list_scores.')
if not species_list:
# Import species_list from data directory
with open(os.path.join(data_directory,'oxidation_states/species_list.txt'), 'r') as f:
species_list = eval(f.readline())
print('INFO: Using default species_list.')
scores_dict = {}
for key in list_scores.keys():
an = {}
for spec, val in zip(species_list, list_scores[key]):
an[spec] = val
scores_dict[key] = an
probabilities_list = []
for struc in structures:
scores = []
comp = set(list(struc['structure'].species))
comp = [(sp.symbol, sp.oxi_state) for sp in comp]
an_symbols = [an[0] for an in list_scores.keys()]
site_C = lattice.Site([0.5,0.5,0.5],[-2,-1])
perovskite = lattice.Lattice([site_A,site_B,site_C],space_group=221)
# In[4]:
search = smact.ordered_elements(3,87)
# In[5]:
A_list = []
B_list = []
C_list = [['O',-2,1.35],['S',-2,1.84],['Se',-2,1.98],['F',-1,1.285],['Br',-1,1.96],['I',-1,2.2]]
for element in search:
with open(path.join(smact.data_directory, 'shannon_radii.csv'), 'rU') as f:
reader = csv.reader(f)
r_shannon=False
for row in reader:
if row[2]=="12_n" and row[0]==element and int(row[1]) in site_A.oxidation_states:
A_list.append([row[0],row[1],row[4]])
if row[2]=="6_n" and row[0]==element and int(row[1]) in site_B.oxidation_states:
B_list.append([row[0],row[1],row[4]])
# In[6]:
charge_balanced = []
goldschmidt_cubic = []
goldschmidt_ortho = []
a_too_large = []
def radius_shannon(element, oxidation):
with open(path.join(smact.data_directory,
'shannon_radii.csv'), 'rU') as f:
reader = csv.reader(f)
r_shannon = False
for row in reader:
if (element == row[0] and float(oxidation) == float(row[1])
and row[2] == '4_n'): # only for Wurtzite
r_shannon = row[3]
return r_shannon