Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A problem reading the DIELECTRIC TENSOR #1

Open
alonkukl opened this issue Mar 1, 2015 · 3 comments
Open

A problem reading the DIELECTRIC TENSOR #1

alonkukl opened this issue Mar 1, 2015 · 3 comments

Comments

@alonkukl
Copy link

alonkukl commented Mar 1, 2015

Hi

I came a cross a problem with vasp and the dielectric tensor, sometimes when the valuesof the tensor are very big the numbers in the OUTCAR are mixedup and so the python script doesn't read them correctly. For example see the following sinnpet

MACROSCOPIC STATIC DIELECTRIC TENSOR (including local field effects in DFT)
  ------------------------------------------------------
       13738.431079-16959.202530     2.426989
        -7663.060793 23943.531628    -3.049640
            2.471794    -5.009690  1175.736030
  ------------------------------------------------------

In vasprun.xml the data is printed correctly, so I suggest to try and read the OUTCAR, and if it doesn't succeed then read the data from the xml with the following commands:

from lxml import etree
doc = etree.parse('vasprun.xml')
values = [c.text for c in doc.xpath("/modeling/calculation/varray")[3].getchildren()]
@alonkukl
Copy link
Author

alonkukl commented Mar 1, 2015

Or even try and use this code:

        if "MACROSCOPIC STATIC DIELECTRIC TENSOR" in line:
            outcar_fh.readline()
            try:
                epsilon.append([float(x) for x in outcar_fh.readline().split()])
                epsilon.append([float(x) for x in outcar_fh.readline().split()])
                epsilon.append([float(x) for x in outcar_fh.readline().split()])
            except:
                doc = etree.parse('vasprun.xml')
                epsilon = [[float(x) for x in c.text.split()] for c in doc.xpath("/modeling/calculation/varray")[3].getchildren()]
            return epsilon

@arkamita1
Copy link

Hi ,
Using this code I had some problem and I modified it in the following way:

    if "MACROSCOPIC STATIC DIELECTRIC TENSOR" in line:
        outcar_fh.readline()
        try:
            epsilon.append([float(x) for x in outcar_fh.readline().split()])
            epsilon.append([float(x) for x in outcar_fh.readline().split()])
            epsilon.append([float(x) for x in outcar_fh.readline().split()])
        except:
            import xml.etree.ElementTree as ET
            doc = ET.parse('vasprun.xml')
            epsilon = [[float(x) for x in c.text.split()] for c in doc.xpath("/modeling/calculation/varray")[3].getchildren()]
        return epsilon

I got a error message: ElementTree instance has no attribute 'xpath'
How to get rid of this problem?

@afonari
Copy link
Contributor

afonari commented May 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants