예제 #1
0
파일: test.py 프로젝트: WMD-group/SMACT
 def test_element_dictionary(self):
     newlist = ['O', 'Rb', 'W']
     dictionary = smact.element_dictionary(newlist)
     self.assertEqual(dictionary['O'].crustal_abundance, 461000.0)
     self.assertEqual(dictionary['Rb'].oxidation_states, [-1, 1])
     self.assertEqual(dictionary['W'].name, 'Tungsten')
     self.assertTrue('Rn' in smact.element_dictionary())
예제 #2
0
 def test_element_dictionary(self):
     newlist = ['O', 'Rb', 'W']
     dictionary = smact.element_dictionary(newlist)
     self.assertEqual(dictionary['O'].crustal_abundance, 461000.0)
     self.assertEqual(dictionary['Rb'].oxidation_states, [-1, 1])
     self.assertEqual(dictionary['W'].name, 'Tungsten')
     self.assertTrue('Rn' in smact.element_dictionary())
예제 #3
0
def band_gap_Harrison(anion,
                      cation,
                      verbose=False,
                      distance=None,
                      elements_dict=None):
    """
    Estimates the band gap from elemental data.

    The band gap is estimated using the principles outlined in
    Harrison's 1980 work "Electronic Structure and the Properties of
    Solids: The Physics of the Chemical Bond".

    Args:
        Anion (str): Element symbol of the dominant anion in the system.

        Cation (str): Element symbol of the the dominant cation in the system.
        Distance (float or str): Nuclear separation between anion and cation
                i.e. sum of ionic radii.
        verbose: An optional True/False flag. If True, additional information
                is printed to the standard output. [Defult: False]
        elements_dict (dict): Element symbol keys with smact.Element
                objects values. This may be provided to prevent
                excessive reading of data files.

    Returns (float): Band gap in eV.

    """

    # Set constants
    hbarsq_over_m = 7.62

    # Get anion and cation
    An = anion
    Cat = cation
    d = float(distance)

    # Get elemental data:
    elements_dict = smact.element_dictionary((An, Cat))
    An, Cat = elements_dict[An], elements_dict[Cat]

    # Calculate values of equation components
    V1_Cat = old_div((Cat.eig - Cat.eig_s), 4)
    V1_An = old_div((An.eig - An.eig_s), 4)
    V1_bar = old_div((V1_An + V1_Cat), 2)
    V2 = 2.16 * hbarsq_over_m / (d**2)
    V3 = old_div((Cat.eig - An.eig), 2)
    alpha_m = old_div((1.11 * V1_bar), sqrt(V2**2 + V3**2))

    # Calculate Band gap [(3-43) Harrison 1980 ]
    Band_gap = (old_div(3.60, 3)) * (sqrt(V2**2 + V3**2)) * (1 - alpha_m)
    if verbose:
        print("V1_bar = ", V1_bar)
        print("V2 = ", V2)
        print("alpha_m = ", alpha_m)
        print("V3 = ", V3)

    return Band_gap
예제 #4
0
def band_gap_Harrison(anion, cation, verbose=False,
                      distance=None):

    """
    Estimates the band gap from elemental data.

    The band gap is estimated using the principles outlined in
    Harrison's 1980 work "Electronic Structure and the Properties of
    Solids: The Physics of the Chemical Bond".

    Args:
        Anion (str): Element symbol of the dominant anion in the system

        Cation (str): Element symbol of the the dominant cation in the system
        Distance (float or str): Nuclear separation between anion and cation
                i.e. sum of ionic radii
        verbose (bool) : An optional True/False flag. If True, additional
        information is printed to the standard output. [Defult: False]

    Returns :
        Band_gap (float): Band gap in eV

    """

    # Set constants
    hbarsq_over_m = 7.62

    # Get anion and cation
    An = anion
    Cat = cation
    d = float(distance)

    # Get elemental data:
    elements_dict = smact.element_dictionary((An, Cat))
    An, Cat = elements_dict[An], elements_dict[Cat]

    # Calculate values of equation components
    V1_Cat = (Cat.eig - Cat.eig_s)/4
    V1_An = (An.eig - An.eig_s)/4
    V1_bar = (V1_An + V1_Cat)/2
    V2 = 2.16 * hbarsq_over_m / (d**2)
    V3 = (Cat.eig - An.eig)/2
    alpha_m = (1.11*V1_bar)/sqrt(V2**2 + V3**2)

    # Calculate Band gap [(3-43) Harrison 1980 ]
    Band_gap = (3.60/3.)*(sqrt(V2**2 + V3**2))*(1-alpha_m)
    if verbose:
        print("V1_bar = ", V1_bar)
        print("V2 = ", V2)
        print("alpha_m = ", alpha_m)
        print("V3 = ", V3)

    return Band_gap
