Your question seems to have the hidden assumption that temperature is defined as the partial derivative of entropy with respect to energy, but that is not a universal point of view in general thermodynamic applications. Here I summarize two possible approaches to your question: from an equilibrium, generalized Gibbsian viewpoint, and from the viewpoint of non-equilibrium continuum thermomechanics. References are listed at the end.
Generalized Gibbsian thermostatics
In the kind of equilibrium situation that you seem to consider, the generalized "Gibbsian" point of view is that
We state which quantities define the thermodynamic state (and therefore the system), in a non-redundant way. In your case it seems you can take any three of the energies $U,U_1,U_2,U_{12}$, the remaining one being determined them, plus any other relevant thermodynamic quantities. Of course we can change the set of basic quantities to equivalent ones; this corresponds to choosing a different coordinate system on the manifold of thermodynamic states.
We give the "fundamental equation" (Gibbs's and Weightman's terminology) that specifies how the entropy of the system depends on the thermodynamic variables. This function is usually required to be convex, but this property can be problematic or undefined in non-extensive systems, and some authors seem to drop this requirement to deal with phase transitions, for example (see eg Wightman, Landsberg & Tranah).
Then any equilibrium state is determined by maximizing the entropy function with respect to the constraints imposed on the system, expressed as functional relations between the thermodynamic variables. Of course it can happen that there's no maximum or that there are many maxima (this can also happen in standard textbook cases, see eg Callen, Appendix C p. 321). This is a general point of view that does not require extensivity or similar properties. With extensive systems additional properties of the entropy function are usually required.
From this point of view temperature becomes a somewhat secondary concept, and you could define auxiliary temperatures, if they are useful, in a "$1/T=\partial S/\partial U$" way. In your case you could define three inverse temperatures $\beta_1 = \partial S/\partial U_1$, $\beta_2 = \partial S/\partial U_2$, $\beta_{12} = \partial S/\partial U_{12}$. If your system has a constrained total energy but the energies $U_1$, $U_2$, $U_{12}$ are unconstrained, then maximization of entropy on the constrain submanifold of the state space leads to $\beta_1=\beta_2=\beta_{12}$ in the usual way. However, note that this $\mathrm{d}S\rvert_{\text{constr. submanifold}} = 0$ point might not be a maximum, and thus not an equilibrium point. See the discussion in Lynden-bell, especially at the bottom of p. 295.
There's also the tricky point to say which quantities should be kept constant in these partial derivatives: usually they are extensive quantities, but your present system is presumably non-extensive. There are studies of equilibrium non-extensive systems (typically gravitational ones), see for example Landsberg & Tranah and Lynden-Bell; but I can't find how they approached the question of the partial derivatives. And I don't know how these studies have developed in recent times.
References for this approach:
Continuum thermomechanics
This is a theory of time-dependent, space-dependent, non-equilibrium thermodynamical and mechanical processes. It's a field theory: physical quantities depend on space and time. Equilibrium thermostatics is obtained in the special case where quantities are time-independent and have a uniform spatial distribution. Great introductions to this theory are Astarita's and Müller & Müller's books.
Temperature here is taken as a primitive quantity which depends on space and time, so there's no question of "defining" it in terms of other quantities. In particular, temperature is a property of matter at every point in space, not of a "subsystem". It can have discontinuities, however: for example we can have $T=T_1$ in a region of space, $T=T_2$ in an adjacent region, and $T=T_{12}$ on the surface separating the two regions. In the case of mixtures of different chemical species it would be possible to define a (spatially dependent) temperature for each of them, but such a generality is usually not pursued; see eg Samohýl & Pekař chap. 4, or Truesdell Lecture 5 and appendices to it.
The "$1/T=\partial S/\partial U$" relation is not generally valid a priori in this theory; see for example Astarita chap. 2 and Samohýl & Pekař chap. 2.
Continuum thermodynamics typically deals with situations with short-range forces, so energy is extensive. Interaction energies may be considered at surfaces (surface tension). But, again, this does not interfere with how temperature is used. See for example Astarita chap. 6.
There is a generalization of this theory that deals with energetically non-extensive systems – typically gravitational ones. Energy and entropy have a "doubly spatial" dependence in this approach. But temperature remains a quantity associated with each single spatial point. See the studies by Gurtin & Williams; unfortunately I'm not updated about recent developments of these studies.
References for this approach:
Final comments
I personally prefer the second approach, because it covers more general situations. And also because in my opinion the "$1/T=\partial S/\partial U$" definition of temperature is vacuous, since it defines temperature in terms of non-directly measurable quantities. Actually we need temperature as a primitive in order to indirectly measure energy: see for example the discussion in Müller & Müller § 2.3. So the "definition" above involves some circularity.
Very insightful further references about all these questions:
This post imported from StackExchange Physics at 2025-01-22 10:48 (UTC), posted by SE-user pglpm