If you compress an ideal gas adiabatically, the average kinetic energy of the particles will increase because collisions with the moving piston will increase the kinetic energy of the colliding particle. For an ideal gas, the intermolecular distances have no bearing on the internal energy.
More specifically, suppose the piston is moving inwards at velocity $u$ and a gas particle hits the piston wall at velocity $v$. Because the piston is much more massive than the particle, you can assume that it gets completely reflected, so the particle will come away with velocity $v+2u$. In practice, $v$ is much bigger than $u$, so this amounts to only a small increase in $K_E$ per collision, but the piston is moving slowly and there will be many such collisions over the course of the compression.
If the compression is being done isothermically, then you are assuming that any excess kinetic energy is being dumped into the heat reservoir. The flow of energy is then from the moving piston to the kinetic energy of the gas particles through collisions with the piston, and from there to the reservoir, and this is assumed to be at such small increments that the mean kinetic energy does not change. Again, for an ideal gas, the intermolecular distances have no bearing on the internal energy.
Regarding water ice, the process of melting is obviously complicated and you cannot simply wrap it up into a simple function of the mean interparticle distance. There are complex interactions between the molecules and these depend quite sensitively on their relative orientation, with the end result being the crystal structure of ice. Your question is, basically, "what is it about the molecular interactions in water that makes the lowest-energy crystal form have the structure it does?", which is obviously a much more complicated question in and of itself (though, of course, it's very well studied).
In Thermodynamics, the specific heat capacity at constant volume and the specific heat capacity at constant pressure are physical properties of a material (irrespective of process) that are precisely defined as follows:
$$C_v=\left(\frac{\partial U}{\partial T}\right)_V$$
and $$C_p=\left(\frac{\partial H}{\partial T}\right)_P$$where the specific internal energy U (per mole or per unit mass) and the specific enthalpy H (per mole or per unit mass) are also physical properties of the material (irrespective of process), with $$H=U+PV$$where V is the specific volume (per mole or per unit mass). For an ideal gas, U and H are functions only of temperature, and not pressure or volume. Therefore, for an ideal gas $$C_p=\left(\frac{dH}{dT}\right)=\frac{dU}{dT}+\frac{d(PV)}{dT}=C_v+\frac{d(RT)}{dT}=C_v+R$$
ADDENDUM
Problem 1: This is a 2 step process involving 1 mole of ideal gas. In Step 1, the system starts out at $P_1$, $V_1$, and $T_1$, and is heated at constant volume to temperature $T_2$ (and corresponding pressure $P_2$). In Step 2, the gas is allowed to expand isothermally and reversibly (being held in contact with a constant temperature bath at $T_2)$ until the pressure is again $P_1$.
Step 1 Questions:
In terms of $T_1$, $T_2$, and $P_1$, what is the final pressure $P_2$ at the end of Step 1?
In terms of $T_1$ and $T_2$, what is $\Delta (PV)$ in Step 1?
In terms of $T_1$ and $T_2$, what is $\Delta U$, $\Delta H$, W, and Q in Step 1?
Step 2 Questions:
In terms of $T_1$, $T_2$, and $V_1$, what is the final volume at the end of Step 2?
What is $\Delta (PV)$ in Step 2?
In terms of $T_1$ and $T_2$, what is W and Q in Step 2?
What is $\Delta U$ and $\Delta H$ in Step 2?
Overall Process Questions:
In terms of $T_1$ and $T_2$, what are Q and W for the overall process?
In terms of $T_1$ and $T_2$, what are $\Delta U$ and $\Delta H$ for the overall process?
What is $\Delta U$ divided by $\Delta T = (T_2-T_1)$ for the overall process?
What is $\Delta H$ divided by $\Delta T = (T_2-T_1)$ for the overall process?
Best Answer
Yes, you can apply the formula $\Delta U$=nCv$\Delta T$ for an ideal gas in a container whether or not the process is isochoric.
This is because the change in internal energy for an ideal gas undergoing some mechanical process is mainly affected by the change in kinetic energy of the gas. It does not depend on the change in volume of gas.So as long as the temperature difference is same the change in internal energy will be same. Heat capacity is the amount of heat required to raise the temperature of a substance by 1 unit so $\Delta U$ is directly proportional to heat capacity and $\Delta T$ along with the number of moles of gas.
When the process is carried with constant volume only then $\Delta W$ is $0$ so in that case $\Delta Q$=$\Delta U$ whereas $\Delta U$=nCv$\Delta T$ holds good always for an ideal gas under some mechanical process.