예제 #5
0
파일: properties.py 프로젝트: AntObi/SMACT
def band_gap_Harrison(anion, cation, verbose=False, distance=None):
    """
    Estimates the band gap from elemental data.

    The band gap is estimated using the principles outlined in
    Harrison's 1980 work "Electronic Structure and the Properties of
    Solids: The Physics of the Chemical Bond".

    Args:
        Anion (str): Element symbol of the dominant anion in the system

        Cation (str): Element symbol of the the dominant cation in the system
        Distance (float or str): Nuclear separation between anion and cation
                i.e. sum of ionic radii
        verbose (bool) : An optional True/False flag. If True, additional
        information is printed to the standard output. [Defult: False]

    Returns :
        Band_gap (float): Band gap in eV

    """

    # Set constants
    hbarsq_over_m = 7.62

    # Get anion and cation
    An = anion
    Cat = cation
    d = float(distance)

    # Get elemental data:
    elements_dict = smact.element_dictionary((An, Cat))
    An, Cat = elements_dict[An], elements_dict[Cat]

    # Calculate values of equation components
    V1_Cat = (Cat.eig - Cat.eig_s) / 4
    V1_An = (An.eig - An.eig_s) / 4
    V1_bar = (V1_An + V1_Cat) / 2
    V2 = 2.16 * hbarsq_over_m / (d**2)
    V3 = (Cat.eig - An.eig) / 2
    alpha_m = (1.11 * V1_bar) / sqrt(V2**2 + V3**2)

    # Calculate Band gap [(3-43) Harrison 1980 ]
    Band_gap = (3.60 / 3.) * (sqrt(V2**2 + V3**2)) * (1 - alpha_m)
    if verbose:
        print("V1_bar = ", V1_bar)
        print("V2 = ", V2)
        print("alpha_m = ", alpha_m)
        print("V3 = ", V3)

    return Band_gap
#! /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')
예제 #7
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')
예제 #8
0
### Use SMACT to generate a list of sensible chemical compositions ###
### and save in some useful format.                                ###

# Imports
from smact.screening import smact_test
from smact import Element, element_dictionary
import itertools
import multiprocessing
from functools import partial
from pymatgen import Composition
from datetime import datetime
import pickle

# Get a dictionary of all Element objects keyed by symbol
all_el = element_dictionary()
all_symbols = [k for k, i in all_el.items()]

### === Set up parameters here === ###
# Either enter symbols manually as str, or use the element dictionary
# that has been imported if there are lots.
symbols = all_symbols[:20]
symbols_to_ignore = ['O']
symbols = [x for x in symbols if x not in symbols_to_ignore]

# Enter elements that must be in every compound, e.g. ['O'] if you
# are only interested in oxides. Else leave as None or remove.
# These elements should also appear in symbols_to_ignore above.
always_include = ['O']

