Skip to content

Commit

Permalink
Bug Fixes (#100)
Browse files Browse the repository at this point in the history
* develop branch

* ToDict and FromDict methods added to classes

* Interface routine fixed, added spacegroup tests, more queue jobs

* Pycodestyle fix

* Tests fix.

* Update README.rst

* Update README.rst

* Create DatasetSummary.rst

* Update README.rst

* Update README.rst

* Pydocstyle fix
  • Loading branch information
knc6 authored Jul 23, 2020
1 parent a9322fc commit 5acac87
Show file tree
Hide file tree
Showing 11 changed files with 257 additions and 289 deletions.
15 changes: 15 additions & 0 deletions DatasetSummary.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
* A summary of the projects

=============== =======================================================================
Projects Brief description
=============== =======================================================================
``JARVIS-DFT`` Density functional theory calculation database for ~40000 3D and ~1000 2D materials. Some of the material-properties include: Heat of formation, Crystal-structural data using OptB88vdW, PBE, LDA functionals, Bandgaps using semi-local, meta-GGA, HSE06 and other beyond DFT methods, Electron and phonon-bandstructures, Elastic, Piezoelectric, Thermoelectric, Dielectric tensors, Exfoliation energies for low-diemnsional materials, Frequency dependent dielectric function, Absorption coefficients, Work-function for 2D materials, Infrared and Raman intensities, Electric field gradient, Magnetic moment, Solar-cell efficiencies, Scanning Tunneling Microscopy (STM) images, Topological spin-orbit spillage, converged k-point and plane wave cut-offs, Wannier-tight binding Hamiltonian parameters and more. The website for JARVIS-DFT: https://www.ctcms.nist.gov/~knc6/JVASP.html
``JARVIS-FF`` Classical molecular dynamics calculation database for ~2000 3D materials with interatomic potential/force-fields. Some of the properties included in JARVIS-FF are energetics, elastic constants, surface energies, defect formations energies and phonon frequencies of materials. The website for JARVIS-FF: https://www.ctcms.nist.gov/~knc6/periodic.html
``JARVIS-ML`` Machine learning prediction tools trained on the JARVIS-DFT data. Some of the ML-prediction models are for Heat of formation, GGA/METAGGA bandgaps, Refractive indices, Bulk and shear modulus, Magnetic moment, Thermoelectric, Piezoelectric and Dielectric properties properties, Exfoliation energies, Solar-cell efficiency, and STM image classification. The website for JARVIS-ML: https://www.ctcms.nist.gov/jarvisml
``JARVIS-Het.`` Heterostructure design tools for 2D materials in the JARVIS-DFT database. Some of the properties available are: work function, Band-alignment, and Heterostructure classification. JARVIS-Heterostructure website: https://www.ctcms.nist.gov/jarvish
``JARVIS-PV`` Solar-cell/Photovoltaic cell design tools. Dataset is made available and the website will be available soon.
``JARVIS-STM`` Scanning-tunneling microscopy images for 2D materials. Dataset is made available and the website will be available soon.
``JARVIS-WTB`` Wannier Tight Binding Hamiltonian parameter dataset. Website: https://www.ctcms.nist.gov/jarviswtb
``JARVIS-EFG`` Electric field gradient dataset. Dataset will be made available and the website will be available soon.
``Downloads`` Download raw metadat at: https://www.ctcms.nist.gov/~knc6/downloads.html
=============== =======================================================================
24 changes: 9 additions & 15 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,16 @@ For more details, checkout our latest article: `JARVIS: An Integrated Infrastru
:target: https://jarvis.nist.gov/


Some important features
=======================================================================

* A summary of the projects

=============== =======================================================================
Projects Brief description
=============== =======================================================================
``JARVIS-DFT`` Density functional theory calculation database for ~40000 3D and ~1000 2D materials. Some of the material-properties include: Heat of formation, Crystal-structural data using OptB88vdW, PBE, LDA functionals, Bandgaps using semi-local, meta-GGA, HSE06 and other beyond DFT methods, Electron and phonon-bandstructures, Elastic, Piezoelectric, Thermoelectric, Dielectric tensors, Exfoliation energies for low-diemnsional materials, Frequency dependent dielectric function, Absorption coefficients, Work-function for 2D materials, Infrared and Raman intensities, Electric field gradient, Magnetic moment, Solar-cell efficiencies, Scanning Tunneling Microscopy (STM) images, Topological spin-orbit spillage, converged k-point and plane wave cut-offs, Wannier-tight binding Hamiltonian parameters and more. The website for JARVIS-DFT: https://www.ctcms.nist.gov/~knc6/JVASP.html
``JARVIS-FF`` Classical molecular dynamics calculation database for ~2000 3D materials with interatomic potential/force-fields. Some of the properties included in JARVIS-FF are energetics, elastic constants, surface energies, defect formations energies and phonon frequencies of materials. The website for JARVIS-FF: https://www.ctcms.nist.gov/~knc6/periodic.html
``JARVIS-ML`` Machine learning prediction tools trained on the JARVIS-DFT data. Some of the ML-prediction models are for Heat of formation, GGA/METAGGA bandgaps, Refractive indices, Bulk and shear modulus, Magnetic moment, Thermoelectric, Piezoelectric and Dielectric properties properties, Exfoliation energies, Solar-cell efficiency, and STM image classification. The website for JARVIS-ML: https://www.ctcms.nist.gov/jarvisml
``JARVIS-Het.`` Heterostructure design tools for 2D materials in the JARVIS-DFT database. Some of the properties available are: work function, Band-alignment, and Heterostructure classification. JARVIS-Heterostructure website: https://www.ctcms.nist.gov/jarvish
``JARVIS-PV`` Solar-cell/Photovoltaic cell design tools. Dataset is made available and the website will be available soon.
``JARVIS-STM`` Scanning-tunneling microscopy images for 2D materials. Dataset is made available and the website will be available soon.
``JARVIS-WTB`` Wannier Tight Binding Hamiltonian parameter dataset. Website: https://www.ctcms.nist.gov/jarviswtb
``JARVIS-EFG`` Electric field gradient dataset. Dataset will be made available and the website will be available soon.
``Downloads`` Download raw metadat at: https://www.ctcms.nist.gov/~knc6/downloads.html
=============== =======================================================================
- **Software workflow tasks**: VASP, Quantum Espresso, BoltzTrap, Wannier90, LAMMPS, Scikit-learn, TensorFlow, LightGBM.

- **HPC clusters**: PBS and SLURM.

- **Examples**: Notebooks and test scripts to explain the package.

- **Available datasets**: `Summary of several datasets <https://github.com/usnistgov/jarvis/blob/master/DatasetSummary.rst>`__ .


Installation
Expand Down
170 changes: 25 additions & 145 deletions jarvis/analysis/interface/zur.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from itertools import product
import numpy as np
from jarvis.core.atoms import Atoms, add_atoms, fix_pbc, VacuumPadding
from jarvis.core.atoms import add_atoms, fix_pbc
from jarvis.core.lattice import Lattice


Expand Down Expand Up @@ -290,12 +290,12 @@ def get_factors(n):
def make_interface(
film="",
subs="",
atol=0.01,
ltol=0.03,
atol=1,
ltol=0.05,
max_area=500,
max_area_ratio_tol=0.09,
seperation=2.0,
vacuum=18.0,
max_area_ratio_tol=1.00,
seperation=3.0,
vacuum=8.0,
):
"""
Use as main function for making interfaces/heterostructures.
Expand All @@ -308,19 +308,18 @@ def make_interface(
subs: substrate/bottom/fixed material.
seperation: minimum seperation between two.
vacuum: vacuum will be added on both sides.
So 2*vacuum will be added.
"""
z = ZSLGenerator(
max_area_ratio_tol=max_area_ratio_tol,
max_area=max_area,
max_length_tol=ltol,
max_angle_tol=atol,
)
film = fix_pbc(
film.center_around_origin([0, 0, 0])
) # .get_string(cart=False)
subs = fix_pbc(
subs.center_around_origin([0, 0, 0])
) # .get_string(cart=False)
film = fix_pbc(film.center_around_origin([0, 0, 0]))
subs = fix_pbc(subs.center_around_origin([0, 0, 0]))
matches = list(z(film.lattice_mat[:2], subs.lattice_mat[:2], lowest=True))
info = {}
info["mismatch_u"] = "na"
Expand Down Expand Up @@ -387,112 +386,29 @@ def make_interface(
film_bottom_z = min(np.array(film_scell.cart_coords)[:, 2])
thickness_sub = abs(substrate_top_z - substrate_bot_z)
thickness_film = abs(film_top_z - film_bottom_z)

min_distance = seperation + (thickness_sub) # +thickness_film/ 2.0
sub_z = (
(vacuum + thickness_sub + thickness_film)
(vacuum + substrate_top_z)
* np.array(subs_scell.lattice_mat[2, :])
/ np.linalg.norm(subs_scell.lattice_mat[2, :])
) # subs.lattice_mat[2, :]
)
shift_normal = (
sub_z / np.linalg.norm(sub_z) * seperation / np.linalg.norm(sub_z)
)
tmp = (
thickness_film / 2 + seperation + thickness_sub / 2
) / np.linalg.norm(subs_scell.lattice_mat[2, :])
shift_normal = (
sub_z / np.linalg.norm(sub_z) * min_distance / np.linalg.norm(sub_z)
tmp
* np.array(subs_scell.lattice_mat[2, :])
/ np.linalg.norm(subs_scell.lattice_mat[2, :])
)
interface = add_atoms(
film_scell, subs_scell, shift_normal
).center_around_origin([0, 0, 0.5])
info["interface"] = VacuumPadding(
atoms=interface, vacuum=vacuum
).get_effective_2d_slab()
print("mismatch_u,mismatch_v", mismatch_u, mismatch_v)
if mismatch_u < 0 or mismatch_v < 0:
print("Maybe unphysical structure")
info["msg"] = "Maybe unphysical structure"
return info


def mismatch_strts(film=[], subs=[], ltol=0.05, atol=10):
"""
Return mismatch and other information as info dict.
Deprecated this module will be removes in the next version.
"""
z = ZSLGenerator()
matches = list(z(film.lattice_mat[:2], subs.lattice_mat[:2], lowest=True))
info = {}
info["mismatch_u"] = "na"
info["mismatch_v"] = "na"
info["mismatch_angle"] = "na"
info["area1"] = "na"
info["area2"] = "na"
info["film_sl"] = film
info["subs_sl"] = subs

uv1 = matches[0]["sub_sl_vecs"]
uv2 = matches[0]["film_sl_vecs"]
u = np.array(uv1)
v = np.array(uv2)
a1 = u[0]
a2 = u[1]
b1 = v[0]
b2 = v[1]
mismatch_u = np.linalg.norm(b1) / np.linalg.norm(a1) - 1
mismatch_v = np.linalg.norm(b2) / np.linalg.norm(a2) - 1
angle1 = (
np.arccos(np.dot(a1, a2) / np.linalg.norm(a1) / np.linalg.norm(a2))
* 180
/ np.pi
combined = interface.center(vacuum=vacuum).center_around_origin(
[0, 0, 0.5]
)
angle2 = (
np.arccos(np.dot(b1, b2) / np.linalg.norm(b1) / np.linalg.norm(b2))
* 180
/ np.pi
)
mismatch_angle = abs(angle1 - angle2)
area1 = np.linalg.norm(np.cross(a1, a2))
area2 = np.linalg.norm(np.cross(b1, b2))
uv_substrate = uv1
uv_mat2d = uv2
substrate_latt = Lattice(
np.array(
[uv_substrate[0][:], uv_substrate[1][:], subs.lattice_mat[2, :]]
)
)
film_norm = np.linalg.norm(film.lattice_mat[2, :])
mat2d_fake_c = film.lattice_mat[2, :] / film_norm * 5.0
mat2d_latt = Lattice(
np.array([uv_mat2d[0][:], uv_mat2d[1][:], mat2d_fake_c])
)
mat2d_latt_fake = Lattice(
np.array(
[film.lattice_mat[0, :], film.lattice_mat[1, :], mat2d_fake_c]
)
)
_, __, scell = subs.lattice.find_matches(
substrate_latt, ltol=ltol, atol=atol
)
scell[2] = np.array([0, 0, 1])
subs = subs.make_supercell_matrix(scell)
_, __, scell = mat2d_latt_fake.find_matches(mat2d_latt, ltol=0.05, atol=1)
scell[2] = np.array([0, 0, 1])
film = film.make_supercell_matrix(scell)

lmap = Lattice(
np.array(
[
subs.lattice_mat[0, :],
subs.lattice_mat[1, :],
film.lattice_mat[2, :],
]
)
)
film.lattice = lmap
info["mismatch_u"] = mismatch_u
info["mismatch_v"] = mismatch_v
info["mismatch_angle"] = mismatch_angle
info["area1"] = area1
info["area2"] = area2
info["film_sl"] = film
info["subs_sl"] = subs
info["interface"] = combined
return info


Expand Down Expand Up @@ -524,42 +440,6 @@ def get_hetero_type(A={}, B={}):
return int_type, stack


def get_hetero(film, substrate, seperation=3.5):
"""Generate heterostructure, deprecated."""
substrate_top_z = max(np.array(substrate.cart_coords)[:, 2])
# substrate_bot_z = min(np.array(substrate.cart_coords)[:, 2])
# film_bottom = min(np.array(film.cart_coords)[:, 2])
# film_top = max(np.array(film.cart_coords)[:, 2])
sub_z = substrate.lattice_mat[2, :]
origin = np.array([0, 0, substrate_top_z])
shift_normal = sub_z / np.linalg.norm(sub_z) * seperation
# thickness_sub = abs(substrate_top_z - substrate_bot_z)
# thickness_film = abs(film_top - film_bottom)
new_coords = []
lattice_mat = substrate.lattice_mat
elements = []
for i in substrate.cart_coords:
new_coords.append(i)
for i in substrate.elements:
elements.append(i)

for i in film.elements:
elements.append(i)
for i in film.cart_coords:
tmp = i
tmp = tmp + origin + shift_normal
new_coords.append(tmp)

interface = Atoms(
lattice_mat=lattice_mat,
elements=elements,
coords=new_coords,
cartesian=True,
)

return interface


"""
if __name__ == "__main__":
s1 = Poscar.from_file(
Expand Down
2 changes: 1 addition & 1 deletion jarvis/core/atoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def to_dict(self):
d = OrderedDict()
d["lattice_mat"] = self.lattice_mat.tolist()
d["coords"] = np.array(self.coords).tolist()
d["elements"] = self.elements
d["elements"] = np.array(self.elements).tolist()
d["abc"] = self.lattice.lat_lengths()
d["angles"] = self.lattice.lat_angles()
d["cartesian"] = self.cartesian
Expand Down
3 changes: 1 addition & 2 deletions jarvis/io/boltztrap/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ def __init__(
condtens_fixdoping = self.read_condtens_fixdoping()
self.condtens_fixdoping = condtens_fixdoping
if halltens_fixdoping == []:
halltens_fixdoping = self.read_condtens_fixdoping()
halltens_fixdoping = self.read_halltens_fixdoping()
self.halltens_fixdoping = halltens_fixdoping

def to_dict(self):
"""Return output as a dictionary."""
d = OrderedDict()
d["path"] = self.path
d["outtrans_data"] = self.outtrans_data

d["intrans_data"] = self.intrans_data
d["halltens_fixdoping"] = self.halltens_fixdoping
d["condtens_fixdoping"] = self.condtens_fixdoping
Expand Down
29 changes: 14 additions & 15 deletions jarvis/io/vasp/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def __init__(
elements=[],
pot_type="POT_GGA_PAW_PBE",
pot_json_path="",
potcar_strings={},
potcar_strings=[],
):
"""
Initialize the Potcar class.
Expand All @@ -329,21 +329,24 @@ def __init__(
self._potcar_strings = potcar_strings
self._pot_json_path = pot_json_path

if self._potcar_strings == {}:
if self._potcar_strings == []:
pot_json_file = str(
os.path.join(os.path.dirname(__file__), "default_potcars.json")
)
self._pot_json_path = pot_json_file
pot_json = open(pot_json_file, "r")
pot_json_selected = json.load(pot_json)
pot_json.close()
potcar_strings = OrderedDict()
potcar_strings = [] # OrderedDict()
for i in self._elements:
for j, k in pot_json_selected.items():
if i == j:
potcar_strings.setdefault(i, k)
potcar_strings.append(pot_json_selected[i])
# for j, k in pot_json_selected.items():
# if i == j:
# potcar_strings.setdefault(i, k)
self._potcar_strings = potcar_strings
if len(self._elements) != len(self._potcar_strings.keys()):
print("self._elements", self._elements)
print("self._potcar_strings", self._potcar_strings)
if len(self._elements) != len(self._potcar_strings):
raise ValueError(
"Number of elements is not same as potcar_strings",
self._elements,
Expand All @@ -353,12 +356,8 @@ def __init__(
pot_json = open(self._pot_json_path, "r")
pot_json_selected = json.load(pot_json)
pot_json.close()
potcar_strings = OrderedDict()
for i, j in pot_json_selected.items():
if i in self._elements:
potcar_strings.setdefault(i, j)
self._potcar_strings = potcar_strings
if len(self._elements) != len(self._potcar_strings.keys()):
if len(self._elements) != len(self._potcar_strings):
msg = "Number of elements not same as potcar_strings"
raise ValueError(msg)

Expand All @@ -375,10 +374,10 @@ def from_dict(self, d={}):
def to_dict(self):
"""Convert to a dictionary."""
d = OrderedDict()
d["elements"] = self._elements
d["elements"] = np.array(self._elements).tolist()
d["pot_type"] = self._pot_type
d["pot_json_path"] = self._pot_json_path
d["potcar_strings"] = self._potcar_strings
d["potcar_strings"] = np.array(self._potcar_strings).tolist()
return d

def catenate_potcar_files(
Expand All @@ -397,7 +396,7 @@ def list_potcar_files(self):
vasp_dir = str(os.environ["JARVIS_VASP_PSP_DIR"])
vasp_psp_dir = str(os.path.join(vasp_dir, self._pot_type))
potcar_strings = self._potcar_strings
for i, j in potcar_strings.items():
for j in potcar_strings:
tmp = os.path.join(vasp_psp_dir, j, "POTCAR")
pot_files.append(tmp)
return pot_files
Expand Down
Loading

0 comments on commit 5acac87

Please sign in to comment.