def solute_defect_density(structure,
                          e0,
                          vac_defs,
                          antisite_defs,
                          solute_defs,
                          solute_concen=0.01,
                          T=800,
                          trial_chem_pot=None,
                          plot_style="highchargs"):
    """
    Wrapper for the solute_site_preference_finder.
    The computed plot data is prepared based on plot_style.

    Args:
        structure: pymatgen.core.structure.Structure object representing the
            primitive or unitcell of the crystal.
        e0: The total energy of the undefected system.
            This is E0 from VASP calculation.
        vac_defs: List of vacancy defect parameters in the dictionary format.
            The keys of the dict associated with each vacancy defect are
            1) site_index, 2) site_specie, 3) site_multiplicity, and
            4) energy. 1-3 can be obtained from
            pymatgen.analysis.defects.point_defects.Vacancy class.
            Site index is expected to start with 1 (fortran index).
        antisite_defs: List of antisite defect parameters in the dictionary
            format. The keys of the dict associated with each antisite defect
            are 1) site_index, 2) site_specie, 3) site_multiplicity,
            4) substitution_specie, and 5) energy. 1-3 can be obtained
            from pymatgen.analysis.defects.point_defects.Vacancy class.
        solute_defs: List of solute defect parameters in the dictionary
            format. Similary to that of antisite defs, wtih solute specie
            specified in substitution_specie
        solute_concen: Solute concentration (in fractional value)
        T: Temperature in Kelvin
        trial_chem_pot (optional): Trial chemical potentials to speedup
            the plot generation. Format is {el1:mu1,...}
        plot_style (string): Allowed options are
            1) highcharts (default)
            2) gnuplot

    Returns:
        The plot data is generated and returned in asked format.
    """

    # solute_site_pref_data, def_conc_data = solute_site_preference_finder(
    def_conc_data = solute_site_preference_finder(
        structure,
        e0,
        T,
        vac_defs,
        antisite_defs,
        solute_defs,
        solute_concen=solute_concen,
        trial_chem_pot=trial_chem_pot)

    if plot_style == 'highcharts':
        "Energy data is ignored in this mode"
        hgh_chrt_data = {}
        hgh_chrt_data['xAxis'] = def_conc_data['x_label']
        hgh_chrt_data['yAxis'] = def_conc_data['y_label']

        series = []
        x = def_conc_data['x']
        for y_data in def_conc_data['y']:
            y = y_data['data']
            xy = zip(x, y)
            xy = [list(el) for el in xy]
            name = y_data['name'].strip('$')
            flds = name.split('_')
            def_string = flds[0]
            site_string = flds[1].strip('{}')
            name = def_string + "<sub>" + site_string + "</sub>"
            #series.append({'data':xy, 'name':y_data['name']})
            series.append({'data': xy, 'name': name})
        hgh_chrt_data['series'] = series
        return hgh_chrt_data
    elif plot_style == 'gnuplot':

        def data_to_rows(inp_data, y_lbl_flg):
            rows = []
            labels = []
            labels.append(inp_data['x_label'])
            if y_lbl_flg:
                labels.append(inp_data['y_label'])
            else:
                labels += [y['name'] for y in inp_data['y']]
            rows.append('#' + '\t'.join(labels))
            m = len(inp_data['x'])
            for i in range(m):
                data = []
                data.append(inp_data['x'][i])
                data += [y['data'][i] for y in inp_data['y']]
                data = [float(x) for x in data]
                rows.append('\t'.join(list(map(str, data))))
            return rows

        #solute_site_pref_rows = data_to_rows(solute_site_pref_data, True)
        pt_def_conc_rows = data_to_rows(def_conc_data, False)
        # return solute_site_pref_rows, pt_def_conc_rows
        return pt_def_conc_rows
def solute_defect_density ( structure , e0 , vac_defs , antisite_defs , solute_defs , solute_concen = 0.01 , T = 800 , trial_chem_pot = None , plot_style = "highchargs" ) : def_conc_data = solute_site_preference_finder ( structure , e0 , T , vac_defs , antisite_defs , solute_defs , solute_concen = solute_concen , trial_chem_pot = trial_chem_pot ) if plot_style == 'highcharts' : hgh_chrt_data = { } hgh_chrt_data [ 'xAxis' ] = def_conc_data [ 'x_label' ] hgh_chrt_data [ 'yAxis' ] = def_conc_data [ 'y_label' ] series = [ ] x = def_conc_data [ 'x' ] for y_data in def_conc_data [ 'y' ] : y = y_data [ 'data' ] xy = zip ( x , y ) xy = [ list ( el ) for el in xy ] name = y_data [ 'name' ] . strip ( '$' ) flds = name . split ( '_' ) def_string = flds [ 0 ] site_string = flds [ 1 ] . strip ( '{}' ) name = def_string + "<sub>" + site_string + "</sub>" series . append ( { 'data' : xy , 'name' : name } ) hgh_chrt_data [ 'series' ] = series return hgh_chrt_data elif plot_style == 'gnuplot' : def data_to_rows ( inp_data , y_lbl_flg ) : rows = [ ] labels = [ ] labels . append ( inp_data [ 'x_label' ] ) if y_lbl_flg : labels . append ( inp_data [ 'y_label' ] ) else : labels += [ y [ 'name' ] for y in inp_data [ 'y' ] ] rows . append ( '#' + '\t' . join ( labels ) ) m = len ( inp_data [ 'x' ] ) for i in range ( m ) : data = [ ] data . append ( inp_data [ 'x' ] [ i ] ) data += [ y [ 'data' ] [ i ] for y in inp_data [ 'y' ] ] data = [ float ( x ) for x in data ] rows . append ( '\t' . join ( list ( map ( str , data ) ) ) ) return rows pt_def_conc_rows = data_to_rows ( def_conc_data , False ) return pt_def_conc_rows
Wrapper for the solute_site_preference_finder.
    The computed plot data is prepared based on plot_style.

    Args:
        structure: pymatgen.core.structure.Structure object representing the
            primitive or unitcell of the crystal.
        e0: The total energy of the undefected system.
            This is E0 from VASP calculation.
        vac_defs: List of vacancy defect parameters in the dictionary format.
            The keys of the dict associated with each vacancy defect are
            1) site_index, 2) site_specie, 3) site_multiplicity, and
            4) energy. 1-3 can be obtained from
            pymatgen.analysis.defects.point_defects.Vacancy class.
            Site index is expected to start with 1 (fortran index).
        antisite_defs: List of antisite defect parameters in the dictionary
            format. The keys of the dict associated with each antisite defect
            are 1) site_index, 2) site_specie, 3) site_multiplicity,
            4) substitution_specie, and 5) energy. 1-3 can be obtained
            from pymatgen.analysis.defects.point_defects.Vacancy class.
        solute_defs: List of solute defect parameters in the dictionary
            format. Similary to that of antisite defs, wtih solute specie
            specified in substitution_specie
        solute_concen: Solute concentration (in fractional value)
        T: Temperature in Kelvin
        trial_chem_pot (optional): Trial chemical potentials to speedup
            the plot generation. Format is {el1:mu1,...}
        plot_style (string): Allowed options are
            1) highcharts (default)
            2) gnuplot

    Returns:
        The plot data is generated and returned in asked format.