File: grain_boundary.py

package info (click to toggle)
python-emmet-core 0.84.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 77,220 kB
  • sloc: python: 16,355; makefile: 30
file content (88 lines) | stat: -rw-r--r-- 2,283 bytes parent folder | download
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from typing import List, Optional
from pydantic import field_validator, BaseModel, Field
from enum import Enum
from datetime import datetime
from emmet.core.common import convert_datetime

from pymatgen.analysis.gb.grain import GrainBoundary


class GBTypeEnum(Enum):
    """
    Grain boundary types
    """

    tilt = "tilt"
    twist = "twist"


class GrainBoundaryDoc(BaseModel):
    """
    Grain boundary energies, work of separation...
    """

    material_id: Optional[str] = Field(
        None,
        description="The Materials Project ID of the material. This comes in the form: mp-******.",
    )

    sigma: Optional[int] = Field(
        None,
        description="Sigma value of the boundary.",
    )

    type: Optional[GBTypeEnum] = Field(
        None,
        description="Grain boundary type.",
    )

    rotation_axis: Optional[List[int]] = Field(
        None,
        description="Rotation axis.",
    )

    gb_plane: Optional[List[int]] = Field(
        None,
        description="Grain boundary plane.",
    )

    rotation_angle: Optional[float] = Field(
        None,
        description="Rotation angle in degrees.",
    )

    gb_energy: Optional[float] = Field(
        None,
        description="Grain boundary energy in J/m^2.",
    )

    initial_structure: Optional[GrainBoundary] = Field(
        None, description="Initial grain boundary structure."
    )

    final_structure: Optional[GrainBoundary] = Field(
        None, description="Final grain boundary structure."
    )

    pretty_formula: Optional[str] = Field(
        None, description="Reduced formula of the material."
    )

    w_sep: Optional[float] = Field(None, description="Work of separation in J/m^2.")

    cif: Optional[str] = Field(None, description="CIF file of the structure.")

    chemsys: Optional[str] = Field(
        None, description="Dash-delimited string of elements in the material."
    )

    last_updated: Optional[datetime] = Field(
        None,
        description="Timestamp for the most recent calculation for this Material document.",
    )

    # Make sure that the datetime field is properly formatted
    @field_validator("last_updated", mode="before")
    @classmethod
    def handle_datetime(cls, v):
        return convert_datetime(cls, v)