Vtotav.py: Difference between revisions

From Wiki
Jump to navigation Jump to search
QiangLi (talk | contribs)
No edit summary
No edit summary
 
(18 intermediate revisions by 5 users not shown)
Line 1: Line 1:
There is a script written by Python to convert LOCPOT for visualization.
There is a script written in Python to convert LOCPOT for visualization.  
 
The source of this script is from  Github [https://github.com/compphys/ase_tools/blob/master/scripts/vtotav.py] It is based on ASE; therefore you must first install the ASE environment either by using pip:
 
  pip install --upgrade --user ase
 
or following the instructions on the webpage [https://wiki.fysik.dtu.dk/ase/install.html#installation-using-pip].
 
 
* 1) Download vtotav.py by clicking the link or from our Wiki: [[Image:Vtotav.tgz]]
 
* 2) Uncompress vtotav.tgz and copy it to your bin folder ($HOME/bin)
 
* 3) Make it executable 
 
  chmod u+x ~/bin/vtotav.py
 
* 4) In terminal, go to the folder containing work function calculation and run it with command:
 
  vtotav.py  LOCPOT  z  (z is the direction, you can use x,y,and z, depending on your system)
 
* 5) You will get the output file named LOCPOT_Z. You can open it with Libreoffice/Excel or use one of the visualization methods given below.
 
 
Vtotav.py is written in python 2. Depending on your version of the ASE environment it might not be compatible, as the newest ASE version requires python 3. Therefore you need to convert the python 2 script to python 3 by using the automated python 2 to 3 conversion programme [https://docs.python.org/2/library/2to3.html]:
 
  2to3 -w vtotav.py
 
(-w to write it) and by changing the first line in the script to ''#!/usr/bin/env python3''


The source of this script is from  Github [https://github.com/compphys/ase_tools/blob/master/scripts/vtotav.py]


You can download it by clicking the link or from our Wiki:


[[Image:Vtotav.tgz]]
---------  Method 1 to visualize the LOCPOT_Z file
 
 
* Download this python script: [[Image:Workplot.tgz]] and in the terminal, run: python wplot.py


1 install ASE environment[https://wiki.fysik.dtu.dk/ase/install.html#installation-using-pip]:
  pip install --upgrade --user ase


2 Uncompress and copy it to your bin folder
---------  Method 2 to visualize the LOCPOT_Z file


3 chmod u+x ~/bin/vtotav.py


4 In terminal, go to the folder containing work function calculation and run it with command: vtotav.py  LOCPOT  z   (z is the direction)
* You can also download another script to plot workfunction [[Image:Workplot_nathan.tgz‎]], but beware it gives huge figures :p (see below). The script requires one argument at the least; put "z" to define the file to be read as LOCPOT_Z


5 You will get output file named  LOCPOT_Z
* It has additional options too; the first EXTRA argument passed in the commandline sets the title (use dashes ""). Add two additional numbers to specify the range on the x-axis.


6 Because there are many spaces in the output file, I wrote a script to convert those spaces into the excel format data (already in [[Image:Vtotav.tgz]]):  
* Alternatively you can load the script into Excel, Libreoffice or Origin. You'll first have to convert the file to the right format by running the line below in the terminal:


   sed -i '1d' LOCPOT_Z &&  sed -i 's/  */\t/g' LOCPOT_Z &&  sed -i 's/^[ \t]*//' LOCPOT_Z
   sed -i '1d' LOCPOT_Z &&  sed -i 's/  */\t/g' LOCPOT_Z &&  sed -i 's/^[ \t]*//' LOCPOT_Z


7 Copy the numbers from modified LOCPOT_Z to excel or Origin, and draw the figures
* [[Image: Workfunction.png]]
 
8 You can also use the script to plot workfunction [[Image:Workplot.tgz]], it looks like this : [[Image: Workfunction.png]]

Latest revision as of 17:52, 10 December 2019

There is a script written in Python to convert LOCPOT for visualization.

The source of this script is from Github [1] It is based on ASE; therefore you must first install the ASE environment either by using pip:

 pip install --upgrade --user ase 

or following the instructions on the webpage [2].


  • 1) Download vtotav.py by clicking the link or from our Wiki: File:Vtotav.tgz
  • 2) Uncompress vtotav.tgz and copy it to your bin folder ($HOME/bin)
  • 3) Make it executable
 chmod u+x ~/bin/vtotav.py 
  • 4) In terminal, go to the folder containing work function calculation and run it with command:
  vtotav.py  LOCPOT  z   (z is the direction, you can use x,y,and z, depending on your system)
  • 5) You will get the output file named LOCPOT_Z. You can open it with Libreoffice/Excel or use one of the visualization methods given below.


Vtotav.py is written in python 2. Depending on your version of the ASE environment it might not be compatible, as the newest ASE version requires python 3. Therefore you need to convert the python 2 script to python 3 by using the automated python 2 to 3 conversion programme [3]:

  2to3 -w vtotav.py 

(-w to write it) and by changing the first line in the script to #!/usr/bin/env python3



Method 1 to visualize the LOCPOT_Z file


  • Download this python script: File:Workplot.tgz and in the terminal, run: python wplot.py



Method 2 to visualize the LOCPOT_Z file


  • You can also download another script to plot workfunction File:Workplot nathan.tgz, but beware it gives huge figures :p (see below). The script requires one argument at the least; put "z" to define the file to be read as LOCPOT_Z
  • It has additional options too; the first EXTRA argument passed in the commandline sets the title (use dashes ""). Add two additional numbers to specify the range on the x-axis.
  • Alternatively you can load the script into Excel, Libreoffice or Origin. You'll first have to convert the file to the right format by running the line below in the terminal:
 sed -i '1d' LOCPOT_Z &&  sed -i 's/  */\t/g' LOCPOT_Z &&  sed -i 's/^[ \t]*//' LOCPOT_Z