The aim of the crystal module is to be able to easily manipulate all lattice parameters of a crystal and do some basic operation on atomic coordinate such as :
- Compute lattice vectors, volume
- Coordinates transformation
- input or output in VASP or CRYSTAL format
Today, symmetry is not considered. See python ASE for symetry support.
In the following we use a Cu2O crystal as an example.
>>> import crystal
>>> Cu2O = crystal.fromPOSCAR("POSCAR")
--------------------------------------------------
lattice parameters : Cu2O Bulk
--------------------------------------------------
a = 4.26000
b = 4.28000
c = 4.27000
alpha = 90.000
beta = 90.000
gamma = 90.000
--------------------------------------------------
class Crystal allows to describe and do operations on a crystal lattice
Parameters: |
|
---|
If you give the bravais lattice name you may not set all lattice parameters :
>>> cry = crystal.Crystal(a = 3., lattice = "cubic")
>>> print(cry)
--------------------------------------------------
lattice parameters :
--------------------------------------------------
a = 3.00000
b = 3.00000
c = 3.00000
alpha = 90.000
beta = 90.000
gamma = 90.000
--------------------------------------------------
If you give only the bravais lattice, the prompt will ask you parameters needed according to the bravais lattice.
>>> cry = crystal.Crystal(lattice = "hexagonal")
a = 3.
c = 7.
>>> print(cry)
--------------------------------------------------
lattice parameters :
--------------------------------------------------
a = 3.00000
b = 3.00000
c = 7.00000
alpha = 90.000
beta = 90.000
gamma = 120.000
--------------------------------------------------
You can give directly lattice vectors.
>>> cry = crystal.Crystal(veca = [2., 0., 0.], vecb = [-1., sqrt(3), 0.], vecc = [0., 0., 4.])
>>> cry.lattice
'hexagonal'
>>> print(cry)
--------------------------------------------------
lattice parameters :
--------------------------------------------------
a = 2.00000
b = 2.00000
c = 4.00000
alpha = 90.000
beta = 90.000
gamma = 120.000
--------------------------------------------------
You cannot set lattice parameters and lattice vectors at the same time. Only one of them can be set when you create a crystal object in order to ensure consistency between lattice vectors, lattice parameters and bravais lattice name. A method is available in order to print lattice vectors in a cartesian frame.
>>> cry = crystal.Crystal(lattice = "hexagonal")
a = 3.
c = 7.
>>> cry.printLatticeVectors()
--------------------------------------------------
Lattice vectors in cartesian frame : lattice is hexagonal
--------------------------------------------------
a = 3.0000000000 0.0000000000 0.0000000000
b = -1.5000000000 2.5980762114 0.0000000000
c = 0.0000000000 0.0000000000 7.0000000000
--------------------------------------------------
Lattice parameter a, lengths of the vectors :math:` ec{a}`
Lattice parameter b, lengths of the vectors :math:` ec{b}`
Lattice parameter c, lengths of the vectors :math:` ec{c}`
Lattice angle \(lpha\) . All angles must be given in degrees and are return in degrees. They are internally convert in radian when needed.
Lattice angle \(eta\) . All angles must be given in degrees and are return in degrees. They are internally convert in radian when needed.
Lattice angle \(\gamma\) . All angles must be given in degrees and are return in degrees. They are internally convert in radian when needed.
Lattice vector :math:` ec{a}` in a cartesian frame where :math:` ec{a}` is along x axes and :math:` ec{b}` is in the (x,y) plane.
Lattice vector :math:` ec{b}` in a cartesian frame where :math:` ec{a}` is along x axes and :math:` ec{b}` is in the (x,y) plane.
Lattice vector :math:` ec{c}` in a cartesian frame where :math:` ec{a}` is along x axes and :math:` ec{b}` is in the (x,y) plane.
volume of the unit cell.
Name of the lattice according to the 7 Bravais lattices. Remind that symmetry is not considered for the moment.
See bravaisLattice()
Name of the crystal object
number of unit formula
number of atoms in the unit cell
List of atom names of all atoms in the unit cell.
Symmetry group. Nevertheless, remind that symmetry is not considered.
List of cartesian coordinates of the atoms in the unit cell. This is a list object.
See computeRedCoord() and red2cart()
List of reduce coordinates of the atoms in the unit cell. This is a list object.
See computeXYZCoord() and cart2red()
Create a crystal object from a POSCAR/CONTCAR VASP structure file. The POSCAR file can be given as a list of string (lines of the POSCAR file) or you can give a file object, or a file name.
Parameters: |
|
---|
Create a crystal object from an output of CRYSTAL09 program. The function read the last crystallographic cell. Outputfile can be a file or a file name.
Parameters: |
|
---|
Convert reduce coordinate into cartesian coordinate.
Parameters: | x (list or array or ndarray, len(x) = 3) – cartesian coordinate vector |
---|---|
Return type: | list of lenght 3 |
Convert cartesian coordinate into reduce coordinate.
Parameters: | x (list or array or ndarray, len(x) = 3) – reduce coordinate vector |
---|---|
Return type: | list of lenght 3 |
Compute cartesian coordinates for all coordinates stored in self.redCoord.
Compute reduce coordinates for all coordinates stored in self.XYZCoord.
Return the shortest vector in reduce coordinates considering the periodic conditions.
Parameters: |
|
---|---|
Return type: | list |
r1 and r2 must be reduce coordinate and an object of length 3 ! In order to improve efficiency no check are done.
Compute the minimum distance between reduce coordinates r1 and r2 considering the periodic conditions.
Parameters: |
|
---|---|
Return type: | float |
Compute the minimum distance between cartesian coordinates x1 and x2 considering the periodic conditions.
Parameters: |
|
---|---|
Return type: | float |
Compute the minimum distance between atom with index iat and jat considering the periodic conditions.
Parameters: |
|
---|---|
Return type: | float |
Compute the distance between the cartesian postion fo the same atom in self and other structures.
Parameters: | other – crystal object |
---|---|
Return type: | list of distance |
For each atom of the crystal, if an image of the atom belonging to other is closer to the same atom belonging to self, the other’s atom is translated to that position.
This method could be usefull if one wants to compute displacements of atoms after a relaxation of the structre.
param other: crystal object rtype: list of distance
Warning :if lattices of self and other are not the same, this have not any sense.
Build a supercell from the cell defined by the object. Return a new Crystal object as output.
Parameters: |
|
---|---|
Return type: | Crystal |
(Under development) Write cartesian coordinate in a XYZ format
Parameters: | filename (string) – name of the output file. |
---|
Write crystal object in a vasp POSCAR file
Parameters: | filename (string) – name of the output file. |
---|