# Set stoichiometry threshold
threshold = 4
예제 #9
0
def compound_electroneg(verbose=False, elements=None, stoichs=None,
                        elements_dict=None, source='Mulliken'):

    """Estimate electronegativity of compound from elemental data.

    Uses Mulliken electronegativity by default, which uses elemental
    ionisation potentials and electron affinities. Alternatively, can
    use Pauling electronegativity, re-scaled by factor 2.86 to achieve
    same scale as Mulliken method (Nethercot, 1974)
    DOI:10.1103/PhysRevLett.33.1088 .

    Geometric mean is used (n-th root of product of components), e.g.:

    X_Cu2S = (X_Cu * X_Cu * C_S)^(1/3)

    Args:
    elements: A list of elements given as standard elemental symbols.
    Optional: if not used, interactive input of space separated
    elemental symbols will be offered.
    stoichs: A list of stoichiometries, given as integers or floats.
    Optional: if not used, interactive input of space separated
    integers  will be offered.
    verbose: An optional True/False flag. If True, additional information
    is printed to the standard output. [Default: False]
    elements_dict: Dictionary of smact.Element objects; can be provided to
    prevent multiple reads of data files
    source: String 'Mulliken' or 'Pauling'; type of Electronegativity to
    use. Note that in SMACT, Pauling electronegativities are
    rescaled to a Mulliken-like scale.

    Returns:
    Electronegativity: Estimated electronegativity as a float.
    Electronegativity is a dimensionless property.

    Raises:
    (There are no special error messages for this function.)
    """

    if elements:
        elementlist = elements
    if stoichs:
        stoichslist = stoichs

    # Get elements and stoichiometries if not provided as argument
    if not elements:
        elementlist = list(raw_input(
            "Enter elements (space separated): ").split(" "))
    if not stoichs:
        stoichslist = list(raw_input(
            "Enter stoichiometries (space separated): ").split(" "))

    if not elements_dict:
        elements_dict = smact.element_dictionary(elements)

    # Convert stoichslist from string to float
    stoichslist = map(float, stoichslist)

    # Get electronegativity values for each element
    if source == 'Mulliken':
        elementlist = [get_mulliken(elements_dict[el])
                       for el in elementlist]
    elif source == 'Pauling':
        elementlist = [2.86 * get_pauling(elements_dict[el])
                       for el in elementlist]
    else:
        raise Exception("Electronegativity type '{0}'".format(source),
                        "is not recognised")
    # Print optional list of element electronegativities.
    # This may be a useful sanity check in case of a suspicious result.
    if verbose:
        print "Electronegativities of elements=", elementlist

    # Raise each electronegativity to its appropriate power
    # to account for stoichiometry.
    for i in range(0, len(elementlist)):
        elementlist[i] = [elementlist[i]**stoichslist[i]]

    # Calculate geometric mean (n-th root of product)
    prod = product(elementlist)
    compelectroneg = (prod)**(1.0/(sum(stoichslist)))

    if verbose:
        print "Geometric mean = Compound 'electronegativity'=", compelectroneg

    return compelectroneg
예제 #10
0
def band_gap_Harrison(verbose=False, anion=None, cation=None,
                      distance=None, elements_dict=None):

    """
    Estimates the band gap from elemental data.

    The band gap is estimated using the principles outlined in
    Harrison's 1980 work "Electronic Structure and the Properties of
    Solids: The Physics of the Chemical Bond".

    Args:
        Anion (str): Element symbol of the dominant anion in the system.

        Cation (str): Element symbol of the the dominant cation in the system.
        Distance (float or str): Nuclear separation between anion and cation
                i.e. sum of ionic radii.
        verbose: An optional True/False flag. If True, additional information
                is printed to the standard output. [Defult: False]
        elements_dict (dict): Element symbol keys with smact.Element
                objects values. This may be provided to prevent
                excessive reading of data files.

    Returns (float): Band gap in eV.

    """

    # Set constants
    hbarsq_over_m = 7.62

    # Get anion and cation
    if anion:
        An = anion
    if cation:
        Cat = cation
    if not anion:
        An = raw_input("Enter Anion Symbol:")
    if not cation:
        Cat = raw_input("Enter Cation Symbol:")
    if distance:
        d = float(distance)
    if not distance:
        d = float(raw_input("Enter internuclear separation (Angstroms): "))

    # Get elemental data:
    if not elements_dict:
        elements_dict = smact.element_dictionary((An, Cat))
    An, Cat = elements_dict[An], elements_dict[Cat]

    # Calculate values of equation components
    V1_Cat = (Cat.eig - Cat.eig_s)/4
    V1_An = (An.eig - An.eig_s)/4
    V1_bar = (V1_An + V1_Cat)/2
    V2 = 2.16 * hbarsq_over_m / (d**2)
    V3 = (Cat.eig - An.eig)/2
    alpha_m = (1.11*V1_bar)/sqrt(V2**2 + V3**2)

    # Calculate Band gap [(3-43) Harrison 1980 ]
    Band_gap = (3.60/3)*(sqrt(V2**2 + V3**2))*(1-alpha_m)
    if verbose:
        print "V1_bar = ", V1_bar
        print "V2 = ", V2
        print "alpha_m = ", alpha_m
        print "V3 = ", V3

    return Band_gap