-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtutorial.py
More file actions
99 lines (78 loc) · 2.82 KB
/
tutorial.py
File metadata and controls
99 lines (78 loc) · 2.82 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import sys
sys.path.append("/content/conda_dir")
import kwant
import qsymm
import sympy as sp
import numpy as np
import matplotlib.pyplot as plt
from numpy.random import random
from sympy import Q
welcome="Packages are loaded. ¡Welcome!"
def Print(message):
display(Markdown(message))
def print_eq(suffix, eq):
display(Markdown(suffix + r" $%s$ "%latex(eq)))
euler = (sp.Symbol("e",positive=True),sp.exp(1));
def Rz(phi):
return sp.Matrix([ [ sp.cos(phi),-sp.sin(phi), 0 ],
[ sp.sin(phi), sp.cos(phi), 0 ],
[ 0 , 0 , 1 ]
]);
def Rz_2D(phi):
return sp.Matrix([ [ sp.cos(phi),-sp.sin(phi) ],
[ sp.sin(phi), sp.cos(phi) ]
]);
def FirstOrderTaylor( h, x,x0 ):
dx = x; evalx= list(zip(x,x0));
h=h.expand(complex=True)
happ = h.subs( evalx );
for xi,dxi in zip(x,dx):
happ += sp.diff(h,xi).subs(evalx)*dxi;
return sp.simplify(happ);
class Hexagonal:
lat_vec= sp.Array( [
[sp.Rational( 1,2), sp.sqrt(3)/2,sp.Integer(0)],
[sp.Rational(-1,2), sp.sqrt(3)/2,sp.Integer(0)],
[sp.Integer(0),sp.Integer(0),sp.Integer(1)]
]);
rec_vec = sp.Array( sp.Matrix(lat_vec).inv().T*2*sp.pi );
K0 =np.array(sp.Matrix( (rec_vec[0]-rec_vec[1])/3)).flatten();
K1 =np.array(sp.Matrix(-(rec_vec[0]-rec_vec[1])/3)).flatten();
graphene = Hexagonal();
def dot(x,y):
return sp.simplify( ( sp.conjugate(x.T) * y )[0] );
def norm(x):
return sp.sqrt(dot(x,x));
def normalize(x):
return sp.simplify(x)/norm(x);
def delta(x,y):
if(x==y):
return 1
return 0;
def EigenSystem( H, coord_syst=[] ):
Es = []; Psis= [];
eigsyst = H.eigenvects();
for eigv,mul,deg_eigs in eigsyst:
for eig in deg_eigs:
Es.append(eigv.subs(coord_syst));
Psis.append(eig.subs(coord_syst));
Es = [ E for E in Es ];
Psis= [ sp.simplify(normalize(sp.simplify(Psi) )) for Psi in Psis]
return Es,Psis;
def exps2trig(x):
return sp.trigsimp(sp.simplify(x).rewrite(sp.sin))
def half_angles(expr,theta):
half_ang = [ ( 1-sp.cos(theta) , 2 * sp.sin(theta/2)**2 ),
( 1+sp.cos(theta) , 2 * sp.cos(theta/2)**2 ),
( 2+2*sp.cos(theta) , 4 * sp.cos(theta/2)**2 ),
];
trig_assum= Q.positive(sp.sin(theta/2)) & Q.positive(sp.cos(theta/2));
return exps2trig(sp.refine(sp.simplify(sp.simplify(expr).subs(half_ang)),trig_assum));
import requests
import IPython.display as Disp
grafeno_real = 'https://i.pinimg.com/564x/27/73/60/277360f8a8265b0a8008d1d03023a7be.jpg'
grafeno_disp = 'https://icn2.cat/images/20190802_spin-communication.jpg'
def ejemplo_grafeno_real():
return Disp.Image(requests.get(grafeno_real).content);
def ejemplo_dispositivo_grafeno():
return Disp.Image(requests.get(grafeno_disp).content);