[CP2K:9280] Outputting cell information and fractional coordinates

Steve Schmerler elco... at gmail.com
Sat Aug 26 19:10:41 CEST 2017


On Aug 02 04:43 -0700, Efrem Braun wrote:
> Similar question applies when using pwtools. io.write_cif is happy to write 
> a cif file in fractional coordinates given a CP2K output pdb, but is it 
> assuming that CP2K was writing the pdb using a convention that CP2K isn't 
> using?

Hi Efrem

Sorry for being late on this topic. I just stumbled across your mail
mentioning pwtools, so I'd like to answer your question.

pwtools.io.read_pdb() uses pwtools.parse.PDBFile [1] which is a *very
very* basic parser that only extracts cartesian coordinates (ATOM
record), cell parameters (CRYST1 record) and atom symbols. It doesn't
care where the PDB file comes from, so it doesn't assume any
CP2K-specific information [*]. I haven't used CP2K's PDB output, so I
don't know if there is any additional information that may get ignored.

pwtools calculates the cell matrix using the same convention [2] that
Matthias mentioned in this thread some time ago (a along x, b in x-y
plane). Therefore the cell matrix of the Structure object (st.cell from
st=pwtools.io.read_pdb('foo.pdb')) is aligned as described. For
instance:

	In [9]: from pwtools import io as pwio
	In [10]: st=pwio.read_pdb('pwtools/test/files/pdb_struct.pdb')
	In [11]: st.cryst_const
	Out[11]: array([ 10.678,  10.678,  10.678,  90.   ,  90.   ,  90.   ])
	In [12]: st.cell
	Out[12]: 
	array([[  1.06780000e+01,   0.00000000e+00,   0.00000000e+00],
		   [  6.53838926e-16,   1.06780000e+01,   0.00000000e+00],
		   [  6.53838926e-16,   6.53838926e-16,   1.06780000e+01]])


If you have only cell parameters a,b,c,alpha,beta,gamma as in PDB or CIF
files, then there is no other way of calculating the cell, i.e. you need
to specify an orientation of the cell. This is why you get in trouble if
you only have cartesian atom coordinates and cell parameters available
and if the cartesian coordinates don't match (are not aligned with) the
cell calculated using the above convention (or any convention for that
matter). In that case, you are out of luck. In particular, the PDB
parser has no way of inferring whether the cartesian coordinates are
aligned.

If using DCD, you can use DCD_ALIGNED_CELL in a new calculation as
mentioned. What you can also do is let CP2K write .cell text files
which, IIRC, contain the cell vectors in Angstrom. Along with the XYZ
files of cartesian atom coordinates, you can then calculate fractional
coordinates from that. See [3] for how this is done in pwtools. If you
find any errors, please let me know! :) In general, I'd write fractional
coordinates whenever possible and avoid formats such as PDB. However,
last time I checked, CP2K has no option to write fractional coordinates
(I may be wrong, I haven't used it for a while).

[1] https://github.com/elcorto/pwtools/blob/master/parse.py#L441
[2] https://github.com/elcorto/pwtools/blob/master/crys.py#L190
[3] http://elcorto.github.io/pwtools/written/background/coord_trans.html

[*] pwtools is in no way affiliated with the CP2K project, even though it
    can parse CP2K output and is linked from the CP2K wiki :)

best,
Steve



More information about the CP2K-user mailing list