Skip to content

Commit

Permalink
V2.4.0 - (1) Spinor wavefunctions are now supported. (2) New: GUI for…
Browse files Browse the repository at this point in the history
… the plotting tool. (3) BandUP now accepts some optional command-line arguments and flags. (4) Added some new command-line options to the plotting tool. (5) Pythonification of the plotting tool script. All changes are backwards compatible.
  • Loading branch information
Paulo V C Medeiros committed Jul 19, 2014
1 parent 61b1bf4 commit dd8a880
Show file tree
Hide file tree
Showing 22 changed files with 3,645 additions and 835 deletions.
20 changes: 20 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,29 @@ System requirements:
* argparse
* heapq
* Please let me know if I've forgotten to list any other package!
* Optional: If you want to use the graphical user interface (GUI) version
of the plotting tool, you will need to have the PyQt4 package
available in your python install.
If you cannot use the GUI, you can keep using the plotting tool
in the command line, just as usual.



===================================================================================
Tips:
===================================================================================
* It might be handy to include the BandUP_bin folder in your PATH. By doing so,
you'll be able to use BandUP in whataver folder you're working at.
* BandUP accepts some optional command line options. Run the code with the flag
'-help' to see a list of allowed arguments/flags.
* Since the plotting tol has a lot of different options, I've given it a GUI:
utils/post_unfolding/plot/plotting_tool_GUI/BandUP_plot_GUI.pyw
You'll find a symlink to it (bandup_plot) in the BandUP_bin folder.
* The GUI requires that you have PyQt4 in you python install.
* If you move the BandUP_plot_GUI.pyw file, move the BandUP_plot_GUI.ui too.



===================================================================================
Please mind that:
===================================================================================
Expand Down
45 changes: 44 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,57 @@ working_dir=`pwd`
bin_folder="${working_dir}/BandUP_bin"
mkdir -p ${bin_folder}
rm -f ${bin_folder}/BandUP.x
rm -f ${bin_folder}/bandup

cd ${working_dir}/src/external
./BandUP_configure_spglib.sh
./BandUP_configure_cla.sh
cd ${working_dir}/utils/pre_unfolding/get_SCKPTS_pre_BandUP
make
make clean
rm -f ${bin_folder}/get_SCKPTS_pre_BandUP.x
ln -s `pwd`/get_SCKPTS_pre_BandUP.x ${bin_folder}/get_SCKPTS_pre_BandUP.x
cd ${working_dir}/src
make
make clean
mv -f BandUP.x ${bin_folder}
mv -f BandUP.x ${bin_folder}
ln -s ${bin_folder}/BandUP.x ${bin_folder}/bandup
cd ${working_dir}

BANDUP="${bin_folder}/BandUP.x"
BANDUPBINPATH="${bin_folder}"
BANDUPPLOTPATH="${working_dir}/utils/post_unfolding/plot/"
bandup_folder="${working_dir}"

rm -f ${BANDUPBINPATH}/'bandup_plot'
rm -f ${BANDUPBINPATH}/'BandUP_plot_GUI.ui'
rm -f ${BANDUPBINPATH}/'plot_unfolded_EBS_BandUP.py'
ln -s ${BANDUPPLOTPATH}/plotting_tool_GUI/BandUP_plot_GUI.pyw ${BANDUPBINPATH}/'bandup_plot'
ln -s ${BANDUPPLOTPATH}/plotting_tool_GUI/BandUP_plot_GUI.ui ${BANDUPBINPATH}/'BandUP_plot_GUI.ui'
ln -s ${BANDUPPLOTPATH}/plot_unfolded_EBS_BandUP.py ${BANDUPBINPATH}/'plot_unfolded_EBS_BandUP.py'

now="$(date +'%Y_%m_%d-%T')"
for var_name in 'BANDUP' 'BANDUPBINPATH' 'BANDUPPLOTPATH' 'bandup_folder'
do
export_statement="export $var_name=${!var_name}"
for filename in ".bashrc" ".bash_profile" ".profile"
do
file="${HOME}/${filename}"
if [ -e "${file}" ] && [ ! -L "${file}" ]
then
if ! grep -Fq "$export_statement" $file # if environment variable has not been exported before
then
# Making a backup of the file in case it needs to be changed
backup_file="${file}.backup.before_installing_BandUP_${now}"
if [ ! -e "${backup_file}" ]
then
cp "${file}" "${backup_file}"
echo "" >> ${file}
fi
echo "${export_statement} # Set by BandUP in ${now}" >> ${file}
fi
fi
done
done

