Exemple #1
0
from mpds_client import MPDSDataRetrieval, MPDSExport

from kmeans import Point, kmeans, k_from_n
from element_groups import get_element_group

client = MPDSDataRetrieval()

dfrm = client.get_dataframe(
    {
        "classes": "binary",
        "props": "band gap"
    },
    fields={
        'P': [
            'sample.material.chemical_formula',
            'sample.material.chemical_elements',
            'sample.material.condition[0].scalar[0].value',
            'sample.measurement[0].property.units',
            'sample.measurement[0].property.scalar'
        ]
    },
    columns=['Formula', 'Elements', 'SG', 'Units', 'Bandgap'])
dfrm = dfrm[dfrm['Units'] == 'eV']
dfrm = dfrm[(dfrm['Bandgap'] > 0) & (dfrm['Bandgap'] < 20)]

avgbgfrm = dfrm.groupby('Formula')['Bandgap'].mean().to_frame().reset_index(
).rename(columns={'Bandgap': 'AvgBandgap'})

dfrm = dfrm.merge(avgbgfrm, how='outer', on='Formula')
dfrm.drop_duplicates('Formula', inplace=True)
Exemple #2
0
        if error:
            raise RuntimeError(error)
        tpl_query = {
            'formulae': get_formula(ase_obj),
            'lattices': sgn_to_crsystem(ase_obj.info['spacegroup'].no)
        }

    answer = make_request('http://127.0.0.1:5000/predict',
                          {'structure': structure})
    if 'error' in answer:
        raise RuntimeError(answer['error'])

    for prop_id, pdata in prop_models.items():
        tpl_query.update({'props': pdata['name']})
        try:
            resp = client.get_dataframe(tpl_query)
        except APIError as e:
            prop_models[prop_id]['factual'] = None
            if e.code == 1:
                continue
            else:
                raise

        resp['Value'] = resp['Value'].astype(
            'float64')  # to treat values out of bounds given as str
        resp = resp[resp['Units'] == pdata['units']]
        prop_models[prop_id]['factual'] = np.median(resp['Value'])

    for prop_id, pdata in answer['prediction'].items():
        print("{0:40} = {1:6}, factual {2:8} (MAE = {3:4}), {4}".format(
            prop_models[prop_id]['name'], 'conductor'
Exemple #3
0
    return volume / abs(np.linalg.det(ase_obj.cell))


def get_Wiener(ase_obj):
    """
    Example crystal structure descriptor:
    https://en.wikipedia.org/wiki/Wiener_index
    defined per a unit cell
    """
    return np.sum(ase_obj.get_all_distances()) * 0.5


client = MPDSDataRetrieval()

dfrm = client.get_dataframe({
    "classes": "transitional, oxide",
    "props": "isothermal bulk modulus"
})
dfrm = dfrm[np.isfinite(dfrm['Phase'])]
dfrm = dfrm[dfrm['Units'] == 'GPa']
dfrm = dfrm[dfrm['Value'] > 0]

phases = set(dfrm['Phase'].tolist())
answer = client.get_data({"props": "atomic structure"},
                         phases=phases,
                         fields={
                             'S': [
                                 'phase_id', 'entry', 'chemical_formula',
                                 'cell_abc', 'sg_n', 'basis_noneq', 'els_noneq'
                             ]
                         })