Skip to content

Commit

Permalink
transfert. Horrible
Browse files Browse the repository at this point in the history
  • Loading branch information
epolack committed Apr 21, 2023
1 parent eaa099d commit 68289be
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/transfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ Transfer an array `ψk` defined on basis_in ``k``-point kpt_in to basis_out ``k`
function transfer_blochwave_kpt(ψk_in, basis_in::PlaneWaveBasis{T}, kpt_in::Kpoint,
basis_out::PlaneWaveBasis{T}, kpt_out::Kpoint) where {T}
kpt_in == kpt_out && return copy(ψk_in)
@assert kpt_in.n_dof == prod(size(ψk_in, 1:2))
@assert kpt_in.n_dof == prod(size(ψk_in)[1:2])
idcsk_in, idcsk_out = transfer_mapping(basis_in, kpt_in, basis_out, kpt_out)

n_bands = size(ψk_in, 3)
ψk_out = similar(ψk_in, length(G_vectors(basis_out, kpt_out)), n_bands)
ψk_out = similar(ψk_in, basis_out.model.n_components, length(G_vectors(basis_out, kpt_out)), n_bands)
ψk_out .= 0
ψk_out[idcsk_out, :] .= ψk_in[idcsk_in, :]
ψk_out[:, idcsk_out, :] .= ψk_in[:, idcsk_in, :]

ψk_out
end
Expand Down
4 changes: 2 additions & 2 deletions test/transfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ include("testcases.jl")

T = compute_transfer_matrix(basis, bigger_basis) # transfer
Tᵇ = compute_transfer_matrix(bigger_basis, basis) # back-transfer
= [Tk * ψk for (Tk, ψk) in zip(T, ψ)]
= [Tk * ψk[1, :, :] for (Tk, ψk) in zip(T, ψ)]
TᵇTψ = [Tᵇk * Tψk for (Tᵇk, Tψk) in zip(Tᵇ, Tψ)]
@test norm(ψ - TᵇTψ) < eps(eltype(basis))
@test norm([ψk[1, :, :] for ψk in ψ] - TᵇTψ) < eps(eltype(basis))

# TᵇT should be the identity and TTᵇ should be a projection
TᵇT = [Tᵇk * Tk for (Tk, Tᵇk) in zip(T, Tᵇ)]
Expand Down

0 comments on commit 68289be

Please sign in to comment.