  We use entanglement witnesses to detect entanglement in the XY chain in
thermal equilibrium and determine the temperature bound below which the state
is detected as entangled. We consider the entanglement witness based on the
Hamiltonian. Such a witness detects a state as entangled if its energy is
smaller than the energy of separable states. We also consider a family of
entanglement witnesses related to the entanglement negativity of the state. We
test the witnesses in infinite and finite systems. We study how the temperature
bounds obtained are influenced by a quantum phase-transition or a disorder line
in the ground state. Very strong finite-size corrections are observed in the
ordered phase due to the presence of a quasi-degenerate excitation. We also
study the postquench states in the thermodynamic limit after a quench when the
parameters of the Hamiltonian are changed suddenly. In the case of the Ising
model, we find that the mixed postquench state is detected as entangled by the
two methods if the parameters of the Hamiltonian before and after the quench
are close to each other. We find that the two witnesses give qualitatively
similar results, showing that energy-based entanglement witnesses are efficient
in detecting the nearest-neighbor entanglement in spin chains in various
circumstances. For other XY models, we find that the negativity based witnesses
also detect states in some parameter regions where the energy-based witness
does not, in particular, if the quench is performed from the paramagnetic phase
to the ferromagnetic phase and vice versa. The domains in parameter space
corresponding to postquench states detected as entangled by the energy-based
witness have been determined analytically, which stresses further the utility
of our method.
