Skip to content

Commit 2cf17c3

Browse files
committed
update an example to calculate magnetoresistance of Cu
1 parent d8cf608 commit 2cf17c3

16 files changed

+422
-50048
lines changed

examples/Cu/AMR-xy/AMR_rhoT.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Merge data of the same temperature from different folders.
2+
import os
3+
import re
4+
5+
def extract_different_temp_data(f, ca_num, output_dir):
6+
"""
7+
:param f:
8+
:param ca_num
9+
:return:
10+
"""
11+
with open(f, 'r', encoding='utf-8') as data_file:
12+
line = data_file.readline()
13+
while line:
14+
if '# T' in line:
15+
line=line.strip()
16+
tmp = line.split(' ')[-2]
17+
output_file = './{}/{}K.dat'.format(output_dir, tmp)
18+
with open(output_file, 'a+', encoding='utf-8') as out:
19+
out.write('# {}\n'.format(ca_num))
20+
line = data_file.readline()
21+
while line:
22+
if '# T' not in line:
23+
out.write(line)
24+
line = data_file.readline()
25+
else:
26+
break
27+
else:
28+
line = data_file.readline()
29+
30+
31+
if __name__ == '__main__':
32+
number=1 #Btheta as the variable, number=0; Bphi as the variable, number=1
33+
dirs = os.listdir('.')
34+
if not os.path.exists('./rho'):
35+
os.mkdir('./rho')
36+
files= os.listdir('./rho')
37+
for file in files:
38+
if file.endswith('K.dat'):
39+
file_path = os.path.join('./rho', file)
40+
os.remove(file_path)
41+
42+
tmp_list = []
43+
for dir_name in dirs:
44+
if 'Btheta' in dir_name:
45+
angle=re.findall(r'\d+',dir_name)
46+
tmp=int(angle[number])
47+
tmp_list.append(tmp)
48+
tmp_list.sort()
49+
for dir_name_num in tmp_list:
50+
ca_num = str(int(dir_name_num))
51+
#dir_name = 'Btheta' + str(dir_name_num) + 'Bphi90'
52+
dir_name = 'Btheta90'+ 'Bphi' + str(dir_name_num)
53+
extract_different_temp_data('./{}/rho_total_mu_0.00eV.dat'.format(dir_name), ca_num=ca_num, output_dir='rho')

examples/Cu/AMR-xy/AMR_rhotheta.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import os
2+
import re
3+
import numpy as np
4+
def extract_rho_theta(f,dtheta,num_show,interval_line,choose,output_file, output_dir):
5+
index = -1
6+
for _ in range(num_show):
7+
theta=-dtheta
8+
index = index+1
9+
with open(f, 'r', encoding='utf-8') as data_file:
10+
line = data_file.readline()
11+
outfile = './{}/{}'.format(output_dir,output_file)
12+
with open(outfile, 'a+', encoding='utf-8') as out:
13+
out.write('#Btau = {:.2f}\n'.format(choose[index]))
14+
out.write('\n')
15+
while line:
16+
if 'BTau' in line:
17+
theta=theta+dtheta
18+
for __ in range(index*interval_line+1):
19+
line=data_file.readline()
20+
parts=line.split()
21+
formparts=['{:>14}'.format(part) for part in parts]
22+
formparts[0]='{:>5}'.format(str(theta))
23+
line=' '.join(formparts)+'\n'
24+
out.write(line)
25+
line = data_file.readline()
26+
else:
27+
line = data_file.readline()
28+
29+
30+
if __name__ == '__main__':
31+
theta_interval=5
32+
Btau_show=6
33+
Btau_num=101
34+
Btau_max=10
35+
Btau_list=np.linspace(0,Btau_max,Btau_num)
36+
Btau_interval=int((Btau_num-1)/(Btau_show-1))
37+
Btau_choose=Btau_list[::Btau_interval]
38+
dirs = os.listdir('.')
39+
if not os.path.exists('./rhotheta'):
40+
os.mkdir('./rhotheta')
41+
files= os.listdir('./rhotheta')
42+
for file in files:
43+
if file.endswith('K_Btau.dat'):
44+
file_path = os.path.join('./rhotheta', file)
45+
os.remove(file_path)
46+
tmp_list = []
47+
for dir_name in dirs:
48+
if 'K.dat' in dir_name:
49+
number=re.findall(r'\d+\.\d+',dir_name)
50+
tmp_list.append(number[0])
51+
for temperature_name in tmp_list:
52+
temperature_name = str(temperature_name)
53+
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')
54+

