Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #328

Merged
merged 14 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions docs/databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [FigShare](https://figshare.com/authors/Kamal_Choudhary/4445539) based databases

[![Open in Colab]](https://colab.research.google.com/github/knc6/jarvis-tools-notebooks/blob/master/jarvis-tools-notebooks/Analyzing_data_in_the_JARVIS_DFT_dataset.ipynb)
[![Open in SLMat]](https://deepmaterials.github.io/slmat/lab?fromURL=https://raw.githubusercontent.com/deepmaterials/slmat/main/content/Database_analysis.ipynb)


| Database name | Number of data-points | Description |
|-------------------|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------|
| `dft_3d` | 75993 | Various 3D materials properties in JARVIS-DFT database computed with OptB88vdW and TBmBJ methods |
Expand All @@ -25,8 +29,8 @@
| `mp_3d_2020` | 127k | CFID descriptors for materials project |
| `mp_3d` | 84k | CFID descriptors for 84k materials project |
| `megnet2` | 133k | 133k materials and their formation energy in MP |
| `m3gnet_mpf` | 168k | 168k structures and their energy, forces and stresses in MP |
| `m3gnet_mpf_1.5mil` | 1.5 million | 1.5 million structures and their energy, forces and stresses in MP |
| `m3gnet_mpf` | 168k | 168k structures and their energy, forces and stresses in MP |
| `m3gnet_mpf_1.5mil` | 1.5 million | 1.5 million structures and their energy, forces and stresses in MP |
| `twod_matpd` | 6351 | Formation energy and bandgaps of 2D materials properties in 2DMatPedia database |
| `c2db` | 3514 | Various properties in C2DB database |
| `polymer_genome` | 1073 | Electronic bandgap and diecltric constants of crystall ine polymer in polymer genome database |
Expand All @@ -36,6 +40,12 @@
| `oqmd_3d_no_cfid` | 817636 | Formation energies and bandgaps of 3D materials from OQMD database |
| `oqmd_3d` | 460k | CFID descriptors for 460k materials in OQMD |
| `omdb` | 12500 | Bandgaps for organic polymers in OMDB database |
| `alex_pbe_hull` | 116k | Alexandria DB convex hull stable materials with PBE functional |
| `alex_pbe_3d_all` | 5 million | Alexandria DB all 3D materials with PBE |
| `alex_pbe_2d_all` | 200k | Alexandria DB all 2D materials with PBE |
| `alex_pbe_1d_all` | 100k | Alexandria DB all 1D materials with PBE |
| `alex_scan_3d_all` | 500k | Alexandria DB all 3D materials with SCAN |
| `alex_pbesol_3d_all` | 500k | Alexandria DB all 3D materials with PBEsol |
| `hopv` | 4855 | Various properties of molecules in HOPV15 dataset |
| `pdbbind` | 11189 | Bio-molecular complexes database from PDBBind v2015 |
| `pdbbind_core` | 195 | Bio-molecular complexes database from PDBBind core |
Expand Down Expand Up @@ -88,4 +98,6 @@ df = pd.DataFrame(d)
print(df)
```

[Open in SLMat]: https://img.shields.io/badge/Open-SLMat-blue

[Open in Colab]: https://colab.research.google.com/assets/colab-badge.svg
2 changes: 1 addition & 1 deletion jarvis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Version number."""

__version__ = "2024.8.30"
__version__ = "2024.10.10"

import os

Expand Down
17 changes: 12 additions & 5 deletions jarvis/analysis/solarefficiency/solar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
Please find more detailsin:
https://pubs.acs.org/doi/abs/10.1021/acs.chemmater.9b02166
"""

import numpy as np
import os
from scipy.interpolate import interp1d
from numpy import interp
import scipy.constants as constants
from scipy.integrate import simps

try:
from scipy.integrate import simps
except Exception:
from scipy.integrate import simpson as simps

pass
import matplotlib.pyplot as plt


Expand Down Expand Up @@ -69,7 +76,7 @@ def calculate_SQ(
# units of W/(m**3), different than solar_spectra_irradiance!!! (This
# is intentional, it is for convenience)
blackbody_irradiance = (
2.0 * h * c ** 2 / (solar_spectra_wavelength_meters ** 5)
2.0 * h * c**2 / (solar_spectra_wavelength_meters**5)
) * (
1.0
/ (
Expand Down Expand Up @@ -109,7 +116,7 @@ def calculate_SQ(
)

bandgap_blackbody = (
(2.0 * h * c ** 2 / (bandgap_wavelength ** 5))
(2.0 * h * c**2 / (bandgap_wavelength**5))
* (
1.0
/ (
Expand Down Expand Up @@ -273,7 +280,7 @@ def slme(
# units of W/(m**3), different than solar_spectra_irradiance!!! (This
# is intentional, it is for convenience)
blackbody_irradiance = (
2.0 * h * c ** 2 / (solar_spectra_wavelength_meters ** 5)
2.0 * h * c**2 / (solar_spectra_wavelength_meters**5)
) * (
1.0
/ (
Expand All @@ -298,7 +305,7 @@ def slme(
# units of nm
material_wavelength_for_absorbance_data = (
(c * h_e) / (material_energy_for_absorbance_data + 0.00000001)
) * 10 ** 9
) * 10**9

# absorbance interpolation onto each solar spectrum wavelength

Expand Down
2 changes: 1 addition & 1 deletion jarvis/analysis/structure/spacegroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

try:
import spglib
except Exception as exp:
except Exception:
# print(exp)
pass
# from numpy import gcd
Expand Down
14 changes: 12 additions & 2 deletions jarvis/core/atoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,9 @@ def hook(model, input, output):

from alignn.graphs import Graph
from alignn.pretrained import get_figshare_model
import torch

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

g, lg = Graph.atom_dgl_multigraph(
self,
Expand All @@ -1452,6 +1455,8 @@ def hook(model, input, output):
model = get_figshare_model(
model_name="jv_formation_energy_peratom_alignn"
)
g.to(device)
lg.to(device)
h = get_val(model, g, lg)
return h

Expand Down Expand Up @@ -1571,11 +1576,15 @@ def describe(
cutoff=4,
take_n_bonds=2,
include_spg=True,
include_mineral_name=False,
):
"""Describe for NLP applications."""
from jarvis.analysis.diffraction.xrd import XRD

min_name = self.get_minaral_name()
if include_mineral_name:
min_name = self.get_minaral_name()
else:
min_name = "na"
if include_spg:
from jarvis.analysis.structure.spacegroup import Spacegroup3D

Expand Down Expand Up @@ -1713,7 +1722,8 @@ def describe(
+ struct_info["wyckoff"]
+ "."
)
if min_name is not None:
if min_name != "na":
# if min_name is not None:
line3 = (
chem_info["atomic_formula"]
+ " is "
Expand Down
48 changes: 48 additions & 0 deletions jarvis/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from collections import OrderedDict
from collections import defaultdict
from scipy import sparse
from scipy.sparse.linalg import spsolve
import random
import numpy as np
import math
Expand Down Expand Up @@ -334,6 +336,52 @@ def cos_formula(a, b, c):
return np.arccos(res)


def baseline_als(y, lam, p, niter=10):
"""
Adaptive Least Squares fitting for baseline correction

Parameters:
y: array_like
Input signal
lam: float
Lambda (smoothness)
p: float
Asymmetry
niter: int, optional
Number of iterations

Returns:
array_like
The estimated baseline
"""
L = len(y)
D = sparse.diags([1, -2, 1], [0, -1, -2], shape=(L, L - 2))
w = np.ones(L)
for i in range(niter):
W = sparse.spdiags(w, 0, L, L)
Z = W + lam * D.dot(D.transpose())
z = spsolve(Z, w * y)
w = p * (y > z) + (1 - p) * (y < z)
return z


def recast_array(
x_original=[], y_original=[], x_new=np.arange(0, 90, 1), tol=0.1
):
x_original = np.array(x_original)
# Initialize the new y array with NaNs or a default value
y_new = np.full_like(x_new, 0, dtype=np.float64)

# Fill the corresponding bins
for x_val, y_val in zip(x_original, y_original):
closest_index = np.abs(
x_new - x_val
).argmin() # Find the closest x_new index
y_new[closest_index] = y_val
# y_new[y_new<tol]=0
return x_new, y_new


# def is_xml_valid(xsd="jarvisdft.xsd", xml="JVASP-1002.xml"):
# """Check if XML is valid."""
# xml_file = etree.parse(xml)
Expand Down
43 changes: 43 additions & 0 deletions jarvis/db/figshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,48 @@ def get_db_info():
"Obtaining CCCBDB dataset 1333...",
"https://cccbdb.nist.gov/",
],
# https://doi.org/10.6084/m9.figshare.27174897
"alex_pbe_hull": [
"https://figshare.com/ndownloader/files/49622718",
"alexandria_convex_hull_pbe_2023.12.29_jarvis_tools.json",
"Obtaining Alexandria_DB PBE on hull 116k...",
"https://alexandria.icams.rub.de/",
],
# https://doi.org/10.6084/m9.figshare.27174897
"alex_pbe_3d_all": [
"https://figshare.com/ndownloader/files/49622946",
"alexandria_pbe_3d_2024.10.1_jarvis_tools.json",
"Obtaining Alexandria_DB PBE 3D all 5 million, large file...",
"https://alexandria.icams.rub.de/",
],
# https://doi.org/10.6084/m9.figshare.27174897
"alex_pbe_2d_all": [
"https://figshare.com/ndownloader/files/49622988",
"alexandria_pbe_2d_2024.10.1_jarvis_tools.json",
"Obtaining Alexandria_DB PBE 2D all 200k...",
"https://alexandria.icams.rub.de/",
],
# https://doi.org/10.6084/m9.figshare.27174897
"alex_pbe_1d_all": [
"https://figshare.com/ndownloader/files/49622991",
"alexandria_pbe_1d_2024.10.1_jarvis_tools.json",
"Obtaining Alexandria_DB PBE 1D all 100k...",
"https://alexandria.icams.rub.de/",
],
# https://doi.org/10.6084/m9.figshare.27174897
"alex_scan_3d_all": [
"https://figshare.com/ndownloader/files/49623090",
"alexandria_scan_3d_2024.10.1_jarvis_tools.json",
"Obtaining Alexandria_DB SCAN 3D all 500k...",
"https://alexandria.icams.rub.de/",
],
# https://doi.org/10.6084/m9.figshare.27174897
"alex_pbesol_3d_all": [
"https://figshare.com/ndownloader/files/49623096",
"alexandria_ps_3d_2024.10.1_jarvis_tools.json",
"Obtaining Alexandria_DB PBEsol 3D all 500k...",
"https://alexandria.icams.rub.de/",
],
# https://doi.org/10.6084/m9.figshare.13154159
"raw_files": [
"https://ndownloader.figshare.com/files/25295732",
Expand Down Expand Up @@ -671,6 +713,7 @@ def get_wann_phonon(jid="JVASP-1002", factor=15.633302):
# Requires phonopy
from jarvis.io.phonopy.outputs import get_phonon_tb
from jarvis.io.vasp.outputs import Vasprun
from jarvis.io.wannier.outputs import WannierHam

fls = data("raw_files")

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

setup(
name="jarvis-tools",
version="2024.8.30",
version="2024.10.10",
long_description=long_d,
install_requires=[
"numpy>=1.20.1",
Expand Down
Loading