[CP2K:9280] Outputting cell information and fractional coordinates

Efrem Braun efrem... at gmail.com
Sat Aug 26 19:27:39 UTC 2017

Thanks Steve. It's very peculiar to me that CP2K would write out the PDB 
files without aligning the axes as per the normal convention; I think 
there's probably a lot of people that are doing what I did, i.e., assuming 
that the convention is being followed and that the output can be converted 
to other file formats using tools such as openbabel and pwtools. I'm sure 
the CP2K developers have a good reason for having chosen to do this, such 
as FX's point that it makes for better visualization. In that case, it 
might be a good idea to include a sentence in the documentation that the 
printed trajectory is for visualization purposes only. Otherwise, one needs 
to hope that the user will have read this thread to know how to use the 
output properly (I only knew about this because a CP2K user in my group 
expressly warned me against using the printed trajectory and pointed me to 
this thread).

On Saturday, August 26, 2017 at 7:10:47 PM UTC+2, Steve Schmerler wrote:
> 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 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cp2k.org/archives/cp2k-user/attachments/20170826/0de2cdc3/attachment.htm>

More information about the CP2K-user mailing list