Fig. 1: Schematic of the Solvated Jellium Method.
From: Atomistic learning in the electronically grand-canonical ensemble

The unit cell is charge-neutral with excess charge localizing on the metal surface, balanced by charge of opposite sign in the jellium. The total number of electrons is adjusted until the work function meets the target value.