The MaterialsWeb API is built on the Materials API (MAPI).
The best way to access our database is through the MWRester class implemented in QuantumML
as shown below.
from quantumML.rest import MWRester
with MWRester() as mwr:
mwr.get_calculation(filter/s)
To refine the query results the following filters may be applied
The below code shows how to apply the filters for a querry:
from quantumML.rest importb> MWRester
with MWRester() as mwr:
mwr.get_calculation(band_gap_range=[1,1.5], formation_energy_range=[124,150])
This will store the querry as a list of Json response that can be accessed by mwr.results. A single Json response is shown below:
print(mwr.results[1])
Out:
{'url': 'http://172.16.170.227:7800/rest/calculation/106/',
'configuration': None,
'dimension': 2,
'label': 'mp-700',
'path': '/var/www/materialsweb/static/database/mp-700',
'natoms': 4,
'settings': "{'potentials': [{'name': 'Ge_d', 'xc': 'PBE', 'us': False, 'paw': True}, {'name': 'Se', 'xc': 'PBE', 'us': False, 'paw': True}], 'nbands': 28, 'prec': 'accura', 'istart': 0, 'icharg': 2, 'ispin': 2, 'encut': 500.0, 'nelm': 60, 'nelmin': 2, 'ediff': 1e-06, 'lreal': True, 'nsw': 50, 'ibrion': 2, 'isif': 3, 'potim': 0.5, 'pstress': 0.0, 'ismear': 1, 'sigma': 0.1, 'algo': 'fast', 'lwave': True, 'lcharg': True, 'lvtot': False, 'lorbit': 0, 'ldipol': False, 'idipol': 0, 'epsilon': 1.0}",
'energy': -10.4702046,
'energy_pa': -2.61755115,
'magmom': -0.0001349,
'magmom_pa': -3.3725e-05,
'band_gap': 1.2107,
'is_direct': False,
'irreducible_kpoints': 42.0,
'formation_energy': 133.0,
'attempt': 0,
'nsteps': 32,
'converged': True,
'runtime': None,
'entry': 'http://172.16.170.227:7800/rest/entry/113/',
'composition': 'http://172.16.170.227:7800/rest/composition/Ge1%20Se1/',
'input': 'http://172.16.170.227:7800/rest/structure/325/',
'output': 'http://172.16.170.227:7800/rest/structure/324/',
'dos': 'http://172.16.170.227:7800/rest/dos/107/',
'element_set': ['http://172.16.170.227:7800/rest/elements/Ge/',
'http://172.16.170.227:7800/rest/elements/Se/']}
The content of each querry element can be accessed through pythons dictionary syntax as shown below:
for results in mwr.results:
print(results['composition'] + '\t Bandgap = ' + str(results['band_gap'])
Out:
Pd120S2 BandGap = 1.1746
Ge120Se1 BandGap = 1.2107
Pd120Se2 BandGap = 1.3964
I220Pt1 BandGap = 1.4215
I220Pd1 BandGap = 1.1512
Br320Cr1 BandGap = 1.4714
Cr120H120O2 BandGap = 1.0072
Mo120O3 BandGap = 1.1381
currently there are two methods to write the files from a query. The get_calculation method will store all the entries as a list. As a result one can write all of the files from a querry to a directory using the write_all method or write the files of a specific entry using the write method:
Please sign in or register to obtain an API key.