本文整理汇总了Python中pymatgen.phasediagram.pdanalyzer.PDAnalyzer.get_decomp_and_e_above_hull方法的典型用法代码示例。如果您正苦于以下问题:Python PDAnalyzer.get_decomp_and_e_above_hull方法的具体用法?Python PDAnalyzer.get_decomp_and_e_above_hull怎么用?Python PDAnalyzer.get_decomp_and_e_above_hull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pymatgen.phasediagram.pdanalyzer.PDAnalyzer
的用法示例。
在下文中一共展示了PDAnalyzer.get_decomp_and_e_above_hull方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pymatgen.phasediagram.pdanalyzer import PDAnalyzer [as 别名]
# 或者: from pymatgen.phasediagram.pdanalyzer.PDAnalyzer import get_decomp_and_e_above_hull [as 别名]
def main(comp="La0.5Sr0.5MnO3", energy=-43.3610, ostart="", oend="", ostep=""):
"""Get energy above hull for a composition
Args:
comp <str>: Composition in string form
energy <float>: Energy PER FORMULA UNIT of composition given
(Leave the following arguments blank for a non-grand potential
phase diagram.)
ostart <float>: Starting oxygen chemical potential.
oend <float>: Ending oxygen chemical potential.
ostep <float>: Step for oxygen chemical potential
Returns:
Prints to screen
"""
#a = MPRester("<YOUR_MPREST_API_KEY_HERE>")
a = MPRester("wfmUu5VSsDCvIrhz")
mycomp=Composition(comp)
print "Composition: ", mycomp
myenergy=energy
print "Energy: ", myenergy
myPDEntry = PDEntry(mycomp, myenergy)
elements = mycomp.elements
ellist = map(str, elements)
chemsys_entries = a.get_entries_in_chemsys(ellist)
#For reference: other ways of getting entries
#entries = a.mpquery(criteria={'elements':{'$in':['La','Mn'],'$all':['O']},'nelements':3})
#entries = a.mpquery(criteria={'elements':{'$in':['La','Mn','O'],'$all':['O']}},properties=['pretty_formula'])
#entries = a.get_entries_in_chemsys(['La', 'Mn', 'O', 'Sr'])
if ostart=="": #Regular phase diagram
entries = list(chemsys_entries)
entries.append(myPDEntry)
pd = PhaseDiagram(entries)
#plotter = PDPlotter(gppd)
#plotter.show()
ppda = PDAnalyzer(pd)
eabove=ppda.get_decomp_and_e_above_hull(myPDEntry)
print "Energy above hull: ", eabove[1]
print "Decomposition: ", eabove[0]
return eabove
else: #Grand potential phase diagram
orange = np.arange(ostart, oend+ostep, ostep) #add ostep because otherwise the range ends before oend
for o_chem_pot in orange:
entries = list(chemsys_entries)
myGrandPDEntry = GrandPotPDEntry(myPDEntry,{Element('O'): float(o_chem_pot)}) #need grand pot pd entry for GPPD
entries.append(myGrandPDEntry)
gppd = GrandPotentialPhaseDiagram(entries,{Element('O'): float(o_chem_pot)})
gppda = PDAnalyzer(gppd)
geabove=gppda.get_decomp_and_e_above_hull(myGrandPDEntry, True)
print "******** Decomposition for mu_O = %s eV ********" % o_chem_pot
print "%30s%1.4f" % ("mu_O: ",o_chem_pot)
print "%30s%1.4f" % ("Energy above hull (eV): ",geabove[1])
decomp=geabove[0]
#print "Decomp: ", decomp
print "%30s" % "Decomposition: "
for dkey in decomp.keys():
print "%30s:%1.4f" % (dkey.composition,decomp[dkey])
return
示例2: test_1d_pd
# 需要导入模块: from pymatgen.phasediagram.pdanalyzer import PDAnalyzer [as 别名]
# 或者: from pymatgen.phasediagram.pdanalyzer.PDAnalyzer import get_decomp_and_e_above_hull [as 别名]
def test_1d_pd(self):
entry = PDEntry("H", 0)
pd = PhaseDiagram([entry])
pda = PDAnalyzer(pd)
decomp, e = pda.get_decomp_and_e_above_hull(PDEntry("H", 1))
self.assertAlmostEqual(e, 1)
self.assertAlmostEqual(decomp[entry], 1.0)
示例3: test_dim1
# 需要导入模块: from pymatgen.phasediagram.pdanalyzer import PDAnalyzer [as 别名]
# 或者: from pymatgen.phasediagram.pdanalyzer.PDAnalyzer import get_decomp_and_e_above_hull [as 别名]
def test_dim1(self):
#Ensure that dim 1 PDs can eb generated.
for el in ["Li", "Fe", "O2"]:
entries = [e for e in self.entries
if e.composition.reduced_formula == el]
pd = PhaseDiagram(entries)
self.assertEqual(len(pd.stable_entries), 1)
a = PDAnalyzer(pd)
for e in entries:
decomp, ehull = a.get_decomp_and_e_above_hull(e)
self.assertGreaterEqual(ehull, 0)
plotter = PDPlotter(pd)
lines, stable_entries, unstable_entries = plotter.pd_plot_data
self.assertEqual(lines[0][1], [0, 0])
示例4: AnalyseMaterialsProjectJsonDataWithComputedEntries
# 需要导入模块: from pymatgen.phasediagram.pdanalyzer import PDAnalyzer [as 别名]
# 或者: from pymatgen.phasediagram.pdanalyzer.PDAnalyzer import get_decomp_and_e_above_hull [as 别名]
class AnalyseMaterialsProjectJsonDataWithComputedEntries():
"""
Class which will wrap around boilerplate analysis of MaterialsProject-like
json files, containing data extracted using borgs and queens.
It will be assumed that we are providing ComputedEntries objects directly.
"""
def __init__(self):
# some MP analysis power tools
self.compat = MaterialsProjectCompatibility()
return
def extract_alkali_energy(self, computed_Alkali_entry ):
processed_Alkali_entry = self.compat.process_entry(computed_Alkali_entry)
self.E_Alkali = processed_Alkali_entry.energy
return
def extract_phase_diagram_info(self,MP_phase_diagram_json_data_filename):
computed_entries = self._extract_MP_data(MP_phase_diagram_json_data_filename)
processed_entries = self.compat.process_entries(computed_entries)
pd = PhaseDiagram(processed_entries)
self.phase_diagram_analyser = PDAnalyzer(pd)
return
def extract_processed_entries(self,computed_entries):
processed_entries = self.compat.process_entries(computed_entries)
return processed_entries
def extract_energies_above_hull(self,computed_entries,alkali):
processed_entries = self.extract_processed_entries(computed_entries)
list_energy_above_hull = []
list_alkali_content = []
for entry in processed_entries:
decomposition_dict, energy_above_hull = \
self.phase_diagram_analyser.get_decomp_and_e_above_hull(entry, allow_negative=True)
list_energy_above_hull.append(energy_above_hull)
list_alkali_content.append(entry.composition[alkali])
list_energy_above_hull = np.array(list_energy_above_hull)
list_alkali_content = np.array(list_alkali_content )
return list_alkali_content, list_energy_above_hull
def extract_energies(self,computed_entries,alkali):
processed_entries = self.extract_processed_entries(computed_entries)
list_energy = []
list_alkali_content = []
for entry in processed_entries:
list_energy.append(entry.energy)
list_alkali_content.append(entry.composition[alkali])
list_energy = np.array(list_energy)
list_alkali_content = np.array(list_alkali_content )
I = np.argsort(list_alkali_content )
return list_alkali_content[I], list_energy[I]
def _extract_MP_data(self,MP_data_filename):
drone = VaspToComputedEntryDrone()
queen = BorgQueen(drone, "dummy", 1)
queen.load_data(MP_data_filename)
computed_entries = queen.get_data()
del drone
del queen
return computed_entries