Pseudo-tetragonal twinning


5/6: Generate 'HKLF 5' format dataset

The crystal is a four-fold twin in which individuals are related by successive rotation of 90° about the c-axis of the pseudo-tetragonal I-centered cell. A positive rotation of 90° (anticlockwise about c) is achieved by this matrix:

 
4+
[001]
 
=
0
-1
0
1
0
0
0
0
1

Repeated application generates four matrices. Starting with the identity matrix, these are:

 
T
1
=
1
 0
0
0
1
0
0
0
1
 
; T
2
=
0
-1
0
1
0
0
0
0
1
 
; T
3
=
-1
0
0
0
-1
0
0
0
1
 
; T
4
=
0
1
0
-1
0
0
0
0
1

There is no 'best' way to generate the required 'HKLF 5' format datafile. One could write a short Fortran program (or Python script, etc.) to create the file, but the task is quite straightforward and does not require any programming beyond simple text file manipulation. The following describes a logical step-by-step approach that is trivial to adapt to other cases.

Step 1: Split data into separate components
For each of the four individuals, write separate files with indices transformed by the above four matrices. For this, the unix utility awk  is again ideal. The order does not matter, but it makes sense to go stepwise about the (pseudo) four-fold. From an xterm  or other command-line terminal, issue the following commands:
awk '{print $1, $2, $3, $4, $5, 1, NR}' monI.hkl > step1-1.txt
awk '{print -$2, $1, $3, $4, $5, 2, NR}' monI.hkl > step1-2.txt
awk '{print -$1,-$2, $3, $4, $5, 3, NR}' monI.hkl > step1-3.txt
awk '{print $2,-$1, $3, $4, $5, 4, NR}' monI.hkl > step1-4.txt

In the above, a batch number (1-4) is appended to distinguish each component. In an 'HKLF 5' file, the last member of a group of twin-related reflections needs a positive batch number, with the rest negative. The above also appends the line number of each reflection, which will be used to identify the last member of a group in order to fix the sign of the batch numbers (steps 5 and 6, below).

Step 2: Combine components
These files are to be combined, with lines interlaced in sequence. An easy way to achieve this is with the unix utility paste (also accessible on Windows via Cygwin ), which does a 'parallel merge'. We'll trick paste into putting each component on consecutive lines by changing the delimiter from the default (tab) to a newline (\n) character:
paste -d"\n" step1-1.txt step1-2.txt step1-3.txt step1-4.txt > step2.txt

The above writes a file in which contributions to each measured intensity are grouped with sequential batch numbers.

Step 3: Transform from monoclinic-I to monoclinic-P
Transformation from the I-centered setting to primitive monoclinic is via the following matrix:

 
T
I→P
 
=
 0.5
0
 0.5
  0
-0.5
 0
 0.5
0
 -0.5 

This is the same matrix suggested by ADDSYM in section 3. To apply it, we can again use awk :
awk '{print ($1+$3)/2, -$2/2, ($1-$3)/2, $4, $5, $6, $7}' step2.txt > step3.txt

As stated earlier, this produces some lines with non-integer indices, which must be discarded.

Step 4: Eliminate non-integer indices
There are numerous ways to discard lines that have acquired non-integer indices. The following line of awk, for example, only accepts lines that have two dot "." characters.
awk -F. 'NF==3' step3.txt > step4.txt

This works because an 'HKLF 5' file should only have decimal points in the F2 and σ (F2) fields. Note, however, some hkl files written by Platon store F2 and σ (F2) as integers, and thus should have no decimal points at all. Those would need a modified condition (i.e. 'NF==1') in the above one-liner.

Step 5: Flag last member of each twin-related group
We need a way to make the batch number of the last member of each group of twin-related reflections positive and the rest negative. The following awk one-liner gets us part way there:
awk 'NR==1{printf "%s", $0; next}; {print " " $NF; printf "%s", $0}' step4.txt > step5.txt

It writes a new file with each line appended with an extra field, which contains the original line number of the next reflection.

Step 6: Generate 'HKLF 5' format hkl file
The last step sets batch numbers for the last member of each group positive and the rest negative:
awk '{if ($(NF-1)==$(NF)) {m=-1} else {m=1}; printf "%4d%4d%4d%8.2f%8.2f%4d\n", $1, $2, $3, $4, $5, $6*m}' step5.txt > step6.hkl

In the above, original line numbers of consecutive reflections are compared and their signs fixed, as per the 'HKLF 5' format rules. Lastly, it writes an hkl file formatted as '3I4,2F8.2,I4'. A copy is available here:

step6.hkl

The fastidious might want to manually edit the file termination line(s), but SHELXL doesn't care. In the last section we'll use this hkl file and the res file from ADDSYM (i.e. monI_pl.res) to complete the refinement using all the data and with the correct space-group symmetry.



1: Introduction
2: Analysis and file set up with XPREP
3: Solve the structure in I2/a using SHELXD
4: Find true space group symmetry using Platon
5: Generate 'HKLF 5' format dataset
6: Complete four-fold P2/n twin refinement

Return to the main Tutorials page or to the main X-Ray Lab page