Disorder in crystal structure¶
Introduction¶
The class ccdc.crystal.Crystal.Disorder
describes the disorder in a
crystal structure. We can investigate the disorder and make selection of the
available disorder groups.
Loading a structure¶
>>> from functools import reduce
>>> import operator
>>> from ccdc import crystal
>>> from ccdc import io
Here we load a cif file for a crystal structure with multiple disorder assemblies.
>>> cry_reader = io.CrystalReader(disorder_crystal_cif_file)
>>> cry = cry_reader[0]
>>> cry.has_disorder
True
>>> cry.disorder.is_suppressed
False
Investigate crystal disorder¶
The disorder in this structure is not suppressed, which means the disorder is fully represented, and we are able to work with individual disorder groups.
>>> len(cry.disorder.assemblies)
3
>>> [len(assembly.groups) for assembly in cry.disorder.assemblies]
[2, 2, 2]
There are three disorder assemblies, each with two disorder groups. By default, the first disorder group of each disorder assembly is active. Let’s select the second disorder group of the second disorder assembly as active. The void volume of the crystal structure changes as a result.
>>> [assembly.active.id for assembly in cry.disorder.assemblies]
[0, 0, 0]
>>> round(cry.void_volume(probe_radius=0.6, grid_spacing=0.3), 2)
21.56
>>> cry.disorder.assemblies[1].groups[1].activate()
>>> [assembly.active.id for assembly in cry.disorder.assemblies]
[0, 1, 0]
>>> round(cry.void_volume(probe_radius=0.6, grid_spacing=0.3), 2)
21.75
Going through all combinations of the disorder¶
The ccdc.crystal.Crystal.Disorder.combinations
attribute returns an
iterator that yields all combinations of the disorder groups. The crystal is
updated accordingly with the yielded disorder groups. This provides a
convenient way to calculate crystal property taking into account the disorder
occupancies.
>>> void_vol = 0
>>> for active_groups in cry.disorder.combinations:
... vol = cry.void_volume(probe_radius=0.6, grid_spacing=0.3)
... occ = reduce(operator.mul, [group.occupancy for group in active_groups], 1)
... void_vol += vol * occ
>>> print(f'The disorder averaged void volume is {void_vol:.2f} cubic angstroms')
The disorder averaged void volume is 22.05 cubic angstroms