本文整理汇总了Python中pymatgen.MPRester.get_data方法的典型用法代码示例。如果您正苦于以下问题:Python MPRester.get_data方法的具体用法?Python MPRester.get_data怎么用?Python MPRester.get_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.MPRester
的用法示例。
在下文中一共展示了MPRester.get_data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CompositionToStructureFromMP
# 需要导入模块: from pymatgen import MPRester [as 别名]
# 或者: from pymatgen.MPRester import get_data [as 别名]
class CompositionToStructureFromMP(ConversionFeaturizer):
"""
Featurizer to get a Structure object from Materials Project using the
composition alone. The most stable entry from Materials Project is selected,
or NaN if no entry is found in the Materials Project.
Args:
target_col_id (str or None): The column in which the converted data will
be written. If the column already exists then an error will be
thrown unless `overwrite_data` is set to `True`. If `target_col_id`
begins with an underscore the data will be written to the column:
`"{}_{}".format(col_id, target_col_id[1:])`, where `col_id` is the
column being featurized. If `target_col_id` is set to None then
the data will be written "in place" to the `col_id` column (this
will only work if `overwrite_data=True`).
overwrite_data (bool): Overwrite any data in `target_column` if it
exists.
map_key (str): Materials API key
"""
def __init__(self, target_col_id='structure', overwrite_data=False,
mapi_key=None):
super().__init__(target_col_id, overwrite_data)
self.mpr = MPRester(mapi_key)
def featurize(self, comp):
"""
Get the most stable structure from Materials Project
Args:
comp (`pymatgen.core.composition.Composition`): A composition.
Returns:
(`pymatgen.core.structure.Structure`): A Structure object.
"""
entries = self.mpr.get_data(comp.reduced_formula, prop="energy_per_atom")
if len(entries) > 0:
most_stable_entry = \
sorted(entries, key=lambda e: e['energy_per_atom'])[0]
s = self.mpr.get_structure_by_material_id(
most_stable_entry["material_id"])
return[s]
return [float("nan")]
def citations(self):
return [
"@article{doi:10.1063/1.4812323, author = {Jain,Anubhav and Ong,"
"Shyue Ping and Hautier,Geoffroy and Chen,Wei and Richards, "
"William Davidson and Dacek,Stephen and Cholia,Shreyas "
"and Gunter,Dan and Skinner,David and Ceder,Gerbrand "
"and Persson,Kristin A. }, title = {Commentary: The Materials "
"Project: A materials genome approach to accelerating materials "
"innovation}, journal = {APL Materials}, volume = {1}, number = "
"{1}, pages = {011002}, year = {2013}, doi = {10.1063/1.4812323}, "
"URL = {https://doi.org/10.1063/1.4812323}, "
"eprint = {https://doi.org/10.1063/1.4812323}}",
"@article{Ong2015, author = {Ong, Shyue Ping and Cholia, "
"Shreyas and Jain, Anubhav and Brafman, Miriam and Gunter, Dan "
"and Ceder, Gerbrand and Persson, Kristin a.}, doi = "
"{10.1016/j.commatsci.2014.10.037}, issn = {09270256}, "
"journal = {Computational Materials Science}, month = {feb}, "
"pages = {209--215}, publisher = {Elsevier B.V.}, title = "
"{{The Materials Application Programming Interface (API): A simple, "
"flexible and efficient API for materials data based on "
"REpresentational State Transfer (REST) principles}}, "
"url = {http://linkinghub.elsevier.com/retrieve/pii/S0927025614007113}, "
"volume = {97}, year = {2015} } "]
def implementors(self):
return ["Anubhav Jain"]
示例2: MPRester
# 需要导入模块: from pymatgen import MPRester [as 别名]
# 或者: from pymatgen.MPRester import get_data [as 别名]
import pandas as pd
import matplotlib.pyplot as plt
import itertools
df = pd.DataFrame()
allBinaries = itertools.combinations(periodic_table.all_symbols(), 2) # Create list of all binary systems
API_KEY = None # Enter your key received from Materials Project
if API_KEY is None:
m = MPRester()
else:
m = MPRester(API_KEY)
for system in allBinaries:
results = m.get_data(system[0] + '-' + system[1], data_type='vasp') # Download DFT data for each binary system
for material in results: # We will receive many compounds within each binary system
if material['e_above_hull'] < 1e-6: # Check if this compound is thermodynamically stable
dat = [material['pretty_formula'], material['band_gap'], material['formation_energy_per_atom'],
material['density']]
df = df.append(pd.Series(dat), ignore_index=True)
df.columns = ['materials', 'bandgaps', 'formenergies', 'densities']
print df[0:2]
print df.columns
MAX_Z = 100 # maximum length of vector to hold naive feature set
def naive_vectorize(composition):
"""