Skip to content

Commit

Permalink
DGL Graph. (#153)
Browse files Browse the repository at this point in the history
* Update graphs.py

* Uncertainty module added. (#124)

* Uncertainty module added.

* Adding quantile lgbm code.

* Adding quantile lgbm code.

* Adding quantile lgbm code.

* Adding test for quantile lgbm code

* Adding quantile lgbm code.

* Magnetic setup and Uncertainty AI module update. (#125)

* Version change.

* Version change, magmom atoms added, classification models save updates.

* Update and rename LICENSE to LICENSE.rst

* Delete jarvisdft.xsl

* Delete jarvisff.xsl

* Added OQMD, MP, QM9 CFID datasets.

* Added OQMD, MP, QM9 CFID datasets.

* vasp2xml schema update.

* Added OQMD, MP, QM9 CFID datasets and VASP API XML update for phonons. (#130)

* Added OQMD, MP, QM9 CFID datasets.

* Added OQMD, MP, QM9 CFID datasets.

* vasp2xml schema update.

* Update config.yml

* Update config.yml

* Update README.rst

* 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

* XRD DB making bug fix, scattering.json update. (#131)

* 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.

* Develop (#134)

* 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.

* Update README.rst

* Wannier update.

* Version update.

* VASP task update.

* Wannier update (#136)

* 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.

* Wannier update.

* Version update.

* VASP task update.

* Tempfile for downloading zipfiles.

* Pypi fix.

* Pypi fix.

* Updated wannier, vasp2xml, increased tests.

* Update setup.py

* Update action_build.yml

* Speed up test.

* Update DatasetSummary.rst

* Update outputs.py

* Enforce nk1==nk2 in spillage.

* Update test_spillage.py

* Multiple updates.

* Magtest update.

* Version update.

* Increase coverage. (#137)

* 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.

* Wannier update.

* Version update.

* VASP task update.

* Tempfile for downloading zipfiles.

* Pypi fix.

* Pypi fix.

* Updated wannier, vasp2xml, increased tests.

* Update setup.py

* Update action_build.yml

* Speed up test.

* Update DatasetSummary.rst

* Update outputs.py

* Enforce nk1==nk2 in spillage.

* Update test_spillage.py

* Multiple updates.

* Magtest update.

* Version update.

* Update README.rst

* Update README.rst

* Update README.rst

* Update README.rst

* WannierTB Phonons.

* phonopy TB.

* phonopy TB.

* Versionupdate.

* Wannier TB for phonons (#138)

* 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.

* Wannier update.

* Version update.

* VASP task update.

* Tempfile for downloading zipfiles.

* Pypi fix.

* Pypi fix.

* Updated wannier, vasp2xml, increased tests.

* Update setup.py

* Update action_build.yml

* Speed up test.

* Update DatasetSummary.rst

* Update outputs.py

* Enforce nk1==nk2 in spillage.

* Update test_spillage.py

* Multiple updates.

* Magtest update.

* Version update.

* Update README.rst

* Update README.rst

* WannierTB Phonons.

* phonopy TB.

* phonopy TB.

* Versionupdate.

* QAlgo

* Create CODE_OF_CONDUCT.md (#139)

* Update README.rst

* Atoms POSCAR Order update.

* Qiskit tests.

* Lint fix.

* Wien2K extra test, ene file.

* WT.

* WT added.

* Qiskit depedendence.

* Qiskit version.

* Qiskit version.

* Qiskit version.

* Update requirements-ci.txt

* Update requirements-ci.txt

* Update action_build.yml

* Update shell.nix

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Ignore QAlgo tests.

* Make qiskit work.

* Make qiskit work.

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Delete __init__.py

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Pennylane fix attempt.

* Update test_hermsolver.py

* Test ham.

* Test ham.

* Update inputs.py

* Test ham.

* Update action_build.yml

* Update inputs.py

* Create __init__.py

* Test ham.

* Update test_hermsolver.py

* Update test_hermsolver.py

* Test Circuit.

* Update test_hermsolver.py

* Update action_build.yml

* Aer

* Aer .

* Var circuit added.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Fix POSCAR order issue.

* Version change.

* Poscar write fix, CIF reader fix.

* Develop (#141)

* 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.

* Wannier update.

* Version update.

* VASP task update.

* Tempfile for downloading zipfiles.

* Pypi fix.

* Pypi fix.

* Updated wannier, vasp2xml, increased tests.

* Update setup.py

* Update action_build.yml

* Speed up test.

* Update DatasetSummary.rst

* Update outputs.py

* Enforce nk1==nk2 in spillage.

* Update test_spillage.py

* Multiple updates.

* Magtest update.

* Version update.

* Update README.rst

* Update README.rst

* WannierTB Phonons.

* phonopy TB.

* phonopy TB.

* Versionupdate.

* QAlgo

* Atoms POSCAR Order update.

* Qiskit tests.

* Lint fix.

* Wien2K extra test, ene file.

* WT.

* WT added.

* Qiskit depedendence.

* Qiskit version.

* Qiskit version.

* Qiskit version.

* Update requirements-ci.txt

* Update requirements-ci.txt

* Update action_build.yml

* Update shell.nix

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Ignore QAlgo tests.

* Make qiskit work.

* Make qiskit work.

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Delete __init__.py

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Pennylane fix attempt.

* Update test_hermsolver.py

* Test ham.

* Test ham.

* Update inputs.py

* Test ham.

* Update action_build.yml

* Update inputs.py

* Create __init__.py

* Test ham.

* Update test_hermsolver.py

* Update test_hermsolver.py

* Test Circuit.

* Update test_hermsolver.py

* Update action_build.yml

* Aer

* Aer .

* Var circuit added.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Ready for master branch.

* Update shell.nix

* Update __init__.py

* Version change.

* Poscar format fix. (#142)

* Fix POSCAR order issue.

* Version change.

* Poscar write fix, CIF reader fix.

* Develop (#141)

* 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.

* Wannier update.

* Version update.

* VASP task update.

* Tempfile for downloading zipfiles.

* Pypi fix.

* Pypi fix.

* Updated wannier, vasp2xml, increased tests.

* Update setup.py

* Update action_build.yml

* Speed up test.

* Update DatasetSummary.rst

* Update outputs.py

* Enforce nk1==nk2 in spillage.

* Update test_spillage.py

* Multiple updates.

* Magtest update.

* Version update.

* Update README.rst

* Update README.rst

* WannierTB Phonons.

* phonopy TB.

* phonopy TB.

* Versionupdate.

* QAlgo

* Atoms POSCAR Order update.

* Qiskit tests.

* Lint fix.

* Wien2K extra test, ene file.

* WT.

* WT added.

* Qiskit depedendence.

* Qiskit version.

* Qiskit version.

* Qiskit version.

* Update requirements-ci.txt

* Update requirements-ci.txt

* Update action_build.yml

* Update shell.nix

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Ignore QAlgo tests.

* Make qiskit work.

* Make qiskit work.

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Delete __init__.py

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Pennylane fix attempt.

* Update test_hermsolver.py

* Test ham.

* Test ham.

* Update inputs.py

* Test ham.

* Update action_build.yml

* Update inputs.py

* Create __init__.py

* Test ham.

* Update test_hermsolver.py

* Update test_hermsolver.py

* Test Circuit.

* Update test_hermsolver.py

* Update action_build.yml

* Aer

* Aer .

* Var circuit added.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Ready for master branch.

* Update shell.nix

* Update __init__.py

* Minor fix in figshare and spectrum.

* Minor fix in figshare and spectrum.

* Update README.rst

* Lint fix.

* Minor fix in figshare and spectrum. (#143)

* 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.

* Wannier update.

* Version update.

* VASP task update.

* Tempfile for downloading zipfiles.

* Pypi fix.

* Pypi fix.

* Updated wannier, vasp2xml, increased tests.

* Update setup.py

* Update action_build.yml

* Speed up test.

* Update DatasetSummary.rst

* Update outputs.py

* Enforce nk1==nk2 in spillage.

* Update test_spillage.py

* Multiple updates.

* Magtest update.

* Version update.

* Update README.rst

* Update README.rst

* WannierTB Phonons.

* phonopy TB.

* phonopy TB.

* Versionupdate.

* QAlgo

* Atoms POSCAR Order update.

* Qiskit tests.

* Lint fix.

* Wien2K extra test, ene file.

* WT.

* WT added.

* Qiskit depedendence.

* Qiskit version.

* Qiskit version.

* Qiskit version.

* Update requirements-ci.txt

* Update requirements-ci.txt

* Update action_build.yml

* Update shell.nix

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Ignore QAlgo tests.

* Make qiskit work.

* Make qiskit work.

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Delete __init__.py

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Pennylane fix attempt.

* Update test_hermsolver.py

* Test ham.

* Test ham.

* Update inputs.py

* Test ham.

* Update action_build.yml

* Update inputs.py

* Create __init__.py

* Test ham.

* Update test_hermsolver.py

* Update test_hermsolver.py

* Test Circuit.

* Update test_hermsolver.py

* Update action_build.yml

* Aer

* Aer .

* Var circuit added.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Fix POSCAR order issue.

* Version change.

* Poscar write fix, CIF reader fix.

* Develop (#141)

* 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.

* Wannier update.

* Version update.

* VASP task update.

* Tempfile for downloading zipfiles.

* Pypi fix.

* Pypi fix.

* Updated wannier, vasp2xml, increased tests.

* Update setup.py

* Update action_build.yml

* Speed up test.

* Update DatasetSummary.rst

* Update outputs.py

* Enforce nk1==nk2 in spillage.

* Update test_spillage.py

* Multiple updates.

* Magtest update.

* Version update.

* Update README.rst

* Update README.rst

* WannierTB Phonons.

* phonopy TB.

* phonopy TB.

* Versionupdate.

* QAlgo

* Atoms POSCAR Order update.

* Qiskit tests.

* Lint fix.

* Wien2K extra test, ene file.

* WT.

* WT added.

* Qiskit depedendence.

* Qiskit version.

* Qiskit version.

* Qiskit version.

* Update requirements-ci.txt

* Update requirements-ci.txt

* Update action_build.yml

* Update shell.nix

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Ignore QAlgo tests.

* Make qiskit work.

* Make qiskit work.

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Update action_build.yml

* Delete __init__.py

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Qiskit fix attempt.

* Pennylane fix attempt.

* Update test_hermsolver.py

* Test ham.

* Test ham.

* Update inputs.py

* Test ham.

* Update action_build.yml

* Update inputs.py

* Create __init__.py

* Test ham.

* Update test_hermsolver.py

* Update test_hermsolver.py

* Test Circuit.

* Update test_hermsolver.py

* Update action_build.yml

* Aer

* Aer .

* Var circuit added.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Increase test coverage, ASE, Tequila, Qiskit.

* Ready for master branch.

* Update shell.nix

* Update __init__.py

* Version change.

* Minor fix in figshare and spectrum.

* Update README.rst

* Lint fix.

* Minor update.

* Update figshare.py

* Fix build.

* Update README.rst

* docs update.

* Setup requirement change.

* Update version tag. (#145)

* Minor fix in figshare and spectrum.

* Setup requirement change.

* Cleanup graph (#146)

* revert jarvis.core.graph adjacency matrix weights to interatomic distances

* remove jarvis.core.graph.Graph edges with bond length past threshold max_cut

* fix jarvis.core.graph.Graph.adjacency_matrix to support sparse graphs (with no self edges), and update test file to reflect removal of self edges as well

* Update README.rst

* Update README.rst

* develop (#147)

* Update version tag. (#145)

* Minor fix in figshare and spectrum.

* Setup requirement change.

* Cleanup graph (#146)

* revert jarvis.core.graph adjacency matrix weights to interatomic distances

* remove jarvis.core.graph.Graph edges with bond length past threshold max_cut

* fix jarvis.core.graph.Graph.adjacency_matrix to support sparse graphs (with no self edges), and update test file to reflect removal of self edges as well

* Update README.rst

Co-authored-by: Brian DeCost <[email protected]>

* develop (#147)

* Update version tag. (#145)

* Minor fix in figshare and spectrum.

* Setup requirement change.

* Cleanup graph (#146)

* revert jarvis.core.graph adjacency matrix weights to interatomic distances

* remove jarvis.core.graph.Graph edges with bond length past threshold max_cut

* fix jarvis.core.graph.Graph.adjacency_matrix to support sparse graphs (with no self edges), and update test file to reflect removal of self edges as well

* Update README.rst

Co-authored-by: Brian DeCost <[email protected]>

* Travis update.

* Travis update.

* Travis update.

* Travis update.

* Travis update.

* Travis update.

* Travis update.

* Travis update.

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Update requirements-for-ci-only.txt

* Adding Qiskit.

* Adding Qiskit.

* Adding Qiskit.

* Adding Qiskit.

* Version update.

* Version update.

* Adding Qiskit.

* Adding Qiskit.

* Fix travis.

* Fix travis.

* Fix travis.

* Fix travis.

* VASP outputs bug fix.

* Optics module and Dos module of VASP fixed.

* Fixing commit.

* Lint fix.

* Update inputs.py

* Version update.

* README update.

* Graph and dataset update.

* Graph and dataset update.

* Graph and dataset update.

* Graph module update.

* More datasets added.

* Update .travis.yml

* Update .travis.yml

* Exclude tequila tests.

* Exclude tequila tests.

* Extra tests.

* Pytest-cov added.

* Update action_build.yml

* Update action_build.yml

* Covergae update.

* Covergae update.

* StructureDataset test added.

* Graph tests fixed.

* Figshare update.

* STM image links added.

* Update test_figshare.py

* Update test_figshare.py

* Update .travis.yml

* Update .travis.yml

* Cache github action attempt.

* DB update.

* Update action.

* DB update.

* Figshare test update.

* JARVIS-FF DB added.

* Try to increase coverage.

* Polymer genome added.

* Graph update.

* Graph update.

* Graph update.

Co-authored-by: tavazza <[email protected]>
Co-authored-by: Brian DeCost <[email protected]>
  • Loading branch information
3 people authored Mar 14, 2021
1 parent fc8dc35 commit 269d1dc
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 20 deletions.
4 changes: 2 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pennylane>=0.14.1
codecov >=2.1.11
torch >=1.8.0
keras >=2.4.3
tensorflow==2.4.0
tensorflow>=2.4.0
pytest >=6.2.2
pytest-cov >=2.11.1
pytest-xdist>=2.2.1
bokeh>=2.3.0
bokeh>=2.3.0
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.3.11"
__version__ = "2021.3.12"
2 changes: 1 addition & 1 deletion jarvis/core/atoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ def get_all_neighbors(self, r=5, bond_tol=0.15):
for i in indices[within_r]:
if d[i] > bond_tol:
neighbors[i].append([i, j, d[i], image])
return np.array(neighbors)
return np.array(neighbors, dtype="object")

@property
def raw_distance_matrix(self):
Expand Down
81 changes: 67 additions & 14 deletions jarvis/core/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import warnings
from typing import List, Tuple
from jarvis.core.atoms import Atoms
from collections import defaultdict

try:
import torch
Expand Down Expand Up @@ -54,26 +55,54 @@ def __init__(

@staticmethod
def atom_dgl_multigraph(
atoms=None, cutoff=8.0, max_neighbors=12, atom_features="cgcnn"
atoms=None,
cutoff=8.0,
max_neighbors=12,
atom_features="cgcnn",
enforce_undirected=False,
max_attempts=3,
id=None,
):
"""Obtain a DGLGraph for Atoms object."""
all_neighbors = atoms.get_all_neighbors(r=cutoff)
# if a site has too few neighbors, increase the cutoff radius
min_nbrs = min(len(neighborlist) for neighborlist in all_neighbors)
if min_nbrs < max_neighbors:
# print('min_nbrs,max_neighbors=',min_nbrs,max_neighbors)
attempt = 0
while min_nbrs < max_neighbors:
print("extending cutoff radius!", attempt, cutoff, id)
lat = atoms.lattice
r_cut = max(cutoff, lat.a, lat.b, lat.c)
return Graph.atom_dgl_multigraph(
atoms, r_cut, max_neighbors, atom_features
)
attempt += 1
if attempt >= max_attempts:
atoms = atoms.make_supercell([2, 2, 2])
print(
"Making supercell, exceeded,attempts",
max_attempts,
"cutoff",
r_cut,
id,
)
cutoff = r_cut
all_neighbors = atoms.get_all_neighbors(r=cutoff)
min_nbrs = min(len(neighborlist) for neighborlist in all_neighbors)
# return Graph.atom_dgl_multigraph(
# atoms, r_cut, max_neighbors, atom_features
# )

# build up edge list
# NOTE: currently there's no guarantee
# that this creates undirected graphs
# An undirected solution would build the full edge
# list where nodes are
# keyed by (index, image), and ensure
# each edge has a complementary edge
# Currently there's no guarantee that this creates undirected graphs
# An undirected solution would build the full edge list where nodes are
# keyed by (index,image), and ensure each edge has a complementary edge

# indeed,JVASP-59628 is an example of a calculation where this produces
# a graph where one site has no incident edges!

# build an edge dictionary u -> v
# so later we can run through the dictionary
# and remove all pairs of edges
# so what's left is the odd ones out
edges = defaultdict(list)

u, v, r = [], [], []
for site_idx, neighborlist in enumerate(all_neighbors):
Expand All @@ -83,18 +112,37 @@ def atom_dgl_multigraph(

ids = np.array([nbr[1] for nbr in neighborlist])
distances = np.array([nbr[2] for nbr in neighborlist])
c = np.array([nbr[3] for nbr in neighborlist])

# find the distance to the k-th nearest neighbor
max_dist = distances[max_neighbors - 1]

# keep all edges out to the neighbor shell of the k-th neighbor
ids = ids[distances <= max_dist]
c = c[distances <= max_dist]
distances = distances[distances <= max_dist]

u.append([site_idx] * len(ids))
v.append(ids)
r.append(distances)

# keep track of cell-resolved edges
# to enforce undirected graph construction
for dst, cell_id in zip(ids, c):
u_key = f"{site_idx}-(0.0, 0.0, 0.0)"
v_key = f"{dst}-{tuple(cell_id)}"
edge_key = tuple(sorted((u_key, v_key)))
edges[edge_key].append((site_idx, dst))

if enforce_undirected:
# add complementary edges to unpaired edges
for edge_pair in edges.values():
if len(edge_pair) == 1:
src, dst = edge_pair[0]
u.append(dst) # swap the order!
v.append(src)
r.append(atoms.raw_distance_matrix[src, dst])

u = torch.tensor(np.hstack(u))
v = torch.tensor(np.hstack(v))
r = torch.tensor(np.hstack(r)).type(torch.get_default_dtype())
Expand Down Expand Up @@ -334,33 +382,38 @@ def __init__(
self,
structures,
targets,
ids=None,
cutoff=8.0,
maxrows=np.inf,
atom_features="atomic_number",
transform=None,
enforce_undirected=False,
max_neighbors=12,
):
"""Initialize the class."""
self.graphs = []
self.labels = []
self.ids = []

for idx, (structure, target) in enumerate(
tqdm(zip(structures, targets))
for idx, (structure, target, id) in enumerate(
tqdm(zip(structures, targets, ids))
):

if idx >= maxrows:
break

a = Atoms.from_dict(structure)
g = Graph.atom_dgl_multigraph(
a,
atom_features=atom_features,
enforce_undirected=enforce_undirected,
cutoff=cutoff,
max_neighbors=max_neighbors,
id=id,
)

self.graphs.append(g)
self.labels.append(target)
self.ids.append(id)

self.labels = torch.tensor(self.labels).type(torch.get_default_dtype())
self.transform = transform
Expand Down
2 changes: 2 additions & 0 deletions jarvis/db/figshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ def get_request_data(
# f = open(zfile, "wb")
# f.write(r.content)
# f.close()
print("Loading the zipfile...")
data = json.loads(zipfile.ZipFile(path).read(js_tag))
print("Loading completed.")

# with zipfile.ZipFile(zfile, "r") as zipObj:
# # zipObj.extract(path)
Expand Down
4 changes: 3 additions & 1 deletion jarvis/tests/testfiles/core/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ def test_dataset():
d = data("dft_2d")
x = []
y = []
z = []
for i in d[0:100]:
if i["formation_energy_peratom"] != "na":
x.append(i["atoms"])
y.append(i["formation_energy_peratom"])
s = StructureDataset(x, y)
z.append(i["jid"])
s = StructureDataset(x, y, ids=z)


# test_graph()
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.3.11",
version="2021.3.12",
long_description=long_d,
install_requires=[
"numpy>=1.18.5",
Expand Down

0 comments on commit 269d1dc

Please sign in to comment.