What we are dealing with here is an irreversible process, where some of the gas from chamber 2 at temperature $T_2$ flows through the intervening tube and mixes with the gas already present in chamber 1 at temperature $T_1$. This mixing gives rise to irreversibility present in the process. Accordingly, to establish the entropy change for this irreversible process, we must follow the standard procedure of first employing the first law of thermodynamics to establish the final state of the system, and then determining the entropy difference between the initial and final states. (Without establishing the final state of the system, it is not possible to determine the entropy change)
Were are told that at each stage of this process, the pressures within the two chambers are equal. This enables us to establish relationships for the number of moles in each chamber and for the pressure. Let the total number of moles in the two chambers be N, and let the initial number of moles in each chamber be $N_{10}$ and $N_{20}$. And let then number of moles in the two chamber at any other stage of the process be $N_1$ and $N_2$, such that $$N_1+N_2=N_{10}+N_{20}=N\tag{1}$$The condition of equal pressure in the two chambers requires that $$\frac{N_1T_1}{V_1}=\frac{N_2T_2}{V_2}\tag{2}$$If we combine Eqns. 1 and 2, we obtain:
$$N_1=\frac{V_1T_2}{(V_1T_2+V_2T_1)}N\tag{3a}$$and$$N_2=\frac{V_2T_1}{(V_1T_2+V_2T_1)}N\tag{3b}$$
And, for the pressure, we obtain: $$P=\frac{NRT_1T_2}{(V_1T_2+V_2T_1)}\tag{4}$$
Since each of the chambers is an open system, with gas flowing in or out, we must use the open system (control volume) version of the first law of thermodynamics to describe the energy balances. For chambers 1 and 2, these read respectively:
$$d(N_1u_1)=h_2dN_1\tag{5a}$$
$$d(N_2u_2)=h_2dN_2-PdV_2\tag{5b}$$where u and h represent internal energy and enthalpy per mole of gas. The terms $h_2dN_1$ and $h_2dN_2$ in these equations represent enthalpy flow from chamber 2 into chamber 1 and enthalpy flow out of chamber 2, respectively. If we combine Eqns. 3-5, we obtain two equations in two unknowns for the changes in $T_1$ and $T_2$ as functions of the changes in $V_2$.
Let us first work with Eqn. 5b. If we apply the product rule to the left hand side of this equation, we obtain:
$$N_2du_2=(h_2-u_2)dN_2-PdV_2\tag{6}$$But, for an ideal gas, we have: $du_2=C_vdT_2$, $h_2-u_2=RT_2$, and $P=N_2RT_2/V_2$; making these substitutions into Eqn. 6 yields: $$N_2C_vdT_2=RT_2dN_2-\frac{N_2RT_2}{V_2}dV_2\tag{7}$$Dividing this equation by $N_2T_2$yields an exact differential: $$d\ln{\left[T_2\left(\frac{V_2}{N_2}\right)^{R/C_v}\right]}=0\tag{8}$$or, combining this with Eqn. 3b yields:$$T_2\left(\frac{V_1T_2+V_2T_1}{T_1}\right)^{R/C_v}=T_{20}\left(\frac{V_1T_{20}+V_{20}T_{10}}{T_{10}}\right)^{R/C_v}\tag{9}$$
Once $V_2$ is specified, the only unknowns in Eqn. 9 are $T_1$ and $T_2$. Another equation relating these unknowns is provided by Eqn. 5a, the first law open system energy balance on chamber 1. Unfortunately, I have not been able to arrive at an analytic integration of this equation the way I have for Eqn. 5b. However, I will report on what I have obtained so far.
If we employ ideal gas relationships to Eqn. 5a similar to those used for Eqn. 5b, we obtain: $$C_vdT_1=[C_v(T_2-T_2)+RT_2]d\ln{N_1}\tag{10a}$$with $$d\ln{N_1}=d\ln{\left(\frac{T_2}{V_1T_2+V_2T_1}\right)}\tag{10b}$$
Maybe someone else can figure out a way of analytically integrating Eqns. 10, subject to Eqns. 9 to obtain $T_1$ and $T_2$ as functions of $V_2$. So far this has eluded me. As noted previously, we need to obtain these functional relationships in order to determine the change in entropy of the system as a unique function of $V_2$. In practice, if I could not carry out the integration of the equations analytically, I would resort to numerical integration.
ADDENDUM
I did some additional analysis on this problem and was able to simplify Eqns. 10 by combining them with Eqn. 9 to obtain:
$$\frac{dT_1}{dT_2}=\frac{C_v}{R}\frac{T_1}{T_2}\left(\frac{C_p}{C_v}-\frac{T_1}{T_2}\right)\tag{11}$$Note that this equation no longer contains the volumes, and thus describes how $T_1$ must vary in tandem with $T_2$, starting with specified initial values of these parameters, for any arbitrary variation in $V_2$.
GOOD NEWS. (3/5/18)
I've finally been successful in integrating Eqn. 11 analytically to obtain $T_1$ as an explicit function of $T_2$. The result is:
$$T_1=\frac{T_2}{\left[1+\left(\frac{T_{20}}{T_{10}}-1\right)\left(\frac{T_{20}}{T_2}\right)^{C_v/R}\right]}\tag{11a}$$
Note from this that, as would be expected, if $T_{10}=T_{20}$, $T_1=T_2$
CHANGE IN ENTROPY
The change in entropy for this system is given by:
$$\Delta S=(N_1s_1+N_2s_2)-(N_{10}s_{10}+N_{20}s_{20})\tag{12}$$
where the s's are molar entropies:
$$s=C_v\ln{(T/T_{ref})}+R\ln{(v/v_{ref})}\tag{13}$$where $T_{ref}$ and $v_{ref}$ are the temperature and molar volume at some arbitrary reference state; these parameters cancel out of the calculations. The specific volume $v_j$ for chamber j is given by $v_j=V_j/N_j$.
ADDITIONAL ANALYSIS ON 3/5/18
Intuitively, and, based on Eqns. 8 and 9 of the present analysis, we know that the gas remaining in chamber 2 at any time during this process has experienced an adiabatic reversible compression, such that its final entropy per unit mass is equal to its initial entropy per unit mass: $$s_2=s_{20}$$If we substitute this into Eqn. 12, this yields:
$$\Delta S=N_1s_1-N_{10}s_{10}-(N_{20}-N_2)s_{20}\tag{14}$$
Unfortunately, the same kind of simplification can not be made for chamber 1. However, further simplification is possible in the following way: We can substitute the identity $N_1=N_{10}+(N_1-N_{10}$ Into Eqn. 14 to obtain: $$\Delta S=N_{10}(s_1-s_{10})+(N_1-N_{10})s_1-(N_{20}-N_2)s_2\tag{15}$$But, from the material balance, we have, $$(N_1-N_{10})=(N_{20}-N_2)$$Substituting this into equation 15 then yields:
$$\Delta S=N_{10}(s_1-s_{10})-(N_{20}-N_2)(s_2-s_1)\tag{16}$$But, since the pressures are equal in chambers 1 and 2, the term $(s_2-s_1)$ is just:
$(s_2-s_1)=C_p\ln{(T_2/T_1)}$. Therefore, Eqn. 16 becomes:
$$\Delta S=N_{10}(s_1-s_{10})-(N_{20}-N_2)C_p\ln{(T_2/T_1)}\tag{17}$$
CALCULATING THE ENTROPY CHANGE:
- Specify a value for $T_2$
- Use Eqn. 11 to calculate the corresponding value of $T_1$
- Use Eqn. 9 to calculate the corresponding value of $V_2$
- Use Eqns. 3 to calculate the values of $N_1$, $N_2$, $N_{10}$, and $N_{20}$
- Plug values into Eqn. for entropy change