Skip to content

Commit

Permalink
Develop (#134)
Browse files Browse the repository at this point in the history
* Added OQMD, MP, QM9 CFID datasets.

* Added OQMD, MP, QM9 CFID datasets.

* vasp2xml schema update.

* Update config.yml

* XRD DB making bug fix, scattering.json update.

* Minor bug fix in vasp_to_xml.py

* Add license.

* Add license, pin versions

* Remove circle.

* Update shell.nix

* Vasprun single element bug fix.

* Minor updates.

* DB XML and VASP Workflow fix.

* AFLOW CFID added, VASP_PSP_DIR fix.

* Linting fix, new version release.
  • Loading branch information
knc6 authored Nov 10, 2020
1 parent 9601924 commit fa6f9b3
Show file tree
Hide file tree
Showing 17 changed files with 92,670 additions and 126 deletions.
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__ = "2020.10.20"
__version__ = "2020.11.09"
3 changes: 2 additions & 1 deletion jarvis/core/atoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,8 @@ def get_string(self, cart=True, sort_order="X"):
+ cart_frac
)
rest = ""

if coords_ordered.ndim == 1:
coords_ordered = np.array([coords])
for ii, i in enumerate(coords_ordered):
if self.show_props:
rest = (
Expand Down
13 changes: 13 additions & 0 deletions jarvis/core/kpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from numpy import cos, sin
from math import tan, pi
from math import ceil
import math


def generate_kgrid(grid=[5, 5, 5]):
Expand Down Expand Up @@ -74,6 +75,18 @@ def kpts(self):
"""Return k-points arrays."""
return self._kpoints

def kpoints_per_atom(self, atoms=None, kppa=1000):
"""Return Kpoints object for kpoints per atom for a cell."""
if math.fabs((math.floor(kppa ** (1 / 3) + 0.5)) ** 3 - kppa) < 1:
kppa += kppa * 0.01
# latt = atoms.lattice_mat
lengths = atoms.lattice.lat_lengths()
ngrid = kppa / atoms.num_atoms
mult = (ngrid * lengths[0] * lengths[1] * lengths[2]) ** (1 / 3)
num_div = [int(math.floor(max(mult / lg, 1))) for lg in lengths]
kpts = Kpoints3D(kpoints=[num_div])
return kpts

@property
def labels(self):
"""Return k-points labels, used for high BZ points."""
Expand Down
16 changes: 15 additions & 1 deletion jarvis/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
import random
import numpy as np
import math
import xmltodict

# from lxml import etree

def xml_to_dict(fname):
"""Parse XML file."""
with open(fname, "r") as f:
data = xmltodict.parse(f.read())
return data


def get_counts(array=["W", "W", "Mo", "Mo", "S", "S"]):
Expand Down Expand Up @@ -137,6 +143,14 @@ def array_to_string(arr=[]):
return ",".join(map(str, arr))


def chunks(lst, n):
"""Split successive n-sized chunks from list."""
x = []
for i in range(0, len(lst), n):
x.append(lst[i : i + n])
return x


def check_match(a, b, tol=1e-8):
"""Check if a and b are the same, taking into account PBCs."""
if abs(a[0] - b[0]) < tol or abs(abs(a[0] - b[0]) - 1) < tol:
Expand Down
12 changes: 12 additions & 0 deletions jarvis/db/figshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ def datasets(dataset=""):
url = "https://ndownloader.figshare.com/files/25159592"
js_tag = "qm9_data_cfid.json"
print("Obtaining QM9-molecule CFID dataset 134k...")
elif dataset == "aflow1":
url = "https://ndownloader.figshare.com/files/25453256"
js_tag = "CFID-AFLOW-1.json"
print("Obtaining AFLOW-1 CFID dataset 400k...")
elif dataset == "aflow2":
url = "https://ndownloader.figshare.com/files/25453265"
js_tag = "CFID-AFLOW-2.json"
print("Obtaining AFLOW-2 CFID dataset 400k...")
elif dataset == "raw_files":
url = "https://ndownloader.figshare.com/files/25295732"
js_tag = "figshare_data-10-28-2020.json"
print("Obtaining raw io files...")
else:
ValueError("Dataset doesnt exist", dataset)
return url, js_tag
Expand Down
41 changes: 31 additions & 10 deletions jarvis/db/lammps_to_xml.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,43 @@
"""Module to generate XML file for LAMMPS calculation."""
import numpy as np
from jarvis.core.atoms import get_supercell_dims

from jarvis.db.jsonutils import loadjson
from jarvis.analysis.structure.spacegroup import Spacegroup3D
from jarvis.core.utils import stringdict_to_xml

mp_jv = loadjson("/rk2/knc6/DB/MP/mp_jv_id.json")


def get_jvid(mp=""):
"""Get JARVIS-ID for MPID."""
jvid = ""
try:
jvid = "'" + ",".join(mp_jv[mp]) + "'"
except Exception as exp:
print("No JID", exp)
pass
return jvid


def basic_data(data={}, source="JARVIS-FF-LAMMPS"):
"""Get basic data for table."""
info = {}
info["id"] = data["jid"]
info["source_folder"] = data["source_folder"]
info["tmp_source_folder"] = "'" + data["source_folder"] + "'"
info["tmp_id"] = "'" + data["jid"] + "'"
ref = data["source_folder"].split("/")[-1].split("@")[1].split("_")[0]
info["ref"] = "'" + ref + "'"
info["jvid"] = get_jvid(ref)
final_atoms = data["bulk_data"]["final_str"]
initial_atoms = data["bulk_data"]["initial_str"]
info["formula"] = final_atoms.composition.reduced_formula
info["tmp_formula"] = "'" + final_atoms.composition.reduced_formula + "'"
info["elements"] = ",".join(final_atoms.uniq_species)
info["tmp_elements"] = "'" + ",".join(final_atoms.uniq_species) + "'"
info["number_uniq_species"] = len(final_atoms.uniq_species)
info["data_source"] = source
info["tmp_data_source"] = "'" + source + "'"
info["pair_style"] = data["bulk_data"]["pair_style"]
info["pair_coeff"] = data["bulk_data"]["pair_coeff"]
# info["pair_coeff"] = (
Expand Down Expand Up @@ -74,7 +95,7 @@ def basic_data(data={}, source="JARVIS-FF-LAMMPS"):
info["final_crystal_system"] = final_spg.crystal_system

et = ""
print(data["bulk_data"]["elastic_tensor"]["raw_et_tensor"])
# print(data["bulk_data"]["elastic_tensor"]["raw_et_tensor"])
try:
if data["bulk_data"]["elastic_tensor"] != "":
cij = np.round(
Expand All @@ -88,8 +109,8 @@ def basic_data(data={}, source="JARVIS-FF-LAMMPS"):
+ '"</cij>'
)

except Exception:
print("Cannot obtain elastic tensor data.", info["source_folder"])
except Exception as exp:
print("Cannot obtain elastic tensor data.", info["source_folder"], exp)
pass

info["elastic_tensor"] = et
Expand Down Expand Up @@ -138,11 +159,11 @@ def basic_data(data={}, source="JARVIS-FF-LAMMPS"):
+ ",".join(map(str, label_points))
+ "'</phonon_bandstructure_label_points>"
)
except Exception:
print("Cannot obtain phonon band data.")
except Exception as exp:
print("Cannot obtain phonon band data.", exp)

# Comment until 4 MB text size error
# info["phonon_band_line"] = phonon_band_line
info["phonon_band_line"] = phonon_band_line
phonon_dos_line = ""
try:
freq = data["dos_freq"]
Expand Down Expand Up @@ -190,9 +211,9 @@ def write_xml(data={}, filename="temp.xml"):
if __name__ == "__main__":
from jarvis.io.lammps.outputs import parse_material_calculation_folder
# fold = '/rk2/knc6/JARVIS-FF/ALLOY8/\
# Mishin-Ni-Al-2009.eam.alloy_nist/bulk@mp-23_fold'
fold = "/rk2/knc6/JARVIS-FF/COMB/ffield.TiON.comb3_nist/bulk@mp-25433_fold"
fold = '/rk2/knc6/JARVIS-FF/ALLOY8/
Mishin-Ni-Al-2009.eam.alloy_nist/bulk@mp-23_fold'
x = parse_material_calculation_folder(fold)
write_xml(x)
print('src',x["source_folder"].split('/')[-1].split('@')[1].split('_')[0])
"""
Loading

0 comments on commit fa6f9b3

Please sign in to comment.