Skip to content

Commit

Permalink
update an example to calculate magnetoresistance of Cu
Browse files Browse the repository at this point in the history
  • Loading branch information
quanshengwu committed May 18, 2024
1 parent d8cf608 commit 2cf17c3
Show file tree
Hide file tree
Showing 16 changed files with 422 additions and 50,048 deletions.
53 changes: 53 additions & 0 deletions examples/Cu/AMR-xy/AMR_rhoT.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Merge data of the same temperature from different folders.
import os
import re

def extract_different_temp_data(f, ca_num, output_dir):
"""
:param f:
:param ca_num
:return:
"""
with open(f, 'r', encoding='utf-8') as data_file:
line = data_file.readline()
while line:
if '# T' in line:
line=line.strip()
tmp = line.split(' ')[-2]
output_file = './{}/{}K.dat'.format(output_dir, tmp)
with open(output_file, 'a+', encoding='utf-8') as out:
out.write('# {}\n'.format(ca_num))
line = data_file.readline()
while line:
if '# T' not in line:
out.write(line)
line = data_file.readline()
else:
break
else:
line = data_file.readline()


if __name__ == '__main__':
number=1 #Btheta as the variable, number=0; Bphi as the variable, number=1
dirs = os.listdir('.')
if not os.path.exists('./rho'):
os.mkdir('./rho')
files= os.listdir('./rho')
for file in files:
if file.endswith('K.dat'):
file_path = os.path.join('./rho', file)
os.remove(file_path)

tmp_list = []
for dir_name in dirs:
if 'Btheta' in dir_name:
angle=re.findall(r'\d+',dir_name)
tmp=int(angle[number])
tmp_list.append(tmp)
tmp_list.sort()
for dir_name_num in tmp_list:
ca_num = str(int(dir_name_num))
#dir_name = 'Btheta' + str(dir_name_num) + 'Bphi90'
dir_name = 'Btheta90'+ 'Bphi' + str(dir_name_num)
extract_different_temp_data('./{}/rho_total_mu_0.00eV.dat'.format(dir_name), ca_num=ca_num, output_dir='rho')
54 changes: 54 additions & 0 deletions examples/Cu/AMR-xy/AMR_rhotheta.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import os
import re
import numpy as np
def extract_rho_theta(f,dtheta,num_show,interval_line,choose,output_file, output_dir):
index = -1
for _ in range(num_show):
theta=-dtheta
index = index+1
with open(f, 'r', encoding='utf-8') as data_file:
line = data_file.readline()
outfile = './{}/{}'.format(output_dir,output_file)
with open(outfile, 'a+', encoding='utf-8') as out:
out.write('#Btau = {:.2f}\n'.format(choose[index]))
out.write('\n')
while line:
if 'BTau' in line:
theta=theta+dtheta
for __ in range(index*interval_line+1):
line=data_file.readline()
parts=line.split()
formparts=['{:>14}'.format(part) for part in parts]
formparts[0]='{:>5}'.format(str(theta))
line=' '.join(formparts)+'\n'
out.write(line)
line = data_file.readline()
else:
line = data_file.readline()


if __name__ == '__main__':
theta_interval=5
Btau_show=6
Btau_num=101
Btau_max=10
Btau_list=np.linspace(0,Btau_max,Btau_num)
Btau_interval=int((Btau_num-1)/(Btau_show-1))
Btau_choose=Btau_list[::Btau_interval]
dirs = os.listdir('.')
if not os.path.exists('./rhotheta'):
os.mkdir('./rhotheta')
files= os.listdir('./rhotheta')
for file in files:
if file.endswith('K_Btau.dat'):
file_path = os.path.join('./rhotheta', file)
os.remove(file_path)
tmp_list = []
for dir_name in dirs:
if 'K.dat' in dir_name:
number=re.findall(r'\d+\.\d+',dir_name)
tmp_list.append(number[0])
for temperature_name in tmp_list:
temperature_name = str(temperature_name)
extract_rho_theta('./{}K.dat'.format(temperature_name),dtheta=theta_interval,num_show=Btau_show, interval_line=Btau_interval,choose=Btau_choose,output_file='./{}K_Btau.dat'.format(temperature_name), output_dir='rhotheta')

41 changes: 41 additions & 0 deletions examples/Cu/AMR-xy/AMR_rhoxx.gnu
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
set encoding iso_8859_1
set terminal pdfcairo enhanced color font "Arial,20" size 8, 6
set output 'rhoxx.pdf'
set border lw 10
set autoscale fix
set ylabel '{/Symbol r}_{xx}*{/Symbol t} ({/Symbol W}*m*s)'
set format y "%1.1e"
set xlabel '{/Symbol \161}'
set xrange [0:180]
set yrange [1.2e-21:2.5e-21]
set xtics 30
set key outside
#unset key
set palette defined (0 'red', 1 'green')
unset colorbox

