In partially ionised plasmas, the magnetic field can become decoupled from
the neutral gas and diffuse through it in a process known as ambipolar
diffusion. Although ambipolar diffusion has been implemented in several grid
codes, we here provide an implementation in smoothed particle
magnetohydrodynamics (SPMHD). We use the strong coupling approximation in which
the ion density is negligible, allowing a single fluid approach. The equations
are derived to conserve energy, and to provide a positive definite contribution
to the entropy. We test the implementation in both a simple 1D SPMHD code and
the fully 3D code PHANTOM. The wave damping test yields agreement within 0.03-2
per cent of the analytical result, depending on the value of the collisional
coupling constant. The oblique C-shocks test yields results that typically
agree within 4 per cent of the semi-analytical result. Our algorithm is
therefore suitable for exploring the effect ambipolar diffusion has on physical
processes, such as the formation of stars from molecular clouds.Comment: Accepted for publication by MNRA