Principle of virtual power applied to deformable semiconductors with strain, polarization, and magnetization gradients