# End of script
8 changes: 6 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ FCFLAGS += -diag-disable remark
# Aliases
current_dir = $(shell pwd)
BandUP_src_folder = $(current_dir)
cla_folder = $(BandUP_src_folder)/external/claf90
spglib_folder = $(BandUP_src_folder)/external/spglib-1.5.2
vasp_related_modules_folder = $(BandUP_src_folder)/vasp_related_modules

# libraries needed for linking
LIBS = $(spglib_folder)/src/.libs/libsymspg.a

# Folders containing needed sources
vpath %.f90 $(cla_folder)
vpath %.f90 $(spglib_folder)/example
vpath %.f90 $(BandUP_src_folder)
vpath %.f90 $(vasp_related_modules_folder)
Expand All @@ -42,14 +44,16 @@ EXE = BandUP.x
# "make" builds all
all: $(EXE)

cla.o: kinds.o
options_setup_mod.o: cla.o kinds.o
math_mod.o: spglib_f08.o
band_unfolding_routines_mod.o: math_mod.o
read_wavecar_mod.o: math_mod.o general_io_mod.o
read_vasp_files_mod.o: math_mod.o general_io_mod.o strings_mod.o
write_vasp_files_mod.o: math_mod.o general_io_mod.o strings_mod.o
io_routines_mod.o: math_mod.o strings_mod.o general_io_mod.o read_vasp_files_mod.o write_vasp_files_mod.o read_wavecar_mod.o
$(OBJ): spglib_f08.o math_mod.o io_routines_mod.o read_wavecar_mod.o read_vasp_files_mod.o write_vasp_files_mod.o band_unfolding_routines_mod.o
$(EXE): spglib_f08.o math_mod.o band_unfolding_routines_mod.o general_io_mod.o read_wavecar_mod.o read_vasp_files_mod.o write_vasp_files_mod.o strings_mod.o io_routines_mod.o $(OBJ)
$(OBJ): cla.o kinds.o options_setup_mod.o spglib_f08.o math_mod.o io_routines_mod.o read_wavecar_mod.o read_vasp_files_mod.o write_vasp_files_mod.o band_unfolding_routines_mod.o
$(EXE): cla.o kinds.o options_setup_mod.o spglib_f08.o math_mod.o band_unfolding_routines_mod.o general_io_mod.o read_wavecar_mod.o read_vasp_files_mod.o write_vasp_files_mod.o strings_mod.o io_routines_mod.o $(OBJ)

# ======================================================================
# General rules
Expand Down
46 changes: 26 additions & 20 deletions src/band_unfolding_routines_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -192,22 +192,22 @@ end subroutine define_pckpts_to_be_checked


subroutine select_coeffs_to_calc_spectral_weights(selected_coeff_indices, &
iall_G,b_matrix_pc,B_matrix_SC,nplane, &
iall_G,b_matrix_pc,B_matrix_SC, &
folding_G, &
tol_for_vec_equality)
!! Copyright (C) 2013, 2014 Paulo V. C. Medeiros
implicit none
integer, dimension(:), allocatable, intent(out) :: selected_coeff_indices
integer, dimension(:,:), intent(in) :: iall_G !Coordinates of the G points in the [b1, b2, b3] basis.
real(kind=dp), dimension(1:3,1:3), intent(in) :: b_matrix_pc,B_matrix_SC
integer, intent(in) :: nplane
real(kind=dp), dimension(1:3), intent(in) :: folding_G
real(kind=dp), intent(in) :: tol_for_vec_equality
integer :: alloc_stat, ig
integer :: alloc_stat, ig, nplane
real(kind=dp), dimension(1:3) :: SC_G, trial_pc_g,g
real(kind=dp) :: tol

