How would I model the transient behaviour of the system? The spring's displacement over time as well as the pressure change over time?
![Piston displacement.](https://i.stack.imgur.com/dBf4q.png)
Assume at $t=0$ volume is $V_0$ at pressure $p_0$ and piston position $y=0$. External pressure is $p_a$, piston cross-section $A$ and piston weight is $m$. We ignore all friction. Now we need a Newtonian equation of motion.
Net force in $y$-direction, at any time:
$$F_y=pA-p_aA-ky$$
Newton's second law:
$$F_y=ma_y$$
Isothermal Ideal Gas law:
$$pV=p_0V_0$$
During expansion:
$$p=p_0\frac{V_0}{V}$$
$$V=V_0+yA$$
$$p=p_0\frac{V_0}{V_0+yA}$$
Equation of motion:
$$p_0\frac{AV_0}{V_0+yA}-p_aA-ky=ma_y$$
Chain rule:
$$a_y=\frac{dv_y}{dt}=\frac{dv_y}{dy}\frac{dy}{dt}=v_y\frac{dv_y}{dy}$$
So we have:
$$mv_ydv_y=\Big(p_0\frac{AV_0}{V_0+yA}-p_aA-ky\Big)dy$$
Integrate between relevant boundaries:
$$\int_0^{v_y}mv_ydv_y=\int_0^y\Big(p_0\frac{AV_0}{V_0+yA}-p_aA-ky\Big)dy$$
$$\frac12 mv_y^2=p_0V_0A\int_0^y\frac{dy}{V_0+Ay}-p_aAy-\frac12 ky^2$$
$$K(y)=\frac12 mv_y^2=p_0V_0\ln\frac{V_0+Ay}{V_0}-p_aAy-\frac12 ky^2$$
This is the kinetic energy $K(y)$ after displacement $y$ and the piston speed can be calculated from it:
$$v_y=\sqrt{\frac{2K(y)}{m}}$$
With $v_y=\frac{dy}{dt}$ an expression for $y(t)$ could be attempted but the expression:
$$t=\int_0^t\frac{dy}{v_y}$$
... is not analytically integratable. So no expression for $p(t)$ can be found, at least not analytically.
Update:
I will update the question slightly. I accidentally omitted part of question. I apologise for that. The question in the handbook states that the gas is reversibly heated to 100 C.
Assume initial pressure to be $p_0$ at $V_0$ and $T_0$, so by the IGL:
$$p_0V_0=nRT_0$$
After heating to $T$ the gas has expanded and is now at pressure $p$:
$$p(V_0+yA)=nRT$$
So:
$$\frac{p(V_0+yA)}{p_0V_0}=\frac{T}{T_1}$$
And:
$$p=\frac{p_0V_0}{V_0+yA}\frac{T}{T_1}$$
Now we could insert this expression into the equation of motion but unfortunately we don't have an expression for $T(y)$. That's because the type of expansion isn't specified: adiabatic or polytropic for instance. Obviously for the isothermal case it reduces to the solution above.
So the problem definition is sufficient for the first part of the question but not for the second part.
With the circuits which have been drawn there is no point in referring to series or parallel capacitors as it gets you nowhere.
The use of formulae for capacitors in series and parallel is to simplify the problem.
There is no such advantage here.
Just deal with each configuration from first principles with the important constraints that charge is conserved and that after the capacitors are connected together the voltage across each of the capacitors is the same.
In both cases a and b the initial charges on the capacitors are $q_1=C_1V_1$ and $q_2=C_2V_2$
Now when joining the capacitor the total change shored is $Q= q_1 \pm q_2 = C_1V_1 \pm C_2V_2$ where the positive sign is case a and the negative sign is case b.
In case a after joining the capacitors together the polarities of the plates stay the same whereas in case b if $q_1 > q_2$ then the polarity of the plates of capacitor $C_2$ will be reversed and if $q_2 > q_1$ then the polarity of the plates of capacitor $C_1$ will be reversed.
Assume $q_1>q_2$ and that the new charges on the two capacitors are $Q_1$ and $Q_2$.
Since the potentials across both capacitors must be the same $\dfrac {Q_1}{C_1} = \dfrac{Q_2}{C_2 }= \dfrac{Q-Q_1}{C_2}$
You can then find the new charge on each of the capacitor and the new voltage across both capacitors
Note that if at the start for case b the charge on each capacitor was the same then the final voltage across the capacitors would be zero as there is no charge on the capacitors.
Best Answer
The missing piece in the puzzle is dynamics.
The system can only settle in the stationary end configuration if some sort of damping, i.e., loss of energy, forces it to.
Without damping, the charge would actually oscillate forever between the capacitors; or, in Samuel's example, the water would keep slushing from one fish tank to the other, with energy being converted between kinetic and potential periodically, as in a pendulum.