examples/Cu/AMR-xy/AMR_rhoxx.gnu

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
set encoding iso_8859_1
2+
set terminal pdfcairo enhanced color font "Arial,20" size 8, 6
3+
set output 'rhoxx.pdf'
4+
set border lw 10
5+
set autoscale fix
6+
set ylabel '{/Symbol r}_{xx}*{/Symbol t} ({/Symbol W}*m*s)'
7+
set format y "%1.1e"
8+
set xlabel '{/Symbol \161}'
9+
set xrange [0:180]
10+
set yrange [1.2e-21:2.5e-21]
11+
set xtics 30
12+
set key outside
13+
#unset key
14+
set palette defined (0 'red', 1 'green')
15+
unset colorbox
16+
17+
set lmargin at screen 0.25 # 左边距占页面宽度的10%
18+
set rmargin at screen 0.80 # 右边距占页面宽度的90%
19+
set bmargin at screen 0.2 # 下边距占页面高度的10%
20+
set tmargin at screen 0.9 # 上边距占页面高度的90%
21+
22+
set ylabel offset -5,0
23+
set xlabel offset 0,-1
24+
set key right vertical spacing 5
25+
set xtics font ",33"
26+
set ytics font ",33"
27+
set ylabel font ",40"
28+
set xlabel font ",40"
29+
set key font ",27"
30+
set key spacing 1.2
31+
set key samplen 1.0
32+
set xtics 30
33+
set ytics 0.3e-21
34+
35+
36+
Bmin = 2.00
37+
Bmax = 10.00
38+
NumB = 6
39+
lw = 10
40+
41+
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)

examples/Cu/AMR-xy/AMR_rhozz.gnu

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
set encoding iso_8859_1
2+
set terminal pdfcairo enhanced color font "Arial,20" size 8, 6
3+
set output 'rhozz.pdf'
4+
set border lw 10
5+
set autoscale fix
6+
set ylabel '{/Symbol r}_{zz}*{/Symbol t} ({/Symbol W}*m*s)'
7+
set format y "%1.1e"
8+
set xlabel '{/Symbol \161}'
9+
set xrange [0:180]
10+
set yrange [1.2e-21:2.7e-21]
11+
set xtics 30
12+
set key outside
13+
#unset key
14+
set palette defined (0 'red', 1 'green')
15+
unset colorbox
16+
17+
set lmargin at screen 0.25 # 左边距占页面宽度的10%
18+
set rmargin at screen 0.80 # 右边距占页面宽度的90%
19+
set bmargin at screen 0.2 # 下边距占页面高度的10%
20+
set tmargin at screen 0.9 # 上边距占页面高度的90%
21+
22+
set ylabel offset -5,0
23+
set xlabel offset 0,-1
24+
set key right vertical spacing 5
25+
set xtics font ",33"
26+
set ytics font ",33"
27+
set ylabel font ",40"
28+
set xlabel font ",40"
29+
set key font ",27"
30+
set key spacing 1.2
31+
set key samplen 1.0
32+
set xtics 30
33+
set ytics 0.3e-21
34+
35+
36+
Bmin = 2.00
37+
Bmax = 10.00
38+
NumB = 6
39+
lw = 10
40+
41+
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)

