|
21 | 21 | task_type,
|
22 | 22 | )
|
23 | 23 | from emmet.core.vasp.calculation import (
|
24 |
| - CalculationBaseModel, |
| 24 | + CalculationInput, |
25 | 25 | Calculation,
|
26 | 26 | PotcarSpec,
|
27 | 27 | RunStatistics,
|
@@ -61,22 +61,13 @@ class Potcar(BaseModel):
|
61 | 61 | )
|
62 | 62 |
|
63 | 63 |
|
64 |
| -class OrigInputs(CalculationBaseModel): |
65 |
| - incar: Optional[Union[Incar, Dict]] = Field( |
66 |
| - None, |
67 |
| - description="Pymatgen object representing the INCAR file.", |
68 |
| - ) |
| 64 | +class OrigInputs(CalculationInput): |
69 | 65 |
|
70 | 66 | poscar: Optional[Poscar] = Field(
|
71 | 67 | None,
|
72 | 68 | description="Pymatgen object representing the POSCAR file.",
|
73 | 69 | )
|
74 | 70 |
|
75 |
| - kpoints: Optional[Kpoints] = Field( |
76 |
| - None, |
77 |
| - description="Pymatgen object representing the KPOINTS file.", |
78 |
| - ) |
79 |
| - |
80 | 71 | potcar: Optional[Union[Potcar, VaspPotcar, List[Any]]] = Field(
|
81 | 72 | None,
|
82 | 73 | description="Pymatgen object representing the POTCAR file.",
|
@@ -182,33 +173,26 @@ def from_vasp_calc_doc(
|
182 | 173 | )
|
183 | 174 |
|
184 | 175 |
|
185 |
| -class InputDoc(BaseModel): |
186 |
| - structure: Optional[Structure] = Field( |
187 |
| - None, |
188 |
| - title="Input Structure", |
189 |
| - description="Output Structure from the VASP calculation.", |
190 |
| - ) |
| 176 | +class InputDoc(CalculationInput): |
| 177 | + """Light wrapper around `CalculationInput` with a few extra fields. |
| 178 | + |
| 179 | + pseudo_potentials (Potcar) : summary of the POTCARs used in the calculation |
| 180 | + xc_override (str) : the exchange-correlation functional used if not |
| 181 | + the one specified by POTCAR |
| 182 | + is_lasph (bool) : how the calculation set LASPH (aspherical corrections) |
| 183 | + magnetic_moments (list of floats) : on-site magnetic moments |
| 184 | + """ |
191 | 185 |
|
192 |
| - parameters: Optional[Dict] = Field( |
193 |
| - None, |
194 |
| - description="Parameters from vasprun for the last calculation in the series", |
195 |
| - ) |
196 | 186 | pseudo_potentials: Optional[Potcar] = Field(
|
197 | 187 | None, description="Summary of the pseudo-potentials used in this calculation"
|
198 | 188 | )
|
199 |
| - potcar_spec: Optional[List[PotcarSpec]] = Field( |
200 |
| - None, description="Title and hash of POTCAR files used in the calculation" |
201 |
| - ) |
| 189 | + |
202 | 190 | xc_override: Optional[str] = Field(
|
203 | 191 | None, description="Exchange-correlation functional used if not the default"
|
204 | 192 | )
|
205 | 193 | is_lasph: Optional[bool] = Field(
|
206 | 194 | None, description="Whether the calculation was run with aspherical corrections"
|
207 | 195 | )
|
208 |
| - is_hubbard: bool = Field( |
209 |
| - default=False, description="Is this a Hubbard +U calculation" |
210 |
| - ) |
211 |
| - hubbards: Optional[dict] = Field(None, description="The hubbard parameters used") |
212 | 196 | magnetic_moments: Optional[List[float]] = Field(
|
213 | 197 | None, description="Magnetic moments for each atom"
|
214 | 198 | )
|
@@ -238,22 +222,18 @@ def from_vasp_calc_doc(cls, calc_doc: Calculation) -> "InputDoc":
|
238 | 222 | InputDoc
|
239 | 223 | A summary of the input structure and parameters.
|
240 | 224 | """
|
241 |
| - xc = calc_doc.input.incar.get("GGA") |
| 225 | + xc = calc_doc.input.incar.get("GGA") or calc_doc.input.incar.get("METAGGA") |
242 | 226 | if xc:
|
243 | 227 | xc = xc.upper()
|
244 | 228 |
|
245 | 229 | pot_type, func = calc_doc.input.potcar_type[0].split("_")
|
246 | 230 | func = "lda" if len(pot_type) == 1 else "_".join(func)
|
247 | 231 | pps = Potcar(pot_type=pot_type, functional=func, symbols=calc_doc.input.potcar)
|
248 | 232 | return cls(
|
249 |
| - structure=calc_doc.input.structure, |
250 |
| - parameters=calc_doc.input.parameters, |
| 233 | + **calc_doc.input.model_dump(), |
251 | 234 | pseudo_potentials=pps,
|
252 |
| - potcar_spec=calc_doc.input.potcar_spec, |
253 | 235 | xc_override=xc,
|
254 | 236 | is_lasph=calc_doc.input.parameters.get("LASPH", False),
|
255 |
| - is_hubbard=calc_doc.input.is_hubbard, |
256 |
| - hubbards=calc_doc.input.hubbards, |
257 | 237 | magnetic_moments=calc_doc.input.parameters.get("MAGMOM"),
|
258 | 238 | )
|
259 | 239 |
|
@@ -468,9 +448,15 @@ def model_post_init(self, __context: Any) -> None:
|
468 | 448 | # Always refresh task_type, calc_type, run_type
|
469 | 449 | # See, e.g. https://github.com/materialsproject/emmet/issues/960
|
470 | 450 | # where run_type's were set incorrectly in older versions of TaskDoc
|
471 |
| - self.task_type = task_type(self.orig_inputs) |
| 451 | + |
| 452 | + # To determine task and run type, we search for input sets in this order |
| 453 | + # of precedence: calcs_reversed, inputs, orig_inputs |
| 454 | + for inp_set in [self.calcs_reversed[0].input, self.input, self.orig_inputs]: |
| 455 | + if inp_set is not None: |
| 456 | + break |
| 457 | + self.task_type = task_type(inp_set) |
472 | 458 | self.run_type = self._get_run_type(self.calcs_reversed)
|
473 |
| - self.calc_type = self._get_calc_type(self.calcs_reversed, self.orig_inputs) |
| 459 | + self.calc_type = self._get_calc_type(self.calcs_reversed, inp_set) |
474 | 460 |
|
475 | 461 | # TODO: remove after imposing TaskDoc schema on older tasks in collection
|
476 | 462 | if self.structure is None:
|
|
0 commit comments