for fldidx,fields_str in enumerate(fields_strings):
        fields = fields_str.split(' -> ')
        for elidx,elem in enumerate(chemsys[:-1]):
            print fields_str, elem
            plt = plotter.get_plot()
            title = elem+': '+fields_str
            if fldidx == 3 and elidx == 1: title = fields_str
            plt.suptitle(title, fontsize=24)
            plt.triplot(grid_triang, 'k:')

            # heatmap
            x, y, z = [], [], []
            for idx,(comp,cid) in enumerate(comps_cids):
                comp_str = comp if args.dev else doc[cid]['_id']
                composition = Composition(comp_str)
                x0, x1, x2 = [composition.get_atomic_fraction(el) for el in chemsys]
                x.append(x0+x2/2.) # NOTE x0 might need to be replace with x1
                y.append(x2*math.sqrt(3.)/2.)
                if fldidx < 3:
                    zval = mpfile.document[comp_str]['{} XMCD'.format(elem)][fields[0]][fields[1]]
                    if fldidx == 0: norms[elem] = zval
                    elif fldidx == 1: xmcd_diffs[elem] = zval
                    else: xmcd_diffs[elem] -= zval
                    z.append(zval)
                else:
                    mag += xmcd_diffs[elem] * factors[elem] * norms[elem]
                    if elidx == 1: z.append(mag)

            if fldidx == 3 and elidx == 0: continue
            #x0, x1, x2 = 1/2., 1/3., 1/6.
            #plt.plot(x0+x2/2., x2*math.sqrt(3.)/2., "ko", linewidth=4, markeredgecolor="k", markerfacecolor="r", markersize=8)
示例#2
0
        for elidx, elem in enumerate(chemsys[:-1]):
            print fields_str, elem
            plt = plotter.get_plot()
            title = elem + ": " + fields_str
            if fldidx == 3 and elidx == 1:
                title = fields_str
            plt.suptitle(title, fontsize=24)
            plt.triplot(grid_triang, "k:")

            # heatmap
            x, y, z = [], [], []
            for idx, (comp, cid) in enumerate(comps_cids):
                comp_str = comp if args.dev else doc[cid]["_id"]
                composition = Composition(comp_str)
                x0, x1, x2 = [
                    composition.get_atomic_fraction(el) for el in chemsys
                ]
                x.append(x0 +
                         x2 / 2.0)  # NOTE x0 might need to be replace with x1
                y.append(x2 * math.sqrt(3.0) / 2.0)
                if fldidx < 3:
                    zval = mpfile.document[comp_str]["{} XMCD".format(elem)][
                        fields[0]][fields[1]]
                    if fldidx == 0:
                        norms[elem] = zval
                    elif fldidx == 1:
                        xmcd_diffs[elem] = zval
                    else:
                        xmcd_diffs[elem] -= zval
                    z.append(zval)
                else:
示例#3
0
                    battery_table['working_ion']))):

        # load crystal object from cif
        charge_crystal = Structure.from_str(cif_data[id_charge].value, 'cif')
        discharge_crystal = Structure.from_str(cif_data[id_discharge].value,
                                               'cif')

        # specific features
        finder = SpacegroupAnalyzer(charge_crystal)
        space_group_feat = np.array([finder.get_space_group_number()])
        crystal_system_feat = create_feature_from_crystal_system(
            finder.get_crystal_system())
        ion_feat = create_feature_from_wokring_ion(ion)
        dischr_comp = Composition(discharge_crystal.formula)
        ion_concentrate = np.array(
            [dischr_comp.get_atomic_fraction(Element(ion))])

        # calculate features from element property
        charge_formula = charge_crystal.formula
        discharge_formula = discharge_crystal.formula
        feature_from_chr_formula = create_feature_from_formula(
            charge_formula, element_data)
        feature_from_dischr_formula = create_feature_from_formula(
            discharge_formula, element_data)
        feature_from_ion = create_feature_from_formula(ion, element_data)

        # if charge_formula is a single element
        if feature_from_chr_formula.shape[0] == 44:
            feature_from_chr_formula = np.concatenate(
                [feature_from_chr_formula,
                 np.zeros(44)])