examples/Cu/AMR-xy/xyplane.sh

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/bin/bash
2+
3+
# alpha is the angle between the magnetic field and the z' axis in the z'-b plane, where z' axis is
4+
# perpendicular to a and b axis.
5+
6+
for ((iphi=0; iphi<=36; iphi++))
7+
do
8+
9+
theta=90
10+
phi=`echo "$iphi*5"|bc`
11+
dir='Btheta'$theta'Bphi'$phi
12+
echo $theta $phi $dir
13+
mkdir $dir
14+
15+
cat >$dir/wt.in <<EOF
16+
&TB_FILE
17+
Hrfile = 'wannier90_hr.dat_nsymm48'
18+
/
19+
20+
21+
&CONTROL
22+
Boltz_OHE_calc = T
23+
Symmetry_Import_calc = T ! please set it to be true for magnetoresistance calculation
24+
/
25+
26+
&SYSTEM
27+
SOC = 0 ! without soc : SOC=0; with soc : SOC=1
28+
E_FERMI = 7.7083 ! e-fermi
29+
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
30+
NumOccupied = 6 ! set it anyway even don't use it.
31+
/
32+
33+
&PARAMETERS
34+
OmegaNum = 1 ! omega number
35+
OmegaMin = 0 ! energy interval
36+
OmegaMax = 0 ! energy interval E_i= OmegaMin+ (OmegaMax-OmegaMin)/(OmegaNum-1)*(i-1)
37+
EF_broadening = 0.05 ! in eV, a broadening factor to choose the k points for integration
38+
Nk1 =81 ! Kmesh(1) for KCUBE_BULK
39+
Nk2 =81 ! Kmesh(2) for KCUBE_BULK
40+
Nk3 =81 ! Kmesh(3) for KCUBE_BULK
41+
BTauNum= 101 ! Number of B*tau we calculate
42+
BTauMax = 10.0 ! The maximum B*tau, starting from Btau=0.
43+
Tmin = 30 ! Temperature in Kelvin
44+
Tmax = 120 ! Temperature in Kelvin
45+
NumT = 4 ! number temperature we calculate. T_i=Tmin+(Tmax-Tmin)*(i-1)/(NumT-1)
46+
Nslice_BTau_Max = 20000 ! increase this number if negative magnetoresistance occurs, default =5000
47+
RKF45_PERIODIC_LEVEL = 1 !
48+
/
49+
50+
LATTICE
51+
Angstrom
52+
0.0000000 1.8075000 1.8075000
53+
1.8075000 0.0000000 1.8075000
54+
1.8075000 1.8075000 0.0000000
55+
56+
ATOM_POSITIONS
57+
1 ! number of atoms for projectors
58+
Cartisen ! Direct or Cartisen coordinate
59+
Cu 0.000000 0.000000 0.000000
60+
61+
PROJECTORS
62+
9 ! number of projectors
63+
Cu s s s s s dxy dyz dzx dx2-y2 dz2
64+
65+
SURFACE ! should be given even don't use
66+
1 0 0
67+
0 1 0
68+
69+
SELECTEDBANDS
70+
1
71+
6
72+
73+
KCUBE_BULK
74+
0.00 0.00 0.00 ! Original point for 3D k plane
75+
1.00 0.00 0.00 ! The first vector to define 3d k space plane
76+
0.00 1.00 0.00 ! The second vector to define 3d k space plane
77+
0.00 0.00 1.00 ! The third vector to define 3d k cube
78+
EOF
79+
80+
cat>$dir/wt-theta.sh<<EOF2
81+
#!/bin/bash -l
82+
83+
##SBATCH --exclusive
84+
#SBATCH --account=hmt03
85+
#SBATCH --time=72:00:00
86+
##SBATCH --exclude=hpcc[154,155,156,114]
87+
#SBATCH --nodes=1
88+
##SBATCH --gres=gpu:4
89+
#SBATCH --partition=long
90+
#SBATCH --ntasks-per-core=1
91+
#SBATCH --cpus-per-task=1
92+
#SBATCH --ntasks-per-node=56
93+
#SBATCH --job-name=vasp_run
94+
#SBATCH --output=./log
95+
#SBATCH --error=./errormsg
96+
export OMP_NUM_THREADS=1
97+
export MKL_NUM_THREADS=1
98+
export MV2_ENABLE_AFFINITY=0
99+
echo "The current job ID is $SLURM_JOB_ID"
100+
echo "Running on $SLURM_JOB_NUM_NODES nodes:"
101+
echo $SLURM_JOB_NODELIST
102+
echo "Using $SLURM_NTASKS_PER_NODE tasks per node"
103+
echo "A total of $SLURM_NTASKS tasks is used"
104+
105+
ulimit -s unlimited
106+
ulimit -c unlimited
107+
module load cuda11.8
108+
module load oneapi22.3
109+
module load nvhpc/22.11
110+
111+
mpirun /home/liuzh/Wanniertools/wannier_tools/bin/wt.x
112+
113+
echo work done
114+
EOF2
115+
116+
cp wannier90_hr.dat_nsymm48 $dir/
117+
cd $dir
118+
sbatch wt-theta.sh
119+
cd ..
120+
done
121+

