|
1 | 1 | from __future__ import annotations
|
2 | 2 |
|
3 | 3 | import json
|
| 4 | +import numpy as np |
4 | 5 | from collections import defaultdict
|
5 | 6 |
|
6 | 7 | from monty.json import MontyDecoder
|
@@ -134,3 +135,27 @@ def get_forceconstants_from_material_id(self, material_id: str):
|
134 | 135 | raise MPRestError("No object found")
|
135 | 136 |
|
136 | 137 | 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