From c6171309982612140fc559440a0c5a60616bd53c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89tienne=20Polack?= <polack@hollved.net>
Date: Tue, 2 May 2023 14:07:02 +0200
Subject: [PATCH] single component for direct minimisation

---
 src/scf/direct_minimization.jl | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/scf/direct_minimization.jl b/src/scf/direct_minimization.jl
index a7e9e52276..faef2ca3db 100644
--- a/src/scf/direct_minimization.jl
+++ b/src/scf/direct_minimization.jl
@@ -76,13 +76,16 @@ function direct_minimization(basis::PlaneWaveBasis{T}, ψ0;
     model = basis.model
     @assert iszero(model.temperature)  # temperature is not yet supported
     @assert isnothing(model.εF)        # neither are computations with fixed Fermi level
+    @assert model.n_components == 1    # neither are multicomponents
     filled_occ = filled_occupation(model)
     n_spin = model.n_spin_components
     n_bands = div(model.n_electrons, n_spin * filled_occ, RoundUp)
     Nk = length(basis.kpoints)
 
     if ψ0 === nothing
-        ψ0 = [random_orbitals(basis, kpt, n_bands) for kpt in basis.kpoints]
+        ψ0_rand = [random_orbitals(basis, kpt, n_bands) for kpt in basis.kpoints]
+        Tψ = eltype(eltype(eltype(ψ0_rand)))
+        ψ0 = [reinterpret(reshape, Tψ, ψ0k_rand) for ψ0k_rand in ψ0_rand]
     end
     occupation = [filled_occ * ones(T, n_bands) for ik = 1:Nk]