  We consider the optimal control of switching on a coupling term between two
quantum many-body systems. Specifically, we (i) quantify the energetic cost of
establishing a weak junction between two quantum spin-$1/2$ chains in finite
time $\tau$ and (ii) identify the energetically optimal protocol to realize it.
For linear driving protocols, we find that for long times the excess
(irreversible) work scales as $\tau^{-\eta}$, where $\eta=1, 2$ or a
nonuniversal number depending on the phase of the chains. Interestingly,
increasing a $J_z$ anisotropy in the chains suppresses the excess work thus
promoting quasi-adiabaticity. The general optimal control problem is solved,
employing a Chebyshev ansatz. We find that the optimal control protocol is
intimately sensitive to the chain phases.
