0. 前言以及AbiPy的介绍:

目前能实现各种计算结构文件之间相互转换的脚本或者软件非常之多,比如常用的VASPKIT软件、pymatgen、ase等。但是支持格式多,方便使用,而且可以双向任意转换的并不是很多。以下给出VASPKIT软件结构转换功能的截图:

数据结构的相关算法分析(AbiPy实现计算结构文件之间的相互转换)(1)

https://vaspkit.com/tutorials.html

AbiPy是一款基于python语言为Abinit程序开发的后处理程序,关于AbiPy的详细介绍可以参考Github (https://github.com/abinit/abipy):

AbiPy is a Python library to analyze the results produced by Abinit, an open-source program for the ab-initio calculations of the physical properties of materials within Density Functional Theory and Many-Body perturbation theory. It also provides tools to generate input FILEs and workflows to automate ab-initio calculations and typical convergence studies. AbiPy is interfaced with pymatgen and this allows users to benefit from the different tools and python objects available in the pymatgen ecosystem.

1. AbiPy的安装:

https://abinit.github.io/abipy/installation.html

pip install abipy

2. AbiPy中abistruct.py模块文件格式转换(convert)功能使用:

https://abinit.github.io/abipy/postprocessing_howto.html

安装好Abipy之后,可以输入下面命令查看abistruct.py convert功能的基本使用方法。

abistruct.py convert --help

usage: abistruct.py convert [-h] [-v] [--loglevel LOGLEVEL] [-f FORMAT] [filepath]positional arguments: filepath File with the crystalline structure (Abinit Netcdf files, CIF, Abinit input/output files, POSCAR ...)optional arguments: -h, --help show this help message and exit -v, --verbose verbose, can be supplied multiple times to increase verbosity --loglevel LOGLEVEL Set the loglevel. Possible values: CRITICAL, ERROR (default), WARNING, INFO, DEBUG -f FORMAT, --format FORMAT Output format. Default: cif. Accept: (abivars, cif, xsf, poscar, qe, siesta, wannier90, cssr, json, None)

以下给出了三种常见的文件转换使用示意,其中FILE是需要转换的文件名称如果没有指定-f参数,默认转换为cif文件格式。-f支持的文件格式见上面。

abistruct.py convert FILE # generate a CIF file (default behaviour).abistruct.py convert FILE -f xsf > out.xsfabistruct.py convert FILE -f poscar > POSCAR

以下以Materials Project网站的立方结构CsPbI3为例讲述cif和POSCAR之间的相互转换。首先下载得到下面文件:

CsPbI3_mp-1069538_conventional_standard.cif

第一步:实现cif到POSCAR之间的转换

abistruct.py convert CsPbI3_mp-1069538_conventional_standard.cif -f poscar > POSCAR

gtang@hexu-All-Series:~$ cat POSCARCs1 Pb1 I31.06.414145000000 0.000000000000 0.0000000000000.000000000000 6.414145000000 0.0000000000000.000000000000 0.000000000000 6.414145000000Cs Pb I1 1 3direct0.500000000000 0.500000000000 0.500000000000 Cs0.000000000000 0.000000000000 0.000000000000 Pb0.000000000000 0.000000000000 0.500000000000 I0.000000000000 0.500000000000 0.000000000000 I0.500000000000 0.000000000000 0.000000000000 I

第二步:实现POSCAR到cif之间的转换

abistruct.py convert POSCAR -f cif > CsPbI3.cif

数据结构的相关算法分析(AbiPy实现计算结构文件之间的相互转换)(2)

https://materialsproject.org/materials/mp-1069538/#

附录:AbiPy支持的文件格式:

Extension Class----------------- -----------------------------------------------------.abi <class 'abipy.abio.abivars.AbinitInputFile'>.in <class 'abipy.abio.abivars.AbinitInputFile'>.abo <class 'abipy.abio.outputs.AbinitOutputFile'>.out <class 'abipy.abio.outputs.AbinitOutputFile'>.log <class 'abipy.abio.outputs.AbinitLogFile'>.cif <class 'abipy.core.structure.Structure'>POSCAR <class 'abipy.core.structure.Structure'>.cssr <class 'abipy.core.structure.Structure'>.cube <class 'abipy.core.mixins.CubeFile'>anaddb.nc <class 'abipy.dfpt.anaddbnc.AnaddbNcFile'>DEN <class 'abipy.electrons.denPOT.DensityFortranFile'>.psp8 <class 'pymatgen.io.abinit.pseudos.Pseudo'>.pspnc <class 'pymatgen.io.abinit.pseudos.Pseudo'>.fhi <class 'pymatgen.io.abinit.pseudos.Pseudo'>JTH.xml <class 'pymatgen.io.abinit.pseudos.Pseudo'>.wout <class 'abipy.wannier90.wout.WoutFile'>COHPCAR.lobster <class 'abipy.electrons.lobster.CoxpFile'>COOPCAR.lobster <class 'abipy.electrons.lobster.CoxpFile'>ICOHPLIST.lobster <class 'abipy.electrons.lobster.ICoxpFile'>DOSCAR.lobster <class 'abipy.electrons.lobster.LobsterDoscarFile'>GSR.nc <class 'abipy.electrons.gsr.GsrFile'>ESKW.nc <class 'abipy.electrons.eskw.EskwFile'>DEN.nc <class 'abipy.electrons.denpot.DensityNcFile'>OUT.nc <class 'abipy.abio.outputs.OutNcFile'>VHA.nc <class 'abipy.electrons.denpot.VhartreeNcFile'>VXC.nc <class 'abipy.electrons.denpot.VxcNcFile'>VHXC.nc <class 'abipy.electrons.denpot.VhxcNcFile'>POT.nc <class 'abipy.electrons.denpot.PotNcFile'>WFK.nc <class 'abipy.waves.wfkfile.WfkFile'>HIST.nc <class 'abipy.dynamics.hist.HistFile'>PSPS.nc <class 'abipy.electrons.psps.PspsFile'>DDB <class 'abipy.dfpt.ddb.DdbFile'>PHBST.nc <class 'abipy.dfpt.phonons.PhbstFile'>PHDOS.nc <class 'abipy.dfpt.phonons.PhdosFile'>SCR.nc <class 'abipy.electrons.scr.ScrFile'>SIGRES.nc <class 'abipy.electrons.gw.SigresFile'>GRUNS.nc <class 'abipy.dfpt.gruneisen.GrunsNcFile'>MDF.nc <class 'abipy.electrons.bse.MdfFile'>FATBANDS.nc <class 'abipy.electrons.fatbands.FatBandsFile'>FOLD2BLOCH.nc <class 'abipy.electrons.fold2bloch.Fold2BlochNcfile'>CUT3DDENPOT.nc <class 'abipy.electrons.denpot.Cut3dDenPotNcFile'>OPTIC.nc <class 'abipy.electrons.optic.OpticNcFile'>A2F.nc <class 'abipy.eph.a2f.A2fFile'>SIGEPH.nc <class 'abipy.eph.sigeph.SigEPhFile'>TRANSPORT.nc <class 'abipy.eph.transportfile.TransportFile'>V1SYM.nc <class 'abipy.eph.v1sym.V1symFile'>GKQ.nc <class 'abipy.eph.gkq.GkqFile'>V1QNU.nc <class 'abipy.eph.v1qnu.V1qnuFile'>V1QAVG.nc <class 'abipy.eph.v1qavg.V1qAvgFile'>ABIWAN.nc <class 'abipy.wannier90.abiwan.AbiwanFile'>

,