Welcome to pyriodic’s documentation!¶
pyriodic is an in-development library to handle a database of three-dimensional structures. It also supports several simple manipulations of structures.
Installation¶
Install pyriodic from source on github:
pip install git+https://github.com/klarh/pyriodic.git#egg=pyriodic-structures
By default, pyriodic only ships with a few very simple structures; other libraries can be added by installing other packages, such as pyriodic-aflow, which contains structures from the AFLOW project.
API Reference¶
-
class
pyriodic.
Database
[source]¶ Manage an in-memory database of structures
Database objects wrap a sqlite database containing structure information. Structures can be added to and read from the database.
Databases should only be written to by a single thread at once.
Currently the only table populated in the database is unit_cells, with the fields:
- name (str): Short name of the structure type
- space_group (int): Integer representation of the space group of the structure
- size (int): Number of particles in the unit cell
- structure (
Structure
): Structure object
-
insert_unit_cell
(name, space_group, structure, cursor=None)[source]¶ Insert a unit cell into this database object
Parameters: - name – Short name of the structure
- space_group – Integer representation of the space group for the structure
- structure –
Structure
object to store - cursor – Database connection cursor (optional)
-
class
pyriodic.
Structure
(positions, types, box)[source]¶ Container for a single set of coordinates
Structure objects hold all of the important quantities for a structural example, like coordinates and the system box.
-
add_gaussian_noise
(magnitude)[source]¶ Add gaussian noise to each particle
Parameters: magnitude – Scale of the zero-mean gaussian nose Returns: A new Structure
with the gaussian noise applied.
-
replicate
(nx=1, ny=1, nz=1)[source]¶ Replicate the system a given number of times in each dimension
Parameters: - nx – Number of times to replicate in the x direction
- ny – Number of times to replicate in the y direction
- nz – Number of times to replicate in the z direction
Returns: A new
Structure
that has been replicated appropriately
-
replicate_upto
(N_target)[source]¶ Replicate the system to have at least a given number of particles
Replicas are iteratively added in the shortest dimension of the box until at least N_target particles are present.
Parameters: N_target – Minimum number of particles to have in the resulting structure Returns: A new Structure
that has been replicated appropriately
-
rescale_linear
(factor)[source]¶ Rescale all distances in the system by the given factor
The coordinates and box are scaled by the given factor.
Parameters: factor – Number to scale all lengths in the system by Returns: a new Structure
that has been scaled accordingly
-
rescale_number_density
(phi)[source]¶ Rescale the system to the given number density
The box and all coordinates are scaled by an appropriate factor to produce a box with the given number density (number of particles/volume).
Parameters: phi – Number density of the resulting system Returns: a new Structure
with the given density
-
rescale_shortest_distance
(l)[source]¶ Rescale the system to have the given shortest distance between points
The box and all coordinates are scaled by an appropriate factor to produce a system with the given shortest distance between any two points. This method is currently N^2 in the number of points, but may be improved in the future.
Parameters: l – Shortest distance of the resulting system Returns: a new Structure
with the given shortest distance
-