tol = 0.1_dp * tol_for_vec_equality
nplane = size(iall_G, dim=2)
deallocate(selected_coeff_indices, stat=alloc_stat)
do while((.not. allocated(selected_coeff_indices)) .and. &
(tol <= max_tol_for_vec_equality))
Expand Down Expand Up @@ -375,29 +375,35 @@ subroutine get_delta_Ns_for_output(delta_N_only_selected_dirs,delta_N_symm_avrgd
delta_N,dirs_req_for_symmavgd_EBS_along_pcbz_dir,pckpts_to_be_checked)
!! Copyright (C) 2013, 2014 Paulo V. C. Medeiros
implicit none
type(delta_Ns_for_output), intent(out) :: delta_N_only_selected_dirs, delta_N_symm_avrgd_for_EBS
type(delta_Ns), intent(in) :: delta_N
type(delta_Ns_for_output), dimension(:), allocatable, intent(out) :: delta_N_only_selected_dirs, delta_N_symm_avrgd_for_EBS
type(delta_Ns), dimension(:), intent(in) :: delta_N
type(selected_pcbz_directions), intent(in) :: pckpts_to_be_checked
type(irr_bz_directions), dimension(:), intent(in) :: dirs_req_for_symmavgd_EBS_along_pcbz_dir
integer :: nener,i_selec_pcbz_dir,ipc_kpt,i_needed_dirs
integer :: nener, i_selec_pcbz_dir, ipc_kpt, i_needed_dirs, n_spinor_components, i_spinor
real(kind=dp), dimension(:), allocatable :: avrgd_dNs
real(kind=dp) :: weight

call allocate_delta_Ns_for_output_type(delta_N_only_selected_dirs,pckpts_to_be_checked)
call allocate_delta_Ns_for_output_type(delta_N_symm_avrgd_for_EBS,pckpts_to_be_checked)
nener = size(delta_N%selec_pcbz_dir(1)%needed_dir(1)%pckpt(1)%dN(:))
n_spinor_components = size(delta_N, dim=1)
allocate(delta_N_only_selected_dirs(1:n_spinor_components))
allocate(delta_N_symm_avrgd_for_EBS(1:n_spinor_components))

nener = size(delta_N(1)%selec_pcbz_dir(1)%needed_dir(1)%pckpt(1)%dN(:))
allocate(avrgd_dNs(1:nener))
do i_selec_pcbz_dir=1,size(delta_N%selec_pcbz_dir(:))
delta_N_only_selected_dirs%pcbz_dir(i_selec_pcbz_dir) = delta_N%selec_pcbz_dir(i_selec_pcbz_dir)%needed_dir(1)
do ipc_kpt=1, size(delta_N%selec_pcbz_dir(i_selec_pcbz_dir)%needed_dir(1)%pckpt(:))
avrgd_dNs(:) = 0.0_dp
allocate(delta_N_symm_avrgd_for_EBS%pcbz_dir(i_selec_pcbz_dir)%pckpt(ipc_kpt)%dN(1:nener))
do i_needed_dirs=1,size(delta_N%selec_pcbz_dir(i_selec_pcbz_dir)%needed_dir(:))
weight = dirs_req_for_symmavgd_EBS_along_pcbz_dir(i_selec_pcbz_dir)%irr_dir(i_needed_dirs)%weight
avrgd_dNs = avrgd_dNs + weight*delta_N%selec_pcbz_dir(i_selec_pcbz_dir)%needed_dir(i_needed_dirs)%pckpt(ipc_kpt)%dN(:)
enddo
delta_N_symm_avrgd_for_EBS%pcbz_dir(i_selec_pcbz_dir)%pckpt(ipc_kpt)%dN(:) = avrgd_dNs(:)
enddo
do i_spinor=1,n_spinor_components
call allocate_delta_Ns_for_output_type(delta_N_only_selected_dirs(i_spinor), pckpts_to_be_checked)
call allocate_delta_Ns_for_output_type(delta_N_symm_avrgd_for_EBS(i_spinor), pckpts_to_be_checked)
do i_selec_pcbz_dir=1,size(delta_N(i_spinor)%selec_pcbz_dir(:))
delta_N_only_selected_dirs(i_spinor)%pcbz_dir(i_selec_pcbz_dir) = delta_N(i_spinor)%selec_pcbz_dir(i_selec_pcbz_dir)%needed_dir(1)
do ipc_kpt=1, size(delta_N(i_spinor)%selec_pcbz_dir(i_selec_pcbz_dir)%needed_dir(1)%pckpt(:))
avrgd_dNs(:) = 0.0_dp
allocate(delta_N_symm_avrgd_for_EBS(i_spinor)%pcbz_dir(i_selec_pcbz_dir)%pckpt(ipc_kpt)%dN(1:nener))
do i_needed_dirs=1,size(delta_N(i_spinor)%selec_pcbz_dir(i_selec_pcbz_dir)%needed_dir(:))
weight = dirs_req_for_symmavgd_EBS_along_pcbz_dir(i_selec_pcbz_dir)%irr_dir(i_needed_dirs)%weight
avrgd_dNs = avrgd_dNs + weight*delta_N(i_spinor)%selec_pcbz_dir(i_selec_pcbz_dir)%needed_dir(i_needed_dirs)%pckpt(ipc_kpt)%dN(:)
enddo
delta_N_symm_avrgd_for_EBS(i_spinor)%pcbz_dir(i_selec_pcbz_dir)%pckpt(ipc_kpt)%dN(:) = avrgd_dNs(:)
enddo
enddo
enddo

