Skip to content

Commit 5e43e17

Browse files
committed
v1.02
1 parent 7d0707d commit 5e43e17

File tree

9 files changed

+3675
-17
lines changed

9 files changed

+3675
-17
lines changed

MagneticTB/Corep.wl

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
(* ::Package:: *)
2+
3+
BeginPackage["MagneticTB`"]
4+
5+
6+
Begin["`Private`"]
7+
8+
9+
getSGLatt=SpaceGroupIrep`getSGLatt;
10+
BasicVectors=SpaceGroupIrep`BasicVectors;
11+
getRotMat=SpaceGroupIrep`getRotMat;
12+
getSpinRotOp=SpaceGroupIrep`getSpinRotOp;
13+
14+
15+
MSGSymStd=MSGCorep`MSGSymStd;
16+
getMSGElem=MSGCorep`getMSGElem;
17+
getBandCorep=MSGCorep`getBandCorep;
18+
showBandCorep=MSGCorep`showBandCorep;
19+
spinMatrix[op_] :=
20+
FullSimplify[Module[{\[Alpha], \[Beta], \[Gamma], nop},
21+
If[Det[op] == -1, nop = -op, nop = op];
22+
{\[Alpha], \[Beta], \[Gamma]} = -EulerAngles[nop];
23+
Transpose@{{E^(I \[Gamma]/2) Cos[\[Beta]/2] E^(I \[Alpha] /2), E^(I \[Gamma]/2) Sin[\[Beta]/2] E^(-I \[Alpha] /2)},
24+
{-E^(-I \[Gamma]/2) Sin[\[Beta]/2] E^(I \[Alpha] /2), E^(-I \[Gamma]/2) Cos[\[Beta]/2] E^(-I \[Alpha] /2)}}]];
25+
26+
27+
getMSGElemFromMSGCorep[MSG_]:=Module[
28+
{SG,brav,msgelem,latt},
29+
30+
31+
32+
If[Not@MemberQ[$Packages,"MSGCorep`"],Print["Please install and import MSGCorep package (https://github.com/goodluck1982/MSGCorep)";Abort[]];];
33+
msgelem=MapAt[If[#==0,"F","T"]&,getMSGElem[MSG],{;;,-1}];
34+
SG=MSG[[1]];
35+
brav=getSGLatt[SG];
36+
latt=BasicVectors[brav]/.{
37+
SpaceGroupIrep`a->MagneticTB`a,
38+
SpaceGroupIrep`b->MagneticTB`b,SpaceGroupIrep`c->MagneticTB`c,
39+
SpaceGroupIrep`\[Alpha]->MagneticTB`\[Alpha],
40+
SpaceGroupIrep`\[Beta]->MagneticTB`\[Beta],
41+
SpaceGroupIrep`\[Gamma]->MagneticTB`\[Gamma]};
42+
Print["Magnetic space group (BNS):",MSGSymStd[MSG]," No. ",StringRiffle[MSG,"."]];
43+
Print["Lattice: ",brav];
44+
Print["Primitive Lattice Vactor: ",latt];
45+
Insert[#,getRotMat[brav,#[[1]]],2]&/@msgelem
46+
47+
];
48+
49+
findLittleGroupOfK[k_]:=Module[{rk,k0},
50+
k0=Mod[k,1,0];
51+
52+
rk=Association@MapIndexed[First@#2->#1&,Insert[#,Inverse@Transpose[#[[2]]],5]&/@symminfo];
53+
(*Print[rk];*)
54+
rk=MapAt[Mod[# . k0,1,0]&,rk,{;;,5}];
55+
(*Print[rk];*)
56+
rk=Select[rk,#[[5]]==k0&&#[[4]]=="F"&];
57+
Keys[rk]
58+
];
59+
60+
61+
62+
getTBBandCorep[MSG_, ham_, param_, kset_] := Module[
63+
{rot,tmp, ops, wc, sym, tr, brav, msgele, eiv, little, trace, cr, coeff,
64+
U, opII, actk
65+
},
66+
tr = Association[];
67+
ops = N@symmetryops;
68+
wc = N@wcc;
69+
sym = symminfo;
70+
tr["nelec"] = Length[ham];
71+
(*Print[basisdict[#]&@basis[[1,1]]];*)
72+
tr["soc"] =If[ListQ[basisdict[#]&@basis[[1,1]]],1,0];
73+
(*Print[tr["soc"]];*)
74+
(*basis*)
75+
tr["nsym"] = Length[sym];
76+
(* brav = getSGLatt[MSG[[1]]];
77+
msgele = getMSGElem[MSG];
78+
rot=getRotMat[brav, #[[1]]] & /@ msgele;*)
79+
rot=sym[[;;,2]];
80+
tr["rot"] = rot;
81+
tr["trans"] = N@sym[[;;,3]];
82+
(*tr["srot"] = N@getSpinRotOp[#[[1]]][[1]] & /@ msgele;*)
83+
(*Print[rot];*)
84+
(*latt={{0,-a,0},{(Sqrt[3] a)/2,a/2,0},{0,0,c}};*)
85+
tr["srot"] = N@spinMatrix[Transpose[latt] . # . Inverse@Transpose@latt] & /@ rot;
86+
87+
(*Abort[];*)
88+
tr["unitary"] = If[# == "F", 1, -1] & /@ sym[[;; , -1]];
89+
tr["nk"] = Length@kset;
90+
tr["kpt"] = kset;
91+
tr["nband"] = Length[ham];
92+
93+
Table[tr[i] = {}, {i, {"ene", "deg", "knsym", "kisym", "trace"}}];
94+
Do[
95+
U = N@DiagonalMatrix[Table[Exp[-2 Pi I kpoint . tau], {tau, wc}]];
96+
(*Print[MatrixForm@U];*)
97+
eiv = Eigensystem[
98+
ConjugateTranspose[
99+
U] . (ham /.
100+
Join[param, Thread[{kx, ky, kz} -> 2 Pi kpoint]]) . U];
101+
eiv = Transpose@SortBy[Transpose[eiv], #[[1]] &];
102+
eiv = Transpose /@ SplitBy[Transpose[eiv], Round[#[[1]], 0.0001] &];
103+
(*Print[eiv];*)
104+
AppendTo[tr["ene"], Flatten@eiv[[;; , 1]]];
105+
AppendTo[tr["deg"],
106+
Flatten[Table[#, {i, #}] & /@ Length /@ eiv[[;; , 1]]]];
107+
little = findLittleGroupOfK[kpoint];
108+
AppendTo[tr["knsym"], Length@little];
109+
AppendTo[tr["kisym"], little];
110+
111+
trace =
112+
Flatten[Table[
113+
Table[
114+
Table[
115+
actk = Inverse[Transpose[symminfo[[i, 2]]]];
116+
(*opII is from GB Liu's note*)
117+
opII =
118+
Exp[-2 Pi I symminfo[[i, 3]] . (actk . (kpoint))] Table[
119+
Exp[2 Pi I actk .
120+
kpoint . (wc[[m]] - (symminfo[[i, 2]] . wc[[l]]))], {m,
121+
Length[wc]}, {l, Length[wc]}] ops[[i]];
122+
Chop@Tr[Conjugate[e[[2]]] . (opII) . Transpose[e[[2]]]]
123+
, {i, little}]
124+
, {nr, Length[e[[1]]]}]
125+
, {e, eiv}]];
126+
127+
AppendTo[tr["trace"], Partition[trace, Length[little]]];
128+
129+
, {kpoint, kset}];
130+
(*Print[tr];*)
131+
cr = getBandCorep[MSG, tr];
132+
Print["Magnetic space group (BNS): ", MSGSymStd[MSG]," No. ",StringRiffle[MSG,"."]];
133+
Print["Lattice: ",brav];
134+
(*Print[cr];*)
135+
Do[
136+
Print["k-name: "<>#2<>", k-point: "<>ToString[InputForm@#1]<>", little co-group: "<>ToString@#4 &@@cr["kinfo"][[k]]];
137+
Print@showBandCorep[cr, k]
138+
139+
,{k,Length[kset]}]
140+
]
141+
142+
143+
End[]
144+
EndPackage[]
145+

MagneticTB/IO.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
"\n"<>StringJoin[Table[StringJoin[Table[" 1",15]]<>"\n",Quotient[nums,15]],
150150
StringJoin[Table[" 1",Mod[nums,15]]]]<>"\n"];
151151
integerstr[n_]:=ToString@NumberForm[n,5,NumberPadding->{" ",""}];
152-
realstr[n_]:=ToString@NumberForm[N@n,{12,8},NumberPadding->{" ","0"}];
152+
realstr[n_]:=ToString@NumberForm[N@n,{12,8},NumberPadding->{" ","0"},ExponentFunction->(Null&)];
153153
res="Generated by MagneticTB\n"<>ToString[band]<>"\n"<>ToString[Length[hopset]]<>sstr
154154
<>StringRiffle[Table[StringJoin@Flatten[{integerstr/@(#[[;;5]]),realstr/@(#[[6;;]])}&@line],
155155
{line,result}],"\n"];

MagneticTB/Kernel/init.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
Get["MagneticTB`IO`"]
88
Get["MagneticTB`WilsonLoop`"]
99
Get["MagneticTB`Utilities`"]
10-
10+
Get["MagneticTB`Corep`"]
1111

MagneticTB/Usage.wl

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ BeginPackage["MagneticTB`"]
1414
init ::usage = "Init the program"
1515
unsymham ::usage = "Get the unsymmetried Hamiltonian"
1616
symham ::usage = "Get the symmetried Hamiltonian in convenition I"
17-
17+
basis::usage = "basis"
18+
basisdict::usage = "basis"
1819
kx ::usage = ""
1920
ky ::usage = ""
2021
kz ::usage = ""
@@ -55,6 +56,7 @@ symminformation::usage = "Options for init"
5556
basisFunctions::usage = "Options for init"
5657
symmetryset::usage = "Options for symham"
5758
lattpar::usage = "Options for init"
59+
symmetrizationHRInit::usage = "Options for init"
5860

5961

6062
(* ::Subsubsection:: *)
@@ -107,6 +109,10 @@ texOutput ::usage =""
107109

108110

109111

112+
getMSGElemFromMSGCorep::usage = ""
113+
getTBBandCorep::usage = ""
114+
115+
110116
(* ::Subsubsection:: *)
111117
(*Utilities*)
112118

MagneticTB/Utilities.wl

+8-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ BeginPackage["MagneticTB`"]
66
Begin["`Private`"]
77

88

9+
directSum =(*FullSimplify@*)ArrayFlatten[{{#1, 0}, {0, #2}}] &;
10+
11+
912
texOutput[mat_]:=Module[{ptex},
1013
ptex=ToString[TeXForm@mat];
1114
StringReplace[ToString[ptex],{
@@ -49,6 +52,7 @@ braLatt=<|"CubicP" -> {{{a, 0, 0}, {0, a, 0}, {0, 0, a}},
4952
"MonoclinicB" -> {{{a, 0, 0}, {0, 0, b}, {c*Cos[\[Beta]],
5053
c*Sin[\[Beta]],0}}, {{a/2, 0, b/2}, {-a/2, 0, b/2},
5154
{c*Cos[\[Beta]], c*Sin[\[Beta]],0}}},
55+
5256
"TriclinicP" -> {{{a, 0, 0}, {b*Cos[\[Gamma]], b*Sin[\[Gamma]], 0},
5357
{c*Cos[\[Beta]], c*(Cos[\[Alpha]] - Cos[\[Beta]]*Cos[\[Gamma]])*
5458
Csc[\[Gamma]], c*Sqrt[1 - Cos[\[Alpha]]^2 - Cos[\[Beta]]^2 +
@@ -70,8 +74,10 @@ msgop[number_]:=Module[{data},
7074

7175

7276

73-
symhamII[ham_]:=Module[{U,hII},
74-
U=DiagonalMatrix[Table[Exp[-I{kx,ky,kz} . tau],{tau,wcc}]];
77+
Options[symhamII] = {"wcc"->None};
78+
symhamII[ham_, OptionsPattern[]]:=Module[{U,hII,wc},
79+
If[OptionValue["wcc"]===None,wc=wcc,wc=OptionValue["wcc"]];
80+
U=DiagonalMatrix[Table[Exp[-I{kx,ky,kz} . tau],{tau,wc}]];
7581
hII=ComplexExpand[ConjugateTranspose[U]] . ham . U;
7682
Expand[TrigToExp@FullSimplify@hII]
7783
];

MagneticTB/WilsonLoop.wl

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
(* ::Package:: *)
22

3-
BeginPackage["MagneticTBDevelop`"]
4-
3+
(*BeginPackage["MagneticTBDevelop`"]
4+
*)
55

66

77

8-
Begin["`Private`"]
8+
(*Begin["`Private`"]*)
99

1010

1111

@@ -298,8 +298,8 @@ Table[Eigenvalues[N@h[kp]],{kp,path1k}]\[Transpose]
298298
];
299299

300300

301-
End[]
301+
(*End[]
302302
EndPackage[]
303-
303+
*)
304304

305305

MagneticTB/plot.wl

+8-3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ bandplot[pathstr_,npoint_,ham_,rule_,OptionsPattern[]]:=Module[{tmp,kps,hkps,hkp
8686
{maxenergy,minenergy}={Max[Flatten[data[[;;,;;,2]]]],Min[Flatten[data[[;;,;;,2]]]]};
8787
maxenergy=Max[Abs/@{maxenergy,minenergy}];
8888
(* {maxenergy,minenergy}={.6,-.3};*)
89+
(*Print[minenergy,maxenergy];*)
8990
yticks={#,
9091
Style[Round[#,.1],Black,FontFamily->font,24]}&/@Subdivide[-maxenergy,0,3];
9192
yticks=Join[yticks,Drop[{#,
@@ -120,10 +121,14 @@ Options[compareBand]= {plotRange->All};
120121
compareBand[pathstr_,npoint_,ham_,rule_,vaspband_,OptionsPattern[]]:=
121122
Module[{tmp,kps,hkps,hkp,xticks,yticks,font,data,oriband,norband,vaspplotdata,tbband},
122123
oriband=Partition[vaspband[[;;,2]],npoint];
124+
(*Print[oriband];*)
123125
norband=Table[If[i==1,oriband[[i]],Join[{oriband[[i-1]][[-1]]},oriband[[i]]]],{i,Length[oriband]}];
124-
vaspplotdata=Flatten[MapIndexed[{100(#2[[1]]-1)+#2[[3]]-1,#1}&,Transpose/@norband,{3}],1];
126+
(*Print[norband];*)
127+
If[Length[norband]>1,PrependTo[norband[[1]],norband[[1,1]]]];
128+
vaspplotdata=Flatten[MapIndexed[{(npoint)(#2[[1]]-1)+#2[[3]]-1,#1}&,Transpose/@norband,{3}],1];
129+
(*Print[vaspplotdata];*)
125130
hkp={};
126-
(* hkps=Partition[Partition[StringSplit[pathstr],5][[;;,-1]],2];*)
131+
(*hkps=Partition[Partition[StringSplit[pathstr],5][[;;,-1]],2];*)
127132
hkps=Transpose[pathstr][[2]];
128133
font="Times";
129134
Do[If[i==1,AppendTo[hkp,hkps[[i]][[1]]];AppendTo[hkp,hkps[[i]][[2]]],
@@ -141,7 +146,7 @@ compareBand[pathstr_,npoint_,ham_,rule_,vaspband_,OptionsPattern[]]:=
141146
data=Chop@Flatten[MapIndexed[{npoint(#2[[1]]-1)+#2[[3]]-1,#1}&,data,{3}],1];
142147
xticks=Transpose@{(npoint) Range[0,Length[hkp]-1],Style[#,Black,FontFamily->font,24]&/@hkp};
143148
{maxenergy,minenergy}={Max[Flatten[data[[;;,;;,2]]]],Min[Flatten[data[[;;,;;,2]]]]};
144-
{maxenergy,minenergy}={.6,.1};
149+
(*{maxenergy,minenergy}={.6,.1};*)
145150
yticks={#,
146151
Style[Round[#,.01],Black,FontFamily->font,24]}&/@Subdivide[-maxenergy,0,2];
147152
yticks=Join[yticks,Drop[{#,

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,15 @@ v1.00c
4646

4747
v1.01 2022/07/22
4848
* Fixed an issue where in very rare cases the order of basis functions would change due to the automatic unitarization.
49+
50+
v1.02 2022/12/1
51+
* MagneticTB can calculate the band corep of tight-binding model!
52+
** Before using this capability, ``MSGCorep``` and ```SpaceGroupIrep``` package are needed to be install.
53+
** Add two function ```getMSGElemFromMSGCorep``` and ```getTBBandCorep```, both two funcitons are depending on the ```MSGCorep``` package
54+
** getMSGElemFromMSGCorep[{N1, N2}] gives the magnetic space group element from ```MSGCorep``` package, where N1.N2 is the BNS magnetic space group number.
55+
** ```getTBBandCorep[BNSNo, Hamiltonian, paramaters, kset]```, give the co-representations of tight-binding model, where BNSNo is the BNS magnetic space group number, Hamiltonian is the Hamiltonian generated by MagneticTB, parameters is the parameter in the tight-binding model, kset is the list contains several k points.
56+
** For Orthorhombic and Monoclinic lattice, if you want to calculate the corep of tight-binding model please use ```getMSGElemFromMSGCorep``` to get the magnetic space group elements rather than ```msgop```. For other lattices both ```msgop``` and ```getMSGElemFromMSGCorep``` are OK.
57+
** See examples.nb for concrete example.
58+
** Please also consider to cite ```MSGCorep``` package if you are using this capabilities.
59+
60+

0 commit comments

Comments
 (0)