Git Product home page Git Product logo

vaspy's Introduction

VASPy

Build Status Code Health platform versions

Introduction

VASPy is a pure Python library designed to make it easy and quick to manipulate VASP files.

You can use VASPy to manipulate VASP files in command lins or write your own python scripts to process VASP files and visualize VASP data.

In /scripts , there are some scripts written by me for daily use.

More interfaces examples in Jupyter Notebook format are in /examples. Any contribution is welcomed!

Installation

  1. Via pip(recommend):

    pip install vaspy
    
  2. Via easy_install:

    easy_install vaspy
    
  3. From source:

    python setup.py install
    

If you want to use mayavi to visualize VASP data, it is recommened to install Canopy environment on your device instead of installing it manually.

After installing canopy, you can set corresponding aliases, for example:

alias canopy='/Users/<yourname>/Library/Enthought/Canopy/edm/envs/User/bin/python'
alias canopy-pip='/Users/<yourname>/Library/Enthought/Canopy/edm/envs/User/bin/pip'
alias canopy-ipython='/Users/<yourname>/Library/Enthought/Canopy/edm/envs/User/bin/ipython'
alias canopy-jupyter='/Users/<yourname>/Library/Enthought/Canopy/edm/envs/User/bin/jupyter'

Then you can install VASPy to canopy:

canopy-pip install vaspy

Examples

manipulate splited DOS file in command-line

# Manipulate splited DOS files.
>>> from vaspy.electro import DosX
>>> a = DosX('DOS1')
>>> b = DosX('DOS8')

# Merge DOS data.
>>> c = a
>>> c.reset_data()              # Initialize DOS data
>>> for i in range(1, 10):
>>>    c += DosX('DOS'+str(i))  # Merge DOS data.
>>> ...
>>> c.data                      # Get data(numpy array/matrix)
>>> c.tofile()                  # Get new DOS file with merged data

# Plot.
>>> c.plotsum(0, (5, 10))

Output

https://github.com/PytLab/VASPy/blob/dev/pic/pDOS.png

Visualize ELFCAR

>>> from vaspy.electro import ElfCar
>>> a = ElfCar()
>>> a.plot_contour()   # Plot coutour
>>> a.plot_mcontour()  # Plot coutour using mlab(with Mayavi installed)
>>> a.plot_contour3d() # Plot 3D coutour
>>> a.plot_field()     # Plot scalar field

Output

https://github.com/PytLab/VASPy/blob/master/pic/contour2d.png

https://github.com/PytLab/VASPy/blob/master/pic/contours.png

3D contour

https://github.com/PytLab/VASPy/blob/master/pic/contour3d.png

Scalar field

https://github.com/PytLab/VASPy/blob/master/pic/field.png

Charge difference (Use ChgCar class)

https://github.com/PytLab/VASPy/blob/master/pic/contourf.png

Manipulate XDATCAR:

>>> from vaspy.atomco import XdatCar
>>> xdatcar = XdatCar()
>>> # Get Cartisan coordinates and step number in XDATCAR.
>>> for item in xdatcar:
>>>     print(item.step)
>>>     print(xdatcar.dir2cart(xdatcar.bases, item.coordinates))

>>> python xdatcar_to_arc.py

animation

https://github.com/PytLab/VASPy/blob/master/pic/sn2_my.gif

Process animation file:

Now VASPy can manipulate animation files to get more realistice results like atom trajectories or 2D/3D probability distribution.

https://github.com/PytLab/VASPy/blob/master/pic/pd.png

You can write your OWN script to process VASP files

From the author

Welcome to use VASPy (●'◡'●)ノ♥

  • If you find any bug, please report it to me by opening a issue.
  • VASPy needs to be improved, your contribution will be welcomed.

Important update log

Date Version Description
2016-08-08 0.7.0 Enhance universality
2016-07-15 0.6.0 Compatible with python 3
2015-08-04 0.1.0 Initial version

vaspy's People

Contributors

pytlab avatar skyirm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vaspy's Issues

vaspy路径错误

在cannopy环境中,C:\Users\y7216\Downloads\VASPy-master\scripts\md_viz\map.py路径下运行vasp包中的map程序发生报错:

C:\Users\y7216\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\matplotlib\pyplot.py:524: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
  max_open_warning, RuntimeWarning)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
C:\Users\y7216\Downloads\VASPy-master\scripts\md_viz\map.py in <module>()
     29     # Merge all positions.
     30 
---> 31     trajs = get_trajectories()
     32     positions = np.concatenate(trajs)
     33 
C:\Users\y7216\Downloads\VASPy-master\scripts\md_viz\traj.py in get_trajectories()
     12 
     13 def get_trajectories():
---> 14     xdatcar = XdatCar()
     15     ani = AniFile()
     16 
