Skip to content
This repository was archived by the owner on Jul 2, 2025. It is now read-only.

Commit 3e01c35

Browse files
authored
Develop (#328)
* Fix repo. * Update databases.md * Update databases.md * Update databases.md * Version update. * Update utils.py * Update utils.py * Update solar.py * Add model bug fix. * Lint fix. * Add Alexandria DB. * Update databases.md * Add Alexandria DB.
1 parent 7f2f2bf commit 3e01c35

File tree

8 files changed

+132
-12
lines changed

8 files changed

+132
-12
lines changed

docs/databases.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

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

5+
[![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)
6+
[![Open in SLMat]](https://deepmaterials.github.io/slmat/lab?fromURL=https://raw.githubusercontent.com/deepmaterials/slmat/main/content/Database_analysis.ipynb)
7+
8+
59
| Database name | Number of data-points | Description |
610
|-------------------|-----------------------|---------------------------------------------------------------------------------------------------------------------------------------|
711
| `dft_3d` | 75993 | Various 3D materials properties in JARVIS-DFT database computed with OptB88vdW and TBmBJ methods |
@@ -25,8 +29,8 @@
2529
| `mp_3d_2020` | 127k | CFID descriptors for materials project |
2630
| `mp_3d` | 84k | CFID descriptors for 84k materials project |
2731
| `megnet2` | 133k | 133k materials and their formation energy in MP |
28-
| `m3gnet_mpf` | 168k | 168k structures and their energy, forces and stresses in MP |
29-
| `m3gnet_mpf_1.5mil` | 1.5 million | 1.5 million structures and their energy, forces and stresses in MP |
32+
| `m3gnet_mpf` | 168k | 168k structures and their energy, forces and stresses in MP |
33+
| `m3gnet_mpf_1.5mil` | 1.5 million | 1.5 million structures and their energy, forces and stresses in MP |
3034
| `twod_matpd` | 6351 | Formation energy and bandgaps of 2D materials properties in 2DMatPedia database |
3135
| `c2db` | 3514 | Various properties in C2DB database |
3236
| `polymer_genome` | 1073 | Electronic bandgap and diecltric constants of crystall ine polymer in polymer genome database |
@@ -36,6 +40,12 @@
3640
| `oqmd_3d_no_cfid` | 817636 | Formation energies and bandgaps of 3D materials from OQMD database |
3741
| `oqmd_3d` | 460k | CFID descriptors for 460k materials in OQMD |
3842
| `omdb` | 12500 | Bandgaps for organic polymers in OMDB database |
43+
| `alex_pbe_hull` | 116k | Alexandria DB convex hull stable materials with PBE functional |
44+
| `alex_pbe_3d_all` | 5 million | Alexandria DB all 3D materials with PBE |
45+
| `alex_pbe_2d_all` | 200k | Alexandria DB all 2D materials with PBE |
46+
| `alex_pbe_1d_all` | 100k | Alexandria DB all 1D materials with PBE |
47+
| `alex_scan_3d_all` | 500k | Alexandria DB all 3D materials with SCAN |
48+
| `alex_pbesol_3d_all` | 500k | Alexandria DB all 3D materials with PBEsol |
3949
| `hopv` | 4855 | Various properties of molecules in HOPV15 dataset |
4050
| `pdbbind` | 11189 | Bio-molecular complexes database from PDBBind v2015 |
4151
| `pdbbind_core` | 195 | Bio-molecular complexes database from PDBBind core |
@@ -88,4 +98,6 @@ df = pd.DataFrame(d)
8898
print(df)
8999
```
90100

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

103+
[Open in Colab]: https://colab.research.google.com/assets/colab-badge.svg

jarvis/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Version number."""
22

3-
__version__ = "2024.8.30"
3+
__version__ = "2024.10.10"
44

55
import os
66

jarvis/analysis/solarefficiency/solar.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@
44
Please find more detailsin:
55
https://pubs.acs.org/doi/abs/10.1021/acs.chemmater.9b02166
66
"""
7+
78
import numpy as np
89
import os
910
from scipy.interpolate import interp1d
1011
from numpy import interp
1112
import scipy.constants as constants
12-
from scipy.integrate import simps
13+
14+
try:
15+
from scipy.integrate import simps
16+
except Exception:
17+
from scipy.integrate import simpson as simps
18+
19+
pass
1320
import matplotlib.pyplot as plt
1421

1522

@@ -69,7 +76,7 @@ def calculate_SQ(
6976
# units of W/(m**3), different than solar_spectra_irradiance!!! (This
7077
# is intentional, it is for convenience)
7178
blackbody_irradiance = (
72-
2.0 * h * c ** 2 / (solar_spectra_wavelength_meters ** 5)
79+
2.0 * h * c**2 / (solar_spectra_wavelength_meters**5)
7380
) * (
7481
1.0
7582
/ (
@@ -109,7 +116,7 @@ def calculate_SQ(
109116
)
110117

111118
bandgap_blackbody = (
112-
(2.0 * h * c ** 2 / (bandgap_wavelength ** 5))
119+
(2.0 * h * c**2 / (bandgap_wavelength**5))
113120
* (
114121
1.0
115122
/ (
@@ -273,7 +280,7 @@ def slme(
273280
# units of W/(m**3), different than solar_spectra_irradiance!!! (This
274281
# is intentional, it is for convenience)
275282
blackbody_irradiance = (
276-
2.0 * h * c ** 2 / (solar_spectra_wavelength_meters ** 5)
283+
2.0 * h * c**2 / (solar_spectra_wavelength_meters**5)
277284
) * (
278285
1.0
279286
/ (
@@ -298,7 +305,7 @@ def slme(
298305
# units of nm
299306
material_wavelength_for_absorbance_data = (
300307
(c * h_e) / (material_energy_for_absorbance_data + 0.00000001)
301-
) * 10 ** 9
308+
) * 10**9
302309

303310
# absorbance interpolation onto each solar spectrum wavelength
304311

jarvis/analysis/structure/spacegroup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
try:
1414
import spglib
15-
except Exception as exp:
15+
except Exception:
1616
# print(exp)
1717
pass
1818
# from numpy import gcd

jarvis/core/atoms.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,9 @@ def hook(model, input, output):
14381438

14391439
from alignn.graphs import Graph
14401440
from alignn.pretrained import get_figshare_model
1441+
import torch
1442+
1443+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
14411444

14421445
g, lg = Graph.atom_dgl_multigraph(
14431446
self,
@@ -1452,6 +1455,8 @@ def hook(model, input, output):
14521455
model = get_figshare_model(
14531456
model_name="jv_formation_energy_peratom_alignn"
14541457
)
1458+
g.to(device)
1459+
lg.to(device)
14551460
h = get_val(model, g, lg)
14561461
return h
14571462

@@ -1571,11 +1576,15 @@ def describe(
15711576
cutoff=4,
15721577
take_n_bonds=2,
15731578
include_spg=True,
1579+
include_mineral_name=False,
15741580
):
15751581
"""Describe for NLP applications."""
15761582
from jarvis.analysis.diffraction.xrd import XRD
15771583

1578-
min_name = self.get_minaral_name()
1584+
if include_mineral_name:
1585+
min_name = self.get_minaral_name()
1586+
else:
1587+
min_name = "na"
15791588
if include_spg:
15801589
from jarvis.analysis.structure.spacegroup import Spacegroup3D
15811590

@@ -1713,7 +1722,8 @@ def describe(
17131722
+ struct_info["wyckoff"]
17141723
+ "."
17151724
)
1716-
if min_name is not None:
1725+
if min_name != "na":
1726+
# if min_name is not None:
17171727
line3 = (
17181728
chem_info["atomic_formula"]
17191729
+ " is "

jarvis/core/utils.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
from collections import OrderedDict
44
from collections import defaultdict
5+
from scipy import sparse
6+
from scipy.sparse.linalg import spsolve
57
import random
68
import numpy as np
79
import math
@@ -334,6 +336,52 @@ def cos_formula(a, b, c):
334336
return np.arccos(res)
335337

336338

339+
def baseline_als(y, lam, p, niter=10):
340+
"""
341+
Adaptive Least Squares fitting for baseline correction
342+
343+
Parameters:
344+
y: array_like
345+
Input signal
346+
lam: float
347+
Lambda (smoothness)
348+
p: float
349+
Asymmetry
350+
niter: int, optional
351+
Number of iterations
352+
353+
Returns:
354+
array_like
355+
The estimated baseline
356+
"""
357+
L = len(y)
358+
D = sparse.diags([1, -2, 1], [0, -1, -2], shape=(L, L - 2))
359+
w = np.ones(L)
360+
for i in range(niter):
361+
W = sparse.spdiags(w, 0, L, L)
362+
Z = W + lam * D.dot(D.transpose())
363+
z = spsolve(Z, w * y)
364+
w = p * (y > z) + (1 - p) * (y < z)
365+
return z
366+
367+
368+
def recast_array(
369+
x_original=[], y_original=[], x_new=np.arange(0, 90, 1), tol=0.1
370+
):
371+
x_original = np.array(x_original)
372+
# Initialize the new y array with NaNs or a default value
373+
y_new = np.full_like(x_new, 0, dtype=np.float64)
374+
375+
# Fill the corresponding bins
376+
for x_val, y_val in zip(x_original, y_original):
377+
closest_index = np.abs(
378+
x_new - x_val
379+
).argmin() # Find the closest x_new index
380+
y_new[closest_index] = y_val
381+
# y_new[y_new<tol]=0
382+
return x_new, y_new
383+
384+
337385
# def is_xml_valid(xsd="jarvisdft.xsd", xml="JVASP-1002.xml"):
338386
# """Check if XML is valid."""
339387
# xml_file = etree.parse(xml)

jarvis/db/figshare.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,48 @@ def get_db_info():
457457
"Obtaining CCCBDB dataset 1333...",
458458
"https://cccbdb.nist.gov/",
459459
],
460+
# https://doi.org/10.6084/m9.figshare.27174897
461+
"alex_pbe_hull": [
462+
"https://figshare.com/ndownloader/files/49622718",
463+
"alexandria_convex_hull_pbe_2023.12.29_jarvis_tools.json",
464+
"Obtaining Alexandria_DB PBE on hull 116k...",
465+
"https://alexandria.icams.rub.de/",
466+
],
467+
# https://doi.org/10.6084/m9.figshare.27174897
468+
"alex_pbe_3d_all": [
469+
"https://figshare.com/ndownloader/files/49622946",
470+
"alexandria_pbe_3d_2024.10.1_jarvis_tools.json",
471+
"Obtaining Alexandria_DB PBE 3D all 5 million, large file...",
472+
"https://alexandria.icams.rub.de/",
473+
],
474+
# https://doi.org/10.6084/m9.figshare.27174897
475+
"alex_pbe_2d_all": [
476+
"https://figshare.com/ndownloader/files/49622988",
477+
"alexandria_pbe_2d_2024.10.1_jarvis_tools.json",
478+
"Obtaining Alexandria_DB PBE 2D all 200k...",
479+
"https://alexandria.icams.rub.de/",
480+
],
481+
# https://doi.org/10.6084/m9.figshare.27174897
482+
"alex_pbe_1d_all": [
483+
"https://figshare.com/ndownloader/files/49622991",
484+
"alexandria_pbe_1d_2024.10.1_jarvis_tools.json",
485+
"Obtaining Alexandria_DB PBE 1D all 100k...",
486+
"https://alexandria.icams.rub.de/",
487+
],
488+
# https://doi.org/10.6084/m9.figshare.27174897
489+
"alex_scan_3d_all": [
490+
"https://figshare.com/ndownloader/files/49623090",
491+
"alexandria_scan_3d_2024.10.1_jarvis_tools.json",
492+
"Obtaining Alexandria_DB SCAN 3D all 500k...",
493+
"https://alexandria.icams.rub.de/",
494+
],
495+
# https://doi.org/10.6084/m9.figshare.27174897
496+
"alex_pbesol_3d_all": [
497+
"https://figshare.com/ndownloader/files/49623096",
498+
"alexandria_ps_3d_2024.10.1_jarvis_tools.json",
499+
"Obtaining Alexandria_DB PBEsol 3D all 500k...",
500+
"https://alexandria.icams.rub.de/",
501+
],
460502
# https://doi.org/10.6084/m9.figshare.13154159
461503
"raw_files": [
462504
"https://ndownloader.figshare.com/files/25295732",
@@ -671,6 +713,7 @@ def get_wann_phonon(jid="JVASP-1002", factor=15.633302):
671713
# Requires phonopy
672714
from jarvis.io.phonopy.outputs import get_phonon_tb
673715
from jarvis.io.vasp.outputs import Vasprun
716+
from jarvis.io.wannier.outputs import WannierHam
674717

675718
fls = data("raw_files")
676719

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
setup(
1414
name="jarvis-tools",
15-
version="2024.8.30",
15+
version="2024.10.10",
1616
long_description=long_d,
1717
install_requires=[
1818
"numpy>=1.20.1",

0 commit comments

Comments
 (0)