Skip to content

Commit

Permalink
Update elasticity material id query param
Browse files Browse the repository at this point in the history
  • Loading branch information
munrojm committed Nov 20, 2023
1 parent f380b4e commit d5240c5
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mp_api/client/routes/materials/elasticity.py
Expand Up @@ -2,6 +2,7 @@

import warnings
from collections import defaultdict
from mp_api.client.core.utils import validate_ids

from emmet.core.elasticity import ElasticityDoc

Expand All @@ -25,6 +26,7 @@ def search_elasticity_docs(self, *args, **kwargs): # pragma: no cover

def search(
self,
material_ids: str | list[str] | None = None,
elastic_anisotropy: tuple[float, float] | None = None,
g_voigt: tuple[float, float] | None = None,
g_reuss: tuple[float, float] | None = None,
Expand All @@ -42,6 +44,8 @@ def search(
"""Query elasticity docs using a variety of search criteria.
Arguments:
material_ids (str, List[str]): A single Material ID string or list of strings
(e.g., mp-149, [mp-149, mp-13]).
elastic_anisotropy (Tuple[float,float]): Minimum and maximum value to consider for
the elastic anisotropy.
g_voigt (Tuple[float,float]): Minimum and maximum value in GPa to consider for
Expand Down Expand Up @@ -70,6 +74,12 @@ def search(
"""
query_params = defaultdict(dict) # type: dict

if material_ids:
if isinstance(material_ids, str):
material_ids = [material_ids]

query_params.update({"material_ids": ",".join(validate_ids(material_ids))})

if k_voigt:
query_params.update({"k_voigt_min": k_voigt[0], "k_voigt_max": k_voigt[1]})

Expand Down

0 comments on commit d5240c5

Please sign in to comment.