C:\Users\y7216\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\vaspy\atomco.py in __init__(self, filename)
    488           ============  =======================================================
    489         """
--> 490         AtomCo.__init__(self, filename)
    491         self.info_nline = 7  # line numbers of lattice info
    492         self.load()
C:\Users\y7216\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\vaspy\atomco.py in __init__(self, filename)
     24     "Base class to be inherited by atomco classes."
     25     def __init__(self, filename):
---> 26         VasPy.__init__(self, filename)
     27 
     28     def verify(self):
C:\Users\y7216\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\vaspy\__init__.py in __init__(self, filename)
     30         # Check filename validity.
     31 
---> 32         if not os.path.exists(filename):
     33             raise ValueError("{} not exist!!!".format(filename')+'!)
     34 
ValueError: XDATCAR not exist. 

在map代码报错位置前一行添加: print(os.path)语句后,结果中增加了一行:
%run "C:/Users/y7216/Downloads/VASPy-master/scripts/md_viz/map.py" C:\Users\y7216\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\matplotlib\pyplot.py:524: RuntimeWarning: More than 20 figures have been opened.
同样的问题也存在test系列程序中

Traceback (most recent call last):
  File "C:\Users\y7216\Downloads\VASPy-master\tests\incar_test.py", line 23, in test_rdata
    incar = InCar(filename)
  File "C:\Users\y7216\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\vaspy\incar.py", line 32, in __init__
    super(self.__class__, self).__init__(filename)
  File "C:\Users\y7216\AppData\Local\Enthought\Canopy\edm\envs\User\lib\site-packages\vaspy\__init__.py", line 32, in __init__
    if not os.path.exists(filename):
ValueError: ./testdata/INCAR not exist.

----------------------------------------------------------------------
Ran 9 tests in 0.016s

FAILED (errors=8)

Error in Reading ELFCAR

Hi,
I am facing issues with reading the ELFCAR file with VASPy.
Do you think if its a python issue or something else?
Screenshot from 2021-11-08 11-58-09

CHGCAR plot error

I get the following error

Traceback (most recent call last):
  File "test.py", line 9, in <module>
    a = ChgCar()
  File "/home/gallo/software/VASPy/vaspy/electro.py", line 549, in __init__
    ElfCar.__init__(self, filename)
  File "/home/gallo/software/VASPy/vaspy/electro.py", line 268, in __init__
    super(ElfCar, self).__init__(filename)
  File "/home/gallo/software/VASPy/vaspy/atomco.py", line 357, in __init__
    self.load()
  File "/home/gallo/software/VASPy/vaspy/electro.py", line 289, in load
    datalist = line2list(line)
  File "/home/gallo/software/VASPy/vaspy/functions.py", line 20, in line2list
    datalist = [dtype(i) for i in strlist if i != '']
  File "/home/gallo/software/VASPy/vaspy/functions.py", line 20, in <listcomp>
    datalist = [dtype(i) for i in strlist if i != '']
ValueError: could not convert string to float: 'augmentation'

witht the following script

import vaspy

from vaspy.electro import ChgCar

a = ChgCar()

a.plot_contour3d()

调用XsdFile创建POSCAR的问题

您好!这几天在学习VASP,看到您提供的代码,觉得挺好的,想试用一下。但是发现按照您的scripts里边的例子,调用XsdFile类创建POSCAR时候,出现了两个问题。

  • 您的这个代码不能识别P1群之外的其他空间群吗?我发现如果我用Materials Studio 7.0创建的.xsd文件,如果不是P1群,生成的POSCAR就缺对称原子。
  • 创建的POSCAR总是缺第一个原子。比如我用了一个Na8Cl8的.xsd晶胞做测试,发现得到的POSCAR漏掉了原点处的那个Na原子。

我用的Python是2.7版本,MS是7.0版本,用的操作系统是Win10 (32-bit)。因为您提供的.xsd测试文件是8.0版本,我的MS打不开,所以没法测试。附件是MS7.0生成的NaCl文件,我改写的Windows版本的POSCAR生成的Python脚本以及生成的POSCAR,可以看见POSCAR里边缺了原点处的Na原子。想请教一下是哪里出了问题?十分感谢!

test.zip

求助DOS绘制和计算相关内容

您好开发者,
非常感谢您能开发这款方便的工具,有一个疑问就是如何快速分别地计算带有自旋极化的态密度积分数值(如下图,分别计算up和down的积分),并且计算出他们的d-band center,另外如何进行一个选定区域的积分态密度计算(如-1~0eV区域)。
是否需要重新编写脚本呢,还是可以在vaspy自带功能框架下实现?谢谢!!
image

canopy install error

Hi there,
I got stuck in the installation through canopy. The canopy env is all set, while

weiweis@cori07:~/vaspy-0.8.6> canopy-pip install vaspy
-bash: /global/homes/w/weiweis/Canopy/appdata/canopy-2.1.6.3665.rh6-x86_64/bin/pip: /home/vagrant/workspace/Canopy-Installers/ARCH/64bit/LABEL/rh6/build_scripts/: bad interpreter: No such file or directory

I was trying to find it in setup.py to change /home/vagrant/workspace/Canopy-Installers/ARCH/64bit/LABEL/rh6/build_scripts/, but unfortunately, it's not there.

Could you figure out the error?

Thanks
Bests,
Weiwei

for atom trajectory

hi
Thanks for writing such a useful script. I am more interested in atom trajectories or 2D/3D probability distribution from VASP files (such as XDATCAR). Can you please help me how to proceed for that or which of your scripts will work for this?

vaspy不能适配python2.7及其canopy环境

python2.7中类的继承语法有所改变,可能因此导致了大量类似‘ValueError: XDATCAR not exist. ’的错误。
现在canopy环境已更新为内置python2.7,希望可以更新您的vaspy,非常感谢。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.