How to use the smact.Element function in SMACT

To help you get started, we’ve selected a few SMACT examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WMD-group / SMACT / examples / Permutations / binary_permutations.py View on Github external
count_of_ternary = 0
count_raw_ternary = 0
element_count = 0
ion_count = 0
charge_neutral_count = 0
pauling_count = 0
for i, ele_a in enumerate(list_of_elements):
 	element_count = element_count + 1
	paul_a = smact.Element(ele_a).pauling_eneg
	for ox_a in smact.Element(ele_a).oxidation_states:
		ion_count = ion_count + 1
		for j, ele_b in enumerate(list_of_elements[i+1:]):
			element_count = element_count + 1
			paul_b = smact.Element(ele_b).pauling_eneg
			for ox_b in smact.Element(ele_b).oxidation_states:
				ion_count = ion_count + 1
				element = [ele_a, ele_b]
				print element
				oxidation_states = [ox_a, ox_b]
				pauling_electro = [paul_a, paul_b]
				electroneg_makes_sense = pauling_test(oxidation_states, pauling_electro)
				cn_e, cn_r = smact.charge_neutrality([ox_a, ox_b],threshold=1)
				if cn_e:
					charge_neutral_count = charge_neutral_count + 1
					if electroneg_makes_sense:
						pauling_count = pauling_count + 1

print "  "
print "------------------------------------------"
print "------------------------------------------"
print "Summary of screening for ternary compounds"
github WMD-group / SMACT / examples / Permutations / ternary_permutations.py View on Github external
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
charge_neutral_count = 0
pauling_count = 0
for i, ele_a in enumerate(list_of_elements):
 	element_count = element_count + 1
	paul_a = smact.Element(ele_a).pauling_eneg
	for ox_a in smact.Element(ele_a).oxidation_states:
		ion_count = ion_count + 1
		for j, ele_b in enumerate(list_of_elements[i+1:]):
			element_count = element_count + 1
			paul_b = smact.Element(ele_b).pauling_eneg
			for ox_b in smact.Element(ele_b).oxidation_states:
				ion_count = ion_count + 1
				for k, ele_c in enumerate(list_of_elements[i+j+2:]):
				  	element_count = element_count + 1
					paul_c = smact.Element(ele_c).pauling_eneg
					for ox_c in smact.Element(ele_c).oxidation_states:
						ion_count = ion_count + 1
						element = [ele_a, ele_b, ele_c]
						print element
						oxidation_states = [ox_a, ox_b, ox_c]
						pauling_electro = [paul_a, paul_b, paul_c]
						electroneg_makes_sense = pauling_test(oxidation_states, pauling_electro)
github WMD-group / SMACT / examples / Permutations / ternary_permutations.py View on Github external
list_of_elements.append(species[1])
			
count_of_ternary = 0
count_raw_ternary = 0
element_count = 0
ion_count = 0
charge_neutral_count = 0
pauling_count = 0
for i, ele_a in enumerate(list_of_elements):
 	element_count = element_count + 1
	paul_a = smact.Element(ele_a).pauling_eneg
	for ox_a in smact.Element(ele_a).oxidation_states:
		ion_count = ion_count + 1
		for j, ele_b in enumerate(list_of_elements[i+1:]):
			element_count = element_count + 1
			paul_b = smact.Element(ele_b).pauling_eneg
			for ox_b in smact.Element(ele_b).oxidation_states:
				ion_count = ion_count + 1
				for k, ele_c in enumerate(list_of_elements[i+j+2:]):
				  	element_count = element_count + 1
					paul_c = smact.Element(ele_c).pauling_eneg
					for ox_c in smact.Element(ele_c).oxidation_states:
						ion_count = ion_count + 1
						element = [ele_a, ele_b, ele_c]
						print element
						oxidation_states = [ox_a, ox_b, ox_c]
						pauling_electro = [paul_a, paul_b, paul_c]
						electroneg_makes_sense = pauling_test(oxidation_states, pauling_electro)
						cn_e, cn_r = smact.charge_neutrality([ox_a, ox_b, ox_c],threshold=1)
						if cn_e:
							charge_neutral_count = charge_neutral_count + 1
							if electroneg_makes_sense:
github WMD-group / SMACT / examples / Permutations / binary_permutations.py View on Github external
list_of_elements.append(species[1])
			
