我目前正在尝试从materialsproject.org下载一个cif文件,这个文件只能通过API下载。他们告诉我使用Mybinder.org运行他们的代码:
from mp_api.client import MPRester
from pymatgen.analysis.diffraction.xrd import XRDCalculator
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
with MPRester(api_key='8dI6UZHs3Nc9lxTp75RrJcPdwvPn6jZb') as mpr:
# first retrieve the relevant structure
structure = mpr.get_structure_by_material_id('mp-980949')
# important to use the conventional structure to ensure
# that peaks are labelled with the conventional Miller indices
sga = SpacegroupAnalyzer(structure)
conventional_structure = sga.get_conventional_standard_structure()
# this example shows how to obtain an XRD diffraction pattern
# these patterns are calculated on-the-fly from the structure
calculator = XRDCalculator(wavelength='CuKa')
pattern = calculator.get_pattern(conventional_structure)当我运行代码时,它告诉我“检索MaterialsDoc文档: 100%”。从这里我该怎么做?我猜想它只是检索了文档,还没有下载到我的电脑上。我对编程和API完全一无所知。它也不需要下载作为一个cif文件。一个简单的txt。文件也会有帮助。我可以用它创建我自己的cif文件。
我试着用Python从我的PC上运行代码,但是什么也没有发生。在使用Google找到下载从API中检索到的数据的方法之后,我复制了一些其他用于下载检索到的数据的代码,但这也不起作用。
发布于 2022-11-07 19:02:48
你提供的那些东西(这可能是他们告诉你的全部?)假定事先了解或熟悉Python和/或MyBinder。如果他们没有提供给你,那么也许他们会把你引向他们网站上的其他材料和资源?
我认为,如果没有作者的进一步帮助,我们将如何做到这一点:
!curl -OL https://gist.githubusercontent.com/fomightez/8ef2f588965fbc10f19db79ee0035094/raw/778f399652a08a1f4be70400c5592c59e59cd876/demo_use_mp_api_with_MaterialsProject.ipynb。给它几秒钟的时间来获取笔记本文件&然后双击现在应该出现在左侧文件浏览器面板中的那个demo_use_mp_api_with_MaterialsProject.ipynb文件。打开那个笔记本,然后从'File‘>区域> 'Run’> 'Run All Cells‘>中选择,然后在那里查找我在这里所写的其他内容。)structure运行了那个手机然后我看到:
Structure Summary
Lattice
abc : 7.086166087833533 7.086166087833533 8.514034991951231
angles : 54.50319138768853 54.50319138768853 54.77885193228324
volume : 264.22028210282747
A : 3.259891 6.291809 0.0
B : -3.259891 6.291809 0.0
C : 0.0 5.567899 6.441063
pbc : True True True
PeriodicSite: W (1.9253, 6.2918, 0.0000) [0.7953, 0.2047, 0.0000]
PeriodicSite: W (-1.9253, 6.2918, 0.0000) [0.2047, 0.7953, 0.0000]
PeriodicSite: Cl (0.0000, 13.1912, 5.4807) [0.6718, 0.6718, 0.8509]
PeriodicSite: Cl (0.0000, 7.1635, 5.2908) [0.2058, 0.2058, 0.8214]
PeriodicSite: Cl (1.7149, 10.5162, 4.5739) [0.7845, 0.2585, 0.7101]
PeriodicSite: Cl (-1.7149, 10.5162, 4.5739) [0.2585, 0.7845, 0.7101]
PeriodicSite: Cl (1.7149, 7.6353, 1.8672) [0.7415, 0.2155, 0.2899]
PeriodicSite: Cl (-1.7149, 7.6353, 1.8672) [0.2155, 0.7415, 0.2899]
PeriodicSite: Cl (0.0000, 10.9880, 1.1503) [0.7942, 0.7942, 0.1786]
PeriodicSite: Cl (0.0000, 4.9603, 0.9603) [0.3282, 0.3282, 0.1491]我也是用pattern和conventional_structure做的。
(请注意,木星笔记本单元中的最后一行是特殊的,因为REPL上下文将被用来评估和显示相应的输出,不管这一行是什么。)
structure作为示例。在单元格中输入以下内容,将pattern的值保存到文本文件中。%store pattern >pattern.txt几秒钟后,在文件浏览器自动更新之后,您将看到pattern.txt出现在文件浏览器中。如果不想等待,可以在单元格中运行ls。它应该列在当前工作目录中的文件中。
https://stackoverflow.com/questions/74330082
复制相似问题