First, do the electron density for the whole system, noted as rho_all
Do the a loop for all atoms. In this loop, the structure contains one atom, whose position is same as the one in the whole system. The charge density is calculated for such one-atom structure, note as rho_i
Finally, delta rho = rho_all - \sum_i^N rho_i