  We demonstrate how near-perfect entanglement (in fact arbitrarily close to
maximal entanglement) can be generated between the end spins of an
anti-ferromagnetic isotropic Heisenberg chain of length $N$, starting from the
ground state in the $N/2$ excitation subspace, by applying a magnetic field
along a given direction, acting on a single spin only. Temporally optimal
magnetic fields to generate a singlet pair between the two end spins of the
chain are calculated for chains up to length 20 using optimal control theory.
The optimal fields are shown to remain effective in various non-ideal
situations including thermal fluctuations, magnetic field leakage, random
system couplings and decoherence. Furthermore, the quality of the entanglement
generated can be substantially improved by taking these imperfections into
account in the optimization. In particular, the optimal pulse of a given
thermal initial state is also optimal for any other initial thermal state with
lower temperature.
