diff --git a/jarvis/__init__.py b/jarvis/__init__.py index 55e15284..9b8ece67 100644 --- a/jarvis/__init__.py +++ b/jarvis/__init__.py @@ -1,6 +1,6 @@ """Version number.""" -__version__ = "2024.3.24" +__version__ = "2024.3.30" import os diff --git a/jarvis/db/restapi.py b/jarvis/db/restapi.py index 55b4347f..3f41b8f7 100644 --- a/jarvis/db/restapi.py +++ b/jarvis/db/restapi.py @@ -1,4 +1,5 @@ """Module to access or upload data in JARVIS-API.""" + import requests import pprint import os @@ -9,6 +10,25 @@ import json +def jarvisdft_optimade( + prefix="https://jarvis.nist.gov/optimade/jarvisdft/v1/structures/?filter=", + query="elements HAS ALL C,Si", +): + url = prefix + query + vals = [] + while True: + if url is not None: + # print('url', url) + response = requests.get(url) + data = response.json()["data"] + for i in data: + vals.append(i) + url = response.json()["links"]["next"] + else: + break + return vals + + class Api(object): """Class for handling functions for JARVIS-API.""" diff --git a/jarvis/io/lammps/inputs.py b/jarvis/io/lammps/inputs.py index 3e778087..c29ed9a9 100644 --- a/jarvis/io/lammps/inputs.py +++ b/jarvis/io/lammps/inputs.py @@ -61,10 +61,10 @@ def atoms_to_lammps(self, atoms, origin=(0, 0, 0)): xhi = a + xlo m = atoms.lattice._lat xy = np.dot(m[1], m[0] / a) - yhi = np.sqrt(b ** 2 - xy ** 2) + ylo + yhi = np.sqrt(b**2 - xy**2) + ylo xz = np.dot(m[2], m[0] / a) yz = (np.dot(m[1], m[2]) - xy * xz) / (yhi - ylo) - zhi = np.sqrt(c ** 2 - xz ** 2 - yz ** 2) + zlo + zhi = np.sqrt(c**2 - xz**2 - yz**2) + zlo rot_matrix = np.linalg.solve( [[xhi - xlo, 0, 0], [xy, yhi - ylo, 0], [xz, yz, zhi - zlo]], m ) @@ -94,7 +94,7 @@ def read_data( filename="lammps.data", element_order=[], potential_file="pot.mod", - verbose=True, + verbose=False, has_charges=True, ): """Read Lammps data file.""" @@ -179,7 +179,7 @@ def read_data( y[j] = float((lines[i + j + 2]).split()[it + 2]) z[j] = float((lines[i + j + 2]).split()[it + 3]) coords.append([x[j], y[j], z[j]]) - print(coords[-1]) + # print(coords[-1]) f.close() # print ("info",(typ),'coo',(coords),'latt',lat) typ_sp = [str(i, "utf-8") for i in typ] diff --git a/jarvis/io/lammps/outputs.py b/jarvis/io/lammps/outputs.py index da4a4a86..32c72e1a 100644 --- a/jarvis/io/lammps/outputs.py +++ b/jarvis/io/lammps/outputs.py @@ -1,10 +1,10 @@ """Function to analze LAMMPS output.""" + import numpy as np import glob import os from jarvis.analysis.elastic.tensor import ElasticTensor from jarvis.io.lammps.inputs import LammpsData -from jarvis.io.phonopy.outputs import bandstructure_plot, total_dos from jarvis.core.atoms import Atoms @@ -251,6 +251,8 @@ def parse_material_calculation_folder( with optimization, vacancy, phonon, surface etc. """ + from jarvis.io.phonopy.outputs import bandstructure_plot, total_dos + cwd = os.getcwd() jid_file = os.path.join(path, "JARVISFF-ID") if os.path.exists(jid_file): @@ -375,7 +377,9 @@ def parse_material_calculation_folder( return info -def parse_full_ff_folder(path="Mishin-Ni-Al-2009.eam.alloy_nist",): +def parse_full_ff_folder( + path="Mishin-Ni-Al-2009.eam.alloy_nist", +): """Parse complete FF calculation folder.""" cwd = os.getcwd() os.chdir(path) diff --git a/jarvis/io/qe/inputs.py b/jarvis/io/qe/inputs.py index eeac1cc7..fe0099f5 100644 --- a/jarvis/io/qe/inputs.py +++ b/jarvis/io/qe/inputs.py @@ -41,7 +41,7 @@ def __init__( # Download GBRV PSPs by default if url is None: url = ( - "http://www.physics.rutgers.edu/" + "https://www.physics.rutgers.edu/" "gbrv/all_pbesol_UPF_v1.5.tar.gz" ) print("Please cite for PSPs:") diff --git a/jarvis/tasks/lammps/lammps.py b/jarvis/tasks/lammps/lammps.py index bcf6c122..f5b6890f 100644 --- a/jarvis/tasks/lammps/lammps.py +++ b/jarvis/tasks/lammps/lammps.py @@ -142,11 +142,15 @@ def phonons( self, atoms=None, lammps_cmd="", enforce_c_size=15.0, parameters={} ): """Make Phonon calculation setup.""" - from phonopy import Phonopy - from phonopy.file_IO import ( - # parse_FORCE_CONSTANTS, - write_FORCE_CONSTANTS, - ) + try: + from phonopy import Phonopy + from phonopy.file_IO import ( + # parse_FORCE_CONSTANTS, + write_FORCE_CONSTANTS, + ) + except Exception as exp: + print("Phonopy check", exp) + pass bulk = atoms.phonopy_converter() diff --git a/jarvis/tests/testfiles/db/test_restapi.py b/jarvis/tests/testfiles/db/test_restapi.py new file mode 100644 index 00000000..1df984f6 --- /dev/null +++ b/jarvis/tests/testfiles/db/test_restapi.py @@ -0,0 +1,8 @@ +from jarvis.db.restapi import jarvisdft_optimade + + +def test_optimade(): + x = jarvisdft_optimade() + print(x) + print(len(x)) + assert len(x) > 1 diff --git a/setup.py b/setup.py index 00142423..3775af0e 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ setup( name="jarvis-tools", - version="2024.3.24", + version="2024.3.30", long_description=long_d, install_requires=[ "numpy>=1.20.1", @@ -24,8 +24,8 @@ "toolz>=0.9.0", "xmltodict>=0.11.0", "tqdm>=4.41.1", - "mkdocs-material>=9.0.5", - "markdown>=3.2.1", + # "mkdocs-material>=9.0.5", + # "markdown>=3.2.1", # "absl-py==1.4.0", ], package_data={