Thermal expansion of two rods and compression or collision afterwards From the post Thermal expansion of two bolts:

My question is not the original one, but what will happen if the temperature of the two bolts keep raising after they touch? The Young modulus of each bolt is given as $Y_s$ for the steel and $Y_b$ for the brass.
Will the ends of the bolts elevate? Will they go down? To the sides? Or will one bolt compress the other? (In this last case I would have to use the Young modulus of each bolt).
It also would be helpful to have some equations with variables (answers don't need to have numerical calculations) that explain how much will one bolt compresses the other (in case that happens)
 A: This is a perfect problem to tackle using a strain energy approach. The final location of the "joint" formed between the steel and brass bolts butting up against each other will be the one that minimizes the total strain energy stored in the system.
Let's assume linear elasticity, and let's ignore the possibility of buckling. In other words, consider just the left- or right-hand movement of the interface after the bolts touch. The strain energy in material $i$ is $U_i=\frac{1}{2}V_i\sigma_i\epsilon_i$. 
($V_i$ is the volume, but if the cross-sectional area $A$ is the same, then you can use $V_i=L_iA$ and carry the dummy variable $A$ through the derivation below; it will cancel out in the end.)
Hooke's Law tells us that $\epsilon_i=\sigma_i/E_i$. 
The unconstrained linear thermal expansion strain is $\alpha_i \Delta T$, which means that the stress in material $i$ when constrained is $$\sigma_i=E_i\left(\frac{\Delta x_i}{x_{0,i}}-\alpha_i\Delta T\right)$$ where the actual displacement $\Delta x_i$ is positive for extension. 
Now you just need to sum up the $U_i$ terms while keeping the directions straight (because the way I've presented it, you have two different $\Delta x_i$ values with positive values in opposite directions), differentiate the sum with respect to a left or right movement of the point of contact, and set that to zero to find the equilibrium configuration.
(You may detect that you end up with two force terms that need to be equal. That's exactly right; the derivative of energy with respect to a displacement gives a force. That's all a force is, from this viewpoint; it's the system seeking its energy minimum. But the energy approach is much more general than the approach of setting forces equal to each other.)
You'd want to do a sanity check by examining the case in which one material's stiffness is much higher than the other. If rubber butts up against steel, for example, the thermal expansion of the steel should be just about the same as its unconstrained expansion.
EDIT: By request, let's take this a little further. Let's start at the point when the bolts are just in contact and define the positive direction of shared displacement $\Delta x$ as pointing to the right. The total strain energy is $$U=U_1+U_2=\frac{V_1\sigma_1^2}{2E_1}+\frac{V_2\sigma_2^2}{2E_2}$$Differentiating, we have (remembering that $\sigma_i$ is a function of $\Delta x$) $$\frac{dU}{d\Delta x}=\left(\frac{V_1\sigma_1}{E_1}\right)\frac{d\sigma_1}{d\Delta x}+\left(\frac{V_2\sigma_2}{E_2}\right)\frac{d\sigma_2}{d\Delta x}=0$$
Plugging in what we know about $V_i$ and $\sigma_i$, we get the two forces that end up being equal:
$$E_1\left(\frac{\Delta x}{L_1}-\alpha_1\Delta T\right)-E_2\left(-\frac{\Delta x}{L_2}-\alpha_2\Delta T\right)=0$$
Note that some minus signs have appeared because an elongation of material 1 corresponds to a contraction of material 2. Rearranging, $$\Delta x=\Delta T(\alpha_1E_1-\alpha_2E_2)\left(\frac{E_1}{L_1}+\frac{E_2}{L_2}\right)^{-1}$$
which provides the displacement.
Let's do our sanity check:


*

*We see that the movement of the interface is proportional to the temperature change, which looks right. 

*If the two materials have the same stiffness, cross-sectional area, and coefficient of thermal expansion, then the displacement is zero, which also looks right. That condition would correspond to a uniform bar being heated up while being constrained axially between rigid walls. No axial movement is expected in that case. 

*If $E_1>>E_2$, then $\Delta x\approx L_1\alpha_1\Delta T$, which is what we'd expect for an unopposed material.

