atomlib.atoms
Raw atoms collection
This module defines HasAtoms
and the concrete Atoms
,
which holds a collection of atoms with no cell or periodicity. Atoms
is essentially a wrapper around a polars.DataFrame
.
RollingInterpolationMethod
module-attribute
ConcatMethod
module-attribute
ConcatMethod: TypeAlias = Literal[
"horizontal", "vertical", "diagonal", "inner", "align"
]
IntoAtoms
module-attribute
IntoAtoms: TypeAlias = Union[
Dict[str, Sequence[Any]],
Sequence[Any],
ndarray,
DataFrame,
"Atoms",
]
A type convertible into an Atoms
.
AtomSelection
module-attribute
Polars expression selecting a subset of atoms.
Can be used with many Atoms
methods.
AtomValues
module-attribute
Array, value, or polars expression mapping atom symbols to values.
Can be used with with_*
methods on Atoms
HasAtoms
Bases: ABC
Abstract class representing any (possibly compound) collection of atoms.
Source code in atomlib/atoms.py
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 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 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 489 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 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 |
|
columns
property
dtypes
property
dtypes: List[DataType]
schema
property
Return the schema of self
.
RETURNS | DESCRIPTION |
---|---|
Schema
|
A dictionary of column names and |
get_atoms
abstractmethod
Get atoms contained in self
. This should be a low cost method.
PARAMETER | DESCRIPTION |
---|---|
frame
|
Coordinate frame to return atoms in. For a plain
TYPE:
|
Return
The contained atoms
Source code in atomlib/atoms.py
with_atoms
abstractmethod
Return a copy of self with the inner Atoms
replaced.
PARAMETER | DESCRIPTION |
---|---|
atoms
|
TYPE:
|
frame
|
Coordinate frame inside atoms are in. For a plain
TYPE:
|
Return
A copy of self
updated with the given atoms
Source code in atomlib/atoms.py
describe
describe(
percentiles: Union[Sequence[float], float, None] = (
0.25,
0.5,
0.75,
),
*,
interpolation: RollingInterpolationMethod = "nearest"
) -> DataFrame
Return summary statistics for self
. See DataFrame.describe
for more information.
PARAMETER | DESCRIPTION |
---|---|
percentiles
|
List of percentiles/quantiles to include. Defaults to 25% (first quartile), 50% (median), and 75% (third quartile).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
A dataframe containing summary statistics (mean, std. deviation, percentiles, etc.) for each column. |
Source code in atomlib/atoms.py
with_columns
Return a copy of self
with the given columns added.
Source code in atomlib/atoms.py
insert_column
insert_column(index: int, column: Series) -> DataFrame
get_column
get_column(name: str) -> Series
Get the specified column from self
, raising polars.ColumnNotFoundError
if it's not present.
Source code in atomlib/atoms.py
get_columns
get_columns() -> List[Series]
Return all columns from self
as a list of Series
.
Source code in atomlib/atoms.py
get_column_index
Get the index of a column by name, raising polars.ColumnNotFoundError
if it's not present.
group_by
group_by(
*by: Union[IntoExpr, Iterable[IntoExpr]],
maintain_order: bool = False,
**named_by: IntoExpr
) -> GroupBy
Start a group by operation. See DataFrame.group_by
for more information.
Source code in atomlib/atoms.py
pipe
pipe(
function: Callable[Concatenate[HasAtomsT, P], T],
*args: args,
**kwargs: kwargs
) -> T
Apply function
to self
(in method-call syntax).
clone
drop
filter
filter(
*predicates: Union[
None,
IntoExprColumn,
Iterable[IntoExprColumn],
bool,
List[bool],
ndarray,
],
**constraints: Any
) -> Self
Filter self
, removing rows which evaluate to False
.
Source code in atomlib/atoms.py
sort
sort(
by: Union[IntoExpr, Iterable[IntoExpr]],
*more_by: IntoExpr,
descending: Union[bool, Sequence[bool]] = False,
nulls_last: bool = False
) -> DataFrame
Sort the atoms in self
by the given columns/expressions.
Source code in atomlib/atoms.py
slice
head
head(n: int = 5) -> DataFrame
tail
tail(n: int = 5) -> DataFrame
drop_nulls
drop_nulls(
subset: Union[str, Collection[str], None] = None
) -> DataFrame
Drop rows that contain nulls in any of columns subset
.
fill_null
fill_null(
value: Any = None,
strategy: Optional[FillNullStrategy] = None,
limit: Optional[int] = None,
matches_supertype: bool = True,
) -> DataFrame
Fill null values in self
, using the specified value or strategy.
Source code in atomlib/atoms.py
fill_nan
concat
classmethod
concat(
atoms: Union[
HasAtomsT,
IntoAtoms,
Iterable[Union[HasAtomsT, IntoAtoms]],
],
*,
rechunk: bool = True,
how: ConcatMethod = "vertical"
) -> HasAtomsT
Concatenate multiple Atoms
together, handling metadata appropriately.
Source code in atomlib/atoms.py
partition_by
partition_by(
by: Union[str, Sequence[str]],
*more_by: str,
maintain_order: bool = True,
include_key: bool = True,
as_dict: bool = False
) -> Union[List[Self], Dict[Any, Self]]
Group by the given columns and partition into separate dataframes.
Return the partitions as a dictionary by specifying as_dict=True
.
Source code in atomlib/atoms.py
select
Select exprs
from self
, and return as a polars.DataFrame
.
Expressions may either be columns or expressions of columns.
Source code in atomlib/atoms.py
select_schema
select_schema(schema: SchemaDict) -> DataFrame
Select columns from self
and cast to the given schema.
Raises TypeError
if a column is not found or if it can't be cast.
Source code in atomlib/atoms.py
select_props
Select exprs
from self
, while keeping required columns.
RETURNS | DESCRIPTION |
---|---|
Self
|
A |
Self
|
specified properties (as well as required columns). |
Source code in atomlib/atoms.py
try_select
try_select(
*exprs: Union[IntoExpr, Iterable[IntoExpr]],
**named_exprs: IntoExpr
) -> Optional[DataFrame]
Try to select exprs
from self
, and return as a polars.DataFrame
.
Expressions may either be columns or expressions of columns. Returns None
if any
columns are missing.
Source code in atomlib/atoms.py
try_get_column
Try to get a column from self
, returning None
if it doesn't exist.
bbox_atoms
bbox_atoms() -> BBox3D
transform_atoms
transform_atoms(
transform: IntoTransform3D,
selection: Optional[AtomSelection] = None,
*,
transform_velocities: bool = False
) -> Self
Transform the atoms in self
by transform
.
If selection
is given, only transform the atoms in selection
.
Source code in atomlib/atoms.py
round_near_zero
round_near_zero(tol: float = 1e-14) -> Self
Round atom position values near zero to zero.
Source code in atomlib/atoms.py
crop
crop(
x_min: float = -inf,
x_max: float = inf,
y_min: float = -inf,
y_max: float = inf,
z_min: float = -inf,
z_max: float = inf,
) -> Self
Crop, removing all atoms outside of the specified region, inclusive.
Source code in atomlib/atoms.py
deduplicate
deduplicate(
tol: float = 0.001,
subset: Iterable[str] = ("x", "y", "z", "symbol"),
keep: UniqueKeepStrategy = "first",
maintain_order: bool = True,
) -> Self
De-duplicate atoms in self
. Atoms of the same symbol
that are closer than tolerance
to each other (by Euclidian distance) will be removed, leaving only the atom specified by
keep
(defaults to the first atom).
If subset
is specified, only those columns will be included while assessing duplicates.
Floating point columns other than 'x', 'y', and 'z' will not by toleranced.
Source code in atomlib/atoms.py
with_bounds
with_bounds(
cell_size: Optional[VecLike] = None,
cell_origin: Optional[VecLike] = None,
) -> "AtomCell"
Return a periodic cell with the given orthogonal cell dimensions.
If cell_size is not specified, it will be assumed (and may be incorrect).
Source code in atomlib/atoms.py
coords
coords(
selection: Optional[AtomSelection] = None,
*,
frame: Literal["local"] = "local"
) -> NDArray[float64]
Return a (N, 3)
ndarray of atom coordinates (dtype numpy.float64
).
Source code in atomlib/atoms.py
x
y
z
velocities
velocities(
selection: Optional[AtomSelection] = None,
) -> Optional[NDArray[float64]]
Return a (N, 3)
ndarray of atom velocities (dtype numpy.float64
).
Source code in atomlib/atoms.py
types
types() -> Optional[Series]
Returns a Series
of atom types (dtype polars.Int32
).
Source code in atomlib/atoms.py
masses
masses() -> Optional[Series]
Returns a Series
of atom masses (dtype polars.Float32
).
Source code in atomlib/atoms.py
add_atom
add_atom(
elem: Union[int, str],
/,
x: Union[ArrayLike, float],
y: Optional[float] = None,
z: Optional[float] = None,
**kwargs: Any,
) -> Self
Return a copy of self
with an extra atom.
By default, all extra columns present in self
must be specified as **kwargs
.
Try to avoid calling this in a loop (Use HasAtoms.concat
instead).
Source code in atomlib/atoms.py
pos
pos(
x: Union[Sequence[Optional[float]], float, None] = None,
y: Optional[float] = None,
z: Optional[float] = None,
*,
tol: float = 1e-06,
**kwargs: Any
) -> Expr
Select all atoms at a given position.
Formally, returns all atoms within a cube of radius tol
centered at (x,y,z)
, exclusive of the cube's surface.
Additional parameters given as kwargs
will be checked
as additional parameters (with strict equality).
Source code in atomlib/atoms.py
with_index
with_index(index: Optional[AtomValues] = None) -> Self
Returns self
with a row index added in column 'i' (dtype polars.Int64
).
If index
is not specified, defaults to an existing index or a new index.
Source code in atomlib/atoms.py
with_wobble
with_wobble(wobble: Optional[AtomValues] = None) -> Self
Return self
with the given displacements in column 'wobble' (dtype polars.Float64
).
If wobble
is not specified, defaults to the already-existing wobbles or 0.
Source code in atomlib/atoms.py
with_occupancy
with_occupancy(
frac_occupancy: Optional[AtomValues] = None,
) -> Self
Return self with the given fractional occupancies (dtype polars.Float64
).
If frac_occupancy
is not specified, defaults to the already-existing occupancies or 1.
Source code in atomlib/atoms.py
apply_wobble
Displace the atoms in self
by the amount in the wobble
column.
wobble
is interpretated as a mean-squared displacement, which is distributed
equally over each axis.
Source code in atomlib/atoms.py
apply_occupancy
For each atom in self
, use its frac_occupancy
to randomly decide whether to remove it.
Source code in atomlib/atoms.py
with_type
with_type(types: Optional[AtomValues] = None) -> Self
Return self
with the given atom types in column 'type'.
If types
is not specified, use the already existing types or auto-assign them.
When auto-assigning, each symbol is given a unique value, case-sensitive.
Values are assigned from lowest atomic number to highest.
For instance: ["Ag+", "Na", "H", "Ag"]
=> [3, 11, 1, 2]
Source code in atomlib/atoms.py
with_mass
Return self
with the given atom masses in column 'mass'
.
If mass
is not specified, use the already existing masses or auto-assign them.
Source code in atomlib/atoms.py
with_symbol
with_symbol(
symbols: ArrayLike,
selection: Optional[AtomSelection] = None,
) -> Self
Return self
with the given atomic symbols.
Source code in atomlib/atoms.py
with_coords
with_coords(
pts: ArrayLike,
selection: Optional[AtomSelection] = None,
*,
frame: Literal["local"] = "local"
) -> Self
Return self
replaced with the given atomic positions.
Source code in atomlib/atoms.py
with_velocity
with_velocity(
pts: Optional[ArrayLike] = None,
selection: Optional[AtomSelection] = None,
) -> Self
Return self
replaced with the given atomic velocities.
If pts
is not specified, use the already existing velocities or zero.
Source code in atomlib/atoms.py
Atoms
Bases: AtomsIOMixin
, HasAtoms
A collection of atoms, absent any implied coordinate system.
Implemented as a wrapper around a polars.DataFrame
.
Must contain the following columns:
- coords: array of
[x, y, z]
positions, float - elem: atomic number, int
- symbol: atomic symbol (may contain charges)
In addition, it commonly contains the following columns:
- i: Initial atom number
- wobble: Isotropic Debye-Waller mean-squared deviation (\(\left<u^2\right> = B \cdot \frac{3}{8 \pi^2}\), dimensions of [Length^2])
- frac_occupancy: Fractional occupancy, in the range [0., 1.]
- mass: Atomic mass, in g/mol (approx. Da)
- velocity: array of
[x, y, z]
velocities, float, dimensions of length/time - type: Numeric atom type, as used by programs like LAMMPS
Source code in atomlib/atoms.py
968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 |
|
columns
property
dtypes
property
dtypes: List[DataType]
schema
property
Return the schema of self
.
RETURNS | DESCRIPTION |
---|---|
Schema
|
A dictionary of column names and |
describe
describe(
percentiles: Union[Sequence[float], float, None] = (
0.25,
0.5,
0.75,
),
*,
interpolation: RollingInterpolationMethod = "nearest"
) -> DataFrame
Return summary statistics for self
. See DataFrame.describe
for more information.
PARAMETER | DESCRIPTION |
---|---|
percentiles
|
List of percentiles/quantiles to include. Defaults to 25% (first quartile), 50% (median), and 75% (third quartile).
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
DataFrame
|
A dataframe containing summary statistics (mean, std. deviation, percentiles, etc.) for each column. |
Source code in atomlib/atoms.py
with_columns
Return a copy of self
with the given columns added.
Source code in atomlib/atoms.py
insert_column
insert_column(index: int, column: Series) -> DataFrame
get_column
get_column(name: str) -> Series
Get the specified column from self
, raising polars.ColumnNotFoundError
if it's not present.
Source code in atomlib/atoms.py
get_columns
get_columns() -> List[Series]
Return all columns from self
as a list of Series
.
Source code in atomlib/atoms.py
get_column_index
Get the index of a column by name, raising polars.ColumnNotFoundError
if it's not present.
group_by
group_by(
*by: Union[IntoExpr, Iterable[IntoExpr]],
maintain_order: bool = False,
**named_by: IntoExpr
) -> GroupBy
Start a group by operation. See DataFrame.group_by
for more information.
Source code in atomlib/atoms.py
pipe
pipe(
function: Callable[Concatenate[HasAtomsT, P], T],
*args: args,
**kwargs: kwargs
) -> T
Apply function
to self
(in method-call syntax).
clone
drop
filter
filter(
*predicates: Union[
None,
IntoExprColumn,
Iterable[IntoExprColumn],
bool,
List[bool],
ndarray,
],
**constraints: Any
) -> Self
Filter self
, removing rows which evaluate to False
.
Source code in atomlib/atoms.py
sort
sort(
by: Union[IntoExpr, Iterable[IntoExpr]],
*more_by: IntoExpr,
descending: Union[bool, Sequence[bool]] = False,
nulls_last: bool = False
) -> DataFrame
Sort the atoms in self
by the given columns/expressions.
Source code in atomlib/atoms.py
slice
head
head(n: int = 5) -> DataFrame
tail
tail(n: int = 5) -> DataFrame
drop_nulls
drop_nulls(
subset: Union[str, Collection[str], None] = None
) -> DataFrame
Drop rows that contain nulls in any of columns subset
.
fill_null
fill_null(
value: Any = None,
strategy: Optional[FillNullStrategy] = None,
limit: Optional[int] = None,
matches_supertype: bool = True,
) -> DataFrame
Fill null values in self
, using the specified value or strategy.
Source code in atomlib/atoms.py
fill_nan
concat
classmethod
concat(
atoms: Union[
HasAtomsT,
IntoAtoms,
Iterable[Union[HasAtomsT, IntoAtoms]],
],
*,
rechunk: bool = True,
how: ConcatMethod = "vertical"
) -> HasAtomsT
Concatenate multiple Atoms
together, handling metadata appropriately.
Source code in atomlib/atoms.py
partition_by
partition_by(
by: Union[str, Sequence[str]],
*more_by: str,
maintain_order: bool = True,
include_key: bool = True,
as_dict: bool = False
) -> Union[List[Self], Dict[Any, Self]]
Group by the given columns and partition into separate dataframes.
Return the partitions as a dictionary by specifying as_dict=True
.
Source code in atomlib/atoms.py
select
Select exprs
from self
, and return as a polars.DataFrame
.
Expressions may either be columns or expressions of columns.
Source code in atomlib/atoms.py
select_schema
select_schema(schema: SchemaDict) -> DataFrame
Select columns from self
and cast to the given schema.
Raises TypeError
if a column is not found or if it can't be cast.
Source code in atomlib/atoms.py
select_props
Select exprs
from self
, while keeping required columns.
RETURNS | DESCRIPTION |
---|---|
Self
|
A |
Self
|
specified properties (as well as required columns). |
Source code in atomlib/atoms.py
try_select
try_select(
*exprs: Union[IntoExpr, Iterable[IntoExpr]],
**named_exprs: IntoExpr
) -> Optional[DataFrame]
Try to select exprs
from self
, and return as a polars.DataFrame
.
Expressions may either be columns or expressions of columns. Returns None
if any
columns are missing.
Source code in atomlib/atoms.py
try_get_column
Try to get a column from self
, returning None
if it doesn't exist.
bbox_atoms
bbox_atoms() -> BBox3D
transform_atoms
transform_atoms(
transform: IntoTransform3D,
selection: Optional[AtomSelection] = None,
*,
transform_velocities: bool = False
) -> Self
Transform the atoms in self
by transform
.
If selection
is given, only transform the atoms in selection
.
Source code in atomlib/atoms.py
round_near_zero
round_near_zero(tol: float = 1e-14) -> Self
Round atom position values near zero to zero.
Source code in atomlib/atoms.py
crop
crop(
x_min: float = -inf,
x_max: float = inf,
y_min: float = -inf,
y_max: float = inf,
z_min: float = -inf,
z_max: float = inf,
) -> Self
Crop, removing all atoms outside of the specified region, inclusive.
Source code in atomlib/atoms.py
deduplicate
deduplicate(
tol: float = 0.001,
subset: Iterable[str] = ("x", "y", "z", "symbol"),
keep: UniqueKeepStrategy = "first",
maintain_order: bool = True,
) -> Self
De-duplicate atoms in self
. Atoms of the same symbol
that are closer than tolerance
to each other (by Euclidian distance) will be removed, leaving only the atom specified by
keep
(defaults to the first atom).
If subset
is specified, only those columns will be included while assessing duplicates.
Floating point columns other than 'x', 'y', and 'z' will not by toleranced.
Source code in atomlib/atoms.py
with_bounds
with_bounds(
cell_size: Optional[VecLike] = None,
cell_origin: Optional[VecLike] = None,
) -> "AtomCell"
Return a periodic cell with the given orthogonal cell dimensions.
If cell_size is not specified, it will be assumed (and may be incorrect).
Source code in atomlib/atoms.py
coords
coords(
selection: Optional[AtomSelection] = None,
*,
frame: Literal["local"] = "local"
) -> NDArray[float64]
Return a (N, 3)
ndarray of atom coordinates (dtype numpy.float64
).
Source code in atomlib/atoms.py
x
y
z
velocities
velocities(
selection: Optional[AtomSelection] = None,
) -> Optional[NDArray[float64]]
Return a (N, 3)
ndarray of atom velocities (dtype numpy.float64
).
Source code in atomlib/atoms.py
types
types() -> Optional[Series]
Returns a Series
of atom types (dtype polars.Int32
).
Source code in atomlib/atoms.py
masses
masses() -> Optional[Series]
Returns a Series
of atom masses (dtype polars.Float32
).
Source code in atomlib/atoms.py
add_atom
add_atom(
elem: Union[int, str],
/,
x: Union[ArrayLike, float],
y: Optional[float] = None,
z: Optional[float] = None,
**kwargs: Any,
) -> Self
Return a copy of self
with an extra atom.
By default, all extra columns present in self
must be specified as **kwargs
.
Try to avoid calling this in a loop (Use HasAtoms.concat
instead).
Source code in atomlib/atoms.py
pos
pos(
x: Union[Sequence[Optional[float]], float, None] = None,
y: Optional[float] = None,
z: Optional[float] = None,
*,
tol: float = 1e-06,
**kwargs: Any
) -> Expr
Select all atoms at a given position.
Formally, returns all atoms within a cube of radius tol
centered at (x,y,z)
, exclusive of the cube's surface.
Additional parameters given as kwargs
will be checked
as additional parameters (with strict equality).
Source code in atomlib/atoms.py
with_index
with_index(index: Optional[AtomValues] = None) -> Self
Returns self
with a row index added in column 'i' (dtype polars.Int64
).
If index
is not specified, defaults to an existing index or a new index.
Source code in atomlib/atoms.py
with_wobble
with_wobble(wobble: Optional[AtomValues] = None) -> Self
Return self
with the given displacements in column 'wobble' (dtype polars.Float64
).
If wobble
is not specified, defaults to the already-existing wobbles or 0.
Source code in atomlib/atoms.py
with_occupancy
with_occupancy(
frac_occupancy: Optional[AtomValues] = None,
) -> Self
Return self with the given fractional occupancies (dtype polars.Float64
).
If frac_occupancy
is not specified, defaults to the already-existing occupancies or 1.
Source code in atomlib/atoms.py
apply_wobble
Displace the atoms in self
by the amount in the wobble
column.
wobble
is interpretated as a mean-squared displacement, which is distributed
equally over each axis.
Source code in atomlib/atoms.py
apply_occupancy
For each atom in self
, use its frac_occupancy
to randomly decide whether to remove it.
Source code in atomlib/atoms.py
with_type
with_type(types: Optional[AtomValues] = None) -> Self
Return self
with the given atom types in column 'type'.
If types
is not specified, use the already existing types or auto-assign them.
When auto-assigning, each symbol is given a unique value, case-sensitive.
Values are assigned from lowest atomic number to highest.
For instance: ["Ag+", "Na", "H", "Ag"]
=> [3, 11, 1, 2]
Source code in atomlib/atoms.py
with_mass
Return self
with the given atom masses in column 'mass'
.
If mass
is not specified, use the already existing masses or auto-assign them.
Source code in atomlib/atoms.py
with_symbol
with_symbol(
symbols: ArrayLike,
selection: Optional[AtomSelection] = None,
) -> Self
Return self
with the given atomic symbols.
Source code in atomlib/atoms.py
with_coords
with_coords(
pts: ArrayLike,
selection: Optional[AtomSelection] = None,
*,
frame: Literal["local"] = "local"
) -> Self
Return self
replaced with the given atomic positions.
Source code in atomlib/atoms.py
with_velocity
with_velocity(
pts: Optional[ArrayLike] = None,
selection: Optional[AtomSelection] = None,
) -> Self
Return self
replaced with the given atomic velocities.
If pts
is not specified, use the already existing velocities or zero.
Source code in atomlib/atoms.py
read
classmethod
read(path: FileOrPath, ty: FileType) -> HasAtomsT
read(
path: FileOrPath, ty: Optional[FileType] = None
) -> HasAtomsT
Read a structure from a file.
Supported types can be found in the io module.
If no ty
is specified, it is inferred from the file's extension.
Source code in atomlib/mixins.py
read_cif
classmethod
read_cif(
f: Union[FileOrPath, CIF, CIFDataBlock],
block: Union[int, str, None] = None,
) -> HasAtomsT
Read a structure from a CIF file.
If block
is specified, read data from the given block of the CIF file (index or name).
Source code in atomlib/mixins.py
read_xyz
classmethod
read_xyz(f: Union[FileOrPath, XYZ]) -> HasAtomsT
read_xsf
classmethod
read_xsf(f: Union[FileOrPath, XSF]) -> HasAtomsT
read_cfg
classmethod
read_cfg(f: Union[FileOrPath, CFG]) -> HasAtomsT
read_lmp
classmethod
read_lmp(
f: Union[FileOrPath, LMP],
type_map: Optional[Dict[int, Union[str, int]]] = None,
) -> HasAtomsT
Read a structure from a LAAMPS data file.
Source code in atomlib/mixins.py
write_cif
write_cif(f: FileOrPath)
write_xyz
write_xyz(f: FileOrPath, fmt: XYZFormat = 'exyz')
write_xsf
write_xsf(f: FileOrPath)
write_cfg
write_cfg(f: FileOrPath)
write_lmp
write_lmp(f: FileOrPath)
write
write(path: FileOrPath, ty: FileType)
write(path: FileOrPath, ty: Optional[FileType] = None)
Write this structure to a file.
A file type may be specified using ty
.
If no ty
is specified, it is inferred from the path's extension.
Source code in atomlib/mixins.py
empty
staticmethod
empty() -> Atoms
get_atoms
with_atoms
bbox
bbox() -> BBox3D