What I know:
In general, the work done by a conservative force $F$ is equal to the negative change in a potential energy.
$$\int_1 ^2F.ds = - (U_2 - U_1) $$
A potential energy is always associated with a conservative force.
When choosing the conservative force as the force of gravity we get
$$\int_1 ^2W.ds = -mg(y_2-y_1)=- (U_2 - U_1) $$
When choosing the conservative force as the spring force we get
$$\int_1 ^2F_s.ds = -(\frac{1}{2}kx_2 ^2 -\frac{1}{2}kx_1 ^2)=- (U_2 - U_1) $$
So I conclude that every conservative force's work should give rise to -ve of the difference between the values of a function at two positions and this function is the potential energy function.
What I have trouble with:
When introducing the concept of strain energy (which is also a type of potential energy) my textbook determines the work done by the external gradually applied load P (on a bar) and says that this energy will be stored in the bar as strain energy. It doesn't start with the defining equation of potential energy which is $\int_1 ^2F.ds = - (U_2 - U_1) $.
So, my question is,
how can I use this equation ($\int_1 ^2F.ds = - (U_2 - U_1) $) to come up with the strain energy of the bar?
What will be the conservative force $F$ in this case, which I will be using in this $\int_1 ^2F.ds = - (U_2 - U_1) $ equation to find the potential energy? (I suppose it is internal forces, but still, how can I use those internal forces to come up with a relation of the form $\int_1 ^2F.ds = - (U_2 - U_1) $?)