  We present a method for total energy minimizations and molecular dynamics
simulations based either on tight-binding or on Kohn-Sham hamiltonians. The
method leads to an algorithm whose computational cost scales linearly with the
system size. The key features of our approach are
  (i) an orbital formulation with single particle wavefunctions constrained to
be localized in given regions of space, and (ii) an energy functional which
does not require either explicit orthogonalization of the electronic orbitals,
or inversion of an overlap matrix.
  The foundations and accuracy of the approach and the performances of the
algorithm are discussed, and illustrated with several numerical examples
including Kohn-Sham hamiltonians. In particular we present calculations with
tight-binding hamiltonians for diamond, graphite, a carbon linear chain and
liquid carbon at low pressure. Even for a complex case such as liquid carbon --
a disordered metallic system with differently coordinated atoms -- the
agreement between standard diagonalization schemes and our approach is very
good. Our results establish the accuracy and reliability of the method for a
wide class of systems and show that tight binding molecular dynamics
simulations with a few thousand atoms are feasible on small workstations.
