Consider a body in equillibrium under the action of a set of loads and constraints. The action of the loads produces a dispalcement u, a function of the coordinates i.e.u= u(x,y,z). Under the action of this load the work done = Load x displacement = Work, W. This work must equal the strain energy V developed in the body due to the deformation. This strain energy may be computed from the stresses and strains developed in the body energy = stress x strain integrated over the whole body.
Now imagine an additional imaginary (virtual) displacement as shown below. This virtual displacement is arbitrary except where there is a constraint. At locations with a constraint the imaginary displacement is 0. This requirement is often stated as " the virtual displacements are compatible". The virtual displacement will also cause virtual strains.V = W

Similarly the Total Strain energy = stress x (actual strain + virtual
strain) = Actual strain energy + internal virtual strain energy =
V + IVSE.
Equating W + EVW = V + IVSE
But W = V, thus
EVW = IVSE
This is the principle of virtual work ! External virtual work
equals the internal virtual strain energy.
DERIVATION OF ELEMENT STIFFNESS USING PVW
We now illustrate the use of the above principle in deriving element
stiffness matrices.

Step 1 Assume displacement (deformation) say linear. Thus u looks like
Ni, Nj are called shape functions.
Now we can construct a variation (assumed displacement).
Step 2
and
Internal Virtual Strain Energy is
![]()
External Virtual Work is
Equating the internal virtual strain energy and external
virtual work and cancelling the virtual displacements on both sides we
have:

We note here that this method of deriving the element stiffness matrix is very general and as long as expressions for work and energy are available. The same method can be used for all types of problems irrespective of dimnesion (2D/3D) complexity of the problem (thermal effects, magnetic effects, coupled flow and structure etc.).