How to use the smact.neutral_ratios 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 / smact / informatics.py View on Github external
Returns:
        species_comps (list): Compositions as tuples of Pymatgen Species objects.
        """

    initial_comps_list = []
    for sp1, sp2, an in tqdm(itertools.product(position1, position2, position3)):
        e1, oxst1 = sp1.symbol, int(sp1.oxi_state)
        eneg1 = Element(e1).pauling_eneg
        e2, oxst2 = sp2.symbol, int(sp2.oxi_state)
        eneg2 = Element(e2).pauling_eneg
        e3, oxst3 = an.symbol, int(an.oxi_state)
        eneg3 = Element(e3).pauling_eneg

        symbols = [e1,e2,e3]
        ox_states = [oxst1, oxst2, oxst3]
        cn_e, cn_r = neutral_ratios(ox_states, threshold=threshold)

        if cn_e:
            enegs = [eneg1,eneg2,eneg3]
            eneg_ok = pauling_test(ox_states, enegs, symbols=symbols, repeat_cations=False)
            if eneg_ok:
                for ratio in cn_r:
                    comp = (symbols, ox_states, list(ratio))
                    initial_comps_list.append(comp)
    print('Number of compositions before reduction:  {}'.format(len(initial_comps_list)))

    # Create a list of pymatgen species for each comp
    print('Converting to Pymatgen Species...')
    species_comps = []
    for i in tqdm(initial_comps_list):
        comp = {}
        for sym,ox,ratio in zip(i[0],i[1],i[2]):
github WMD-group / SMACT / smact / screening.py View on Github external
species_unique (bool): Whether or not to consider elements in different
        oxidation states as unique in the results.
    Returns:
        allowed_comps (list): Allowed compositions for that chemical system
        in the form [(elements), (oxidation states), (ratios)] if species_unique=True
        or in the form [(elements), (ratios)] if species_unique=False.
    """
    compositions = []

    # Get symbols and electronegativities
    symbols = tuple(e.symbol for e in els)
    electronegs = [e.pauling_eneg for e in els]
    ox_combos = [e.oxidation_states for e in els]
    for ox_states in itertools.product(*ox_combos):
        # Test for charge balance
        cn_e, cn_r = neutral_ratios(ox_states, threshold=threshold)
        # Electronegativity test
        if cn_e:
            electroneg_OK = pauling_test(ox_states, electronegs)
            if electroneg_OK:
                for ratio in cn_r:
                    compositions.append(tuple([symbols,ox_states,ratio]))

    # Return list depending on whether we are interested in unique species combinations
    # or just unique element combinations.
    if species_unique:
        return(compositions)
    else:
        compositions = [(i[0], i[2]) for i in compositions]
        compositions = list(set(compositions))
        return compositions
github WMD-group / SMACT / examples / build_library_bandgaps.py View on Github external
def binary_generator(search_space, elements):
    # Iterate over all binary combinations (e.g. (Li, Be), (Li, Na)...)    
    for el_a, el_b in itertools.combinations(search_space, 2):
        # Read possible oxidation states from element dictionary
        for ox_combo in itertools.product(elements[el_a].oxidation_states,
                                          elements[el_b].oxidation_states):
            # When a legal combination is found, yield it
            # and move onto next binary combination
            success, stoichs = smact.neutral_ratios(ox_combo)
            if success:
                yield (el_a, el_b, stoichs[0])
                break
github WMD-group / SMACT / examples / Counting / ElementCombinationsParallel.py View on Github external
def n_neutral_ratios(oxidation_states, threshold=8):
            return len(smact.neutral_ratios(oxidation_states,
                                            threshold=threshold)[1])