Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
knc6 committed May 29, 2021
2 parents 1d02393 + 5c8124f commit 6a755b6
Show file tree
Hide file tree
Showing 10 changed files with 611 additions and 45 deletions.
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
language: python
python:
- "3.8"
cache: pip
install:
- pip install --upgrade --upgrade-strategy eager -r dev-requirements.txt -e .
- python setup.py develop
#- coverage run -m pytest
#- coverage report -m
#- pip uninstall qiskit
#- pip install qiskit ase numpy>=1.18.5 scipy>=1.4.1 matplotlib>=3.0.0 phonopy==2.8.1 coverage lightgbm==2.1.0 flask joblib networkx tqdm dgl scikit-learn pandas pennylane codecov torch keras tensorflow==2.3.0 pytest pytest-cov bokeh
#- pip install -r requirements-for-ci-only.txt
#- pip install git+https://github.com/aspuru-guzik-group/tequila.git
#- pip install git+https://github.com/aspuru-guzik-group/tequila.git@402d8eb8c4c632c2d48c75e2f798a46967d28899
#- python setup.py develop

script:
- pip install --upgrade --upgrade-strategy eager -r dev-requirements.txt -e .
2 changes: 1 addition & 1 deletion jarvis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""Version number."""
__version__ = "2021.05.25"
__version__ = "2021.05.28"
13 changes: 9 additions & 4 deletions jarvis/analysis/stm/tersoff_hamann.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ def __init__(
self.repeat = [rep_x, rep_y]
self.scell = self.atoms.make_supercell_matrix([rep_x, rep_y, 1])

def constant_height(self, tol=2, filename="testh.png"):
def constant_height(self, tol=2, filename="testh.png", skew_tol=7):
"""Get iso-height image."""
# TODO: Find out reason for the mysterious skew_tol=7
# Maybe try opencv or code up affine module tself
if not self.zcut:
self.zcut = int((self.zmaxp + tol) / self.c * self.nz)
img_ext = np.tile(self.chg[:, :, self.zcut], self.repeat)
Expand All @@ -54,7 +56,7 @@ def constant_height(self, tol=2, filename="testh.png"):
plt.xticks([])
plt.yticks([])
if self.skew:
tmp = 90 - self.atoms.lattice.angles[2]
tmp = 90 - self.atoms.lattice.angles[2] + skew_tol
else:
tmp = 0
data = self.get_plot(
Expand All @@ -74,7 +76,9 @@ def constant_height(self, tol=2, filename="testh.png"):

return info

def constant_current(self, tol=2, pc=None, ext=0.15, filename="testc.png"):
def constant_current(
self, tol=2, pc=None, ext=0.15, filename="testc.png", skew_tol=7
):
"""Return the constant-current cut the charge density."""
zmax_ind = int(self.zmaxp / self.c * self.nz) + 1
# Find what z value is near the current, and take avergae
Expand All @@ -101,7 +105,7 @@ def constant_current(self, tol=2, pc=None, ext=0.15, filename="testc.png"):
plt.xticks([])
plt.yticks([])
if self.skew:
tmp = 90 - self.atoms.lattice.angles[2]
tmp = 90 - self.atoms.lattice.angles[2] + skew_tol
else:
tmp = 0

Expand Down Expand Up @@ -129,6 +133,7 @@ def get_plot(self, ax, Z, extent, transform):
origin="lower",
extent=extent,
clip_on=True,
aspect="auto",
) # ,cmap=plt.get_cmap('gray')

trans_data = transform + ax.transData
Expand Down
2 changes: 2 additions & 0 deletions jarvis/analysis/thermodynamics/energetics.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ def form_enp(atoms=None, total_energy=None, chem_pots=None):
but can be generalized by changing unary_energy.
"""
dd = atoms.composition.to_dict()
# print ('dd',dd)
ref = 0.0
for k, v in dd.items():
e1 = unary_energy(el=k, chem_pots=chem_pots)
# print (k,v,e1,total_energy)
if e1 == "na":
ref = "na"
ValueError("Element reference does not exist", e1)
Expand Down
2 changes: 1 addition & 1 deletion jarvis/analysis/thermodynamics/unary_qe_tb.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"H": {"jid": "na", "energy": -12.317418912143957}, "Li": {"jid": "na", "energy": -193.62366379259288}, "Be": {"jid": "na", "energy": -378.33271399884393}, "B": {"jid": "na", "energy": -79.54332692210605}, "C": {"jid": "na", "energy": -146.6870430830551}, "N": {"jid": "na", "energy": -264.9808449233288}, "O": {"jid": "na", "energy": -431.4806788041891}, "F": {"jid": "na", "energy": -656.1002396462983}, "Na": {"jid": "na", "energy": -1293.4591121095514}, "Mg": {"jid": "na", "energy": -1700.5928382383904}, "Al": {"jid": "na", "energy": -86.72355655980466}, "Is": {"jid": "na", "energy": -124.52516698389941}, "Si": {"jid": "na", "energy": -124.52516780024092}, "P": {"jid": "na", "energy": -205.08238367544425}, "S": {"jid": "na", "energy": -322.53145585852116}, "Cl": {"jid": "na", "energy": -449.92737880903024}, "K": {"jid": "na", "energy": -773.4131373566968}, "Ca": {"jid": "na", "energy": -1016.1982069190918}, "Sc": {"jid": "na", "energy": -1277.4913772053585}, "Ti": {"jid": "na", "energy": -1614.1060823523}, "V": {"jid": "na", "energy": -1963.958068876441}, "Cr": {"jid": "na", "energy": -2376.8029866539887}, "Mn": {"jid": "na", "energy": -2862.7231751981794}, "Fe": {"jid": "na", "energy": -3395.5464767619437}, "Co": {"jid": "na", "energy": -4050.7204951869967}, "Ni": {"jid": "na", "energy": -4662.012072644577}, "Cu": {"jid": "na", "energy": -5485.782824805897}, "Zn": {"jid": "na", "energy": -6273.923813896862}, "Ga": {"jid": "na", "energy": -5643.066107584661}, "Ge": {"jid": "na", "energy": -2895.8877637611886}, "As": {"jid": "na", "energy": -539.1256795756696}, "Se": {"jid": "na", "energy": -585.5415564396837}, "Br": {"jid": "na", "energy": -549.5025146993344}, "Rb": {"jid": "na", "energy": -721.8202223234264}, "Sr": {"jid": "na", "energy": -951.3921947621201}, "Y": {"jid": "na", "energy": -1255.8629687227242}, "Zr": {"jid": "na", "energy": -1341.1703946593695}, "Nb": {"jid": "na", "energy": -1594.4600566567829}, "Mo": {"jid": "na", "energy": -1884.5691449249175}, "Tc": {"jid": "na", "energy": -2359.116531490067}, "Ru": {"jid": "na", "energy": -2633.372883019565}, "Rh": {"jid": "na", "energy": -2321.697263731273}, "Pd": {"jid": "na", "energy": -2698.1840890133817}, "Ag": {"jid": "na", "energy": -4017.956005941796}, "Cd": {"jid": "na", "energy": -1556.4639991256156}, "In": {"jid": "na", "energy": -1809.2660917640735}, "Sn": {"jid": "na", "energy": -2158.0618065162375}, "Sb": {"jid": "na", "energy": -2507.3027268564465}, "Te": {"jid": "na", "energy": -356.3523613681483}, "I": {"jid": "na", "energy": -884.5179057241818}, "Cs": {"jid": "na", "energy": -854.8693570827407}, "Ba": {"jid": "na", "energy": -952.6213921576432}, "La": {"jid": "na", "energy": -1385.3824159629892}, "Hf": {"jid": "na", "energy": -2149.366316816515}, "Ta": {"jid": "na", "energy": -1918.4918629158617}, "W": {"jid": "na", "energy": -2151.9944453357753}, "Re": {"jid": "na", "energy": -2578.125019256137}, "Os": {"jid": "na", "energy": -2690.114023448249}, "Ir": {"jid": "na", "energy": -2462.157764208214}, "Pt": {"jid": "na", "energy": -2858.0346668136735}, "Au": {"jid": "na", "energy": -1557.3933760510517}, "Hg": {"jid": "na", "energy": -1462.3647709728443}, "Tl": {"jid": "na", "energy": -1966.4356961294002}, "Pb": {"jid": "na", "energy": -2226.0464492713695}, "Bi": {"jid": "na", "energy": -2512.7909210780376}}
{"Li": {"jid": "JQE-57", "energy": -195.51908984324695, "element": "Li"}, "Ag": {"jid": "JQE-949", "energy": -4021.1782370066794, "element": "Ag"}, "Al": {"jid": "JQE-1670", "energy": -90.67827673683328, "element": "Al"}, "As": {"jid": "JQE-2248", "energy": -543.9902158765085, "element": "As"}, "Au": {"jid": "JQE-2872", "energy": -1561.2567730403207, "element": "Au"}, "B": {"jid": "JQE-3341", "energy": -86.25179968039993, "element": "B"}, "Ba": {"jid": "JQE-3734", "energy": -954.7497347916109, "element": "Ba"}, "Be": {"jid": "JQE-4289", "energy": -382.308540743205, "element": "Be"}, "Bi": {"jid": "JQE-4678", "energy": -2516.8543991295205, "element": "Bi"}, "Br": {"jid": "JQE-5093", "energy": -551.1837797587827, "element": "Br"}, "C": {"jid": "JQE-5607", "energy": -156.12934818046347, "element": "C"}, "Ca": {"jid": "JQE-5808", "energy": -1018.3142595251056, "element": "Ca"}, "Cd": {"jid": "JQE-5894", "energy": -1557.6525829180491, "element": "Cd"}, "Cl": {"jid": "JQE-6293", "energy": -451.7637749827161, "element": "Cl"}, "Co": {"jid": "JQE-6443", "energy": -4058.026232121897, "element": "Co"}, "Cr": {"jid": "JQE-6528", "energy": -2386.315434157787, "element": "Cr"}, "Cs": {"jid": "JQE-6703", "energy": -855.7252433899572, "element": "Cs"}, "Cu": {"jid": "JQE-6914", "energy": -5490.0462533427035, "element": "Cu"}, "F": {"jid": "JQE-872400", "energy": -657.9127327692863, "element": "F"}, "Fe": {"jid": "JQE-7234", "energy": -3404.1051746170187, "element": "Fe"}, "Ga": {"jid": "JQE-7304", "energy": -5646.255995772408, "element": "Ga"}, "Ge": {"jid": "JQE-7508", "energy": -2900.603573827195, "element": "Ge"}, "H": {"jid": "JQE-7622", "energy": -15.597468602922518, "element": "H"}, "Hf": {"jid": "JQE-7755", "energy": -2156.975264674982, "element": "Hf"}, "I": {"jid": "JQE-872405", "energy": -886.1068773719674, "element": "I"}, "In": {"jid": "JQE-8078", "energy": -1812.0903766466186, "element": "In"}, "Ir": {"jid": "JQE-8269", "energy": -2471.6469596834986, "element": "Ir"}, "La": {"jid": "JQE-8321", "energy": -1390.3602239500322, "element": "La"}, "Mg": {"jid": "JQE-872487", "energy": -1702.3105451657002, "element": "Mg"}, "Mn": {"jid": "JQE-9216", "energy": -2871.89070545973, "element": "Mn"}, "Mo": {"jid": "JQE-9392", "energy": -1895.825612818842, "element": "Mo"}, "N": {"jid": "JQE-872396", "energy": -273.3476736266709, "element": "N"}, "Na": {"jid": "JQE-872393", "energy": -1294.7777441425123, "element": "Na"}, "Nb": {"jid": "JQE-10644", "energy": -1604.4889283644648, "element": "Nb"}, "Ni": {"jid": "JQE-10789", "energy": -4667.90230320086, "element": "Ni"}, "O": {"jid": "JQE-11020", "energy": -436.44902387756355, "element": "O"}, "Os": {"jid": "JQE-11252", "energy": -2701.7015420840276, "element": "Os"}, "P": {"jid": "JQE-11769", "energy": -210.6353389154419, "element": "P"}, "Pb": {"jid": "JQE-12013", "energy": -2229.833192748342, "element": "Pb"}, "Pd": {"jid": "JQE-12075", "energy": -2702.6439534286214, "element": "Pd"}, "Pt": {"jid": "JQE-12182", "energy": -2864.7389474330976, "element": "Pt"}, "Rb": {"jid": "JQE-12376", "energy": -722.7505520954641, "element": "Rb"}, "Rh": {"jid": "JQE-12609", "energy": -2328.7630943049703, "element": "Rh"}, "Ru": {"jid": "JQE-12742", "energy": -2642.8727607533615, "element": "Ru"}, "S": {"jid": "JQE-872511", "energy": -326.63541573143476, "element": "S"}, "Sb": {"jid": "JQE-13365", "energy": -2511.6234316184637, "element": "Sb"}, "Sc": {"jid": "JQE-13563", "energy": -1282.2510054223924, "element": "Sc"}, "Se": {"jid": "JQE-13755", "energy": -589.0888410770095, "element": "Se"}, "Si": {"jid": "JQE-14276", "energy": -130.0700990360536, "element": "Si"}, "Sn": {"jid": "JQE-14426", "energy": -2162.091797400208, "element": "Sn"}, "Sr": {"jid": "JQE-872507", "energy": -953.2103430699553, "element": "Sr"}, "Ta": {"jid": "JQE-14822", "energy": -1928.6498679992137, "element": "Ta"}, "Tc": {"jid": "JQE-14868", "energy": -2369.9074475140847, "element": "Tc"}, "Te": {"jid": "JQE-15137", "energy": -359.66240685774454, "element": "Te"}, "Ti": {"jid": "JQE-15181", "energy": -1621.072024003093, "element": "Ti"}, "Tl": {"jid": "JQE-15403", "energy": -1968.9122687439897, "element": "Tl"}, "V": {"jid": "JQE-15503", "energy": -1972.59706781866, "element": "V"}, "W": {"jid": "JQE-15692", "energy": -2163.904701873018, "element": "W"}, "Y": {"jid": "JQE-15855", "energy": -1260.6621512946945, "element": "Y"}, "Zn": {"jid": "JQE-868701", "energy": -6275.499226465034, "element": "Zn"}, "Zr": {"jid": "JQE-872338", "energy": -1348.761333483072, "element": "Zr"}, "K": {"jid": "JQE-872482", "energy": -774.4488745931519, "element": "K"}, "Hg": {"jid": "JQE-875284", "energy": -1462.887709986209, "element": "Hg"}, "Re": {"jid": "JQE-871165", "energy": -2590.21588614387, "element": "Re"}}
87 changes: 76 additions & 11 deletions jarvis/db/qe_to_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from jarvis.core.atoms import get_supercell_dims
from jarvis.analysis.structure.spacegroup import Spacegroup3D
from jarvis.core.utils import stringdict_to_xml, xml_to_dict, array_to_string
from jarvis.io.qe.outputs import DataFileSchema
from jarvis.io.qe.outputs import ProjHamXml, DataFileSchema
from jarvis.analysis.thermodynamics.energetics import (
form_enp,
get_unary_qe_tb_energy,
Expand All @@ -28,6 +28,7 @@ def parse_material_calculation_folder(
"jid",
"source_folder",
"final_energy",
"final_energy_breakdown",
# "initial_structure",
"natoms",
"final_spacegroup_number",
Expand All @@ -52,8 +53,10 @@ def parse_material_calculation_folder(
"is_spin_orbit",
"data_source",
"forces",
"stress",
"nelec",
"f_enp",
"dos",
]
for i in keys:
info[i] = "na"
Expand All @@ -73,31 +76,34 @@ def parse_material_calculation_folder(
f = gzip.open(dat_path, "rb")
file_content = f.read()
data = xmltodict.parse(file_content)
if "step" in data["qes:espresso"]:
set_key = "step"
elif "output" in data["qes:espresso"]:
if "output" in data["qes:espresso"]:
set_key = "output"
elif "step" in data["qes:espresso"]:
set_key = "step"
else:
raise ValueError("Inconsisten QE version.")
data_schm = DataFileSchema(data=data, set_key=set_key)
else:
dat_path = os.path.join(save_path, i)
data = xml_to_dict(dat_path)
if "step" in data["qes:espresso"]:
set_key = "step"
elif "output" in data["qes:espresso"]:
if "output" in data["qes:espresso"]:
set_key = "output"
elif "step" in data["qes:espresso"]:
set_key = "step"
else:
raise ValueError("Inconsisten QE version.")
data_schm = DataFileSchema(data=data, set_key=set_key)
info["final_energy"] = data_schm.final_energy
for ii, jj in data_schm.final_energy_breakdown.items():
info[ii] = jj
final_strt = data_schm.final_structure
info["final_structure"] = (
"'"
+ data_schm.final_structure.get_string().replace("\n", "\\n")
+ "'"
)
try:
print("data_schm.final_energy", data_schm.final_energy)
f_enp = form_enp(
atoms=final_strt,
chem_pots=get_unary_qe_tb_energy(),
Expand Down Expand Up @@ -153,7 +159,7 @@ def parse_material_calculation_folder(
"""

info["energy_per_atom"] = round(
float(data_schm.final_energy) / float(final_strt.num_atoms), 4
float(data_schm.energy_per_atom), 4
)

info["cif"] = ""
Expand Down Expand Up @@ -186,11 +192,69 @@ def parse_material_calculation_folder(
info["is_spin_polarized"] = data_schm.is_spin_polarized
info["is_spin_orbit"] = data_schm.is_spin_orbit
info["data_source"] = source
info["forces"] = array_to_string(
[" ".join(map(str, j)) for j in data_schm.forces]
info["forces"] = (
"'"
+ array_to_string(
[" ".join(map(str, j)) for j in data_schm.forces]
)
+ "'"
)
info["stress"] = (
"'"
+ array_to_string(
[" ".join(map(str, j)) for j in data_schm.stress]
)
+ "'"
)
try:
projham_xml_path_gz = os.path.join(path, "projham_K.xml.gz")
projham_xml_path = os.path.join(path, "projham_K.xml")
if os.path.exists(projham_xml_path):
energies, dos, pdos, names = ProjHamXml(
filename=projham_xml_path
).dos()
line = (
"<edos_energies>'"
+ ",".join(map(str, energies))
+ "'</edos_energies>"
)
line += (
"<total_edos_up>'"
+ ",".join(map(str, dos))
+ "'</total_edos_up>"
)
line += "<elemental_dos>"
for n, nn in enumerate(names):
pdos_n = pdos[:, n]
line += str(nn) + "_" + ",".join(map(str, pdos_n)) + ";"
line += "</elemental_dos>"

info["dos"] = line
elif os.path.exists(projham_xml_path_gz):
energies, dos, pdos, names = ProjHamXml(
filename=projham_xml_path_gz
).dos()
line = (
"<edos_energies>'"
+ ",".join(map(str, energies))
+ "'</edos_energies>"
)
line += (
"<total_edos_up>'"
+ ",".join(map(str, dos))
+ "'</total_edos_up>"
)
line += "<elemental_dos>'"
for n, nn in enumerate(names):
pdos_n = pdos[:, n]
line += str(nn) + "_" + ",".join(map(str, pdos_n)) + ";"
line += "'</elemental_dos>"
info["dos"] = line
else:
info["dos"] = "na"
# print(pprint.pprint(info))
except Exception as exp:
pass
return info


Expand All @@ -213,7 +277,8 @@ def write_xml(path="", filename="temp.xml"):


"""
path='/rk2/knc6/UniveralTB/julia_data/TEST_ELS/POSCAR_JVASP-1002'
#path='/rk2/knc6/UniveralTB/julia_data/TEST_ELS/POSCAR_JVASP-1002'
#path='/rk2/knc6/UniveralTB/julia_data/TEST_BIN/POSCAR_JVASP-10016'
if __name__ == "__main__":
#path = "/rk2/knc6/UniveralTB/julia_data/
#Si_C_kspace/POSCAR_tio2_rutile_vnscf_vol_1"
Expand Down
Loading

0 comments on commit 6a755b6

Please sign in to comment.