Source code for htesp.crystal
#!/usr/bin/env python
#"""Writen by Niraj K. Nepal, Ph.D."""
"""Module to extract information about systems for running calculations"""
import sys
from pymatgen.core import structure
from pymatgen.io.pwscf import PWInput
from htesp.htepc import MpConnect as mpc
from htesp.element_extract import plain_value
[docs]
def convex_hull(comp):
"""
Function to extract energy above hull from the Materials Project database.
Parameters:
-----------
comp : str
Compound name.
Returns:
--------
tuple
A tuple containing the energy above hull, formation energy per atom, and magnetic ordering information.
"""
obj = mpc()
print(comp)
obj.setting(comp)
# FIX(28): emmet's Ordering is a plain Enum, so the caller comparing
# this against 'NM' needs the value, not the member.
order = plain_value(obj.data['ordering'])
return obj.data['energy_above_hull'],obj.data['formation_energy_per_atom'],order
[docs]
def main(filename=None, argv=None):
"""
Main function to extract properties from Materials Project and relaxed outputs.
Usage:
------
python script.py filename comp cond
filename : str
Name of the QE input file.
comp : str
Compound name.
cond : str
Condition indicator.
Returns:
--------
None
"""
# FIX(21): ``main`` is the entry point htesp.workflow.run_helper() calls;
# the file name may also be passed directly.
if filename is None:
argv = list(sys.argv[1:] if argv is None else argv)
if not argv:
raise SystemExit("usage: crystal.py <scf input | POSCAR | CONTCAR>")
filename = argv[0]
#comp = sys.argv[2]
#ehull,form_e,order=convex_hull(comp)
#cond = sys.argv[3]
#if cond == "initial":
# print("\n")
# print("******* Extracting properties from materials project and relaxed outputs *********\n")
# print("* FE (eV/atom): {} ".format(round(form_e,4)))
# print("* e_above_hull (eV/atom): {} ".format(ehull))
# print("* Ordering: {} ".format(order) + "\n")
crystal_extract(filename)
if __name__ == "__main__":
main()