In The Feynman Lectures on Physics, Vol II, 10–5 Fields and forces with dielectrics describes a method for finding the force between two charged conductors in a dielectric. I accept the first part of his description of its application:
Let us now ask what the force would be between two charged conductors in a dielectric. We consider a liquid dielectric that is homogeneous everywhere. We have seen earlier that one way to obtain the force is to differentiate the energy with respect to the appropriate distance. If the conductors have equal and opposite charges, the energy $U=Q^{2}/2C,$ where $C$ is their capacitance. Using the principle of virtual work, any component is given by a differentiation; for example,
$$F_{x}=-\frac{\partial U}{\partial x}=-\frac{Q^{2}}{2}\frac{\partial}{\partial x}\left(\frac{1}{C}\right).$$
Since the dielectric increases the capacity by a factor $\kappa$, all forces will be reduced by this same factor.
However; the following is contrary to my understanding of the application of the principle of virtual work:
One point should be emphasized. What we have said is true only if the dielectric is a liquid. Any motion of conductors that are embedded in a solid dielectric changes the mechanical stress conditions of the dielectric and alters its electrical properties, as well as causing some mechanical energy change in the dielectric. Moving the conductors in a liquid does not change the liquid. The liquid moves to a new place but its electrical characteristics are not changed.
The principle of virtual work, as I understand it, says we can make any imaginary change to a parameter to find the amount by which dependent variables change as a result. Suppose we only have a computer model of the configuration for which we want the forces. We can vary all the design variables so that there is no mechanical stress produced.
That is, if we want to change the separation between the plates of a capacitor, for example, we change the amount of dielectric between the plates at the same time we change $d$ by $\delta{d}$. First we calculate the energy of the original configuration. Then we modify the design by a small amount and recalculate the energy. Dividing the change in energy by the change $\delta{d}$ gives us an approximation of the derivative.
Does anybody agree that Feynman's asserted limitation to the application of virtual work in this circumstance is incorrect?
Edit to add:
I don't have Lanczos's book with me, but I believe he gives an even clearer exposition of what I'm talking about than does Wells.
From Lagrangian Dynamics, by D. A. Wells, page 30, Real and Virtual Displacements: Virtual work. In discussing the behavior of a particle $m$ moving on a flat surface, Wells states:
$m$ moves along some definite path (determined by Newton's laws) in space and at the same time traces a line on the surface. During any given interval of time $dt,$ $m$ undergoes a specific displacement $ds (dx,dy,dz)$ measured say relative to stationary axes. Here $ds$ is referred to as an "actual" or "real" displacement.
Consider now any arbitrary displacement $\delta{s} (\delta{x},\delta{y},\delta{z})$ not necessarily along the above mentioned path. In this case $\delta{s}$ is referred to as a virtual displacement. For convenience in what follows, we mention three classes of such displacements: (a) $\delta{s}$ in any direction in space, completely disregarding the surface ...
For a virtual displacement of any type the "virtual work" done by $F$ is given by
$$\delta{W}=F\delta{s} \cos{F,\delta{s}}=F_x\delta{x}+F_y\delta{y}+F_z\delta{z}$$