This repository has been archived by the owner on Mar 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtbtoymodel.jl
109 lines (84 loc) · 3.27 KB
/
tbtoymodel.jl
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
100
101
102
103
104
105
106
107
108
109
module ToyTB
#######################################################################
### The s-orbital Toy model ###
#######################################################################
export ToyTBModel
using Potentials, TightBinding, ASE, MatSciPy
import Potentials.evaluate, Potentials.evaluate_d
export evaluate, evaluate_d
type ToyTBOverlap <: PairPotential
end
# return 0.0 if two parameters are passed (only for off-diagional terms)
evaluate(p::ToyTBOverlap, r, R) = 0.0
evaluate_d(p::ToyTBOverlap, r, R) = 0.0
# return 1.0 for diagonal terms (when r = 0)
evaluate(p::ToyTBOverlap, r) = (r == 0.0 ? 1.0 : error("ToyTBOverlap(r) : r must be 0.0"))
#type ToyHop <: PairPotential
# A
# r0
#end
#@inline morse_exp(p::ToyHop, r) = exp(-p.A * (r/p.r0 - 1.0))
#@inline function evaluate(p::ToyHop, r)
# e = morse_exp(p, r); return e .* (e - 2.0)
#end
#@inline function evaluate_d(p::ToyHop, r)
# e = morse_exp(p, r); return (-2.0 * p.A / p.r0) * e .* (e - 1.0)
#end
"""`ToyTBModel`: constructs a simple 1-orbital tight binding model.
It doesn't model anything but can be used for quick tests. The hopping function
is given by
h(r) = MORSE(r; alpha, r0) * η(r; rcut)
### Parameters
* alpha = 2.0, r0 = 1.0, rcut = 2.7 : Morse potential parameters
* beta = 1.0 : electronic temperature
* fixed_eF = true : if true, then the chemical potential is fixed (default at 0.0)
* eF = 0.0 : chemical potential (if fixed)
* hfd = 1e-6 : finite difference step for computing hessians
"""
function ToyTBModel(;alpha=2.0, r0=1.0, rcut=2.5, beta=1.0, fixed_eF=true,
eF = 0.0, hfd=1e-6)
hop = SWCutoff(MorsePotential(1.0, alpha, r0), rcut, 1.0)
#hop = MorsePotential(1.0, alpha, r0)
return TBModel(hop = hop,
overlap = ToyTBOverlap(),
smearing = FermiDiracSmearing(beta),
norbitals = 1,
Rcut = rcut,
fixed_eF = fixed_eF,
eF = eF,
nkpoints = (0,0,0),
hfd=hfd)
end
# ###################### TEST (ENERGY/FORCE) FUNCTIONS OF TOYTB ###############
# function potential_energy_(atm::ASEAtoms, tbm::TBModel)
# Natm = length(atm)
# i, j, r = MatSciPy.neighbour_list(atm, "ijd", cutoff(tbm))
# h = tbm.hop(r)
# H = sparse(i, j, h, Natm, Natm)
# epsn, C = sorted_eig(H, speye(Natm))
# f = tbm.smearing(epsn, tbm.eF)
# E = r_sum(f .* epsn)
# return E
# end
# function forces_(atm::ASEAtoms, tbm::TBModel)
# Natm = length(atm)
# i, j, r, R = MatSciPy.neighbour_list(atm, "ijdD", cutoff(tbm))
# # recompute hamiltonian and spectral decomposition
# h = tbm.hop(r)
# H = sparse(i, j, h, Natm, Natm)
# epsn, C = sorted_eig(H, speye(Natm))
# df = tbm.smearing(epsn, tbm.eF) + epsn .* (@D tbm.smearing(epsn, tbm.eF))
# # compute derivatives of hopping
# dhop = @D tbm.hop(r)
# frc = zeros(3, Natm)
# for a = 1:3
# # dH = sparse(i, j, dhop .* (R[a,j] - R[a,i])' ./ r, Natm, Natm)
# dH = sparse(i, j, dhop .* (-R[:,a]) ./ r, Natm, Natm)
# dH_x_C = dH * C
# for s = 1:Natm
# frc[a,:] += 2.0 * df[s] .* C[:,s]' .* dH_x_C[:,s]'
# end
# end
# return frc
# end
end