Generate figures: Difference between revisions

From Wiki
Jump to navigation Jump to search
Rgarcia (talk | contribs)
New page: To map several molecules at once, put together the CONTCAR files (CONT*). Then use this script: ---- # # # # # # # # # # # # # # # # # # # # # # # Edited by Rodrigo García, July 10, 2...
 
Rgarcia (talk | contribs)
 
(74 intermediate revisions by 4 users not shown)
Line 1: Line 1:
To map several molecules at once, put together the CONTCAR files (CONT*). Then use this script:
go back to [[Main Page]], [[Computational Resources]], [[Scripts]] or [[VASP]], [[Scripts for VASP]]


To map several molecules at once, put together the CONTCAR files (CONT*). Then use the attached scrip with xcrysden.


----
The script has three parts.


# # # # # # # # # # # # # # # # # # # # # #
===1. Convert POSCAR/CONTCAR to *.xsf===
# Edited by Rodrigo García, July 10, 2012.#
# This program requires v2kxsf conversor. # <--- Available on https://nano.tu-dresden.de/~jkunstmann/software.html
# Tested on vasp 5.x files                #
# Author: David Karhanek                  #
# # # # # # # # # # # # # # # # # # # # # #


# Batch conversion .pos (POSCAR) to .xsf (XCRYSDEN)
In order to use this tool, you will need the program v2xsf. Find attached here [[Image:Xcrysden.tgz]] or here [[https://nano.tu-dresden.de/~jkunstmann/software.html]]. First, put v2xsf in your /home/bin/ folder and make it executable (chmod +x v2xsf). Then, put all your CONTCAR/POSCAR in the same folder with the extension *.vasp and execute the following command in a terminal:
mkdir xsf eps # pos
echo "Converting POSCARs to XSF files..."
for j in `ls CONT*` ; do
  ./v2xsf $j          # You need the program v2kxsf
  uncompress $j.xsf.gz # The program automatically compress, so unzip
# Old code fragment
# upu -q '{quiet; layers@create byatom 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ;\
#          layers@delete hard 0; export xsf}' $j > /dev/null
# mv $j $j.pos
done


# EPS Print Preparation
for j in `ls *.vasp` ; do v2xsf $j ; done
echo "Preparing TCL script for EPS export..."
 
for i in `ls *.xsf`
If you are working with surfaces, you may want to eliminate the bottom layer before that. This example is for (111) metals with 2sqrt(3)×2sqrt(3) symmetry.
do                              # resize 640 480
 
for j in `ls *.vasp` ; do sed -i "7s/48/36/g" $j ; sed -i "10,21d" $j ; done
 
===2. Script preparation===
XCrysDen can work with a *.tcl script as input file. This utility will build that script for you:
 
#!/bin/bash
# # # # # # # # # # # # # # # # # # # # # # # # #
# Created by Rodrigo García-Muelas            #
#                                          #
# Suitable for VASP 5.x                  # 
# First review:  July 10, 2012.            #
# Current review: Oct 16, 2018.              #
# # # # # # # # # # # # # # # # # # # # # # # # #
#
# Notes:
# 1. The input files should be *.vasp
# 2. Requires v2xsf conversor <--- Available on VASP webpage.
# 3. Inspired by a similar creation from David Karhanek.
# 4. Remember to write in the terminal: for j in `ls *.vasp` ; do v2xsf $j ; done
#
# remove old tcl scripts (this section needs to be fix)
if [ -e epsprinting.tcl ] ; then echo "removing old epsprinting.tcl" ; rm -f epsprinting.tcl ; fi
#
# comprobates if you have *.xsf.gz files
if [ -z `ls *.vasp.xsf.gz` ] ; then
echo "Please execute: "
echo "for j in \`ls *.vasp\` ; do sed -i "7s/48/36/g" \$j ; sed -i "10,21d" \$j ; done"
echo "for j in \`ls *.vasp\` ; do v2xsf \$j ; done"
echo "All your POSCAR's should have .vasp extension"
exit
fi
#
# Note: you can use: "resize 640 480" or "resize 800 1000" or "resize 640 480", etc. Limit around 4000.
#####################
# Loop for side view:
for i in `ls *.vasp.xsf.gz`
do 
  cat >>epsprinting.tcl<<!
  cat >>epsprinting.tcl<<!
scripting::open --xsf $i
scripting::open --xsf $i
scripting::displayWindow resize 1200 900
scripting::displayWindow resize 800 800
xc_newvalue .mesa 8  0 1.000000 1.000000 1.000000
xc_newvalue .mesa 8  0 1.000000 1.000000 1.000000
xc_newvalue .mesa 8  1 0.500000 1.000000 1.000000
xc_newvalue .mesa 8  1 1.000000 1.000000 1.000000
xc_newvalue .mesa 8  6 0.750000 0.750000 0.750000
xc_newvalue .mesa 8  3 1.000000 1.000000 0.500000
xc_newvalue .mesa 8 22 1.000000 1.000000 1.000000
xc_newvalue .mesa 8  5 0.670000 0.330000 0.000000
scripting::displayMode3D BallStick
xc_newvalue .mesa 8  6 0.250000 0.250000 0.250000
set myParam(COV_SCALE)       1.25
xc_newvalue .mesa 8  7 0.000000 0.000000 1.000000
set myParam(FRAMECOL)        {10 10 0.50}
xc_newvalue .mesa 8  8 1.000000 0.000000 0.000000
scripting::load_myParam
xc_newvalue .mesa 8  9 0.000000 1.000000 0.000000
scripting::display on atomic-labels
xc_newvalue .mesa 8 16 0.906000 0.882000 0.275000
scripting::display on crystal-cells  
xc_newvalue .mesa 8 26 1.000000 0.930000 0.870000
scripting::buildCrystal 2 2 2
xc_newvalue .mesa 8 27 0.870000 0.930000 1.000000
scripting::zoom 15
xc_newvalue .mesa 8 28 0.800000 1.000000 1.000000
scripting::printToFile ${i%\.xsf}.eps
xc_newvalue .mesa 8 29 1.000000 0.920000 0.880000
xc_newvalue .mesa 8 30 0.900000 0.900000 0.900000
xc_newvalue .mesa 8 34 0.951000 0.882000 0.230000
xc_newvalue .mesa 8 44 1.000000 0.800000 1.000000
xc_newvalue .mesa 8 45 1.000000 0.800000 1.000000
xc_newvalue .mesa 8 46 0.900000 0.900000 1.000000
xc_newvalue .mesa 8 47 0.933333 0.933333 0.933333
xc_newvalue .mesa 8 48 1.000000 0.880000 0.920000
xc_newvalue .mesa 8 49 0.925000 0.925000 1.000000
xc_newvalue .mesa 8 52 0.996000 0.882000 0.185000
xc_newvalue .mesa 8 75 1.000000 0.950000 0.850000
xc_newvalue .mesa 8 76 1.000000 0.900000 0.900000
xc_newvalue .mesa 8 77 1.000000 0.800000 1.000000
xc_newvalue .mesa 8 78 0.900000 1.000000 0.900000
xc_newvalue .mesa 8 79 1.000000 1.000000 0.800000
xc_newvalue .mesa 4  1 0.90000
xc_newvalue .mesa 4  3 0.90000
xc_newvalue .mesa 4  5 1.50000
xc_newvalue .mesa 4  6 2.05000
xc_newvalue .mesa 4  7 1.90000
xc_newvalue .mesa 4  8 1.80000
xc_newvalue .mesa 4  9 1.70000
xc_newvalue .mesa 4 16 2.90000
xc_newvalue .mesa 4 26 3.10000
xc_newvalue .mesa 4 27 3.05000
xc_newvalue .mesa 4 28 2.95000
xc_newvalue .mesa 4 29 2.95000
xc_newvalue .mesa 4 30 2.95000
xc_newvalue .mesa 4 34 3.05000
xc_newvalue .mesa 4 44 3.55000
xc_newvalue .mesa 4 45 3.47000
xc_newvalue .mesa 4 46 3.40000
xc_newvalue .mesa 4 47 3.45000
xc_newvalue .mesa 4 48 3.50000
xc_newvalue .mesa 4 49 2.40000
xc_newvalue .mesa 4 52 3.20000
xc_newvalue .mesa 4 75 3.55000
xc_newvalue .mesa 4 76 3.55000
xc_newvalue .mesa 4 77 3.55000
xc_newvalue .mesa 4 78 3.55000
xc_newvalue .mesa 4 79 3.55000
scripting::displayMode3D BallStick
set myParam(TESSELLATION)      99.00
set myParam(COV_SCALE)         1.25
set myParam(FRAMECOL)        { 0.00 0.00 0.00 }  
set myParam(BACKGROUND)      { 1.00 1.00 1.00 }
scripting::load_myParam
scripting::display off crystal-cells
scripting::displayMode3D BallStick
scripting::display as cell-unit symm
scripting::buildCrystal 1 1 1
xc_translparam set 0 0 1
scripting::rotate x 90
scripting::zoom 2
scripting::printToFile ${i%\.vasp.xsf.gz}_s.png
!
done
# Loop for top view:
for i in `ls *.vasp.xsf.gz`
do                              # resize 640 480
cat >>epsprinting.tcl<<!
scripting::open --xsf $i
scripting::displayWindow resize 800 800
xc_newvalue .mesa 8  0 1.000000 1.000000 1.000000
xc_newvalue .mesa 8  1 1.000000 1.000000 1.000000
xc_newvalue .mesa 8  3 1.000000 1.000000 0.500000
xc_newvalue .mesa 8  5 0.670000 0.330000 0.000000
xc_newvalue .mesa 8  6 0.250000 0.250000 0.250000
xc_newvalue .mesa 8  7 0.000000 0.000000 1.000000
xc_newvalue .mesa 8  8 1.000000 0.000000 0.000000
xc_newvalue .mesa 8  9 0.000000 1.000000 0.000000
xc_newvalue .mesa 8 16 0.906000 0.882000 0.275000
xc_newvalue .mesa 8 26 1.000000 0.930000 0.870000
xc_newvalue .mesa 8 27 0.870000 0.930000 1.000000
xc_newvalue .mesa 8 28 0.800000 1.000000 1.000000
xc_newvalue .mesa 8 29 1.000000 0.920000 0.880000
xc_newvalue .mesa 8 30 0.900000 0.900000 0.900000
xc_newvalue .mesa 8 34 0.951000 0.882000 0.230000
xc_newvalue .mesa 8 44 1.000000 0.800000 1.000000
xc_newvalue .mesa 8 45 1.000000 0.800000 1.000000
xc_newvalue .mesa 8 46 0.900000 0.900000 1.000000
xc_newvalue .mesa 8 47 0.933333 0.933333 0.933333
xc_newvalue .mesa 8 48 1.000000 0.880000 0.920000
xc_newvalue .mesa 8 49 0.925000 0.925000 1.000000
xc_newvalue .mesa 8 52 0.996000 0.882000 0.185000
xc_newvalue .mesa 8 75 1.000000 0.950000 0.850000
xc_newvalue .mesa 8 76 1.000000 0.900000 0.900000
xc_newvalue .mesa 8 77 1.000000 0.800000 1.000000
xc_newvalue .mesa 8 78 0.900000 1.000000 0.900000
xc_newvalue .mesa 8 79 1.000000 1.000000 0.800000
xc_newvalue .mesa 4  1 0.90000
xc_newvalue .mesa 4  3 0.90000
xc_newvalue .mesa 4  5 1.50000
xc_newvalue .mesa 4  6 2.05000
xc_newvalue .mesa 4  7 1.90000
xc_newvalue .mesa 4  8 1.80000
xc_newvalue .mesa 4  9 1.70000
xc_newvalue .mesa 4 16 2.90000
xc_newvalue .mesa 4 26 3.10000
xc_newvalue .mesa 4 27 3.05000
xc_newvalue .mesa 4 28 2.95000
xc_newvalue .mesa 4 29 2.95000
xc_newvalue .mesa 4 30 2.95000
xc_newvalue .mesa 4 34 3.05000
xc_newvalue .mesa 4 44 3.55000
xc_newvalue .mesa 4 45 3.47000
xc_newvalue .mesa 4 46 3.40000
xc_newvalue .mesa 4 47 3.45000
xc_newvalue .mesa 4 48 3.50000
xc_newvalue .mesa 4 49 2.40000
xc_newvalue .mesa 4 52 3.20000
xc_newvalue .mesa 4 75 3.55000
xc_newvalue .mesa 4 76 3.55000
xc_newvalue .mesa 4 77 3.55000
xc_newvalue .mesa 4 78 3.55000
xc_newvalue .mesa 4 79 3.55000
scripting::displayMode3D BallStick
set myParam(TESSELLATION)      99.00
set myParam(COV_SCALE)          1.25
set myParam(FRAMECOL)        { 0.00 0.00 0.00 }
set myParam(BACKGROUND)      { 1.00 1.00 1.00 }
scripting::load_myParam
scripting::display on crystal-cells  
scripting::displayMode3D BallStick
scripting::display as cell-unit symm
scripting::buildCrystal 1 1 1
xc_translparam set 0 0 1
scripting::zoom 2
scripting::printToFile ${i%\.vasp.xsf.gz}_t.png
!
done
echo "Now run XCrySDen in script mode: xcrysden -s epsprinting.tcl"
 
 
Explanation:
 
You can set the size of the window with the command below. Notice that a bigger window size imply a larger and heavier image.
scripting::displayWindow resize 800 1000
 
You can change the colors of your atoms. The example shows H, C, O and Pt (Z=1,6,8,78) and colors white (1.00 1.00 1.00 RGB), gray, red and light green:
xc_newvalue .mesa 8  1 1.000000 1.000000 1.000000
xc_newvalue .mesa 8  6 0.250000 0.250000 0.250000
xc_newvalue .mesa 8  8 1.000000 0.000000 0.000000
xc_newvalue .mesa 8 78 0.800000 1.000000 0.800000
 
To change the size of the ball for each element, you have this part:
xc_newvalue .mesa 4  1 0.90000
xc_newvalue .mesa 4  6 2.05000
xc_newvalue .mesa 4  8 1.80000
xc_newvalue .mesa 4 78 3.55000
 
The quality of the texture can be adjusted with the tessellation factor. Use low values (20) for fast screening, tests, and images of internal use. Use large values (99) for publication-quality images.
set myParam(TESSELLATION)      20.00
 
To colour the borders of the supercell in black:
set myParam(FRAMECOL)          { 0.00 0.00 0.00 }
 
Set the background color as white to be printer-friendly.
set myParam(BACKGROUND)        { 1.00 1.00 1.00 }
 
Build a 1×1×1 supercell
scripting::buildCrystal 1 1 1
 
 
Play with these parameters in order to focus your cell at your wish:
scripting::rotate x 90
scripting::zoom 2
 
Do NOT put comments in the epsprinting.tcl file.
 
===3. Printing and post-processing===
 
Run XCrysDen in scripting mode by typing:
$ xcrysden -s epsprinting.tcl
 
Tips:
* If you want to convert the background of an image from white to transparent, write in the command line:
 
convert -transparent white <input_file> <output_file>
 
* If you want to crop transparent spaces, write in the command line:
convert -trim <input_file> <output_file>
 
* If you want to crop the side view images, do:
convert -gravity Center -crop 120x30%+0+100\! <input_file> <output_file>
 
* You can also do ("x" and "y" directions, + for right/up , - for left/down:
convert -crop +0-275 <input_file> <output_file>
 
* In batch mode:
for j in *.png ; do echo $j ; convert -transparent white $j $j ; done
for j in *.png ; do echo $j ; convert -trim $j $j ; done
for j in *.png ; do echo $j ; convert -gravity Center -crop 120x30%+0+100\! $j $j ; done
 
* It would also work:
for j in `ls *.png` ; do echo $j ; convert -transparent white $j $j ; done
for j in `ls *.png` ; do echo $j ; convert -trim $j $j ; done
for j in `ls *.png` ; do echo $j ; convert -gravity Center -crop 120x30%+0+100\! $j $j ; done
 
* If you generated your figures in other formats (i.e. *.eps), and you want to convert them into png:
  for j in *eps ; do echo $j ; convert $j ${j%%.eps}.png ; done
  for j in *eps ; do echo $j ; convert -density 600 $j ${j%%.eps}.png ; done
 
* To remove the weird blue fog, as soon as it starts generating the images, press shift+x (Or menu: Modify > materials/fog/antialias parameters) and in "Emision colour" set the blue component to zero. Then "Update" and "Close". You may need to repeat the commands for the first images just to have it well done.


!
For aditional commands, see [[http://www.xcrysden.org/doc/prog/contours.tcl.html]]
done
# Feel free to modify resize, buildcrystal and zoom parametens
# set myParam(FRAMECOL)        {0.00 0.00 0.50}
# you can add those parameters before line 38 (scripting::zoom) :
# scripting::rotate x 45
# scripting::rotate y 45
# scripting::rotate x 45
# xc_translparam set 13 6 2
# xc_translparam set 7 2 5
# etc, see http://www.xcrysden.org/doc/prog/plot_all_MO.sh.html


# EPS Printing
==Merging everything as a LaTeX table==
echo "The TCL script 'epsprinting.tcl' is now ready for use with XCrysDen... "
This script exemplifies how to prepare the input tex file for a series of NEB. It results in the table-temp.tex file:
echo ""
#!/bin/bash
echo "Please wait while XCrysDen generate your figures"
# Rodrigo García-Muelas
sleep 1
# Version 5 May 2021
xcrysden -s epsprinting.tcl
outputf="table-temp.tex"    # output file 
pathfig="./raw/"              # all figures are placed in a subfolder called raw, for have some order 
rm -f $outputf
#side view must be reduced by a factor x0.9315184 if there is a metal at (,0,0)
qt="\includegraphics[width=0.2060\\textwidth]{$pathfig"
qs="\includegraphics[width=0.2000\\textwidth,trim=0mm 105mm 0mm 120mm,clip=true]{$pathfig"
touch $outputf
for k in `cat '0-list.txt'` ; do
echo $k
i=$k
echo "\hline                                      " >> $outputf
echo "\multicolumn{4}{c}{ " $i " } \\\\*          " >> $outputf
echo $qt$i"-00_t.png} & " $qt$i"-02_t.png} & " $qt$i"-03_t.png} & " $qt$i"-05_t.png} \\\\* " >> $outputf
echo $qs$i"-00_s.png} & " $qs$i"-02_s.png} & " $qs$i"-03_s.png} & " $qs$i"-05_s.png} \\\\  " >> $outputf
done


# Clean up and Exit
# mv *.pos pos/          # old fragment. The original one moves CONTCAR files
mv *.xsf xsf/
mv *.eps eps/
mv epsprinting.tcl xsf/


echo "Finished! Good luck
Then open this LaTeX file and compile it. It will call the previous table and compile all figures.
\documentclass[a4paper,10pt]{article}
\usepackage[a4paper,portrait,bindingoffset=5mm,left=10mm,right=10mm,top=10mm,bottom=10mm,footskip=5mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{longtable}
\graphicspath { {raw/} }
% Title Page
\title{Figures}
\author{Rodrigo Garcia-Muelas}
\begin{document}
\maketitle
%\begin{abstract}
%\end{abstract}
This is a NEB table automatically generated in LaTeX.
Perhaps you want to ``trim'' all figures before compiling with imagemagick.
\begin{longtable}{ l l l l }
\caption{Images 00, 02, 03, and 05 of a NEB }
\label{t.figpca}  \\
  \hline
  00 & 02 & 03 & 05 \\
  \hline
  \endfirsthead
  \multicolumn{4}{c}{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
  \hline
  00 & 02 & 03 & 05 \\ \hline
  \endhead
  \hline
  \multicolumn{4}{r}{{Continues on next page {} }} \\
  \endfoot
  \hline
  \endlastfoot
\input{./table-temp}
\end{longtable}
\end{document}


----
--[[User:Rgarcia|Rgarcia]] 19:23, 12 December 2012 (CET)

Latest revision as of 20:03, 3 May 2021

go back to Main Page, Computational Resources, Scripts or VASP, Scripts for VASP

To map several molecules at once, put together the CONTCAR files (CONT*). Then use the attached scrip with xcrysden.

The script has three parts.

1. Convert POSCAR/CONTCAR to *.xsf[edit]

In order to use this tool, you will need the program v2xsf. Find attached here File:Xcrysden.tgz or here [[1]]. First, put v2xsf in your /home/bin/ folder and make it executable (chmod +x v2xsf). Then, put all your CONTCAR/POSCAR in the same folder with the extension *.vasp and execute the following command in a terminal:

for j in `ls *.vasp` ; do v2xsf $j ; done

If you are working with surfaces, you may want to eliminate the bottom layer before that. This example is for (111) metals with 2sqrt(3)×2sqrt(3) symmetry.

for j in `ls *.vasp` ; do sed -i "7s/48/36/g" $j ; sed -i "10,21d" $j ; done

2. Script preparation[edit]

XCrysDen can work with a *.tcl script as input file. This utility will build that script for you:

#!/bin/bash

# # # # # # # # # # # # # # # # # # # # # # # # #
# Created by Rodrigo García-Muelas            #
#                                           #
# Suitable for VASP 5.x                  #   
# First review:  July 10, 2012.             #
# Current review: Oct 16, 2018.              #
# # # # # # # # # # # # # # # # # # # # # # # # # 
#
# Notes:
# 1. The input files should be *.vasp
# 2. Requires v2xsf conversor <--- Available on VASP webpage.
# 3. Inspired by a similar creation from David Karhanek.
# 4. Remember to write in the terminal: for j in `ls *.vasp` ; do v2xsf $j ; done
#
# remove old tcl scripts (this section needs to be fix)
if [ -e epsprinting.tcl ] ; then echo "removing old epsprinting.tcl" ; rm -f epsprinting.tcl ; fi
#
# comprobates if you have *.xsf.gz files
if [ -z `ls *.vasp.xsf.gz` ] ; then 
echo "Please execute: "
echo "for j in \`ls *.vasp\` ; do sed -i "7s/48/36/g" \$j ; sed -i "10,21d" \$j ; done"
echo "for j in \`ls *.vasp\` ; do v2xsf \$j ; done" 
echo "All your POSCAR's should have .vasp extension"
exit
fi 
#
# Note: you can use: "resize 640 480" or "resize 800 1000" or "resize 640 480", etc. Limit around 4000.

#####################
# Loop for side view:
for i in `ls *.vasp.xsf.gz`
do   
cat >>epsprinting.tcl<<!
scripting::open --xsf $i
scripting::displayWindow resize 800 800
xc_newvalue .mesa 8  0 1.000000 1.000000 1.000000
xc_newvalue .mesa 8  1 1.000000 1.000000 1.000000
xc_newvalue .mesa 8  3 1.000000 1.000000 0.500000
xc_newvalue .mesa 8  5 0.670000 0.330000 0.000000
xc_newvalue .mesa 8  6 0.250000 0.250000 0.250000
xc_newvalue .mesa 8  7 0.000000 0.000000 1.000000
xc_newvalue .mesa 8  8 1.000000 0.000000 0.000000
xc_newvalue .mesa 8  9 0.000000 1.000000 0.000000
xc_newvalue .mesa 8 16 0.906000 0.882000 0.275000
xc_newvalue .mesa 8 26 1.000000 0.930000 0.870000 
xc_newvalue .mesa 8 27 0.870000 0.930000 1.000000
xc_newvalue .mesa 8 28 0.800000 1.000000 1.000000
xc_newvalue .mesa 8 29 1.000000 0.920000 0.880000
xc_newvalue .mesa 8 30 0.900000 0.900000 0.900000
xc_newvalue .mesa 8 34 0.951000 0.882000 0.230000
xc_newvalue .mesa 8 44 1.000000 0.800000 1.000000
xc_newvalue .mesa 8 45 1.000000 0.800000 1.000000
xc_newvalue .mesa 8 46 0.900000 0.900000 1.000000
xc_newvalue .mesa 8 47 0.933333 0.933333 0.933333
xc_newvalue .mesa 8 48 1.000000 0.880000 0.920000
xc_newvalue .mesa 8 49 0.925000 0.925000 1.000000
xc_newvalue .mesa 8 52 0.996000 0.882000 0.185000
xc_newvalue .mesa 8 75 1.000000 0.950000 0.850000
xc_newvalue .mesa 8 76 1.000000 0.900000 0.900000
xc_newvalue .mesa 8 77 1.000000 0.800000 1.000000
xc_newvalue .mesa 8 78 0.900000 1.000000 0.900000
xc_newvalue .mesa 8 79 1.000000 1.000000 0.800000
xc_newvalue .mesa 4  1 0.90000
xc_newvalue .mesa 4  3 0.90000
xc_newvalue .mesa 4  5 1.50000
xc_newvalue .mesa 4  6 2.05000
xc_newvalue .mesa 4  7 1.90000
xc_newvalue .mesa 4  8 1.80000
xc_newvalue .mesa 4  9 1.70000
xc_newvalue .mesa 4 16 2.90000
xc_newvalue .mesa 4 26 3.10000
xc_newvalue .mesa 4 27 3.05000
xc_newvalue .mesa 4 28 2.95000
xc_newvalue .mesa 4 29 2.95000
xc_newvalue .mesa 4 30 2.95000
xc_newvalue .mesa 4 34 3.05000
xc_newvalue .mesa 4 44 3.55000
xc_newvalue .mesa 4 45 3.47000
xc_newvalue .mesa 4 46 3.40000
xc_newvalue .mesa 4 47 3.45000
xc_newvalue .mesa 4 48 3.50000
xc_newvalue .mesa 4 49 2.40000
xc_newvalue .mesa 4 52 3.20000
xc_newvalue .mesa 4 75 3.55000
xc_newvalue .mesa 4 76 3.55000
xc_newvalue .mesa 4 77 3.55000
xc_newvalue .mesa 4 78 3.55000
xc_newvalue .mesa 4 79 3.55000
scripting::displayMode3D BallStick
set myParam(TESSELLATION)      99.00
set myParam(COV_SCALE)          1.25
set myParam(FRAMECOL)         { 0.00 0.00 0.00 } 
set myParam(BACKGROUND)       { 1.00 1.00 1.00 }
scripting::load_myParam
scripting::display off crystal-cells 
scripting::displayMode3D BallStick
scripting::display as cell-unit symm
scripting::buildCrystal 1 1 1
xc_translparam set 0 0 1 
scripting::rotate x 90
scripting::zoom 2
scripting::printToFile ${i%\.vasp.xsf.gz}_s.png

!
done

# Loop for top view:
for i in `ls *.vasp.xsf.gz`
do                              # resize 640 480
cat >>epsprinting.tcl<<!
scripting::open --xsf $i
scripting::displayWindow resize 800 800
xc_newvalue .mesa 8  0 1.000000 1.000000 1.000000
xc_newvalue .mesa 8  1 1.000000 1.000000 1.000000
xc_newvalue .mesa 8  3 1.000000 1.000000 0.500000
xc_newvalue .mesa 8  5 0.670000 0.330000 0.000000
xc_newvalue .mesa 8  6 0.250000 0.250000 0.250000
xc_newvalue .mesa 8  7 0.000000 0.000000 1.000000
xc_newvalue .mesa 8  8 1.000000 0.000000 0.000000
xc_newvalue .mesa 8  9 0.000000 1.000000 0.000000
xc_newvalue .mesa 8 16 0.906000 0.882000 0.275000
xc_newvalue .mesa 8 26 1.000000 0.930000 0.870000 
xc_newvalue .mesa 8 27 0.870000 0.930000 1.000000
xc_newvalue .mesa 8 28 0.800000 1.000000 1.000000
xc_newvalue .mesa 8 29 1.000000 0.920000 0.880000
xc_newvalue .mesa 8 30 0.900000 0.900000 0.900000
xc_newvalue .mesa 8 34 0.951000 0.882000 0.230000
xc_newvalue .mesa 8 44 1.000000 0.800000 1.000000
xc_newvalue .mesa 8 45 1.000000 0.800000 1.000000
xc_newvalue .mesa 8 46 0.900000 0.900000 1.000000
xc_newvalue .mesa 8 47 0.933333 0.933333 0.933333
xc_newvalue .mesa 8 48 1.000000 0.880000 0.920000
xc_newvalue .mesa 8 49 0.925000 0.925000 1.000000
xc_newvalue .mesa 8 52 0.996000 0.882000 0.185000
xc_newvalue .mesa 8 75 1.000000 0.950000 0.850000
xc_newvalue .mesa 8 76 1.000000 0.900000 0.900000
xc_newvalue .mesa 8 77 1.000000 0.800000 1.000000
xc_newvalue .mesa 8 78 0.900000 1.000000 0.900000
xc_newvalue .mesa 8 79 1.000000 1.000000 0.800000
xc_newvalue .mesa 4  1 0.90000
xc_newvalue .mesa 4  3 0.90000
xc_newvalue .mesa 4  5 1.50000
xc_newvalue .mesa 4  6 2.05000
xc_newvalue .mesa 4  7 1.90000
xc_newvalue .mesa 4  8 1.80000
xc_newvalue .mesa 4  9 1.70000
xc_newvalue .mesa 4 16 2.90000
xc_newvalue .mesa 4 26 3.10000
xc_newvalue .mesa 4 27 3.05000
xc_newvalue .mesa 4 28 2.95000
xc_newvalue .mesa 4 29 2.95000
xc_newvalue .mesa 4 30 2.95000
xc_newvalue .mesa 4 34 3.05000
xc_newvalue .mesa 4 44 3.55000
xc_newvalue .mesa 4 45 3.47000
xc_newvalue .mesa 4 46 3.40000
xc_newvalue .mesa 4 47 3.45000
xc_newvalue .mesa 4 48 3.50000
xc_newvalue .mesa 4 49 2.40000
xc_newvalue .mesa 4 52 3.20000
xc_newvalue .mesa 4 75 3.55000
xc_newvalue .mesa 4 76 3.55000
xc_newvalue .mesa 4 77 3.55000
xc_newvalue .mesa 4 78 3.55000
xc_newvalue .mesa 4 79 3.55000
scripting::displayMode3D BallStick
set myParam(TESSELLATION)      99.00
set myParam(COV_SCALE)          1.25
set myParam(FRAMECOL)         { 0.00 0.00 0.00 } 
set myParam(BACKGROUND)       { 1.00 1.00 1.00 }
scripting::load_myParam
scripting::display on crystal-cells 
scripting::displayMode3D BallStick
scripting::display as cell-unit symm
scripting::buildCrystal 1 1 1
xc_translparam set 0 0 1 
scripting::zoom 2
scripting::printToFile ${i%\.vasp.xsf.gz}_t.png 

!
done

echo "Now run XCrySDen in script mode: xcrysden -s epsprinting.tcl"


Explanation:

You can set the size of the window with the command below. Notice that a bigger window size imply a larger and heavier image.

scripting::displayWindow resize 800 1000

You can change the colors of your atoms. The example shows H, C, O and Pt (Z=1,6,8,78) and colors white (1.00 1.00 1.00 RGB), gray, red and light green:

xc_newvalue .mesa 8  1 1.000000 1.000000 1.000000
xc_newvalue .mesa 8  6 0.250000 0.250000 0.250000
xc_newvalue .mesa 8  8 1.000000 0.000000 0.000000
xc_newvalue .mesa 8 78 0.800000 1.000000 0.800000

To change the size of the ball for each element, you have this part:

xc_newvalue .mesa 4  1 0.90000
xc_newvalue .mesa 4  6 2.05000
xc_newvalue .mesa 4  8 1.80000
xc_newvalue .mesa 4 78 3.55000

The quality of the texture can be adjusted with the tessellation factor. Use low values (20) for fast screening, tests, and images of internal use. Use large values (99) for publication-quality images.

set myParam(TESSELLATION)      20.00

To colour the borders of the supercell in black:

set myParam(FRAMECOL)          { 0.00 0.00 0.00 }

Set the background color as white to be printer-friendly.

set myParam(BACKGROUND)        { 1.00 1.00 1.00 }

Build a 1×1×1 supercell

scripting::buildCrystal 1 1 1 


Play with these parameters in order to focus your cell at your wish:

scripting::rotate x 90
scripting::zoom 2

Do NOT put comments in the epsprinting.tcl file.

3. Printing and post-processing[edit]

Run XCrysDen in scripting mode by typing:

$ xcrysden -s epsprinting.tcl

Tips:

  • If you want to convert the background of an image from white to transparent, write in the command line:
convert -transparent white <input_file> <output_file>
  • If you want to crop transparent spaces, write in the command line:
convert -trim <input_file> <output_file>
  • If you want to crop the side view images, do:
convert -gravity Center -crop 120x30%+0+100\! <input_file> <output_file>
  • You can also do ("x" and "y" directions, + for right/up , - for left/down:
convert -crop +0-275 <input_file> <output_file>
  • In batch mode:
for j in *.png ; do echo $j ; convert -transparent white $j $j ; done
for j in *.png ; do echo $j ; convert -trim $j $j ; done
for j in *.png ; do echo $j ; convert -gravity Center -crop 120x30%+0+100\! $j $j ; done
  • It would also work:
for j in `ls *.png` ; do echo $j ; convert -transparent white $j $j ; done
for j in `ls *.png` ; do echo $j ; convert -trim $j $j ; done
for j in `ls *.png` ; do echo $j ; convert -gravity Center -crop 120x30%+0+100\! $j $j ; done
  • If you generated your figures in other formats (i.e. *.eps), and you want to convert them into png:
 for j in *eps ; do echo $j ; convert $j ${j%%.eps}.png ; done
 for j in *eps ; do echo $j ; convert -density 600 $j ${j%%.eps}.png ; done
  • To remove the weird blue fog, as soon as it starts generating the images, press shift+x (Or menu: Modify > materials/fog/antialias parameters) and in "Emision colour" set the blue component to zero. Then "Update" and "Close". You may need to repeat the commands for the first images just to have it well done.

For aditional commands, see [[2]]

Merging everything as a LaTeX table[edit]

This script exemplifies how to prepare the input tex file for a series of NEB. It results in the table-temp.tex file:

#!/bin/bash 
# Rodrigo García-Muelas
# Version 5 May 2021 

outputf="table-temp.tex"    # output file  
pathfig="./raw/"              # all figures are placed in a subfolder called raw, for have some order  

rm -f $outputf

#side view must be reduced by a factor x0.9315184 if there is a metal at (,0,0)
qt="\includegraphics[width=0.2060\\textwidth]{$pathfig"
qs="\includegraphics[width=0.2000\\textwidth,trim=0mm 105mm 0mm 120mm,clip=true]{$pathfig"

touch $outputf 

for k in `cat '0-list.txt'` ; do

echo $k
i=$k

echo "\hline                                       "  >> $outputf
echo "\multicolumn{4}{c}{ " $i " } \\\\*           "  >> $outputf

echo $qt$i"-00_t.png} & " $qt$i"-02_t.png} & " $qt$i"-03_t.png} & " $qt$i"-05_t.png} \\\\* " >> $outputf
echo $qs$i"-00_s.png} & " $qs$i"-02_s.png} & " $qs$i"-03_s.png} & " $qs$i"-05_s.png} \\\\  " >> $outputf

done 


Then open this LaTeX file and compile it. It will call the previous table and compile all figures.

\documentclass[a4paper,10pt]{article}
\usepackage[a4paper,portrait,bindingoffset=5mm,left=10mm,right=10mm,top=10mm,bottom=10mm,footskip=5mm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{longtable}
\graphicspath { {raw/} }

% Title Page
\title{Figures}
\author{Rodrigo Garcia-Muelas}

\begin{document}
\maketitle

%\begin{abstract}
%\end{abstract}

This is a NEB table automatically generated in LaTeX. 
Perhaps you want to ``trim all figures before compiling with imagemagick.

\begin{longtable}{ l l l l }
\caption{Images 00, 02, 03, and 05 of a NEB }
\label{t.figpca}  \\

  \hline
  00 & 02 & 03 & 05 \\
  \hline
  \endfirsthead

  \multicolumn{4}{c}{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
  \hline
  00 & 02 & 03 & 05 \\ \hline
  \endhead

  \hline
  \multicolumn{4}{r}{{Continues on next page {} }} \\
  \endfoot

  \hline
  \endlastfoot

\input{./table-temp}

\end{longtable}

\end{document} 

--Rgarcia 19:23, 12 December 2012 (CET)