A new approach to the calculation of the thermodynamic potential of inhomogeneous electron gas