set lmargin at screen 0.25 # 左边距占页面宽度的10%
set rmargin at screen 0.80 # 右边距占页面宽度的90%
set bmargin at screen 0.2 # 下边距占页面高度的10%
set tmargin at screen 0.9 # 上边距占页面高度的90%

set ylabel offset -5,0
set xlabel offset 0,-1
set key right vertical spacing 5
set xtics font ",33"
set ytics font ",33"
set ylabel font ",40"
set xlabel font ",40"
set key font ",27"
set key spacing 1.2
set key samplen 1.0
set xtics 30
set ytics 0.3e-21


Bmin = 2.00
Bmax = 10.00
NumB = 6
lw = 10

plot for [i=0:NumB-1] '90.0000K_Btau.dat' every :::i::i+1 u 1:2 w l lw lw title sprintf('B=%.0f T',2*i)
41 changes: 41 additions & 0 deletions examples/Cu/AMR-xy/AMR_rhozz.gnu
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
set encoding iso_8859_1
set terminal pdfcairo enhanced color font "Arial,20" size 8, 6
set output 'rhozz.pdf'
set border lw 10
set autoscale fix
set ylabel '{/Symbol r}_{zz}*{/Symbol t} ({/Symbol W}*m*s)'
set format y "%1.1e"
set xlabel '{/Symbol \161}'
set xrange [0:180]
set yrange [1.2e-21:2.7e-21]
set xtics 30
set key outside
#unset key
set palette defined (0 'red', 1 'green')
unset colorbox

set lmargin at screen 0.25 # 左边距占页面宽度的10%
set rmargin at screen 0.80 # 右边距占页面宽度的90%
set bmargin at screen 0.2 # 下边距占页面高度的10%
set tmargin at screen 0.9 # 上边距占页面高度的90%

set ylabel offset -5,0
set xlabel offset 0,-1
set key right vertical spacing 5
set xtics font ",33"
set ytics font ",33"
set ylabel font ",40"
set xlabel font ",40"
set key font ",27"
set key spacing 1.2
set key samplen 1.0
set xtics 30
set ytics 0.3e-21


Bmin = 2.00
Bmax = 10.00
NumB = 6
lw = 10

plot for [i=0:NumB-1] '90.0000K_Btau.dat' every :::i::i+1 u 1:10 w l lw lw title sprintf('B=%.0f T',2*i)
121 changes: 121 additions & 0 deletions examples/Cu/AMR-xy/xyplane.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#!/bin/bash

# alpha is the angle between the magnetic field and the z' axis in the z'-b plane, where z' axis is
# perpendicular to a and b axis.

for ((iphi=0; iphi<=36; iphi++))
do

theta=90
phi=`echo "$iphi*5"|bc`
dir='Btheta'$theta'Bphi'$phi
echo $theta $phi $dir
mkdir $dir

cat >$dir/wt.in <<EOF
&TB_FILE
Hrfile = 'wannier90_hr.dat_nsymm48'
/
&CONTROL
Boltz_OHE_calc = T
Symmetry_Import_calc = T ! please set it to be true for magnetoresistance calculation
/
&SYSTEM
SOC = 0 ! without soc : SOC=0; with soc : SOC=1
E_FERMI = 7.7083 ! e-fermi
Btheta= $theta, Bphi= $phi ! magnetic field direction, Btheta is the angle with z axial, Bphi is the angle with respect to x axial in the x-y plane
NumOccupied = 6 ! set it anyway even don't use it.
/
&PARAMETERS
OmegaNum = 1 ! omega number
OmegaMin = 0 ! energy interval
OmegaMax = 0 ! energy interval E_i= OmegaMin+ (OmegaMax-OmegaMin)/(OmegaNum-1)*(i-1)
EF_broadening = 0.05 ! in eV, a broadening factor to choose the k points for integration
Nk1 =81 ! Kmesh(1) for KCUBE_BULK
Nk2 =81 ! Kmesh(2) for KCUBE_BULK
Nk3 =81 ! Kmesh(3) for KCUBE_BULK
BTauNum= 101 ! Number of B*tau we calculate
BTauMax = 10.0 ! The maximum B*tau, starting from Btau=0.
Tmin = 30 ! Temperature in Kelvin
Tmax = 120 ! Temperature in Kelvin
NumT = 4 ! number temperature we calculate. T_i=Tmin+(Tmax-Tmin)*(i-1)/(NumT-1)
Nslice_BTau_Max = 20000 ! increase this number if negative magnetoresistance occurs, default =5000
RKF45_PERIODIC_LEVEL = 1 !
/
LATTICE
Angstrom
0.0000000 1.8075000 1.8075000
1.8075000 0.0000000 1.8075000
1.8075000 1.8075000 0.0000000
ATOM_POSITIONS
1 ! number of atoms for projectors
Cartisen ! Direct or Cartisen coordinate
Cu 0.000000 0.000000 0.000000
PROJECTORS
9 ! number of projectors
Cu s s s s s dxy dyz dzx dx2-y2 dz2
SURFACE ! should be given even don't use
1 0 0
0 1 0
SELECTEDBANDS
1
6
KCUBE_BULK
0.00 0.00 0.00 ! Original point for 3D k plane
1.00 0.00 0.00 ! The first vector to define 3d k space plane
0.00 1.00 0.00 ! The second vector to define 3d k space plane
0.00 0.00 1.00 ! The third vector to define 3d k cube
EOF

