pwtools.random.RandomStructure

class pwtools.random.RandomStructure(symbols, vol_scale=4, angle_range=[60.0, 120.0], vol_range_scale=[0.7, 1.3], length_range_scale=[0.7, 1.3], close_scale=1, cell_maxtry=100, atom_maxtry=1000, verbose=False)[source]

Bases: object

Create a random structure, based on atom number and composition alone (symbols).

The mean target cell volume and cell side lengths are determined from covalent radii of all atoms (see pwtools.atomic_data.covalent_radii).

Examples

>>> rs = crys.RandomStructure(['Si']*50)
>>> st = rs.get_random_struct()

For many atoms (~ 200), the creation takes a while b/c as more and more atoms are already present, we need many more tries to get another random atom into the struct. Then, _atoms_too_close() is called a lot, which is the bottleneck. Hint: plot(rs.counters['coords']).

__init__(symbols, vol_scale=4, angle_range=[60.0, 120.0], vol_range_scale=[0.7, 1.3], length_range_scale=[0.7, 1.3], close_scale=1, cell_maxtry=100, atom_maxtry=1000, verbose=False)[source]
Parameters:
  • symbols (list of strings) – Atom symbols. Defines number of atoms and composition.

  • vol_scale (float) – Scale volume estimated from sum of covalent spheres (lower bound for volume). Only values > 1 make sense. This is used to get the mean target volume (increase “the holes” between spheres). Large values will create large cells with much space between atoms.

  • angle_range (sequence of 2 floats [min, max]) – Range of allowed random cell angles.

  • vol_range_scale (sequence of 2 floats [min, max]) – Scale estimated mean volume by min and max to get allowed volume range.

  • length_range_scale (sequence of 2 floats [min, max]) – Scale estimated mean cell side length (3rd root of mean volume) by min and max to get allowed cell side range.

  • close_scale (float) – Scale allowed distance between atoms (from sum of covalent radii). Use < 1.0 to make tightly packed structures, i.e. small values will allow close atoms, large values make big spaces but will also make the structure generation more likely to fail.

  • atom_maxtry (cell_maxtry /) – Maximal attempts to create a random cell / insert random atom into cell before RandomStructureFail is raised.

  • verbose (bool, optional) – Print stuff while trying to generate structs.

Methods

get_random_cryst_const()

Create random cryst_const.

get_random_struct([fail])

Generate random cryst_const and atom coords.