CITE THIS NOTEBOOK: MaterialsProjectLink: Wolfram functions for calling Materials Project Rest API by Kirill Belov. Wolfram Community DEC 5 2022.
ORIGINAL PACLET: Kirill Belov (2022). MaterialsProjectLink: Wolfram functions for calling Materials Project Rest API. Wolfram Function Repository. https://resources.wolframcloud.com/PacletRepository/resources/KirillBelov/MaterialsProjectLink/
CITE THIS NOTEBOOK: MaterialsProjectLink: Wolfram functions for calling Materials Project Rest API by Kirill Belov. Wolfram Community DEC 5 2022.
ORIGINAL PACLET: Kirill Belov (2022). MaterialsProjectLink: Wolfram functions for calling Materials Project Rest API. Wolfram Function Repository. https://resources.wolframcloud.com/PacletRepository/resources/KirillBelov/MaterialsProjectLink/
ORIGINAL PACLET: Kirill Belov (2022). MaterialsProjectLink: Wolfram functions for calling Materials Project Rest API. Wolfram Function Repository. https://resources.wolframcloud.com/PacletRepository/resources/KirillBelov/MaterialsProjectLink/
About
About
My friend who studies chemistry and uses the Wolfram Language in his work asked me “How can I use data from Materials Project in Wolfram Mathematica?”. To be honest, I didn’t even know what he was asking. I clarified it what kind of data store it is. I studied its documentation and realized that access to the open data of this project can be done very quickly. First I made a small prototype and then created a standard paclet. I am not a chemist, I do not know what illustrative examples can be demonstrated. I just took some examples from here. If you have more useful examples - be sure to show the imitation!
Install package
Install package
PacletInstall["KirillBelov/MaterialsProjectLink"]
Basic Examples
Basic Examples
Import the package:
In[]:=
<<KirillBelov`MaterialsProjectLink`
Save your API key:
In[]:=
Export[FileNameJoin[{$HomeDirectory,".MaterialsProjectLinkAPIKey.wl"}],<|"APIKey"->"g7EYgVnYFjXbbq7Fh6dsKwDdZElmAmyF"|>]
Out[]=
C:\Users\Kirill\.MaterialsProjectLinkAPIKey.wl
Check that API is available:
In[]:=
getMaterials[allFields->True]
Out[]=
Materials explorer
Materials explorer
Find chemical system H-O:
In[]:=
CH=getSummary[chemsys->"C-H"][["data",All,"material_id"]]
Out[]=
{mp-1096986,mp-995217,mp-985782,mp-866659,mp-30168,mp-1195106,mp-1021328,mp-995184,mp-995202,mp-1079612,mp-995197,mp-1097016,mp-603334,mp-995195,mp-995200}
All formulas:
In[]:=
getMaterialsByMaterialId[#,fields->{"formula_pretty","material_id"}][["data",1]]&/@CH
Out[]=
{_id619ed1bb2c86325a028acc38,formula_prettyHC,material_idmp-1096986,_id619edc9c2c86325a028cc954,formula_prettyH2C3,material_idmp-995217,_id619ee4d82c86325a028e26b0,formula_prettyH2C,material_idmp-985782,_id619ee4d82c86325a028e2746,formula_prettyH34C19,material_idmp-866659,_id619ee4d82c86325a028e2745,formula_prettyH34C19,material_idmp-30168,_id619ed3e52c86325a028b36d8,formula_prettyH8C5,material_idmp-1195106,_id619ed89d2c86325a028c1743,formula_prettyH4C,material_idmp-1021328,_id619ee0112c86325a028d5fbd,formula_prettyHC2,material_idmp-995184,_id619ee4432c86325a028e0ac8,formula_prettyHC6,material_idmp-995202,_id619ed1bb2c86325a028acc39,formula_prettyHC,material_idmp-1079612,_id619ed1bb2c86325a028acc36,formula_prettyHC,material_idmp-995197,_id619ede962c86325a028d2124,formula_prettyH4C7,material_idmp-1097016,_id619ee0112c86325a028d5fbe,formula_prettyHC2,material_idmp-603334,_id619ed1bb2c86325a028acc37,formula_prettyHC,material_idmp-995195,_id619edf2b2c86325a028d3668,formula_prettyHC3,material_idmp-995200}
Summary Queries
Summary Queries
Structure data for silicon (mp-149):
In[]:=
docs=getSummaryByMaterialId["mp-149",fields->"structure"]
Out[]=
data{_id633dfed93e1d94017bd5a70c,structure@modulepymatgen.core.structure,@classStructure,charge0,latticematrix{{0.,2.73436,2.73436},{2.73436,0.,2.73436},{2.73436,2.73436,0.}},a3.86697,b3.86697,c3.86697,alpha60.,beta60.,gamma60.,volume40.8883,sites{species{elementSi,occu1},abc{0.25,0.25,0.25},xyz{1.36718,1.36718,1.36718},labelSi,propertiesmagmom0.,species{elementSi,occu1},abc{0.,0.,0.},xyz{0.,0.,0.},labelSi,propertiesmagmom0.}}
And structure:
In[]:=
structure=docs[["data",1,"structure"]]
Out[]=
@modulepymatgen.core.structure,@classStructure,charge0,latticematrix{{0.,2.73436,2.73436},{2.73436,0.,2.73436},{2.73436,2.73436,0.}},a3.86697,b3.86697,c3.86697,alpha60.,beta60.,gamma60.,volume40.8883,sites{species{elementSi,occu1},abc{0.25,0.25,0.25},xyz{1.36718,1.36718,1.36718},labelSi,propertiesmagmom0.,species{elementSi,occu1},abc{0.,0.,0.},xyz{0.,0.,0.},labelSi,propertiesmagmom0.}
Find all Materials Project IDs for entries with dielectric data:
In[]:=
docs=getSummary["hasProps"->"dielectric",fields->"material_id"];
And all materials:
In[]:=
docs[["data",All,"material_id"]]
Out[]=
{mp-754802,mp-549737,mp-766811,mp-8076,mp-7090,mp-28630,mp-19262,mp-556582,mp-553303,mp-22934,mp-1397370,mp-510456,mp-24007,mp-555836,mp-504506,mp-675525,mp-756951,mp-556553,mp-6987,mp-1019576,mp-1211746,mp-38487,mp-554799,mp-3785,mp-763609,mp-656887,mp-1224,mp-2667,mp-23418,mp-4103,mp-1078443,mp-25542,mp-2632,mp-20727,mp-31116,mp-29287,mp-1522,mp-5614,mp-8426,mp-768305,mp-1208162,mp-27834,mp-570238,mp-8714,mp-7456,mp-22875,mp-998428,mp-696944,mp-17792,mp-27192,mp-567949,mp-27833,mp-1222618,mp-677335,mp-625576,mp-7774,mp-754000,mp-961684,mp-675821,mp-758574,mp-753476,mp-5679,mp-27648,mp-1189906,mp-9062,mp-764355,mp-1057286,mp-568032,mp-1029965,mp-1205739,mp-6081,mp-722865,mp-11641,mp-2741,mp-558828,mp-27839,mp-989524,mp-1105143,mp-1214796,mp-2852,mp-35264,mp-6972,mp-3870,mp-553243,mp-1210184,mp-571544,mp-7623,mp-1019323,mp-33024,mp-32539,mp-9338,mp-550998,mp-11018,mp-8890,mp-752395,mp-18000,mp-409,mp-20569,mp-27243,mp-774933}
Calculation (task) IDs and types for silicon (mp-149):
In[]:=
docs=getMaterialsByMaterialId["mp-149",fields->"calc_types"]
Out[]=
data{_id619ee3ad2c86325a028df525,calc_typesmp-655585GGA Static,mp-656511GGA NSCF Line,mp-655936GGA NSCF Uniform,mp-11721GGA Structure Optimization,mp-149GGA Structure Optimization,mp-1057373GGA Static,mp-1057366GGA Structure Optimization,mp-1057380GGA NSCF Uniform,mp-1059585GGA Structure Optimization,mp-1059589GGA Static,mp-1059603GGA NSCF Uniform,mp-1120258GGA Structure Optimization,mp-1120259GGA Structure Optimization,mp-1141021GGA DFPT Dielectric,mp-1248038GGA Structure Optimization,mp-1249516GGA NMR Electric Field Gradient,mp-1267607GGA NMR Nuclear Shielding,mp-1440634GGA Static,mp-1686587GGA NSCF Uniform,mp-1791788GGA Static,mp-1594776GGA NSCF Line,mp-1592727GGA NSCF Line,mp-1059604GGA NSCF Line,mp-1057384GGA NSCF Line}
Task ids:
In[]:=
taskIds=Keys[docs[["data",1,"calc_types"]]]
Out[]=
{mp-655585,mp-656511,mp-655936,mp-11721,mp-149,mp-1057373,mp-1057366,mp-1057380,mp-1059585,mp-1059589,mp-1059603,mp-1120258,mp-1120259,mp-1141021,mp-1248038,mp-1249516,mp-1267607,mp-1440634,mp-1686587,mp-1791788,mp-1594776,mp-1592727,mp-1059604,mp-1057384}
Task types:
In[]:=
taskTypes=Values[docs[["data",1,"calc_types"]]]
Out[]=
{GGA Static,GGA NSCF Line,GGA NSCF Uniform,GGA Structure Optimization,GGA Structure Optimization,GGA Static,GGA Structure Optimization,GGA NSCF Uniform,GGA Structure Optimization,GGA Static,GGA NSCF Uniform,GGA Structure Optimization,GGA Structure Optimization,GGA DFPT Dielectric,GGA Structure Optimization,GGA NMR Electric Field Gradient,GGA NMR Nuclear Shielding,GGA Static,GGA NSCF Uniform,GGA Static,GGA NSCF Line,GGA NSCF Line,GGA NSCF Line,GGA NSCF Line}
Band gaps for all materials containing only Si and O:
In[]:=
docs=getSummary[chemsys->"Si-O",fields->{"material_id","band_gap"}];
As assoc:
In[]:=
mpid=<|Query["data",All,{"material_id","band_gap"}/*Apply[Rule]]@docs|>
Out[]=
mp-8629982.6763,mp-5580255.6213,mp-5565534.9023,mp-5570245.6822,mp-5564545.5651,mp-6673835.5162,mp-5614882.7816,mp-5611815.6107,mp-11948280.0905,mp-10215034.5285,mp-5321055.559,mp-6000025.4577,mp-5570764.0358,mp-6673735.5745,mp-127875.6273,mp-182805.6999,mp-92584.0091,mp-5601555.7966,mp-5608265.4292,mp-6000045.4296,mp-6000295.4247,mp-6000145.7274,mp-12036555.4771,mp-5593894.7204,mp-5598725.6106,mp-6000015.491,mp-5588915.6471,mp-5558915.4968,mp-6159935.5574,mp-5539455.6059,mp-5549465.863,mp-5589475.6495,mp-13911760.1484,mp-9361870.,mp-12581965.6518,mp-5602035.7301,mp-76485.7192,mp-12040575.5444,mp-6468955.7207,mp-5569635.9648,mp-10631180.,mp-6000805.4798,mp-100641.7396,mp-6537635.3421,mp-6001115.5173,mp-6000495.6468,mp-12502615.6701,mp-5603365.5874,mp-116845.5458,mp-5467945.8552,mp-5609735.4387,mp-6000635.6966,mp-6000605.6832,mp-69475.1682,mp-12564995.931,mp-5566625.5653,mp-5569615.736,mp-5569945.3836,mp-6409170.6554,mp-83525.3649,mp-5568805.0612,mp-6000715.4719,mp-5593605.6782,mp-5587335.2427,mp-6395065.6572,mp-69455.5037,mp-5577712.3054,mp-6000785.6143,mp-13532595.5609,mp-70005.7194,mp-70295.7944,mp-5599285.4895,mp-6000515.5706,mp-5574655.5449,mp-6000525.4991,mp-6000185.4453,mp-5542675.6122,mp-5575915.6246,mp-5583746.2197,mp-11796513.4528,mp-6000765.958,mp-12052135.3649,mp-6394805.6231,mp-6395125.6163,mp-5551475.3545,mp-6397486.1775,mp-5541755.7494,mp-12490905.7758,mp-6396825.6453,mp-172795.7092,mp-12088670.,mp-9728085.5882,mp-5564695.7427,mp-6380380.,mp-12040264.1957,mp-5589314.5368,mp-11795295.4553,mp-5608364.9428,mp-6517075.7241,mp-5595505.6097
Stable materials (on the hull) with large band gaps (>3eV):
Stable mpids:
Conclusion
Conclusion
I hope this short note will be useful to someone. In the future I plan to improve this package. Moreover, if suddenly you are engaged in chemistry and see some potential useful application for yourself personally, be sure to write to me here or in the comments. State your wishes and I will implement it in my package. Thank you all for your attention!