1
$\begingroup$

I would like to extract data of surface properties and grain boundary properties for Cu polymorph #0 from the website: http://crystalium.materialsvirtuallab.org using Mathematica.

So far I tried with Import, but it doesn't seem to work because it seems to import data only from the main page, and not for the particular properties from element Cu:

Import["http://crystalium.materialsvirtuallab.org", "Data"]
(*
{" home ", {{{{" Cycle through different views > ", {{"Surface \
properties", {"Miller indices", "Area fraction"}, {"J/m 2", "eV/Å 2", 
        "eV"}}, {"{[{ surface.is_reconstructed ? '*' : ''}]}", 
       "{[{surface.surface_energy | number : 2}]}", 
       "{[{surface.surface_energy_EV_PER_ANG2 | number : 3}]}", 
       "{[{surface.work_function | number : 3}]}", 
       "{[{surface.area_fraction | number : 2 }]}", 
       "cif"}}}, {"Weighted surf. energy", "=", 
     "{[{ wulff.weighted_surface_energy |number : 2 }]} J/m 2 ( \
{[{wulff.weighted_surface_energy_EV_PER_ANG2 | number : 3 }]} eV/Å 2 \
)"}, {"Weighted work function", "=", 
     "{[{ wulff.weighted_work_function |number : 2 }]} eV"}, {"Shape \
factor", "=", 
     "{[{ wulff.shape_factor | number : 2 }]}"}, {"Surf. energy \
anisotropy", "=", 
     "{[{ wulff.surface_anisotropy | number : 3 }]}"}}, {{"Grain \
boundary properties", {"Type", "Rotation axis", "Rotation angle", 
      "GB plane"}, {"J/m 2", "eV/Å 2", "J/m 2", 
      "eV/Å 2"}}, {"{[{grain_boundary.sigma}]}", 
     "{[{grain_boundary.type}]}", 
     "{[{grain_boundary.rotation_angle | number : 2}]}", 
     "{[{grain_boundary.gb_energy | number : 2}]}", 
     "{[{grain_boundary.gb_energy_EV_PER_ANG2 | number : 3}]}", 
     "{[{grain_boundary.w_sep | number : 3}]}", 
     "{[{grain_boundary.w_sep_EV_PER_ANG2 | number : 2}]}", 
     "cif"}}}, {{"H", "He"}, {"Li ", "Be ", "B ", "C ", "N", "O", "F",
     "Ne"}, {"Na ", "Mg ", "Al ", "Si ", "P ", "S ", "Cl", 
    "Ar"}, {"K ", "Ca ", "Sc ", "Ti ", "V ", "Cr ", "Mn ", "Fe ", 
    "Co ", "Ni ", "Cu ", "Zn ", "Ga ", "Ge ", "As ", "Se ", "Br", 
    "Kr"}, {"Rb ", "Sr ", "Y ", "Zr ", "Nb ", "Mo ", "Tc ", "Ru ", 
    "Rh ", "Pd ", "Ag ", "Cd ", "In ", "Sn ", "Sb ", "Te ", "I", 
    "Xe"}, {"Cs ", "Ba ", "Hf ", "Ta ", "W ", "Re ", "Os ", "Ir ", 
    "Pt ", "Au ", "Hg ", "Tl ", "Pb ", "Bi ", "Po", "At", 
    "Rn"}, {"Fr", "Ra"}, {"La ", "Ce ", "Pr ", "Nd ", "Pm ", "Sm ", 
    "Eu ", "Gd ", "Tb ", "Dy ", "Ho ", "Er ", "Tm ", "Yb ", 
    "Lu "}, {"Ac ", "Th ", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", 
    "Cf", "Es", "Fm", "Md", "No", "Lr"}}}}
*)

Is it possible to import with Mathematica the tables with data that you can see in the website upon clicking on each chemical element?

$\endgroup$
3
$\begingroup$

This url contains raw data:

Import["http://crystalium.materialsvirtuallab.org/crystallium/data/Cu"]

To access the html of the new page, here is a variation of the method provided in a previous answer, targeting polymorph #0 info. Note that I have added a pause to allow time for the script associated with the click to execute (otherwise I get the original html).

session = StartWebSession[]
WebExecute[session, 
 "OpenPage" -> "http://crystalium.materialsvirtuallab.org/"]

cu = WebExecute[session, "LocateElements" -> "CSSSelector" -> "#Cu"]
WebExecute[session, "ClickElement" -> cu]
Pause[2];
html = WebExecute[session, 
  "JavascriptExecute" -> 
   "return document.getElementsByClassName('polymorph')[0].outerHTML;"]

DeleteObject[session]
  
$\endgroup$
2
  • $\begingroup$ Thanks, yes this url works! $\endgroup$ – Ferca Dec 8 '20 at 11:10
  • $\begingroup$ that's sufficient. I accept the answer! $\endgroup$ – Ferca Dec 8 '20 at 18:32
2
$\begingroup$

Using V12 or later

session = StartWebSession[]
WebExecute[session, "OpenPage" -> "http://crystalium.materialsvirtuallab.org/"]

cu = WebExecute[session, "LocateElements" -> "CSSSelector" -> "#Cu"]
WebExecute[session, "ClickElement" -> cu]

html = WebExecute[session, 
   "JavascriptExecute" -> "return document.documentElement.outerHTML;"];
ImportString[html, "Data"]

DeleteObject[session]
$\endgroup$
4
  • $\begingroup$ Thanks for your answer. It seems to get to website and pick the element, but ImportString appears to not return the result I want. I tried to use Import instead of ImportString in V12.1.1.0, but still no luck in importing. $\endgroup$ – Ferca Dec 8 '20 at 11:07
  • $\begingroup$ @Ferca The code of this answer worked for me. $\endgroup$ – Anton Antonov Dec 8 '20 at 14:54
  • $\begingroup$ @AntonAntonov do you get the same output as when using the code from the other answer: Import["http://crystalium.materialsvirtuallab.org/crystallium/data/Cu"] ? This is is the output I am looking for. Perhaps I was not clear in my question. $\endgroup$ – Ferca Dec 8 '20 at 15:32
  • 1
    $\begingroup$ @Ferca No, not the same answer. I was just saying the posted code worked. $\endgroup$ – Anton Antonov Dec 8 '20 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.