end subroutine get_delta_Ns_for_output
Expand Down
4 changes: 4 additions & 0 deletions src/external/BandUP_configure_cla.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /bin/sh

rm -rf claf90
tar -xvzf claf90.tgz
Binary file added src/external/claf90.tgz
Binary file not shown.
73 changes: 63 additions & 10 deletions src/general_io_mod.f90
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
!! Copyright (C) 2013 Paulo V. C. Medeiros
!! Copyright (C) 2013, 2014 Paulo V. C. Medeiros
!!
!! This file is part of BandUP: Band Unfolding code for Plane-wave based calculations.
!!
Expand All @@ -17,16 +17,25 @@

module general_io
implicit none
SAVE
PRIVATE
PUBLIC :: available_io_unit, package_version, file_header_BandUP, file_header_BandUP_short, &
file_for_pc_reduced_to_prim_cell, file_for_SC_reduced_to_prim_cell

character(len=30), parameter :: package_version="2.3.0, 2014-06-11"
character(len=127), parameter :: file_header_BandUP="# File created by BandUP - Band Unfolding code for Plane-wave based calculations, &
V"//trim(adjustl(package_version)), &
file_header_BandUP_short="# File created by BandUP, V"//trim(adjustl(package_version)), &
file_for_pc_reduced_to_prim_cell="BandUP_suggestion_of_pc_for_your_reference_unit_cell.POSCAR", &
file_for_SC_reduced_to_prim_cell="BandUP_suggestion_of_smaller_SC_based_on_your_input_SC.POSCAR"
PUBLIC :: available_io_unit, file_extension, filename_without_extension, &
str_len, package_version, file_header_BandUP, file_header_BandUP_short, &
file_for_pc_reduced_to_prim_cell, file_for_SC_reduced_to_prim_cell, &
input_file_prim_cell, input_file_supercell, input_file_pc_kpts, input_file_energies, &
output_file_only_user_selec_direcs, output_file_symm_averaged_EBS, WF_file

integer, parameter :: str_len=256
character(len=30), parameter :: package_version="2.4.0 (BETA), 2014-07-19"
character(len=str_len), parameter :: file_header_BandUP="# File created by BandUP - Band Unfolding code for Plane-wave based calculations, &
V"//trim(adjustl(package_version)), &
file_header_BandUP_short="# File created by BandUP, V"//trim(adjustl(package_version)), &
file_for_pc_reduced_to_prim_cell="BandUP_suggestion_of_pc_for_your_reference_unit_cell.POSCAR", &
file_for_SC_reduced_to_prim_cell="BandUP_suggestion_of_smaller_SC_based_on_your_input_SC.POSCAR"

character(len=str_len) :: input_file_prim_cell, input_file_supercell, &
input_file_pc_kpts, input_file_energies, WF_file, &
output_file_only_user_selec_direcs, output_file_symm_averaged_EBS
!! Functions and subroutines
CONTAINS

Expand Down Expand Up @@ -66,5 +75,49 @@ function available_io_unit(min_unit,max_unit) result(unit_num)

end function available_io_unit

function file_extension(filename, extention_length) result(ext)
implicit none
character(len=:), allocatable :: ext
character(len=*), intent(in) :: filename
integer, intent(in), optional :: extention_length
integer :: ext_length, dot_position

ext_length = 3
if(present(extention_length))then
ext_length = extention_length
endif
allocate(character(ext_length) :: ext)

ext = ''
if(len(filename) >= ext_length + 1)then
dot_position = scan(filename, '.', back=.TRUE.)
if(dot_position > 0)then
ext = trim(adjustl(filename(dot_position + 1:len(filename))))
endif
endif

end function file_extension


function filename_without_extension(filename) result(rtn)
implicit none
character(len=*), intent(in) :: filename
character(len=len(filename)) :: rtn
integer :: dot_position

if(trim(adjustl(filename))=='')then
rtn = ''
return
endif

dot_position = scan(filename, '.', back=.TRUE.)
if(dot_position > 0)then
rtn = filename(1:dot_position-1)
else
rtn = trim(adjustl(filename))
endif

end function filename_without_extension


end module general_io
Loading

0 comments on commit dd8a880

Please sign in to comment.