Crystal Structure
Categories:
For many different tasks performed in the PM suite, a crystal structure, or some component of a crystal structure, must be provided to the code. Most likely, this will be done using a yaml input file, and the two required key words are vec and atoms, which will contain the lattice vectors and the basis atoms, respectively. Considering the flourite structure, the most straightforward yaml file would be:
# xtal.yml
vec:
[[0.000000,2.764309,2.764309],
[2.764309,0.000000,2.764309],
[2.764309,2.764309,0.000000]]
atoms:
- Ca:
[[0,0,0]]
- F:
[[0.25,0.25,0.25],
[0.75,0.75,0.75]]
The code will infer that there is one basis atom labeled Ca and two basis atoms labeled F.
When entering matrices, we will always run the input through our general array parser (see parse_array if interested in the details). Therefore, there are many different options for entering a matrix as a string. For example, consider the following two examples:
scale: 2.764309
vec: |
0 1 1
1 0 1
1 1 0
atoms:
- Ca: |
0 0 0
- F: |
1/4 1/4 1/4
3/4 3/4 3/4
scale: 2.764309
vec: 0 1 1 ; 1 0 1 ; 1 1 0
atoms:
- Ca: 0 0 0
- F: 1/4 1/4 1/4 ; 3/4 3/4 3/4
where scale is a constant that multiplies all lattice vectors (a list of three constants could have been provided), and the vertical lines tells yaml to expect a text block. Our parser has a hierarchy of delimiters, ranging from space, comma, semicolon, newline. In the above example, we have two types of delimiters (i.e. spaces and newlines), which tells the code to form a matrix.
Warning
Potential Errors in yaml input
In the case of syntax error in YAML file, a RuntimeError
will be thrown indicating the an error has
occurred during the YAML loading process. For example, with the following text as YAML input:
scale: 2.764309
vec: |
0 1 1 ; 1 0 1 ; 1 1 0
atoms:
- Ca: |
0 0 0
- F: |
1/4 1/4 1/4 ; 3/4 3/4 3/4
The following error message will appear:
RuntimeError: Following error occured processing input YAML string:
ScannerError: while scanning a simple key
in "<unicode string>", line 6, column 5
could not find expected ':'
in "<unicode string>", line 7, column 3
Prototype Crystal Structures
There are a number of very common crystal structures that are adopted in numerous compounds, such as rock salt, flourite, etc. There is a simple command line script to output these crystal structures.
$ pm-prototype-xtal --perovskite
# Crystal
vec:
[[ 3.91300000, 0.00000000, 0.00000000],
[ 0.00000000, 3.91300000, 0.00000000],
[ 0.00000000, 0.00000000, 3.91300000]]
atoms:
- Sr:
[[ 0.50000000, 0.50000000, 0.50000000]]
- Ti:
[[ 0.00000000, 0.00000000, 0.00000000]]
- O:
[[ 0.50000000, 0.00000000, 0.00000000],
[ 0.00000000, 0.50000000, 0.00000000],
[ 0.00000000, 0.00000000, 0.50000000]]
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.