Package: quantum-esperanto
Quantum Esperantois a fast parser of XML files output by DFT codes (vaspas of now) written in Cython.
It takes advantage of lxml, a Python wrapper aroundlibxml2library, and its Cython interface.
XML files are parsed to a Python dictionary in a transparent way. It is really fast, up to 10 times faster than the
parser used bypymatgenproject.InstallationThe development versions of librarieslibxml2andlibxsltmust be present in the system. Check with the command:$ xslt-configAlso, C compiler such asgccmust be present. The recommended way of installing Quantum Esperanto is withpipfrom PyPI:$ pip install quantum_esperantoIf one is interested in obtaining latest versions of the package, it can be installed using the source
code fromGitHub:$ git clone https://github.com/tilde-lab/quantum_esperanto
$ cd quantum_esperanto
$ pip install .The Python prerequisites for the package arenumpyandlxml(should be installed automatically withpip).It is possible to install the package in development mode. This will installCythonas well asnosetest suite.
To do it issue the following command after cloning the repository and changing the directory:$ cd quantum_esperanto
$ pip install -e .[dev]After install it is possible to run several tests to check if the installation was completed successfully. It can be
done with the following commands inquantum_esperantodirectory:$ python setup.py testIf everything is OK, you’re all set to start using the package.UsageThe parser can be used in a very simple way. First, the parser has to be instantiated, and then theparse_filemethod of the parser returns the dictionary of parsed values:fromquantum_esperanto.vaspimportVaspParserparser=VaspParser()d=parser.parse_file('vasprun.xml')The possible arguments for the parser are:recover(boolean, default:True) a flag that allows recovering broken XML. It is very useful in case of unfinished
calculations; however, it exits on the first XML error and the returned dictionary contains parsed values up to the
first XML error only. When XML recovery is needed, a warning is printed to stderr.whitelist(list, default:None) the list of parent tag names that are only needed to parsed. If None, then all tags are parsed.Parsing resultThe result of parsing is a dictionary that follows the structure ofvasprun.xml. The keys of the dictionary are
either tag names (fori,v,varraytags), ortag:tag nameconstruction (for tags that do have name
attribute), or just tags themselves. The values are either tag contents converted to the right type (specified bytypetag attribute) or (in case of varrays and sets) Numpy arrays. Fortran overflows (denoted by*****) are converted to
NaNs in case of float values and to MAXINT in case of integer values.Example:xml file<structurename="primitive_cell"><crystal><varrayname="basis"><v>1.433000001.433000001.43300000</v><v>1.43300000-1.43300000-1.43300000</v><v>-1.433000001.43300000-1.43300000</v></varray><iname="volume">11.77059895</i><varrayname="rec_basis"><v>0.348918350.348918350.00000000</v><v>0.34891835-0.00000000-0.34891835</v><v>-0.000000000.34891835-0.34891835</v></varray></crystal><varrayname="positions"><v>0.000000000.000000000.00000000</v></varray></structure>resulting dictionary(printed withpprint):{'structure:primitive_cell':{'crystal':{'basis':array([[1.433,1.433,1.433],[1.433,-1.433,-1.433],[-1.433,1.433,-1.433]]),'rec_basis':array([[0.34891835,0.34891835,0.],[0.34891835,-0.,-0.34891835],[-0.,0.34891835,-0.34891835]]),'volume':11.77059895},'positions':array([[0.,0.,0.]])}}LicenseQuantum Esperanto is licensed under MIT license.