count_of_ternary = 0
count_raw_ternary = 0
element_count = 0
ion_count = 0
charge_neutral_count = 0
pauling_count = 0
for i, ele_a in enumerate(list_of_elements):
 	element_count = element_count + 1
	paul_a = smact.Element(ele_a).pauling_eneg
	for ox_a in smact.Element(ele_a).oxidation_states:
		ion_count = ion_count + 1
		for j, ele_b in enumerate(list_of_elements[i+1:]):
			element_count = element_count + 1
			paul_b = smact.Element(ele_b).pauling_eneg
			for ox_b in smact.Element(ele_b).oxidation_states:
				ion_count = ion_count + 1
				element = [ele_a, ele_b]
				print element
				oxidation_states = [ox_a, ox_b]
				pauling_electro = [paul_a, paul_b]
				electroneg_makes_sense = pauling_test(oxidation_states, pauling_electro)
				cn_e, cn_r = smact.charge_neutrality([ox_a, ox_b],threshold=1)
				if cn_e:
					charge_neutral_count = charge_neutral_count + 1
					if electroneg_makes_sense:
						pauling_count = pauling_count + 1

print "  "
print "------------------------------------------"
print "------------------------------------------"
github WMD-group / SMACT / examples / Permutations / binary_permutations.py View on Github external
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
charge_neutral_count = 0
pauling_count = 0
for i, ele_a in enumerate(list_of_elements):
 	element_count = element_count + 1
	paul_a = smact.Element(ele_a).pauling_eneg
	for ox_a in smact.Element(ele_a).oxidation_states:
		ion_count = ion_count + 1
		for j, ele_b in enumerate(list_of_elements[i+1:]):
			element_count = element_count + 1
			paul_b = smact.Element(ele_b).pauling_eneg
github WMD-group / SMACT / smact / properties / Band_gap_simple.py View on Github external
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): "))

    # Calculate values of equation components
    V1_Cat = (smact.Element(Cat).eig - smact.Element(Cat).eig_s)/4
    V1_An = (smact.Element(An).eig - smact.Element(An).eig_s)/4
    V1_bar = (V1_An + V1_Cat)/2
    V2 = 2.16 * hbarsq_over_m / (d**2)
    V3 = (smact.Element(Cat).eig - smact.Element(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
github WMD-group / SMACT / examples / StuffedWurtzite / StuffedWurtzite.py View on Github external
matrix_hhi[all_elements.index(a_element),
                                               all_elements.index(b_element)] = hhi_rp
                                    output.append([a_element, b_element,
                                                   hhi_rp, method,
                                                   a, b, c, inner_space])

                            else:   ### Shannon radius
                                b_shan = radius_shannon(b_element, b_ox)
                                if a_ox + b_ox == lattice_charge:
                                    g = [float(a_shan), float(b_shan)]
                                    method = "shannon radii"
                                    (a, b, c, alpha, beta, gamma) = lattice_parameters.wurtzite(g)
                                    # Calculate the space inside the cage
                                    inner_space = inner_space = a * (6**0.5) - (4*g[0])
                                    hhi_a = smact.Element(a_element).HHI_p
                                    hhi_b = smact.Element(b_element).HHI_p
                                    hhi_rp = (float(hhi_a)*float(hhi_b))**0.5
                                    holes[all_elements.index(a_element), all_elements.index(b_element)] = inner_space
                                    matrix_hhi[all_elements.index(a_element), all_elements.index(b_element)] = hhi_rp
                                    output.append([a_element, b_element, hhi_rp, method, a, b, c, inner_space])

with open('wurtzite.csv', 'w') as csvfile:
    csv_writer = csv.writer(csvfile, delimiter=',',
                            quotechar='"', quoting=csv.QUOTE_MINIMAL)
    csv_writer.writerow(["Element A", "Element B",
                         "HHI index (geometric mean)", "method",
                         "a / AA", "b / AA", "c / AA", "pore volume / AA^3"])
    for structure in output:
        csv_writer.writerow(structure)


hhi_max = 2000
github WMD-group / SMACT / examples / Permutations / threaded_count.py View on Github external
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);
    chargeNeutralCount = sum(count2 for count1, count2, count3 in result);
    paulingSensibleCount = sum(count3 for count1, count2, count3 in result);

    totalTime = time.time() - startTime;
github WMD-group / SMACT / smact / data.py View on Github external
def get_pauling(element):
    """Pauling electronegativity of specified element.

    Arguments:
        symbol (smact.Element or str): Element object or symbol

    Returns:
        pauling_eneg (float): Pauling electronegativity

    """
    if type(element) == str:       
        element = smact.Element(element)
    elif type(element) != smact.Element:
        raise Exception("Unexpected type: {0}".format(type(element)))        

    return element.pauling_eneg
github WMD-group / SMACT / smact / data.py View on Github external
def get_covalent(symbol):
    """Covalent radius of specified element.
    Drawn from Open Babel data table.

    Arguments:
        symbol (string): Element label

    Returns:
        covalent_radius (float): Covalent radius
    """
    from smact import Element
    A = Element(symbol)
    return A.covalent_radius