diff --git a/docs/databases.md b/docs/databases.md index f8b153b0..16bc6ef2 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -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 | @@ -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 | @@ -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 | @@ -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 \ No newline at end of file diff --git a/jarvis/__init__.py b/jarvis/__init__.py index 34d2ef41..bccb3347 100644 --- a/jarvis/__init__.py +++ b/jarvis/__init__.py @@ -1,6 +1,6 @@ """Version number.""" -__version__ = "2024.8.30" +__version__ = "2024.10.10" import os diff --git a/jarvis/analysis/solarefficiency/solar.py b/jarvis/analysis/solarefficiency/solar.py index 2ab64c46..c004eb08 100644 --- a/jarvis/analysis/solarefficiency/solar.py +++ b/jarvis/analysis/solarefficiency/solar.py @@ -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 @@ -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 / ( @@ -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 / ( @@ -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 / ( @@ -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 diff --git a/jarvis/analysis/structure/spacegroup.py b/jarvis/analysis/structure/spacegroup.py index f797071c..dd6b9394 100644 --- a/jarvis/analysis/structure/spacegroup.py +++ b/jarvis/analysis/structure/spacegroup.py @@ -12,7 +12,7 @@ try: import spglib -except Exception as exp: +except Exception: # print(exp) pass # from numpy import gcd diff --git a/jarvis/core/atoms.py b/jarvis/core/atoms.py index a31a1e38..d12ebe4b 100644 --- a/jarvis/core/atoms.py +++ b/jarvis/core/atoms.py @@ -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, @@ -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 @@ -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 @@ -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 " diff --git a/jarvis/core/utils.py b/jarvis/core/utils.py index 7fde5013..7588fb79 100644 --- a/jarvis/core/utils.py +++ b/jarvis/core/utils.py @@ -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 @@ -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=1.20.1",