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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423
|
from datetime import datetime
from pydantic import field_validator, BaseModel, Field
from emmet.core.mpid import MPID
from pymatgen.phonon.bandstructure import PhononBandStructureSymmLine
from pymatgen.phonon.dos import PhononDos as PhononDosObject
from typing import List, Tuple, Optional
from emmet.core.utils import DocEnum
from pymatgen.core import Structure
from emmet.core.math import Vector3D, Tensor4R
from emmet.core.polar import DielectricDoc, BornEffectiveCharges, IRDielectric
from emmet.core.structure import StructureMetadata
from emmet.core.common import convert_datetime
from typing_extensions import Literal
class PhononBSDOSDoc(BaseModel):
"""
Phonon band structures and density of states data.
"""
material_id: Optional[MPID] = Field(
None,
description="The Materials Project ID of the material. This comes in the form: mp-******.",
)
ph_bs: Optional[PhononBandStructureSymmLine] = Field(
None,
description="Phonon band structure object.",
)
ph_dos: Optional[PhononDosObject] = Field(
None,
description="Phonon density of states object.",
)
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)
class PhononWarnings(DocEnum):
ASR = "ASR break", "acoustic sum rule max breaking is larger than 30 cm^-1."
CNSR = "CNSR break", "charge neutrality sum rule max breaking is larger than 0.2."
NEG_FREQ = (
"has negative frequencies",
"phonon band structure has negative "
"frequencies anywhere in the Brillouin zone.",
)
SMALL_Q_NEG_FREQ = (
"has small q negative frequencies",
"the phonon band structure has negative frequencies,"
" but these are small and very close to the Gamma point "
"(usually related to numerical errors).",
)
class PhononBandStructure(BaseModel):
"""
Document with a pymatgen serialized phonon band structure.
"""
material_id: str = Field(
...,
description="The ID of this material, used as a universal reference across property documents."
"This comes in the form: mp-******",
)
doc_type: Literal["bs"] = Field(
"bs", description="The type of the document: a phonon band structure."
)
band_structure: Optional[dict] = Field(
None,
description="Serialized version of a pymatgen "
"PhononBandStructureSymmLine object.",
)
last_updated: datetime = Field(
description="Timestamp for the most recent calculation update for this property",
default_factory=datetime.utcnow,
)
created_at: datetime = Field(
description="Timestamp for when this material document was first created",
default_factory=datetime.utcnow,
)
class PhononDos(BaseModel):
"""
Document with a pymatgen serialized phonon density of states (DOS).
"""
material_id: str = Field(
...,
description="The ID of this material, used as a universal reference across property documents."
"This comes in the form: mp-******",
)
doc_type: Literal["dos"] = Field(
"dos", description="The type of the document: a phonon density of states."
)
dos: Optional[dict] = Field(
None, description="Serialized version of a pymatgen CompletePhononDos object."
)
dos_method: Optional[str] = Field(
None, description="The method used to calculate the phonon DOS."
)
last_updated: datetime = Field(
description="Timestamp for the most recent calculation update for this property",
default_factory=datetime.utcnow,
)
created_at: datetime = Field(
description="Timestamp for when this material document was first created",
default_factory=datetime.utcnow,
)
class PhononWebsiteBS(BaseModel):
"""
Document with a serialized version of the phonon band structure suitable
for the phononwebsite (http://henriquemiranda.github.io/phononwebsite/).
"""
material_id: str = Field(
...,
description="The ID of this material, used as a universal reference across property documents."
"This comes in the form: mp-******",
)
doc_type: Literal["phononwebsite"] = Field(
"phononwebsite",
description="The type of the document: a phonon band structure for the phononwebsite.",
)
phononwebsite: Optional[dict] = Field(
None,
description="Phononwebsite dictionary to plot the animated " "phonon modes.",
)
last_updated: datetime = Field(
description="Timestamp for the most recent calculation update for this property",
default_factory=datetime.utcnow,
)
created_at: datetime = Field(
description="Timestamp for when this material document was first created",
default_factory=datetime.utcnow,
)
class Ddb(BaseModel):
"""
Document with a the string version of the DDB file produced by abinit.
"""
material_id: str = Field(
...,
description="The ID of this material, used as a universal reference across property documents."
"This comes in the form: mp-******",
)
doc_type: Literal["ddb"] = Field(
"ddb", description="The type of the document: a DDB file."
)
ddb: Optional[str] = Field(None, description="The string of the DDB file.")
last_updated: datetime = Field(
description="Timestamp for the most recent calculation update for this property",
default_factory=datetime.utcnow,
)
created_at: datetime = Field(
description="Timestamp for when this material document was first created",
default_factory=datetime.utcnow,
)
class ThermodynamicProperties(BaseModel):
"""
Definition of the thermodynamic properties extracted from the phonon frequencies.
"""
temperatures: List[float] = Field(
...,
description="The list of temperatures at which the thermodynamic properties "
"are calculated",
)
cv: List[float] = Field(
...,
description="The values of the constant-volume specific heat.",
alias="heat_capacity",
)
entropy: List[float] = Field(
..., description="The values of the vibrational entropy."
)
class VibrationalEnergy(BaseModel):
"""
Definition of the vibrational contribution to the energy as function of
the temperature.
"""
temperatures: List[float] = Field(
...,
description="The list of temperatures at which the thermodynamic properties "
"are calculated",
)
internal_energy: List[float] = Field(
..., description="The values of the phonon contribution to the internal energy."
)
helmholtz_free_energy: List[float] = Field(
..., description="The values of the Helmholtz free energy."
)
zero_point_energy: float = Field(
..., description="The value of the zero point energy."
)
class Phonon(StructureMetadata):
"""
Definition for a document with data produced by a phonon calculation.
"""
material_id: str = Field(
...,
description="The ID of this material, used as a universal reference across property documents."
"This comes in the form: mp-******",
)
structure: Structure = Field(
..., description="The relaxed structure for the phonon calculation."
)
asr_break: Optional[float] = Field(
None, description="The maximum breaking of the acoustic sum rule (ASR)."
)
warnings: Optional[List[PhononWarnings]] = Field(
None, description="List of warnings associated to the phonon calculation."
)
dielectric: Optional[DielectricDoc] = Field(
None, description="Dielectric properties obtained during a phonon calculations."
)
becs: Optional[BornEffectiveCharges] = Field(
None, description="Born effective charges obtained for a phonon calculation."
)
ir_spectra: Optional[IRDielectric] = Field(
None, description="The IRDielectricTensor."
)
thermodynamic: Optional[ThermodynamicProperties] = Field(
None,
description="The thermodynamic properties extracted from the phonon "
"frequencies.",
)
vibrational_energy: Optional[VibrationalEnergy] = Field(
None, description="The vibrational contributions to the total energy."
)
last_updated: datetime = Field(
description="Timestamp for when this document was last updated",
default_factory=datetime.utcnow,
)
created_at: datetime = Field(
description="Timestamp for when this material document was first created",
default_factory=datetime.utcnow,
)
class AbinitPhonon(Phonon):
"""
Definition for a document with data produced from a phonon calculation
with Abinit.
"""
abinit_input_vars: Optional[dict] = Field(
None,
description="Dict representation of the inputs used to obtain the phonon"
"properties and the main general options (e.g. number of "
"k-points, number of q-points).",
)
class SoundVelocity(BaseModel):
"""
Definition for a document with the sound velocities of the acoustic modes
close to Gamma, as obtained from a phonon calculation.
"""
material_id: str = Field(
...,
description="The ID of this material, in the form: mp-******",
)
structure: Structure = Field(
..., description="The relaxed structure for the phonon calculation."
)
directions: List[Vector3D] = Field(
...,
description="Q-points identifying the directions for the calculation"
"of the speed of sound. In fractional coordinates.",
)
labels: List[Optional[str]] = Field(..., description="labels of the directions.")
sound_velocities: List[Vector3D] = Field(
...,
description="Values of the sound velocities in SI units.",
)
mode_types: List[Tuple[Optional[str], Optional[str], Optional[str]]] = Field(
...,
description="The types of the modes ('transversal', 'longitudinal'). "
"None if not correctly identified.",
)
last_updated: datetime = Field(
description="Timestamp for when this document was last updated",
default_factory=datetime.utcnow,
)
created_at: datetime = Field(
description="Timestamp for when this material document was first created",
default_factory=datetime.utcnow,
)
class ThermalDisplacement(BaseModel):
"""
Definition of a Document for the generalized density of states and
mean square displacements related to phonon oscillations.
"""
material_id: str = Field(
...,
description="The ID of this material, used as a universal reference across property documents."
"This comes in the form: mp-******",
)
last_updated: datetime = Field(
description="Timestamp for the most recent calculation update for this property",
default_factory=datetime.utcnow,
)
created_at: datetime = Field(
description="Timestamp for when this material document was first created",
default_factory=datetime.utcnow,
)
nsites: int = Field(
...,
description="The number of sites in the structure.",
)
nomega: int = Field(
...,
description="The number of frequencies.",
)
ntemp: int = Field(
...,
description="The number of temperatures for which the displacements are calculated",
)
temperatures: List[float] = Field(
...,
description="The list of temperatures at which the thermodynamic properties "
"are calculated",
)
frequencies: List[float] = Field(
..., description="The list of frequencies for the generalized DOS"
)
gdos_aijw: Tensor4R = Field(
...,
description=" Generalized DOS in Cartesian coords, with shape (nsites, 3, 3, nomega)",
)
amu: dict = Field(
..., description="Dictionary of the atomic masses in atomic units."
)
structure: Structure = Field(
..., description="The relaxed structure for the phonon calculation."
)
ucif_t: Tensor4R = Field(
...,
description="Mean squared displacement U tensors as a function of T for T in tmesh in CIF format."
"With shape (natom, 3, 3, ntemp) ",
)
ucif_string_t300k: str = Field(
...,
description="Mean squared displacement U tensors at T=300K in CIF string format.",
)
|