Electronic-structure calculation for metals by local optimization.