Skip to content

Commit

Permalink
Develop (#189)
Browse files Browse the repository at this point in the history
* Image augmentation.

* Augment images.

* Augment images.

* Specie update.

* Add Latt2D, STM image (b-1) fix, image augmentation fix.

* Add Latt2D, STM image (b-1) fix, image augmentation fix.

* Update conf.py

* Update conf.py

* Multi-output graph bacthing.

* Add EDOS dataset.

* Temp.

* Add circuit maker.

* Add circuit maker.

* NELECT update.

* Version update, more DBs added.

* Fix CHGCAR vasp.

* Added volumetric reshape for CHGCAR.

* Tmp

* Tershoff Hamman update, specie update.

* Add crop from center in STM.

* Add Fourier transfor in STM.

* Update STM pytest.

* Add DPI to STM.

* Zeo++ added, Atoms cif update, STM update, random vacancy maker added.

* Atoms tempfile fix, Potcar from atoms module added.

* Test for docs.

* C2DB link update, docs Atoms update.

* C2DB link update, docs Atoms update.

* Version update, COD DB, QM9 JCTC DB added.

* Compostion bug fix, elemental descriptor added.

* Develop (#186)

* Update outputs.py

I added the calculation of the Raman intensities inside parse_raman_dat

* Update outputs.py

* Update outputs.py

* Update outputs.py

* Update cfid.py

* Delete __init__.py

* stylecss added.

* stylecss added.

* Adding extra Makefile/

* Remove examples from docs.

* Docs update.

* Docs update.

* Docs update.

* Docs update.

* Docs update.

* Docs update.

* Docs update.

* Docs update.

* Docs update.

* Docs update.

* Tutorials update.

* Tutorials docs update.

* Docs update,pdb reader updated.

* Update action_build.yml

* Update action_build.yml

* Remove pytraj strong dependencies.

* Update docs, Added PDBBind and HPOV datasets.

* Docs update.

* Add thcikness to surface builder.

* Surface builder update, Chemical only magpie descriptors added, pdb_core dataset added, zeopp tempfile bugfix.

* Typo fix.

* Add names to chem descs.

Co-authored-by: tavazza <tavazza@gmail.com>
Co-authored-by: knc6 <kamal.choudhary@nist.gov>
  • Loading branch information
3 people authored Jul 19, 2021
1 parent 86d91e2 commit 08624c1
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 28 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__ = "2021.07.10"
__version__ = "2021.07.18"
65 changes: 48 additions & 17 deletions jarvis/ai/descriptors/cfid.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,61 @@
https://journals.aps.org/prmaterials/abstract/10.1103/PhysRevMaterials.2.083801
"""
from jarvis.analysis.structure.neighbors import NeighborsAnalysis
from jarvis.core.specie import Specie
from jarvis.core.specie import get_descrp_arr_name
import numpy as np
from math import log
from jarvis.core.composition import Composition
from jarvis.core.specie import Specie


def get_chem_only_descriptors(
formula="Al2O3",
extra=[],
mean_only=False,
max_only=False,
min_only=False,
source="cfid",
):
"""Get jarvis_cfid or magpie descriptors for each formula."""
s = Composition.from_string(formula)
el_dict = s.to_dict()
arr = []
sum = 0
for k, v in el_dict.items():
sum += v
des = v * Specie(k, source=source).get_descrp_arr
arr.append(des)
names = list(Specie("H", source=source)._data["H"].keys())
if mean_only:
chem = np.mean(np.array(arr), axis=0) / sum
names = ["Mean_" + source + "_" + str(n) for n in names]
elif max_only:
chem = np.max(np.array(arr), axis=0) / sum
names = ["Max_" + source + "_" + str(n) for n in names]
elif min_only:
chem = np.min(np.array(arr), axis=0) / sum
names = ["Min_" + source + "_" + str(n) for n in names]
else:
chem = (
list(np.mean(np.array(arr), axis=0) / sum)
+ list(np.max(np.array(arr), axis=0) / sum)
+ list(np.min(np.array(arr), axis=0) / sum)
)
chem = np.array(chem)
names = (
["Mean_" + source + "_" + str(n) for n in names]
+ ["Max_" + source + "_" + str(n) for n in names]
+ ["Min_" + source + "_" + str(n) for n in names]
)
chem = list(chem)
for ii, i in enumerate(extra):
chem.append(i)
nm = "extra_" + str(ii)
names.append(nm)
chem = np.array(chem)
return chem, names


class CFID(object):
"""Convert Atoms class into 1557 descriptors."""

Expand Down Expand Up @@ -1836,22 +1883,6 @@ def feat_names():
return names


def get_chem_only_descriptor(formula="Al2O3"):
"""Get 438 descriptors for a chemical formula."""
s = Composition.from_string(formula)
# print (formula,s)
el_dict = s.to_dict()
arr = []
tot = 0
for k, v in el_dict.items():
tot += v
des = v * Specie(k).get_descrp_arr
arr.append(des)
mean_chem = np.mean(np.array(arr), axis=0) / tot
names = feat_names()[0:438]
return mean_chem, names


"""
if __name__ == "__main__":
box = [[2.715, 2.715, 0], [0, 2.715, 2.715], [2.715, 0, 2.715]]
Expand Down
12 changes: 11 additions & 1 deletion jarvis/analysis/defects/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(
atoms=None,
indices=[0, 0, 1],
layers=3,
thickness=25,
vacuum=18.0,
tol=1e-10,
from_conventional_structure=True,
Expand All @@ -48,6 +49,8 @@ def __init__(
layers: Number of surface layers
thickness: Provide thickness instead of layers
vacuum: vacuum padding
tol: tolerance during dot product
Expand All @@ -63,6 +66,8 @@ def __init__(
self.tol = tol
self.vacuum = vacuum
self.layers = layers
self.thickness = thickness
# Note thickness overwrites layers

def to_dict(self):
"""Convert to a dictionary."""
Expand Down Expand Up @@ -141,7 +146,12 @@ def make_surface(self):
elements=atoms.elements,
cartesian=True,
)

if self.thickness is not None and (self.thickness) > 0:
self.layers = int(self.thickness / new_atoms.lattice.c) + 1
# dims=get_supercell_dims(new_atoms,enforce_c_size=self.thickness)
# print ('dims=',dims,self.layers)
# surf_atoms = new_atoms.make_supercell_matrix([1, 1, dims[2]])
# print('self.layers',self.layers,self.thickness,new_atoms.lattice.c)
surf_atoms = new_atoms.make_supercell_matrix([1, 1, self.layers])
# print("supercell_cart_coords", surf_atoms.frac_coords)

Expand Down
2 changes: 1 addition & 1 deletion jarvis/core/atoms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""This module provides classes to specify atomic structure."""
import numpy as np
from jarvis.core.composition import Composition
from jarvis.core.specie import Specie
from jarvis.core.specie import Specie, atomic_numbers_to_symbols
from jarvis.core.lattice import Lattice, lattice_coords_transformer
from collections import OrderedDict
from jarvis.core.utils import get_counts
Expand Down
1 change: 1 addition & 0 deletions jarvis/core/magpie.json

Large diffs are not rendered by default.

23 changes: 19 additions & 4 deletions jarvis/core/specie.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from jarvis.core.utils import digitize_array
from collections import defaultdict
from collections.abc import Iterable
from jarvis.db.jsonutils import loadjson

el_chem_json_file = str(
os.path.join(os.path.dirname(__file__), "Elements.json")
Expand All @@ -15,6 +16,10 @@
chem_data = json.load(el_chem_json)
el_chem_json.close()

chem_data_magpie = loadjson(
os.path.join(os.path.dirname(__file__), "magpie.json")
)

el_chrg_json_file = str(
os.path.join(os.path.dirname(__file__), "element_charge.json")
)
Expand Down Expand Up @@ -72,10 +77,19 @@ class Specie(object):
"""

def __init__(self, symbol=""):
def __init__(self, symbol="", source="cfid"):
"""Initialize with periodic table element."""
self.symbol = symbol
self._data = chem_data
if source == "cfid":
# Cite reference:
# https://doi.org/10.1103/PhysRevMaterials.2.083801
self._data = chem_data
elif source == "magpie":
# Cite reference:
# https://doi.org/10.1038/npjcompumats.2016.28
self._data = chem_data_magpie
else:
raise ValueError("Option not available.", source)

@property
def Z(self):
Expand Down Expand Up @@ -124,8 +138,9 @@ def get_descrp_arr(self):
arr: array value
"""
arr = []

d = chem_data[self.symbol]
# print ('self._data')
d = self._data[self.symbol]
# d = chem_data[self.symbol]
arr = []
for k, v in d.items():
arr.append(v)
Expand Down
7 changes: 7 additions & 0 deletions jarvis/db/figshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ def get_db_info():
"https://www.nature.com/articles/sdata201686",
],
# https://figshare.com/account/projects/100325/articles/14962356
"pdbbind_core": [
"https://ndownloader.figshare.com/files/28874802",
"pdbbind_2015_core.json",
"Obtaining PDBBind dataset 195...",
"https://doi.org/10.1093/bioinformatics/btu626",
],
# https://figshare.com/account/projects/100325/articles/14962356
"pdbbind": [
"https://ndownloader.figshare.com/files/28816368",
"pdbbind_2015.json",
Expand Down
2 changes: 1 addition & 1 deletion jarvis/io/zeopp/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get_porosity(atoms=None, network_cmd="./network", output_file=None):
largest_included_sphere = lines[0].split()[1]
largest_free_sphere = lines[0].split()[2]
largest_included_sphere_along_free_sphere_path = lines[0].split()[3]
os.close(filename)
os.close(new_file)
os.remove(filename)
return (
largest_included_sphere,
Expand Down
4 changes: 2 additions & 2 deletions jarvis/tests/testfiles/ai/test_desc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from jarvis.ai.descriptors.coulomb import coulomb_matrix
from jarvis.ai.descriptors.elemental import get_element_fraction_desc
from jarvis.core.atoms import Atoms
from jarvis.ai.descriptors.cfid import get_chem_only_descriptor
from jarvis.ai.descriptors.cfid import get_chem_only_descriptors


def test_formula_only():
desc, names = get_chem_only_descriptor("Al2O3")
desc, names = get_chem_only_descriptors("Al2O3", source="magpie")


def test_desc():
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name="jarvis-tools",
version="2021.07.10",
version="2021.07.18",
long_description=long_d,
install_requires=[
"numpy>=1.19.5",
Expand Down

0 comments on commit 08624c1

Please sign in to comment.