examples/Cu/kpath.gnu

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
set encoding iso_8859_1
2+
set terminal pdfcairo enhanced color font "Times-New-Roman,30" size 8,8
3+
set palette defined ( 0 "green", 5 "yellow", 10 "red" )
4+
set output 'kevolve.pdf'
5+
set style data linespoints
6+
set lmargin at screen 0.25 # 左边距占页面宽度的10%
7+
set rmargin at screen 0.95 # 右边距占页面宽度的90%
8+
set bmargin at screen 0.2 # 下边距占页面高度的10%
9+
set tmargin at screen 0.9 # 上边距占页面高度的90%
10+
unset ztics
11+
set pointsize 0.8
12+
set view 0,0
13+
set key font ",40"
14+
set key samplen 0.8
15+
set key spacing 1.5
16+
#set mxtics 0.005
17+
#set ytics 0.05
18+
set xtics font ",55"
19+
set ytics font ",55"
20+
set ylabel font ",60"
21+
set xlabel font ",60"
22+
set ylabel offset -3.8,0
23+
set xtics offset 0.0,-0.1
24+
set xlabel offset 0.0,-0.5
25+
set border lw 10
26+
27+
28+
set xlabel "k_x (1/{\305})"
29+
set ylabel "k_y (1/{\305})"
30+
set xrange [-1.0:1.0]
31+
set yrange [-1.0:1.0]
32+
set xtics 0.4
33+
set ytics 0.4
34+
plot 'K.txt' u ( $2):($3) w p pt 6 ps 0.2 lc rgb '#712A7D' title sprintf('kz=0 (1/{\305})'),\

examples/Cu/lpath.gnu

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
set encoding iso_8859_1
2+
set terminal pdfcairo enhanced color font "Times-New-Roman,30" size 8,8
3+
set palette defined ( 0 "green", 5 "yellow", 10 "red" )
4+
set output 'levolve.pdf'
5+
set style data linespoints
6+
set lmargin at screen 0.25 # 左边距占页面宽度的10%
7+
set rmargin at screen 0.95 # 右边距占页面宽度的90%
8+
set bmargin at screen 0.2 # 下边距占页面高度的10%
9+
set tmargin at screen 0.9 # 上边距占页面高度的90%
10+
unset ztics
11+
set pointsize 0.8
12+
set view 0,0
13+
set key font ",40"
14+
set key samplen 0.8
15+
set key spacing 1.5
16+
#set mxtics 0.005
17+
#set ytics 0.05
18+
set xtics font ",55"
19+
set ytics font ",55"
20+
set ylabel font ",60"
21+
set xlabel font ",60"
22+
set ylabel offset -3.8,0
23+
set xtics offset 0.0,-0.1
24+
set xlabel offset 0.0,-0.5
25+
set border lw 10
26+
27+
28+
set xlabel "l_x ({\305})"
29+
set ylabel "l_y ({\305})"
30+
set xrange [-0.6:0.6]
31+
set yrange [-0.6:0.6]
32+
set xtics 0.3
33+
set ytics 0.3
34+
plot 'K.txt' u ( $5):($6) w p pt 6 ps 0.2 lc rgb '#712A7D' title sprintf('lz=0 ({\305})'),\

examples/Cu/rho.gnu

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)