Skip to content

Commit

Permalink
use ComputedStructureEntries
Browse files Browse the repository at this point in the history
  • Loading branch information
shyamd committed Dec 17, 2020
1 parent 9e9eccd commit a2c5dee
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
10 changes: 5 additions & 5 deletions emmet-core/emmet/core/thermo.py
@@ -1,15 +1,15 @@
""" Core definition of a Thermo Document """
from datetime import datetime
from enum import Enum
from typing import ClassVar, Dict, List
from typing import ClassVar, Dict, List, Union

from pydantic import BaseModel, Field
from pymatgen.analysis.phase_diagram import PhaseDiagram, PhaseDiagramError
from pymatgen.core.periodic_table import Element

from emmet.core.material_property import PropertyDoc
from emmet.core.structure import StructureMetadata
from emmet.stubs import Composition, ComputedEntry
from emmet.stubs import Composition, ComputedEntry, ComputedStructureEntry


class DecompositionProduct(BaseModel):
Expand Down Expand Up @@ -83,14 +83,14 @@ class ThermoDoc(PropertyDoc):
description="List of available energy types computed for this material"
)

entries: Dict[str, ComputedEntry] = Field(
None,
entries: Dict[str, Union[ComputedEntry, ComputedStructureEntry]] = Field(
...,
description="List of all entries that are valid for this material."
" The keys for this dictionary are names of various calculation types",
)

@classmethod
def from_entries(cls, entries: List[ComputedEntry]):
def from_entries(cls, entries: List[Union[ComputedEntry, ComputedStructureEntry]]):

pd = PhaseDiagram(entries)

Expand Down
6 changes: 3 additions & 3 deletions emmet-core/emmet/core/vasp/material.py
Expand Up @@ -12,7 +12,7 @@
from emmet.core.structure import StructureMetadata
from emmet.core.vasp.calc_types import CalcType, RunType, TaskType
from emmet.core.vasp.task import TaskDocument
from emmet.stubs import ComputedEntry, Structure
from emmet.stubs import ComputedStructureEntry, Structure


class MaterialsDoc(CoreMaterialsDoc, StructureMetadata):
Expand All @@ -34,7 +34,7 @@ class MaterialsDoc(CoreMaterialsDoc, StructureMetadata):
None, description="Mappingionary for tracking the provenance of properties"
)

entries: Mapping[RunType, ComputedEntry] = Field(
entries: Mapping[RunType, ComputedStructureEntry] = Field(
None, description="Dictionary for tracking entries for VASP calculations"
)

Expand Down Expand Up @@ -136,7 +136,7 @@ def _structure_eval(task: TaskDocument):

if len(relevant_calcs) > 0:
best_task_doc = relevant_calcs[0]
entry = best_task_doc.entry
entry = best_task_doc.structure_entry
entry.data["task_id"] = entry.entry_id
entry.entry_id = material_id
entries[rt] = entry
Expand Down
16 changes: 15 additions & 1 deletion emmet-core/emmet/core/vasp/task.py
Expand Up @@ -18,7 +18,13 @@
run_type,
task_type,
)
from emmet.stubs import ComputedEntry, Matrix3D, Structure, Vector3D
from emmet.stubs import (
ComputedEntry,
ComputedStructureEntry,
Matrix3D,
Structure,
Vector3D,
)


class Status(ValueEnum):
Expand Down Expand Up @@ -153,3 +159,11 @@ def entry(self):
}

return ComputedEntry.from_dict(entry_dict)

@property
def structure_entry(self):
""" Turns a Task Doc into a ComputedStructureEntry"""
entry_dict = self.entry.as_dict()
entry_dict["structure"] = self.output.structure

return ComputedStructureEntry.from_dict(entry_dict)

0 comments on commit a2c5dee

Please sign in to comment.