예제 #1
0
파일: test.py 프로젝트: WMD-group/SMACT
 def test_ordered_elements(self):
     self.assertEqual(
         smact.ordered_elements(65, 68),
         ['Tb', 'Dy', 'Ho', 'Er'])
     self.assertEqual(
         smact.ordered_elements(52, 52),
         ['Te'])
예제 #2
0
파일: test.py 프로젝트: NanoResearch/SMACT
 def test_ordered_elements(self):
     self.assertEqual(
         smact.ordered_elements(65, 68),
         ['Tb', 'Dy', 'Ho', 'Er'])
     self.assertEqual(
         smact.ordered_elements(52, 52),
         ['Te'])
예제 #3
0
def get_unique_species(structures,
                       ordering='ptable',
                       reverse=False,
                       cation_only=True,
                       metal_only=True):
    """Given a set of pymatgen structures, in the form of dictionaries where the
    Structure is keyed as 'structure', returns a list of all the different
    Species present in that set.
    Args:
        structures (list): Dictionaries containing pymatgen Structures.
        ordering('string'): How to order the Species:
            ptable: order by periodic table position.
            Can be set to None.
        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:
        print('Cations only: ON')
        species_list = [i for i in species_list if (i.oxi_state > 0)]

    print("First species: {0}  last species: {1}".format(
        species_list[0], species_list[-1]))
    return species_list
예제 #4
0
def sort_species(species_list, ordering):
    """Given a list of pymatgen Species, will order them according to a given
    rule and return the ordered list.
    ordering is a string that can take values: 'ptable': order by periodic table position.
    Args:
        species_list (list): Pymatgen species objects
    """
    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]))
        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]
    print("First species: {0}  last species: {1}".format(
        species_list[0], species_list[-1]))
    return species_list
예제 #5
0
# ## Setting up the perovskite lattice
# SMACT lattice is an object which contains information about the positions of the lattice sites, the oxiation states of the potential species at those sites and the spacegroup of the lattice. It can be used to quickly build atomistic models of the results of a screening.

# In[3]:

site_A = smact.lattice.Site([0, 0, 0], [+1, +2, +3])
site_B = smact.lattice.Site([0.5, 0.5, 0.5], [+5, +4, +3, +2])
site_C = smact.lattice.Site([0.5, 0.5, 0.5], [-2, -1])
perovskite = smact.lattice.Lattice([site_A, site_B, site_C], space_group=221)

# ## Set up the chemical space for the search
# Initially we search through the first 100 elements blindly. The total number of possible combinations is returned.

# In[4]:

search = smact.ordered_elements(1, 103)
initial_total = len(list(itertools.combinations(search, 3)))

# ## Applying chemical restrictions
# We now narrow the search space by applying some chemical criteria.
# 1. The X site is either O, S, Se, Cl, Br, or I.
# 2. The B site is known to have octahedral coordination from the [data of Shannon.](http://scripts.iucr.org/cgi-bin/paper?a12967)

# In[5]:

A_list = []
B_list = []
C_list = [['O', -2, 1.35], ['S', -2, 1.84], ['Se', -2, 1.98], ['F', -1, 1.29],
          ['Cl', -1, 1.81], ['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:
예제 #6
0
# SMACT lattice is an object which contains information about the positions of the lattice sites, the oxiation states of the potential species at those sites and the spacegroup of the lattice. It can be used to quickly build atomistic models of the results of a screening.

# In[3]:

site_A = smact.lattice.Site([0,0,0],[+1,+2,+3])
site_B = smact.lattice.Site([0.5,0.5,0.5],[+5,+4,+3,+2])
site_C = smact.lattice.Site([0.5,0.5,0.5],[-2,-1])
perovskite = smact.lattice.Lattice([site_A,site_B,site_C],space_group=221)


# ## Set up the chemical space for the search
# Initially we search through the first 100 elements blindly. The total number of possible combinations is returned.

# In[4]:

search = smact.ordered_elements(1,103)
initial_total = len(list(itertools.combinations(search, 3)))


# ## Applying chemical restrictions
# We now narrow the search space by applying some chemical criteria. 
# 1. The X site is either O, S, Se, Cl, Br, or I.
# 2. The B site is known to have octahedral coordination from the [data of Shannon.](http://scripts.iucr.org/cgi-bin/paper?a12967)

# In[5]:

A_list = []
B_list = []
C_list = [['O',-2,1.35],['S',-2,1.84],['Se',-2,1.98],['F',-1,1.29],['Cl',-1,1.81],['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:
예제 #7
0
smact_directory = '../../smact'
# Append a trailing slash to make coherent directory name - this would select the
# root directory in the case of no prefix, so we need to check
if smact_directory:
    smact_directory = smact_directory + '/'

# In[3]:

site_A = lattice.Site([0, 0, 0], [-1])
site_B = lattice.Site([0.5, 0.5, 0.5], [+5, +4])
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 = [['F', -1, 4.47]]
for element in search:
    with open(smact_directory + 'data/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:
            if 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(
#! /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

def print_status(text):
    "Refresh progress meter on one line"
    stdout.write(text + '\r')
예제 #9
0
#! /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

def print_status(text):
    "Refresh progress meter on one line"
    stdout.write(text + '\r')
예제 #10
0
# root directory in the case of no prefix, so we need to check
if smact_directory:
    smact_directory = smact_directory + '/'


# In[3]:

site_A = lattice.Site([0,0,0],[-1])
site_B = lattice.Site([0.5,0.5,0.5],[+5,+4])
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 = [['F',-1,4.47]]
for element in search:
    with open(smact_directory + 'data/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:
            if row[0]==element and int(row[1]) in site_A.oxidation_states:
                A_list.append([row[0],row[1],row[4]])