Skip to content

Commit

Permalink
Summary and synthesis updates (#333)
Browse files Browse the repository at this point in the history
* Bump emmet core in reqs

* Rename search to summary

* Bump emmet core again

* Bump emmet in reqs

* Fix dielectric, elasticity and electrode

* Rename to summary, and synthesis test fixes
  • Loading branch information
munrojm committed Jul 16, 2021
1 parent 329740e commit 2e0ed1f
Show file tree
Hide file tree
Showing 21 changed files with 178 additions and 101 deletions.
15 changes: 7 additions & 8 deletions app.py
Expand Up @@ -42,7 +42,7 @@
)
molecules_store_json = os.environ.get("MOLECULES_STORE", "molecules_store.json")
oxi_states_store_json = os.environ.get("OXI_STATES_STORE", "oxi_states_store.json")
search_store_json = os.environ.get("SEARCH_STORE", "search_store.json")
summary_store_json = os.environ.get("SUMMARY_STORE", "summary_store.json")

es_store_json = os.environ.get("ES_STORE", "es_store.json")

Expand Down Expand Up @@ -222,11 +222,11 @@
collection_name="oxi_states",
)

search_store = MongoURIStore(
summary_store = MongoURIStore(
uri=f"mongodb+srv://{db_uri}",
database="mp_core",
key="material_id",
collection_name="search",
collection_name="summary",
)

es_store = MongoURIStore(
Expand Down Expand Up @@ -320,7 +320,7 @@
insertion_electrodes_store = loadfn(insertion_electrodes_store_json)
molecules_store = loadfn(molecules_store_json)
oxi_states_store = loadfn(oxi_states_store_json)
search_store = loadfn(search_store_json)
ssummary_store = loadfn(summary_store_json)

es_store = loadfn(es_store_json)

Expand Down Expand Up @@ -394,7 +394,7 @@
# Phonon
from mp_api.routes.phonon.resources import phonon_bsdos_resource

resources.update({"phonon": [phonon_bsdos_resource(phonon_bs_store),]})
resources.update({"phonon": [phonon_bsdos_resource(phonon_bs_store)]})

# EOS
from mp_api.routes.eos.resources import eos_resource
Expand Down Expand Up @@ -485,15 +485,14 @@
resources.update({"charge_density": [charge_density_resource(s3_chgcar)]})

# Search
from mp_api.routes.search.resources import search_resource, search_stats_resource
from mp_api.routes.summary.resources import summary_resource, summary_stats_resource

resources.update(
{"search": [search_stats_resource(search_store), search_resource(search_store)]}
{"search": [summary_stats_resource(summary_store), summary_resource(summary_store)]}
)

# Electronic Structure
from mp_api.routes.electronic_structure.resources import (
dos_obj_resource,
es_resource,
bs_resource,
bs_obj_resource,
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Expand Up @@ -4,5 +4,5 @@ typing-extensions==3.10.0.0
maggma==0.30.2
requests==2.25.1
monty==2021.7.8
emmet-core==0.5.0
emmet-core==0.8.2
ratelimit==2.2.1
25 changes: 18 additions & 7 deletions src/mp_api/matproj.py
Expand Up @@ -461,6 +461,8 @@ def query(
total_magnetization_normalized_formula_units: Optional[
Tuple[float, float]
] = None,
num_magnetic_sites: Optional[Tuple[int, int]] = None,
num_unique_magnetic_sites: Optional[Tuple[int, int]] = None,
k_voigt: Optional[Tuple[float, float]] = None,
k_reuss: Optional[Tuple[float, float]] = None,
k_vrh: Optional[Tuple[float, float]] = None,
Expand All @@ -471,13 +473,14 @@ def query(
poisson_ratio: Optional[Tuple[float, float]] = None,
e_total: Optional[Tuple[float, float]] = None,
e_ionic: Optional[Tuple[float, float]] = None,
e_static: Optional[Tuple[float, float]] = None,
e_electronic: Optional[Tuple[float, float]] = None,
n: Optional[Tuple[float, float]] = None,
piezoelectric_modulus: Optional[Tuple[float, float]] = None,
weighted_surface_energy: Optional[Tuple[float, float]] = None,
weighted_work_function: Optional[Tuple[float, float]] = None,
surface_anisotropy: Optional[Tuple[float, float]] = None,
surface_energy_anisotropy: Optional[Tuple[float, float]] = None,
shape_factor: Optional[Tuple[float, float]] = None,
has_reconstructed: Optional[bool] = None,
has_props: Optional[List[str]] = None,
theoretical: Optional[bool] = None,
sort_field: Optional[str] = None,
Expand Down Expand Up @@ -516,6 +519,9 @@ def query(
normalized by volume to consider.
total_magnetization_normalized_formula_units (Tuple[float,float]): Minimum and maximum total magnetization
values normalized by formula units to consider.
num_magnetic_sites (Tuple[int,int]): Minimum and maximum number of magnetic sites to consider.
num_unique_magnetic_sites (Tuple[int,int]): Minimum and maximum number of unique magnetic sites
to consider.
k_voigt (Tuple[float,float]): Minimum and maximum value in GPa to consider for
the Voigt average of the bulk modulus.
k_reuss (Tuple[float,float]): Minimum and maximum value in GPa to consider for
Expand All @@ -534,7 +540,7 @@ def query(
Poisson's ratio.
e_total (Tuple[float,float]): Minimum and maximum total dielectric constant to consider.
e_ionic (Tuple[float,float]): Minimum and maximum ionic dielectric constant to consider.
e_static (Tuple[float,float]): Minimum and maximum electronic dielectric constant to consider.
e_electronic (Tuple[float,float]): Minimum and maximum electronic dielectric constant to consider.
n (Tuple[float,float]): Minimum and maximum refractive index to consider.
piezoelectric_modulus (Tuple[float,float]): Minimum and maximum piezoelectric modulus to consider.
weighted_surface_energy (Tuple[float,float]): Minimum and maximum weighted surface energy in J/m² to
Expand All @@ -543,6 +549,7 @@ def query(
surface_energy_anisotropy (Tuple[float,float]): Minimum and maximum surface energy anisotropy values to
consider.
shape_factor (Tuple[float,float]): Minimum and maximum shape factor values to consider.
has_reconstructed (bool): Whether the entry has any reconstructed surfaces.
has_props: (List[str]): The calculated properties available for the material.
theoretical: (bool): Whether the material is theoretical.
sort_field (str): Field used to sort results.
Expand All @@ -554,9 +561,10 @@ def query(
Default is material_id if all_fields is False.
Returns:
([SearchDoc]) List of SearchDoc documents
([SummaryDoc]) List of SummaryDoc documents
"""
return self.search.search_docs( # type: ignore

return self.summary.search_summary_docs( # type: ignore
material_ids=material_ids,
chemsys_formula=chemsys_formula,
nsites=nsites,
Expand All @@ -580,6 +588,8 @@ def query(
total_magnetization=total_magnetization,
total_magnetization_normalized_vol=total_magnetization_normalized_vol,
total_magnetization_normalized_formula_units=total_magnetization_normalized_formula_units,
num_magnetic_sites=num_magnetic_sites,
num_unique_magnetic_sites=num_unique_magnetic_sites,
k_voigt=k_voigt,
k_reuss=k_reuss,
k_vrh=k_vrh,
Expand All @@ -590,13 +600,14 @@ def query(
poisson_ratio=poisson_ratio,
e_total=e_total,
e_ionic=e_ionic,
e_static=e_static,
e_electronic=e_electronic,
n=n,
piezoelectric_modulus=piezoelectric_modulus,
weighted_surface_energy=weighted_surface_energy,
weighted_work_function=weighted_work_function,
surface_anisotropy=surface_anisotropy,
surface_energy_anisotropy=surface_energy_anisotropy,
shape_factor=shape_factor,
has_reconstructed=has_reconstructed,
has_props=has_props,
theoretical=theoretical,
sort_field=sort_field,
Expand Down
2 changes: 1 addition & 1 deletion src/mp_api/routes/__init__.py
Expand Up @@ -15,7 +15,7 @@
from mp_api.routes.dois.client import DOIRester
from mp_api.routes.piezo.client import PiezoRester
from mp_api.routes.magnetism.client import MagnetismRester
from mp_api.routes.search.client import SearchRester
from mp_api.routes.summary.client import SummaryRester
from mp_api.routes.robocrys.client import RobocrysRester
from mp_api.routes.molecules.client import MoleculesRester
from mp_api.routes.synthesis.client import SynthesisRester
Expand Down
25 changes: 19 additions & 6 deletions src/mp_api/routes/dielectric/client.py
Expand Up @@ -15,7 +15,7 @@ def search_dielectric_docs(
self,
e_total: Optional[Tuple[float, float]] = None,
e_ionic: Optional[Tuple[float, float]] = None,
e_static: Optional[Tuple[float, float]] = None,
e_electronic: Optional[Tuple[float, float]] = None,
n: Optional[Tuple[float, float]] = None,
sort_field: Optional[str] = None,
ascending: Optional[bool] = None,
Expand All @@ -30,7 +30,7 @@ def search_dielectric_docs(
Arguments:
e_total (Tuple[float,float]): Minimum and maximum total dielectric constant to consider.
e_ionic (Tuple[float,float]): Minimum and maximum ionic dielectric constant to consider.
e_static (Tuple[float,float]): Minimum and maximum electronic dielectric constant to consider.
e_electronic (Tuple[float,float]): Minimum and maximum electronic dielectric constant to consider.
n (Tuple[float,float]): Minimum and maximum refractive index to consider.
sort_field (str): Field used to sort results.
ascending (bool): Whether sorting should be in ascending order.
Expand All @@ -52,8 +52,13 @@ def search_dielectric_docs(
if e_ionic:
query_params.update({"e_ionic_min": e_ionic[0], "e_ionic_max": e_ionic[1]})

if e_static:
query_params.update({"e_static_min": e_static[0], "e_static_max": e_static[1]})
if e_electronic:
query_params.update(
{
"e_electronic_min": e_electronic[0],
"e_electronic_max": e_electronic[1],
}
)

if n:
query_params.update({"n_min": n[0], "n_max": n[1]})
Expand All @@ -64,8 +69,16 @@ def search_dielectric_docs(
if ascending is not None:
query_params.update({"ascending": ascending})

query_params = {entry: query_params[entry] for entry in query_params if query_params[entry] is not None}
query_params = {
entry: query_params[entry]
for entry in query_params
if query_params[entry] is not None
}

return super().search(
num_chunks=num_chunks, chunk_size=chunk_size, all_fields=all_fields, fields=fields, **query_params
num_chunks=num_chunks,
chunk_size=chunk_size,
all_fields=all_fields,
fields=fields,
**query_params
)
12 changes: 6 additions & 6 deletions src/mp_api/routes/dielectric/query_operators.py
Expand Up @@ -25,11 +25,11 @@ def query(
e_ionic_min: Optional[float] = Query(
None, description="Minimum value for the ionic dielectric constant.",
),
e_static_max: Optional[float] = Query(
None, description="Maximum value for the static dielectric constant.",
e_electronic_max: Optional[float] = Query(
None, description="Maximum value for the electronic dielectric constant.",
),
e_static_min: Optional[float] = Query(
None, description="Minimum value for the static dielectric constant.",
e_electronic_min: Optional[float] = Query(
None, description="Minimum value for the electronic dielectric constant.",
),
n_max: Optional[float] = Query(
None, description="Maximum value for the refractive index.",
Expand All @@ -44,7 +44,7 @@ def query(
d = {
"dielectric.e_total": [e_total_min, e_total_max],
"dielectric.e_ionic": [e_ionic_min, e_ionic_max],
"dielectric.e_static": [e_static_min, e_static_max],
"dielectric.e_electronic": [e_electronic_min, e_electronic_max],
"dielectric.n": [n_min, n_max],
}

Expand All @@ -61,7 +61,7 @@ def ensure_indexes(self): # pragma: no cover
keys = [
"dielectric.e_total",
"dielectric.e_ionic",
"dielectric.e_static",
"dielectric.e_electronic",
"dielectric.n",
]
return [(key, False) for key in keys]
12 changes: 4 additions & 8 deletions src/mp_api/routes/electrodes/client.py
Expand Up @@ -15,10 +15,8 @@ class ElectrodeRester(BaseRester):
def search_electrode_docs( # pragma: ignore
self,
working_ion: Optional[Element] = None,
delta_volume: Optional[Tuple[float, float]] = None,
max_delta_volume: Optional[Tuple[float, float]] = None,
average_voltage: Optional[Tuple[float, float]] = None,
max_voltage: Optional[Tuple[float, float]] = None,
min_voltage: Optional[Tuple[float, float]] = None,
capacity_grav: Optional[Tuple[float, float]] = None,
capacity_vol: Optional[Tuple[float, float]] = None,
energy_grav: Optional[Tuple[float, float]] = None,
Expand All @@ -27,7 +25,7 @@ def search_electrode_docs( # pragma: ignore
fracA_discharge: Optional[Tuple[float, float]] = None,
stability_charge: Optional[Tuple[float, float]] = None,
stability_discharge: Optional[Tuple[float, float]] = None,
num_steps: Optional[Tuple[float, float]] = None,
num_steps: Optional[Tuple[int, int]] = None,
max_voltage_step: Optional[Tuple[float, float]] = None,
sort_field: Optional[str] = None,
ascending: Optional[bool] = None,
Expand All @@ -41,13 +39,11 @@ def search_electrode_docs( # pragma: ignore
Arguments:
working_ion (Element): Element of the working ion.
delta_volume (Tuple[float,float]): Minimum and maximum value of the max volume change in percent for a
max_delta_volume (Tuple[float,float]): Minimum and maximum value of the max volume change in percent for a
particular voltage step.
average_voltage (Tuple[float,float]): Minimum and maximum value of the average voltage for a particular
voltage step in V.
max_voltage (Tuple[float,float]): Minimum and maximum value of the maximum voltage for a particular
voltage step in V.
min_voltage (Tuple[float,float]): Minimum and maximum value of the minimum voltage for a particular
max_voltage_step (Tuple[float,float]): Minimum and maximum value of the maximum voltage for a particular
voltage step in V.
capacity_grav (Tuple[float,float]): Minimum and maximum value of the gravimetric capacity in maH/g.
capacity_vol (Tuple[float,float]): Minimum and maximum value of the volumetric capacity in maH/cc.
Expand Down
File renamed without changes.

0 comments on commit 2e0ed1f

Please sign in to comment.