  Effects of a uniform magnetic field on homoclinic bifurcations in
Rayleigh-B\'{e}nard convection in a fluid of Prandtl number $Pr = 0.01$ are
investigated using direct numerical simulations (DNS). A uniform magnetic field
is applied either in the vertical or in the horizontal direction. For a weak
vertical magnetic field, the possibilities of both forward and backward
homoclinic bifurcations are observed leading to a spontaneous merging of two
limit cycles into one as well as a spontaneous breaking of a limit cycle into
two for lower values of the Chandrasekhar's number ($Q\leq 5$). A slightly
stronger magnetic field makes the convective flow time independent giving the
possibility of stationary patterns at the secondary instability. For horizontal
magnetic field, the $x\leftrightharpoons y$ symmetry is destroyed and neither a
homoclinic gluing nor a homoclinic breaking is observed. Two low-dimensional
models are also constructed: one for a weak vertical magnetic field and another
for a weak horizontal magnetic field. The models qualitatively capture the
features observed in DNS and help understanding the unfolding of bifurcations
close to the onset of magnetoconvection.