cat>$dir/wt-theta.sh<<EOF2
#!/bin/bash -l
##SBATCH --exclusive
#SBATCH --account=hmt03
#SBATCH --time=72:00:00
##SBATCH --exclude=hpcc[154,155,156,114]
#SBATCH --nodes=1
##SBATCH --gres=gpu:4
#SBATCH --partition=long
#SBATCH --ntasks-per-core=1
#SBATCH --cpus-per-task=1
#SBATCH --ntasks-per-node=56
#SBATCH --job-name=vasp_run
#SBATCH --output=./log
#SBATCH --error=./errormsg
export OMP_NUM_THREADS=1
export MKL_NUM_THREADS=1
export MV2_ENABLE_AFFINITY=0
echo "The current job ID is $SLURM_JOB_ID"
echo "Running on $SLURM_JOB_NUM_NODES nodes:"
echo $SLURM_JOB_NODELIST
echo "Using $SLURM_NTASKS_PER_NODE tasks per node"
echo "A total of $SLURM_NTASKS tasks is used"
ulimit -s unlimited
ulimit -c unlimited
module load cuda11.8
module load oneapi22.3
module load nvhpc/22.11
mpirun /home/liuzh/Wanniertools/wannier_tools/bin/wt.x
echo work done
EOF2

cp wannier90_hr.dat_nsymm48 $dir/
cd $dir
sbatch wt-theta.sh
cd ..
done

34 changes: 34 additions & 0 deletions examples/Cu/kpath.gnu
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
set encoding iso_8859_1
set terminal pdfcairo enhanced color font "Times-New-Roman,30" size 8,8
set palette defined ( 0 "green", 5 "yellow", 10 "red" )
set output 'kevolve.pdf'
set style data linespoints
set lmargin at screen 0.25 # 左边距占页面宽度的10%
set rmargin at screen 0.95 # 右边距占页面宽度的90%
set bmargin at screen 0.2 # 下边距占页面高度的10%
set tmargin at screen 0.9 # 上边距占页面高度的90%
unset ztics
set pointsize 0.8
set view 0,0
set key font ",40"
set key samplen 0.8
set key spacing 1.5
#set mxtics 0.005
#set ytics 0.05
set xtics font ",55"
set ytics font ",55"
set ylabel font ",60"
set xlabel font ",60"
set ylabel offset -3.8,0
set xtics offset 0.0,-0.1
set xlabel offset 0.0,-0.5
set border lw 10


set xlabel "k_x (1/{\305})"
set ylabel "k_y (1/{\305})"
set xrange [-1.0:1.0]
set yrange [-1.0:1.0]
set xtics 0.4
set ytics 0.4
plot 'K.txt' u ( $2):($3) w p pt 6 ps 0.2 lc rgb '#712A7D' title sprintf('kz=0 (1/{\305})'),\
34 changes: 34 additions & 0 deletions examples/Cu/lpath.gnu
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
set encoding iso_8859_1
set terminal pdfcairo enhanced color font "Times-New-Roman,30" size 8,8
set palette defined ( 0 "green", 5 "yellow", 10 "red" )
set output 'levolve.pdf'
set style data linespoints
set lmargin at screen 0.25 # 左边距占页面宽度的10%
set rmargin at screen 0.95 # 右边距占页面宽度的90%
set bmargin at screen 0.2 # 下边距占页面高度的10%
set tmargin at screen 0.9 # 上边距占页面高度的90%
unset ztics
set pointsize 0.8
set view 0,0
set key font ",40"
set key samplen 0.8
set key spacing 1.5
#set mxtics 0.005
#set ytics 0.05
set xtics font ",55"
set ytics font ",55"
set ylabel font ",60"
set xlabel font ",60"
set ylabel offset -3.8,0
set xtics offset 0.0,-0.1
set xlabel offset 0.0,-0.5
set border lw 10


set xlabel "l_x ({\305})"
set ylabel "l_y ({\305})"
set xrange [-0.6:0.6]
set yrange [-0.6:0.6]
set xtics 0.3
set ytics 0.3
plot 'K.txt' u ( $5):($6) w p pt 6 ps 0.2 lc rgb '#712A7D' title sprintf('lz=0 ({\305})'),\
13 changes: 0 additions & 13 deletions examples/Cu/rho.gnu

This file was deleted.

Loading

0 comments on commit 2cf17c3

Please sign in to comment.