-
Notifications
You must be signed in to change notification settings - Fork 62
/
material_property.py
59 lines (47 loc) · 1.92 KB
/
material_property.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
""" Core definition of a Materials Document """
from __future__ import annotations
from datetime import datetime
from functools import partial
from typing import ClassVar, Mapping, Optional, Sequence, Type, TypeVar, Union
from pydantic import BaseModel, Field, create_model
from pymatgen.analysis.magnetism import CollinearMagneticStructureAnalyzer, Ordering
from pymatgen.core import Structure
from emmet.core.material import PropertyOrigin
from emmet.core.mpid import MPID
from emmet.core.structure import StructureMetadata
S = TypeVar("S", bound="PropertyDoc")
class PropertyDoc(StructureMetadata):
"""
Base model definition for any singular materials property. This may contain any amount
of structure metadata for the purpose of search
This is intended to be inherited and extended not used directly
"""
property_name: ClassVar[str]
material_id: Union[MPID, int] = Field(
...,
description="The ID of the material, used as a universal reference across proeprty documents."
"This comes in the form of an MPID or int",
)
last_updated: datetime = Field(
description="Timestamp for the most recent calculation update for this property",
default_factory=datetime.utcnow,
)
origins: Sequence[PropertyOrigin] = Field(
[], description="Dictionary for tracking the provenance of properties"
)
warnings: Sequence[str] = Field(
None, description="Any warnings related to this property"
)
@classmethod
def from_structure( # type: ignore[override]
cls: Type[S], structure: Structure, material_id: Union[MPID, int], **kwargs
) -> S:
"""
Builds a materials document using the minimal amount of information
"""
return super().from_structure( # type: ignore
structure=structure,
material_id=material_id,
include_structure=False,
**kwargs
)