Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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))
print(list_of_elements)
print(enumerate(list_of_elements))
for ternary in itertools.permutations(list_of_elements,3):
print(ternary)
count_of_ternary = 0
count_raw_ternary = 0
element_count = 0
ion_count = 0
charge_neutral_count = 0
pauling_count = 0
for ternary in itertools.combinations(list_of_elements,3):
# print(ternary)
if ret1:
chargeNeutralCount = chargeNeutralCount + 1;
if smact.pauling_test(oxidationStates, electronegativities):
paulingSensibleCount = paulingSensibleCount + 1;
return (combinationCount, chargeNeutralCount, paulingSensibleCount);
#EndRegion
#Region: Main
#COMMENT: When using multiprocessing, the "main" code *must* be enclosed in this block - otherwise, bad things happen (at least, they do on Windows...).
if __name__ == "__main__":
elementList = smact.ordered_elements(1, 100);
startTime = time.time();
searchPrimitives = [smact.Element(element) for element in elementList];
threadPool = Pool(4);
#COMMENT: The mapping function returns a tuple of counts, and the list of these generated by Pool.map() needs to be summed at the end; this isn't great, but it's probably better than shared state.
result = threadPool.map(_Kernel, itertools.combinations(searchPrimitives, 4), 100);
#COMMENT: To see whether or not multithreading makes a difference, we can also try the equivalent single-thread code.
#result = [_Kernel(argument) for argument in itertools.combinations(searchPrimitives, 4)];
combinationCount = sum(count1 for count1, count2, count3 in result);
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))
print(list_of_elements)
print(enumerate(list_of_elements))
for ternary in itertools.permutations(list_of_elements,3):
import matplotlib.pyplot as plt
import matplotlib
from os import path
# In[3]:
site_A = lattice.Site([0,0,0],[+1,+2,+3])
site_B = lattice.Site([0.5,0.5,0.5],[+5,+4,+3,+2])
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]])
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
#------------------------------------------------------------------------------
output = []
# Processing Lattices
#------------------------------------------------------------------------------
lattice_charge = -1
upper_n = 100
lower_n = 1
all_elements = []
element_set = smact.ordered_elements(lower_n, upper_n) # The safety valve!
# Form a separate complete list of elements for quickly accessing proton
# numbers with index()
with open(path.join(smact.data_directory,
'ordered_periodic.txt'), 'rU') as f:
reader = csv.reader(f)
for row in reader:
all_elements.append(row[0])
# Form list of elements known to coordinate tetragonally
tetra_coord_elements = []
for element in element_set:
with open(path.join(smact.data_directory, 'shannon_radii.csv'), 'rU') as f:
reader = csv.reader(f)
r_shannon = False
for row in reader:
#! /usr/bin/env python
import time
import smact
import itertools
from sys import stdout
from smact.screening import eneg_states_test
from multiprocessing import Pool
element_list = smact.ordered_elements(1, 103)
elements = smact.element_dictionary(element_list)
max_n = 4
neutral_stoichiometries_threshold = 8
include_pauling_test = True
pauling_test_threshold = 0.0
# Number of times to report progress during the counting loop.
count_progress_interval = 100
# Parameters for the threaded version of the code.
mp_use = True
mp_processes = 4
mp_chunk_size = 10
reverse (bool): Whether to reverse the ordering (descending order).
cation_only (bool): Whether to only consider species in positive oxidation
states.
metal_only (bool): Whether to only consider metal elements.
Returns:
species_list (list): Unique species that are exhibited in the structures.
"""
# Initially comb through the structures for all unique species
species_list = []
for i in structures:
for sp in i['structure'].composition:
species_list.append((sp))
species_list = list(set(species_list))
ordered_el = ordered_elements(1,103)
# Turn into tuples for easy sorting
species_list = [(i.symbol, i.oxi_state) for i in species_list]
if ordering == 'ptable':
species_list.sort(key = lambda x: (ordered_el.index(x[0]),x[1]), reverse=reverse)
print("Species ordered by periodic table position.")
else:
print('Did not reorder the list of species...')
# Turn back into Species objects
species_list = [Specie(i[0], i[1]) for i in species_list]
if metal_only:
print('Metals only: ON')
species_list = [i for i in species_list if (i.symbol in metals)]
if cation_only: