1. atoms¶
1.1. get_index_matrices¶
Build index matrices M and N to build the real and reciprocal space samplings.
Python | Julia |
---|---|
1ms = np.arange(np.prod(self.s))
2m1 = np.floor(ms / (self.s[2] * self.s[1])) % self.s[0]
3m2 = np.floor(ms / self.s[2]) % self.s[1]
4m3 = ms % self.s[2]
5M = np.column_stack((m1, m2, m3))
6
7n1 = m1 - (m1 > self.s[0] / 2) * self.s[0]
8n2 = m2 - (m2 > self.s[1] / 2) * self.s[1]
9n3 = m3 - (m3 > self.s[2] / 2) * self.s[2]
10N = np.column_stack((n1, n2, n3))
| 1ms = 0:prod(s)-1
2m1 = floor.(Int64, ms ./ (s[3] .* s[2])) .% s[1]
3m2 = floor.(Int64, ms ./ s[3]) .% s[2]
4m3 = ms .% s[3]
5M = [m1 m2 m3]
6
7n1 = m1 .- (m1 .> s[1] ./ 2.0) .* s[1]
8n2 = m2 .- (m2 .> s[2] ./ 2.0) .* s[2]
9n3 = m3 .- (m3 .> s[3] ./ 2.0) .* s[3]
10N = [n1 n2 n3]
|
1.2. set_cell¶
Build the unit cell and create the respective sampling.
Python | Julia |
---|---|
1self.Natoms = len(self.atom)
2self.Nstate = len(self.f)
3
4R = self.a * np.eye(3)
5self.Omega = np.abs(np.linalg.det(R))
6self.r = M @ np.linalg.inv(np.diag(self.s)) @ R.T
| 1Natoms = length(atom)
2Nstate = length(f)
3
4R = a .* Matrix(1.0I, 3, 3)
5Omega = abs(det(R))
6r = M * inv(Diagonal(s)) * R'
|
1.3. set_G¶
Build G-vectors, build squared magnitudes G2, and generate the active space.
Python | Julia |
---|---|
1G = 2 * np.pi * N @ np.linalg.inv(self.R)
2G2 = np.linalg.norm(G, axis=1) ** 2
3active = np.nonzero(2 * self.ecut >= G2)
4self.G2c = G2[active]
5self.Sf = np.sum(np.exp(-1j * self.G @ self.X.T), axis=1)
| 1G = 2.0 .* pi .* N * inv(R)
2G2 = sum(G .^ 2.0; dims = 2)
3active = 2.0 * ecut .>= G2
4G2c = G2[active]
5Sf = sum(exp.(-1im .* G * X'), dims = 2)
|