  An implementation of the Hartree-Fock (HF) method capable of robust
convergence for well-behaved arbitrary central potentials is presented. The
Hartree-Fock equations are converted to a generalized eigenvalue problem by
employing a B-spline basis in a finite-size box. Convergence of the
self-consistency iterations for the occupied electron orbitals is achieved by
increasing the magnitude of the electron-electron Coulomb interaction gradually
to its true value. For the Coulomb central potential, convergence patterns and
energies are presented for a selection of atoms and negative ions, and are
benchmarked against existing calculations. The present approach is also tested
by calculating the ground states for an electron gas confined by a harmonic
potential and also by that of uniformly charged sphere (the jellium model of
alkali-metal clusters). For the harmonically confined electron-gas problem,
comparisons are made with the Thomas-Fermi method and its accurate asymptotic
analytical solution, with close agreement found for the electron energy and
density for large electron numbers. We test the accuracy and effective
completeness of the excited state manifolds by calculating the static dipole
polarizabilities at the HF level and using the Random-Phase Approximation.
Using the latter is crucial for the electron-gas and cluster models, where the
effect of electron screening is very important. Comparisons are made for with
experimental data for sodium clusters of up to $\sim $100 atoms.
