Thermodynamics: Piston spring assembly We have a piston assembly (filled with gas) connected to a spring.  The top of the piston is open to the atmosphere.  The gas is reversibly heated to 100C.
This is an example problem in my thermodynamics handbook (Koretsky, Ex 2.9)
The process is reversible and work is then given by
$$ W = -\int^{V_2}_{V_1}PdV  $$
The displacement of the spring can be written in terms of the change in volume
$$ x = \frac{V-V_1}{A} = \frac{\Delta V}{A} $$
A force balance on the piston yields
$$ P_{air}A = P_{ext}A + kx $$
$$ P_{air} = P_{ext} + \frac{kx}{A^2}$$
Plugging these equation into the first equation:
$$ W = -\int^{V_2}_{V_1}PdV = -\int^{V_2}_{V_1}P_{ext}dV -\int^{\Delta V = V_2-V_1} _{0}\frac{k \Delta V}{A^2}d({\Delta V} )  $$
$$ W = -P_{ext}(\Delta V) - \frac{k \Delta V^2}{2A^2} $$
Applying the ideal gas law
$$ \frac{P_1V_1}{T_1} = \frac{P_2V_2}{T_2} = \frac{V_2}{T_2}(P_{ext} + \frac{kx}{A^2})$$
and solving this equation will give $V_2$ and the work can be found.
EDIT:  The change in internal energy is given by
$$ \Delta u = \int^{T_2}_{T_1}C_pdT = R\int^{T_2}_{T_1}[(A-1) + BT + DT^{-2}]dT $$
$$ \Delta u = R[(A-1)T+\frac{B}{2}T^2 - \frac {D}{T}] | [T_2 T_1] $$
with the parameters for he heat capacity for air from the tables in the book, the internal energy change can be found.
Total heat transfer is then $Q = \Delta u - W$ 

My question. 

How would I model the transient behaviour of the system?  The spring's displacement over time as well as the pressure change over time?
EDIT: Fixed a integration error in the 6th formula.
 A: 
How would I model the transient behaviour of the system? The spring's displacement over time as well as the pressure change over time?


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.
A: I have a possible direction to pursue based on Gert's answer. Gert said the following:
Equation of motion:
$$p_0\frac{AV_0}{V_0+yA}-p_aA-ky=ma_y$$
Can we change Gert's equation to the following and find a solution for $y(t)?$
$$p_0\frac{AV_0}{V_0+yA}-p_aA-ky=m\frac{d^2y}{dt^2}$$
Or:
$$m\frac{d^2y}{dt^2} + ky - p_0\frac{AV_0}{V_0+yA} + p_aA =0$$
If we can find $y(t)$ from that differential equation, then we can find $p(t)$ from this:
$$p(t)=p_0\frac{V_0}{V_0+y(t)A}$$
A: If the piston oscillates, then the process can't be reversible.  The kinetic energy would certainly be dissipated over time by viscous stresses (an irreversible effect) until the system attained a new steady state.  And, what happened to the changes in internal energy U of the gas as it is expanded or compressed.  That is certainly omitted from these analyses.  There is nothing in the problem statement that says that the reversible expansion is carried out isothermally    And, what if the piston mass is negligible?  Since no one responded to my comments regarding the original post, it is difficult to say more at this time.
THIS IS AN EDIT TO THE RESPONSE, ONCE MORE INFORMATION WAS MADE AVAILABLE.
The force balance on the piston is:
$$PA=P_{atm}A+kx$$where x is taken to be zero at time zero.  The change in volume of the gas is given by:$$V-V_0=Ax$$So, combining these equations gives:
$$P=P_{atm}+\frac{k}{A^2}(V-V_0)$$
The rate at which work is being done on the surroundings is thus $$\dot{W}=\left[P_{atm}+\frac{k}{A^2}(V-V_0)\right]\frac{dV}{dt}$$The rate of change of internal energy of the gas is given by:
$$\frac{dU}{dt}=nC_v\frac{dT}{dt}$$So, from the first law of thermodynamics, 
$$nC_v\frac{dT}{dt}=\dot{Q}-\left[P_{atm}+\frac{k}{A^2}(V-V_0)\right]\frac{dV}{dt}$$If we integrate this with respect to time, we get:
$$nC_v(T-T_0)=\int_0^t{\dot{Q}dt}-P_{atm}(V-V_0)-\frac{k}{A^2}\frac{(V-V_0)^2}{2}\tag{1}$$
where $$T=\frac{PV}{nR}=\frac{\left[P_{atm}+\frac{k}{A^2}(V-V_0)\right]V}{nR}$$and $$T_0=\frac{P_{atm}V_0}{nR}$$
So, $$T-T_0=\frac{P_{atm}(V-V_0)}{nR}+\frac{\left[\frac{k}{A^2}(V-V_0)\right]V}{nR}$$
If I substitute this result for the temperature difference into Eqn. 1 to obtain an equation for the volume solely in terms of the cumulative heat added, I obtain:
$$\gamma \left[P_{atm}(V-V_0)+\frac{k}{A^2}\frac{(V-V_0)^2}{2}\right]+\frac{k}{A^2}\frac{V_2-V_0^2}{2}=(\gamma -1)Q$$where Q is the cumulative amount of heat added through time t.
