Skip to content

Commit 99dea3e

Browse files
committed
phonon compute thermo quantities fct
1 parent 307c43b commit 99dea3e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

mp_api/client/routes/materials/phonon.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import json
4+
import numpy as np
45
from collections import defaultdict
56

67
from monty.json import MontyDecoder
@@ -134,3 +135,27 @@ def get_forceconstants_from_material_id(self, material_id: str):
134135
raise MPRestError("No object found")
135136

136137
return result[0]
138+
139+
def compute_thermo_quantities(self, material_id: str, phonon_method: str):
140+
"""Compute thermodynamical quantities for given material ID and phonon_method.
141+
142+
Arguments:
143+
material_id (str): Material ID to calculate quantities for
144+
phonon_method (str): phonon method, i.e. pheasy or dfpt
145+
146+
Returns:
147+
quantities (dict): thermodynamical quantities
148+
"""
149+
use_document_model = self.use_document_model
150+
self.use_document_model = False
151+
docs = self.search(material_ids=material_id, phonon_method=phonon_method)
152+
if not docs or not docs[0]:
153+
raise MPRestError("No phonon document found")
154+
155+
self.use_document_model = True
156+
docs[0]["phonon_dos"] = self.get_dos_from_material_id(
157+
material_id, phonon_method
158+
)
159+
doc = PhononBSDOSDoc(**docs[0])
160+
self.use_document_model = use_document_model
161+
return doc.compute_thermo_quantities(np.linspace(0, 800, 100))

0 commit comments

Comments
 (0)