# Pressure over time in a tank with variable volume and an orifice

I have a tank whose one side can be moved, so we can change the pressure inside the tank by this movement. (In my main case this ig going to be a sinosoidal movement). We add an orifice to the tank, so I can't use the $$pV=const.$$ equation, since the air comes and goes through the orifice. I tried to describe the volumetric flow, one that comes from changing the tank volume and one that comes from the orifice. The volumetric flow rate at the orifice according to Poiseuille's equation for an ideal isothermal gas: $$Q_1(t)=\frac{\pi r^4}{16\mu L}\cdot \frac{p_1^2(t)-p_2^2}{p_2}$$ The other volumetric flow acquired from the movement of the side of the tank, which is known: $$Q_2(t)$$ Where: $$p_1$$ is the pressure inside the tank, $$p_2$$ is the atmospheric pressure outside. From these I can write something like $$V(t)=\int(Q_1(t)+Q_2(t))dt$$ which gives me the volume of the air inside the tank, but I do not see how can I know the pressure from these data. One thing that came to mind is changing the volumetric flow to mass flow, but for that I think I would have to know the pressure. So what is the trick here I could not find on my own?

After a few days I came up with a solution with the following equations. The mass flow rate through the orifice: $$Q_m(t)=\rho(t) \cdot \frac{ \pi r^4}{16\mu L}\cdot \frac{p_1^2(t)-p_2^2}{p_2}$$ The air density inside the box: $$\rho(t)=\frac{m(t)}{V(t)}$$ The mass of the air inside the box: $$m(t)=m_0+\int_0^tQ_m(t)dt$$ The volume of the box according to the linear displacement $$x(t)$$ of a certain area $$A$$: $$V(t)=V_0+x(t)\cdot A$$ Finally from these, I can calculate the pressure inside of the box from time step to time step(I have calculated with constant $$RT$$): $$p(t)=\frac{m(t)RT}{V(t)}$$