crystal
Contains the Crystal
objects, for 3D systems.
Crystal
Storage class for a molecular crystal structure.
Attributes:
Name | Type | Description |
---|---|---|
unit_cell |
UnitCell |
the translational symmetry |
space_group |
SpaceGroup |
the symmetry within the unit cell |
asymmetric_unit |
AsymmetricUnit |
the symmetry unique set of sites in the crystal. Contains information on atomic positions, elements, labels etc. |
properties |
dict |
variable collection of named properties for this crystal |
asym: AsymmetricUnit
property
readonly
short accessor for asymmetric_unit
density
property
readonly
Calculated density of this crystal structure in g/cm^3
id: str
property
readonly
synonym for titl
name: str
property
readonly
synonym for titl
nsites: int
property
readonly
The number of sites in the asymmetric unit.
sg: SpaceGroup
property
readonly
short accessor for space_group
site_atoms: ndarray
property
readonly
Array of asymmetric unit atomic numbers
site_labels
property
readonly
array of labels for sites in the asymmetric_unit
site_positions: ndarray
property
readonly
Row major array of asymmetric unit atomic positions
symmetry_operations: List[chmpy.crystal.symmetry_operation.SymmetryOperation]
property
readonly
Symmetry operations belonging to the space group symmetry of this crystal.
uc: UnitCell
property
readonly
short accessor for unit_cell
__init__(self, unit_cell, space_group, asymmetric_unit, **kwargs)
special
Construct a new crystal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
unit_cell |
UnitCell |
The unit cell for this crystal i.e. the translational symmetry of the crystal structure. |
required |
space_group |
SpaceGroup |
The space group symmetry of this crystal i.e. the generators for populating the unit cell given the asymmetric unit. |
required |
asymmetric_unit |
AsymmetricUnit |
The asymmetric unit of this crystal. The sites of this combined with the space group will generate all translationally equivalent positions. |
required |
**kwargs |
|
Optional properties to (will populate the properties member) store about the the crystal structure. |
{} |
Source code in chmpy/crystal/crystal.py
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 |
|
as_P1(self)
Create a copy of this crystal in space group P 1, with the new asymmetric_unit consisting of self.unit_cell_molecules()
Source code in chmpy/crystal/crystal.py
1658 1659 1660 1661 |
|
as_P1_supercell(self, size)
Create a supercell of this crystal in space group P 1.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size |
Tuple[int] |
size of the P 1 supercell to be created |
required |
Returns:
Type | Description |
---|---|
Crystal |
Crystal object of a supercell in space group P 1 |
Source code in chmpy/crystal/crystal.py
1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 |
|
asymmetric_unit_partial_charges(self)
Calculate the partial charges for the asymmetric unit of this crystal using the EEM method.
Returns:
Type | Description |
---|---|
ndarray |
an |
Source code in chmpy/crystal/crystal.py
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 |
|
atom_group_shape_descriptors(self, atoms, l_max=5, radius=6.0)
Calculate the shape descriptors[1,2] for the given atomic group in this crystal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
atoms |
Tuple |
atoms to include in the as the 'inside' of the shape description. |
required |
l_max |
int |
maximum level of angular momenta to include in the spherical harmonic transform of the molecular shape function. |
5 |
radius |
float |
maximum distance (Angstroms) to include surroundings in the shape description |
6.0 |
Returns:
Type | Description |
---|---|
ndarray |
shape description vector |
References:
[1] PR Spackman et al. Sci. Rep. 6, 22204 (2016)
https://dx.doi.org/10.1038/srep22204
[2] PR Spackman et al. Angew. Chem. 58 (47), 16780-16784 (2019)
https://dx.doi.org/10.1002/anie.201906602
Source code in chmpy/crystal/crystal.py
1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 |
|
atom_group_surroundings(self, atoms, radius=6.0)
Calculate all atoms within the given radius
of the specified
group of atoms in the asymetric unit.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
radius |
float |
the maximum distance (Angstroms) from the origin for inclusion |
6.0 |
Returns:
Type | Description |
---|---|
Tuple |
A list of atomic number, Cartesian position for both the atomic sites in question and their surroundings (as an array) |
Source code in chmpy/crystal/crystal.py
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 |
|
atomic_shape_descriptors(self, l_max=5, radius=6.0, return_coefficients=False)
Calculate the shape descriptors[1,2] for all symmetry unique atoms in this crystal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
l_max |
int |
maximum level of angular momenta to include in the spherical harmonic transform of the molecular shape function. |
5 |
radius |
float |
maximum distance (Angstroms) to include surroundings in the shape description |
6.0 |
return_coefficients |
bool |
also return the spherical harmonic coefficients |
False |
Returns:
Type | Description |
---|---|
ndarray |
shape description vector |
References:
[1] PR Spackman et al. Sci. Rep. 6, 22204 (2016)
https://dx.doi.org/10.1038/srep22204
[2] PR Spackman et al. Angew. Chem. 58 (47), 16780-16784 (2019)
https://dx.doi.org/10.1002/anie.201906602
Source code in chmpy/crystal/crystal.py
1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 |
|
atomic_surroundings(self, radius=6.0)
Calculate all atoms within the given radius
of
each atomic site in the asymmetric unit.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
radius |
float |
the maximum distance (Angstroms) from the origin for inclusion |
6.0 |
Returns:
Type | Description |
---|---|
List[Tuple] |
A list of atomic number, Cartesian position for both the atomic site in question and the surroundings (as an array) |
Source code in chmpy/crystal/crystal.py
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 |
|
atoms_in_radius(self, radius, origin=(0, 0, 0))
Calculate all (periodic) atoms within the given radius
of the specified
origin
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
radius |
float |
the maximum distance (Angstroms) from the origin for inclusion |
required |
origin |
Tuple |
the origin in fractional coordinates |
(0, 0, 0) |
Returns:
Type | Description |
---|---|
dict |
A dictionary mapping (see the the |
Source code in chmpy/crystal/crystal.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 |
|
cartesian_symmetry_operations(self)
Create a list of symmetry operations (rotation, translation) for evaluation of transformations in cartesian space.
The rotation matrices are stored to be used as np.dot(x, R), (i.e. post-multiplicaiton on row-major coordinates)
Returns:
Type | Description |
---|---|
List[Tuple[np.ndarray, np.ndarray]] |
a list of (rotation, translation) |
Source code in chmpy/crystal/crystal.py
1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 |
|
choose_trigonal_lattice(self, choice='H')
Change the choice of lattice for this crystal to either rhombohedral or hexagonal cell
Parameters:
Name | Type | Description | Default |
---|---|---|---|
choice |
str |
The choice of the resulting lattice, either 'H' for hexagonal or 'R' for rhombohedral (default 'H'). |
'H' |
Source code in chmpy/crystal/crystal.py
1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 |
|
from_cif_data(cif_data, titl=None)
classmethod
Initialize a crystal structure from a dictionary of CIF data
Source code in chmpy/crystal/crystal.py
1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 |
|
from_cif_file(filename, data_block_name=None)
classmethod
Initialize a crystal structure from a CIF file
Source code in chmpy/crystal/crystal.py
1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 |
|
from_shelx_file(filename, **kwargs)
classmethod
Initialize a crystal structure from a shelx .res file
Source code in chmpy/crystal/crystal.py
1423 1424 1425 1426 1427 1428 |
|
from_shelx_string(file_content, **kwargs)
classmethod
Initialize a crystal structure from a shelx .res string
Source code in chmpy/crystal/crystal.py
1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 |
|
from_vasp_file(filename, **kwargs)
classmethod
Initialize a crystal structure from a VASP POSCAR file
Source code in chmpy/crystal/crystal.py
1322 1323 1324 1325 |
|
from_vasp_string(string, **kwargs)
classmethod
Initialize a crystal structure from a VASP POSCAR string
Source code in chmpy/crystal/crystal.py
1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 |
|
functional_group_shape_descriptors(self, l_max=5, radius=6.0, kind='carboxylic_acid')
Calculate the shape descriptors [1,2]
for the all atoms in the functional group
given for all symmetry unique molecules in this crystal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
l_max |
int |
maximum level of angular momenta to include in the spherical harmonic transform of the molecular shape function. (default: 5) |
5 |
radius |
float |
maximum distance (Angstroms) of neighbouring atoms to include in stockholder weight calculation (default: 5) |
6.0 |
kind |
str |
Identifier for the functional group type (default: 'carboxylic_acid') |
'carboxylic_acid' |
Returns:
Type | Description |
---|---|
ndarray |
shape description vector |
References:
[1] PR Spackman et al. Sci. Rep. 6, 22204 (2016)
https://dx.doi.org/10.1038/srep22204
[2] PR Spackman et al. Angew. Chem. 58 (47), 16780-16784 (2019)
https://dx.doi.org/10.1002/anie.201906602
Source code in chmpy/crystal/crystal.py
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 |
|
functional_group_surroundings(self, radius=6.0, kind='carboxylic_acid')
Calculate the atomic information for all atoms surrounding each functional group in each symmetry unique molecule in this crystal within the given radius.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
radius |
float |
Maximum distance in Angstroms between any atom in the molecule and the resulting neighbouring atoms |
6.0 |
kind |
str |
the functional group type |
'carboxylic_acid' |
Returns:
Type | Description |
---|---|
List |
A list of tuples of (func_el, func_pos, neigh_el, neigh_pos)
where |
Source code in chmpy/crystal/crystal.py
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 |
|
hirshfeld_surfaces(self, **kwargs)
Alias for self.stockholder_weight_isosurfaces
Source code in chmpy/crystal/crystal.py
904 905 906 |
|
load(filename, **kwargs)
classmethod
Load a crystal structure from file (.res, .cif)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
str |
the path to the crystal structure file |
required |
Returns:
Type | Description |
---|---|
Union[Crystal, dict] |
the resulting crystal structure or dictionary of crystal structures |
Source code in chmpy/crystal/crystal.py
1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 |
|
mesh_scene(self, **kwargs)
Calculate a scene of this meshes of unit cell molecules in this crystal, along with optional void surface.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs |
|
optional arguments used in the generation of this scene. |
{} |
Returns:
Type | Description |
---|---|
trimesh.scene.Scene |
trimesh scene object. |
Source code in chmpy/crystal/crystal.py
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 |
|
molecular_shape_descriptors(self, l_max=5, radius=6.0, with_property=None, return_coefficients=False)
Calculate the molecular shape descriptors[1,2] for all symmetry unique molecules in this crystal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
l_max |
int |
maximum level of angular momenta to include in the spherical harmonic transform of the molecular shape function. |
5 |
radius |
float |
maximum distance (Angstroms) to include surroundings in the shape description |
6.0 |
with_property |
str |
name of the surface property to include in the shape description |
None |
return_coefficients |
bool |
also return the spherical harmonic coefficients |
False |
Returns:
Type | Description |
---|---|
ndarray |
shape description vector |
References:
[1] PR Spackman et al. Sci. Rep. 6, 22204 (2016)
https://dx.doi.org/10.1038/srep22204
[2] PR Spackman et al. Angew. Chem. 58 (47), 16780-16784 (2019)
https://dx.doi.org/10.1002/anie.201906602
Source code in chmpy/crystal/crystal.py
1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 |
|
molecular_shell(self, mol_idx=0, radius=3.8, method='nearest_atom')
Calculate the neighbouring molecules around the molecule with index
mol_idx
, within the given radius
using the specified method
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol_idx |
int |
The index (into |
0 |
radius |
float |
The maximum distance (Angstroms) between the central molecule and the neighbours. |
3.8 |
method |
str |
the method to use when determining inclusion of neighbours. |
'nearest_atom' |
Returns:
Type | Description |
---|---|
List[chmpy.core.molecule.Molecule] |
A list of neighbouring molecules using the given method. |
Source code in chmpy/crystal/crystal.py
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 |
|
molecule_dict(self, **kwargs)
A dictionary of symmetry_unique_molecules
, grouped by
their chemical formulae.
Returns:
Type | Description |
---|---|
dict |
the dictionary of molecules with chemical formula keys and list of molecule values. |
Source code in chmpy/crystal/crystal.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
|
molecule_environment(self, mol, radius=6.0, threshold=0.001)
Calculate the atomic information for all
atoms surrounding the given molecule in this crystal
within the given radius. Atoms closer than threshold
to any atom in the provided molecule will be excluded and
considered part of the molecule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mol |
Molecule |
the molecule whose environment to calculate |
required |
radius |
float |
Maximum distance in Angstroms between any atom in the molecule and the resulting neighbouring atoms |
6.0 |
threshold |
float |
tolerance for detecting the neighbouring sites as part of the given molecule. |
0.001 |
Returns:
Type | Description |
---|---|
Tuple |
A list of tuples of (Molecule, elements, positions)
where |
Source code in chmpy/crystal/crystal.py
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 |
|
molecule_environments(self, radius=6.0, threshold=0.001)
Calculate the atomic information for all atoms surrounding each symmetry unique molecule in this crystal within the given radius.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
radius |
float |
Maximum distance in Angstroms between any atom in the molecule and the resulting neighbouring atoms |
6.0 |
threshold |
float |
tolerance for detecting the neighbouring sites as part of the given molecule. |
0.001 |
Returns:
Type | Description |
---|---|
List[Tuple] |
A list of tuples of (Molecule, elements, positions)
where |
Source code in chmpy/crystal/crystal.py
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 |
|
molecule_shape_descriptors(self, mol, l_max=5, radius=6.0, with_property=None)
Calculate the molecular shape descriptors [1,2]
for
the provided molecule in the crystal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
l_max |
int |
maximum level of angular momenta to include in the spherical harmonic transform of the molecular shape function. |
5 |
radius |
float |
maximum distance (Angstroms) to include surroundings in the shape description |
6.0 |
with_property |
str |
name of the surface property to include in the shape description |
None |
Returns:
Type | Description |
---|---|
ndarray |
shape description vector |
References:
[1] PR Spackman et al. Sci. Rep. 6, 22204 (2016)
https://dx.doi.org/10.1038/srep22204
[2] PR Spackman et al. Angew. Chem. 58 (47), 16780-16784 (2019)
https://dx.doi.org/10.1002/anie.201906602
Source code in chmpy/crystal/crystal.py
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 1086 1087 1088 |
|
promolecule_density_isosurfaces(self, **kwargs)
Calculate promolecule electron density isosurfaces for each symmetry unique molecule in this crystal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs |
|
Keyword arguments used by Options are:
|
{} |
Returns:
Type | Description |
---|---|
List[trimesh.base.Trimesh] |
A list of meshes representing the promolecule density isosurfaces |
Source code in chmpy/crystal/crystal.py
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 |
|
save(self, filename, **kwargs)
Save this crystal structure to file (.cif, .res, POSCAR)
Source code in chmpy/crystal/crystal.py
1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 |
|
slab(self, bounds=((-1, -1, -1), (1, 1, 1)))
Calculate the atoms and associated information for a slab consisting of multiple unit cells.
If unit cell atoms have not been calculated, this calculates their information and caches it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bounds |
Tuple |
Tuple of upper and lower corners (hkl) describing the bounds of the slab. |
((-1, -1, -1), (1, 1, 1)) |
Returns:
Type | Description |
---|---|
dict |
A dictionary of arrays associated with all sites contained in the unit cell of this crystal, members are: asym_atom: corresponding asymmetric unit atom indices for all sites. frac_pos: (N, 3) array of fractional positions for all sites. cart_pos: (N, 3) array of cartesian positions for all sites. element: (N) array of atomic numbers for all sites. symop: (N) array of indices corresponding to the generator symmetry operation for each site. label: (N) array of string labels corresponding to each site occupation: (N) array of occupation numbers for each site. Will warn if any of these are greater than 1.0 cell: (N,3) array of cell indices for each site n_uc: number of atoms in the unit cell n_cells: number of cells in this slab occupation: (N) array of occupation numbers for each site. Will warn if any of these are greater than 1.0 |
Source code in chmpy/crystal/crystal.py
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 |
|
stockholder_weight_isosurfaces(self, kind='mol', **kwargs)
Calculate stockholder weight isosurfaces (i.e. Hirshfeld surfaces) for each symmetry unique molecule or atom in this crystal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kind |
str |
dictates whether we calculate surfaces for each unique molecule or for each unique atom |
'mol' |
kwargs |
|
keyword arguments passed to Options include:
|
{} |
Returns:
Type | Description |
---|---|
List[trimesh.base.Trimesh] |
A list of meshes representing the stockholder weight isosurfaces |
Source code in chmpy/crystal/crystal.py
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 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 |
|
symmetry_unique_dimers(self, radius=3.8, distance_method='nearest_atom')
Calculate the information for all molecule pairs surrounding the symmetry_unique_molecules in this crystal within the given radius.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
radius |
float |
Maximum distance in Angstroms between any atom in the molecule and the resulting neighbouring atoms |
3.8 |
Returns:
Type | Description |
---|---|
|
A dictionary of dimers (Molecule, elements, positions)
where |
Source code in chmpy/crystal/crystal.py
1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 |
|
symmetry_unique_molecules(self, bond_tolerance=0.4)
Calculate a list of connected molecules which contain every site in the asymmetric_unit
Populates the _symmetry_unique_molecules member, subsequent calls to this function will be a no-op.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bond_tolerance |
float |
Bonding tolerance (bonded if d < cov_a + cov_b + bond_tolerance) |
0.4 |
Returns:
Type | Description |
---|---|
List[chmpy.core.molecule.Molecule] |
List of all connected molecules in the asymmetric_unit of this crystal, i.e. the minimum list of connected molecules which contain all sites in the asymmetric unit. If the asymmetric is molecular, the list will be of length num_molecules_in_asymmetric_unit and the total number of atoms will be equal to the number of atoms in the asymmetric_unit |
Source code in chmpy/crystal/crystal.py
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 |
|
to_cartesian(self, coords)
Convert coordinates (row major) from fractional to cartesian coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coords |
np.ndarray |
(N, 3) array of positions assumed to be in fractional coordinates |
required |
Returns:
Type | Description |
---|---|
ndarray |
(N, 3) array of positions transformed to cartesian (orthogonal) coordinates by the unit cell of this crystal. |
Source code in chmpy/crystal/crystal.py
104 105 106 107 108 109 110 111 112 113 114 115 |
|
to_cif_data(self, data_block_name=None)
Convert this crystal structure to cif data dict
Source code in chmpy/crystal/crystal.py
1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 |
|
to_cif_file(self, filename, **kwargs)
save this crystal to a CIF formatted file
Source code in chmpy/crystal/crystal.py
1570 1571 1572 1573 |
|
to_cif_string(self, **kwargs)
save this crystal to a CIF formatted string
Source code in chmpy/crystal/crystal.py
1575 1576 1577 1578 |
|
to_fractional(self, coords)
Convert coordinates (row major) from cartesian to fractional coordinates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coords |
np.ndarray |
(N, 3) array of positions assumed to be in cartesian (orthogonal) coordinates |
required |
Returns:
Type | Description |
---|---|
ndarray |
(N, 3) array of positions transformed to fractional coordinates by the unit cell of this crystal. |
Source code in chmpy/crystal/crystal.py
117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
to_poscar_file(self, filename, **kwargs)
save this crystal to a VASP POSCAR formatted file
Source code in chmpy/crystal/crystal.py
1586 1587 1588 |
|
to_poscar_string(self, **kwargs)
save this crystal to a VASP POSCAR formatted string
Source code in chmpy/crystal/crystal.py
1580 1581 1582 1583 1584 |
|
to_shelx_file(self, filename)
Write this crystal structure as a shelx .res formatted file
Source code in chmpy/crystal/crystal.py
1590 1591 1592 |
|
to_shelx_string(self, titl=None)
Represent this crystal structure as a shelx .res formatted string
Source code in chmpy/crystal/crystal.py
1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 |
|
to_translational_symmetry(self, supercell=(1, 1, 1))
Create a supercell of this crystal in space group P 1.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
supercell |
Tuple[int] |
size of the supercell to be created |
(1, 1, 1) |
Returns:
Type | Description |
---|---|
Crystal |
Crystal object of a supercell in space group P 1 |
Source code in chmpy/crystal/crystal.py
1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 |
|
unit_cell_atoms(self, tolerance=0.01)
Generate all atoms in the unit cell (i.e. with fractional coordinates in [0, 1]) along with associated information about symmetry operations, occupation, elements related asymmetric_unit atom etc.
Will merge atom sites within tolerance of each other, and sum their occupation numbers. A warning will be logged if any atom site in the unit cell has > 1.0 occupancy after this.
Sets the _unit_cell_atom_dict
member as this is an expensive
operation and is worth caching the result. Subsequent calls
to this function will be a no-op.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tolerance |
float |
Minimum separation of sites in the unit cell, below which atoms/sites will be merged and their (partial) occupations added. |
0.01 |
Returns:
Type | Description |
---|---|
dict |
A dictionary of arrays associated with all sites contained in the unit cell of this crystal, members are:
|
Source code in chmpy/crystal/crystal.py
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 |
|
unit_cell_connectivity(self, tolerance=0.4, neighbouring_cells=1)
Periodic connectiviy for the unit cell, populates _uc_graph with a networkx.Graph object, where nodes are indices into the _unit_cell_atom_dict arrays and the edges contain the translation (cell) for the image of the corresponding unit cell atom with the higher index to be bonded to the lower
Bonding is determined by interatomic distances being less than the sum of covalent radii for the sites plus the tolerance (provided as a parameter)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tolerance |
float |
Bonding tolerance (bonded if d < cov_a + cov_b + tolerance) |
0.4 |
neighbouring_cells |
int |
Number of neighbouring cells in which to look for bonded atoms. We start at the (0, 0, 0) cell, so a value of 1 will look in the (0, 0, 1), (0, 1, 1), (1, 1, 1) i.e. all 26 neighbouring cells. 1 is typically sufficient for organic systems. |
1 |
Returns:
Type | Description |
---|---|
Tuple |
A tuple of (sparse_matrix in dict of keys format, dict) the (i, j) value in this matrix is the bond length from i,j the (i, j) value in the dict is the cell translation on j which bonds these two sites |
Source code in chmpy/crystal/crystal.py
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 |
|
unit_cell_molecules(self)
Calculate the molecules for all sites in the unit cell, where the number of molecules will be equal to number of symmetry unique molecules times number of symmetry operations.
Returns:
Type | Description |
---|---|
List[chmpy.core.molecule.Molecule] |
A list of all connected molecules in this crystal, which when translated by the unit cell would produce the full crystal. If the asymmetric is molecular, the list will be of length num_molecules_in_asymmetric_unit * num_symm_operations |
Source code in chmpy/crystal/crystal.py
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 |
|
void_surface(self, *args, **kwargs)
Calculate void surface based on promolecule electron density for the unit cell of this crystal
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs |
|
Keyword arguments used in the evaluation of the surface. Options are:
|
{} |
Returns:
Type | Description |
---|---|
Trimesh |
the mesh representing the promolecule density void isosurface |
Source code in chmpy/crystal/crystal.py
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 |
|