Reciprocal lattice vector order was switched. Now the code works properly up until v_of_rho().