gemdat.trajectory
This module contains class for dealing with trajectories from molecular dynamics simulations.
Trajectory(*, metadata=None, **kwargs)
Bases: Trajectory
Trajectory of sites from a molecular dynamics simulation.
Parameters:
-
metadata
(dict | None
, default:None
) βOptional dictionary with metadata
-
**kwargs
βThese are passed to pymatgen.core.trajectory.Trajectory
Source code in src/gemdat/trajectory.py
52 53 54 55 56 57 58 59 60 61 62 63 |
|
cumulative_displacements: np.ndarray
property
Return cumulative displacement vectors from base positions.
This differs from displacements() in that it ignores the periodic boundary conditions. Instead, it cumulatively tracks the lattice translation vector (jimage).
displacements: np.ndarray
property
Return trajectory displacements as fractional coordinates from base position.
Returns:
-
displacements
(ndarray
) βOutput array with displacements
positions: np.ndarray
property
Return trajectory positions as fractional coordinates.
Returns:
-
positions
(ndarray
) βOutput array with positions
sampling_frequency: float
property
Return number of time steps per second.
total_time: float
property
Return total time for trajectory.
apply_drift_correction(*, fixed_species=None, floating_species=None)
Apply drift correction to trajectory. For details see drift().
If no species are specified, use all species to calculate drift.
Only one of fixed_species
and floating_species
should be specified.
Parameters:
-
fixed_species
(None | str | Collection[str]
, default:None
) βThese species are assumed fixed, and are used to calculate drift (e.g. framework species).
-
floating_species
(None | str | Collection[str]
, default:None
) βThese species are assumed floating, and is used to determine the fixed species.
Returns:
-
trajectory
(Trajectory
) βOuput trajectory with positions corrected for drift
Source code in src/gemdat/trajectory.py
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 |
|
center_of_mass()
Return trajectory with center of mass for positions.
Source code in src/gemdat/trajectory.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
|
distances_from_base_position()
Return total distances from base positions.
Ignores periodic boundary conditions.
Source code in src/gemdat/trajectory.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
|
drift(*, fixed_species=None, floating_species=None)
Compute drift by averaging the displacement from the base positions per frame.
If no species are specified, use all species to calculate drift.
Only one of fixed_species
and floating_species
should be specified.
Parameters:
-
fixed_species
(None | str | Collection[str]
, default:None
) βThese species are assumed fixed, and are used to calculate drift (e.g. framework species).
-
floating_species
(None | str | Collection[str]
, default:None
) βThese species are assumed floating, and is used to determine the fixed species.
Returns:
-
drift
(array
) βOutput array with average drift per frame.
Source code in src/gemdat/trajectory.py
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 |
|
filter(species)
Return trajectory with coordinates for given species only.
Parameters:
-
species
(str | Collection[str]
) βSpecies to select, i.e. 'Li'
Returns:
-
trajectory
(Trajectory
) βOutput trajectory with coordinates for selected species only
Source code in src/gemdat/trajectory.py
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 |
|
from_cache(cache)
classmethod
Load data from cache using pickle.
Parameters:
-
cache
(Path
) βName of cache file
Source code in src/gemdat/trajectory.py
161 162 163 164 165 166 167 168 169 170 171 172 |
|
from_vasprun(xml_file, cache=None, constant_lattice=True, **kwargs)
classmethod
Load data from a vasprun.xml
.
Parameters:
-
xml_file
(Path
) βPath to vasprun.xml
-
cache
(Optional[Path]
, default:None
) βPath to cache data for vasprun.xml
-
constant_lattice
(bool
, default:True
) βWhether the lattice changes during the simulation, such as in an NPT MD simulation.
-
**kwargs
(dict
, default:{}
) βOptional arguments passed to pymatgen.io.vasp.outputs.Vasprun
Returns:
-
trajectory
(Trajectory
) βOutput trajectory
Source code in src/gemdat/trajectory.py
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 |
|
get_lattice(idx=None)
Get lattice.
Parameters:
-
idx
(int | None
, default:None
) βOptionally, get lattice at specified index if the lattice is not constant
Returns:
-
lattice
(Lattice
) βPymatgen Lattice object
Source code in src/gemdat/trajectory.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
|
mean_squared_displacement()
Computes the mean squared displacement using fast Fourier transform.
The algorithm is described in [https://doi.org/10.1051/sfn/201112010]. See also [https://stackoverflow.com/questions/34222272/computing-mean-square-displacement-using-python-and-fft].
Source code in src/gemdat/trajectory.py
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 |
|
plot_displacement_histogram(**kwargs)
See gemdat.plots.displacement_histogram for more info.
Source code in src/gemdat/trajectory.py
542 543 544 545 |
|
plot_displacement_per_atom(**kwargs)
See gemdat.plots.displacement_per_atom for more info.
Source code in src/gemdat/trajectory.py
527 528 529 530 |
|
plot_displacement_per_element(**kwargs)
See gemdat.plots.displacement_per_element for more info.
Source code in src/gemdat/trajectory.py
532 533 534 535 |
|
plot_frequency_vs_occurence(**kwargs)
See gemdat.plots.frequency_vs_occurence for more info.
Source code in src/gemdat/trajectory.py
547 548 549 550 |
|
plot_msd_per_element(**kwargs)
See gemdat.plots.msd_per_element for more info.
Source code in src/gemdat/trajectory.py
537 538 539 540 |
|
plot_vibrational_amplitudes(**kwargs)
See gemdat.plots.vibrational_amplitudes for more info.
Source code in src/gemdat/trajectory.py
552 553 554 555 |
|
split(n_parts=10, equal_parts=False)
Split the trajectory in n similar parts.
Parameters:
-
n_parts
(int
, default:10
) βn_parts
-
equal_parts
(bool = False
, default:False
) βReturn equal parts, convenient for some routines
Returns:
-
List[Trajectory]
β
Source code in src/gemdat/trajectory.py
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
|
to_cache(cache)
Dump data to cache using pickle.
Parameters:
-
cache
(Path
) βName of cache file
Source code in src/gemdat/trajectory.py
174 175 176 177 178 179 180 181 182 183 |
|
to_positions()
Pymatgen does not mod coords back to original unit cell.
See GEMDAT#103
Source code in src/gemdat/trajectory.py
96 97 98 99 100 101 102 |
|
to_volume(resolution=0.2)
Calculate density volume from a trajectory.
All coordinates are binned into voxels. The value of each voxel represents the number of coodinates that are associated with it.
For more info, see gemdat.Volume.
Parameters:
-
resolution
(float
, default:0.2
) βMinimum resolution for the voxels in Angstrom
Returns:
-
vol
(Volume
) βOutput volume
Source code in src/gemdat/trajectory.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
|
transitions_between_sites(sites, floating_specie, site_radius=None, site_inner_fraction=1.0)
Compute transitions between given sites for floating specie.
Parameters:
-
sites
(Structure
) βInput structure with known sites
-
floating_specie
(str
) βName of the floating specie to calculate transitions for
-
site_radius
(float | dict[str, float] | None
, default:None
) βA custom site radius in Γ ngstrom to determine if an atom is at a site. A dict keyed by the site label can be used to have a site per atom type, e.g. `site_radius = {'Li1': 1.0, 'Li2': 1.2}.
-
site_inner_fraction
(float
, default:1.0
) βA fraction of the site radius which is determined to be the
inner site
which is used in jump calculations
Returns:
-
transitions
(Transitions
) β
Source code in src/gemdat/trajectory.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
|