Energy to assemble a capacitor Consider a body $\Omega$, inside of which a dielectric is present. We have a conductor on $\partial \Omega$.
I am trying to understand the computation of the energy required to assemble the entire system. The author of the book I am reading says that one can proceed like this:

*

*assume an initial configuration of zero potential on $\partial \Omega$ and zero charge inside $\Omega$

*introduce the spatial charges, keeping the boundary potential fixed, and compute the energy required to do so

*then, compute the energy required to produce the potential change on the boundary, while keeping the charge distribution fixed

Question 1: why can we proceed like this? Doing 3. then 2. should yield the same result, why so?
Now, here is the main reasoning for 2., at least, how I understood it. We are adding a small charge in a small portion of space $\tau$. Let this charge be $\delta q$. Because of the charges already present, a potential V is induced, and so, the following energy must be supplied, to add $\delta q$ in $\tau$:
$$\delta U = V \delta q$$
Question 2: why don't we account for a change in potential here? Is it because there is no charge at the beginning, so that $\delta U = V \delta q + 0 \cdot \delta V$?
Using in order Gauss's theorem and the divergence theorem to $\Omega \setminus \tau$:
$$\delta U = \int_{\Omega \setminus \tau} \text{div}(-V\delta \mathbf{D}) - \int_{\partial\Omega}-V\delta \mathbf{D}\cdot \nu$$
Here, $\delta \mathbf{D}$ I undestand to be due only to $\delta q$. Using $V=0$ on $\partial\Omega$, expanding the divergence term and using the definition of potential:
$$\delta U = \int_{\Omega\setminus \tau}\mathbf{E}\cdot \mathbf{\delta D} - V \text{div}{\delta \mathbf{D}} =\int_{\Omega\setminus \tau}\mathbf{E}\cdot \mathbf{\delta D}$$
since $\mathbf{\delta D}$ is due to $\delta q$, which is not present outside of $\tau$. The author now says that actually, due to an opposite reasoning to the above, we actually have:
$$\delta U =\int_{\Omega}\mathbf{E}\cdot \mathbf{\delta D}$$
Question 3: what is this reasoning? How can we conclude this?

From pag. 26, The Finite Element Method for Electromagnetic Modeling, Meunier.
 A: *

*This is the process the author imagines. In a simple world where work equals change of potential energy, there is no friction, no hysteresis, and thus work done does not depend on how (along which "path") the system has been assembled. In that case, the only thing that matters to finding work done is the original and the final state. Author's imagined process is not the only possible one, and it is not always physically plausible (due to energy losses that would happen in the real assembling process, e.g. in real dielectrics, due to changing their polarization).


*During the stage 1 it is implicitly assumed that bringing the charge $\delta q$ from outside to its position within domain $\Omega$ does not change position of any other charged particles in the system. This allows us to use the formula $\delta W = V \delta q$ which is derived under the assumption that all the other charges do not move. For derivation of this formula, see my answer here: https://physics.stackexchange.com/a/748669/31895 . It is true this assumption is suspect, and so is the use of the formula, because there are electrodes which are "held at constant potential" during the stage 1. Keeping conductor at constant potential while charges move nearby requires that charges on the conductor rearrange themselves, and we seem to have violation of the assumption that no other charge in the system moves.


*Author's reasoning seems needlessly complicated (and misconceived), where he introduces imaginary boundary between the region $\Omega_q$ and the region $\Omega \setminus \Omega_q$, then approximates the work done twice - first, introducing an error (which causes him to miss the energy in $\Omega_q$), and second, removing it (claiming this missing energy is zero). These errors cancel each other so the result is fine. But there is a much simpler and convincing way to derive the result.
The work done can be expressed as integral over the whole domain
$$
\delta W = V \delta q  = \int_{\Omega} V \delta \rho ~d^3 \mathbf x
$$
where $\delta \rho$ is non-zero in the small space subdomain $\Omega_q$ and vanishes everywhere else. Since $\rho = \nabla \cdot \mathbf D$, and $\delta \nabla \cdot \mathbf D = \nabla\cdot \delta \mathbf D$, we have
$$
\delta W = \int_{\Omega} V ~\nabla \cdot \delta \mathbf D ~d^3 \mathbf x.
$$
Since $\nabla \cdot(V \delta \mathbf D) = \nabla V  \cdot \delta \mathbf D + V ~\nabla \cdot \delta \mathbf D$, we can express the last integral as difference of two integrals
$$
\delta W = \int_{\Omega} \nabla \cdot(V \delta \mathbf D) ~d^3 \mathbf x - \int_{\Omega} \nabla V \cdot \delta \mathbf D ~d^3 \mathbf x.
$$
The first integral can be expressed as surface integral (using the Gauss theorem):
$$
I_1 = \int_{\partial \Omega} d^2\mathbf x \cdot (V \delta \mathbf D)
$$
and we can see it can be neglected when either the potential $V$ vanishes on the boundary of the domain, or the boundary is far enough so that the integral is negligible (this is possible because the integrand decays as $q/r^3$ or faster).
So we are left with the second integral and since $\nabla V = -\mathbf E$, we get
$$
\delta W = \int_{\Omega} \mathbf E\cdot \delta \mathbf D~ d^3\mathbf x.
$$
Fun question: where (which step) did the author lose the contribution to the above integral from the domain $\Omega_q$?
A: Setting the metal's potential zero is an arbitrary choice, you could make 7.5 if you wished as long as you keep it constant so that the work it takes to move the charge from infinity near the metal is kept dependent only on the charge and geometry. This is just the same kind of assumption as how much work it takes to lift a piece of mass off the ground, we always ignore the motion of the earth.
Change in the potential by the added charge $\delta q$ is ignored because it is assumed that $\delta q$ is infinitesimally small relative to the charges that set up the potential $V$.
$\delta \mathbf D$ does "exist" (not zero) also outside of $\tau$ where $\delta q$ resides but $\text{div}\delta \mathbf D =0$
