  In their early stages, protoplanetary discs are sufficiently massive to
undergo gravitational instability (GI). This instability is thought to be
involved in mass accretion, planet formation via gas fragmentation, the
generation of spiral density waves, and outbursts. A key and very recent area
of research is the interaction between the GI and magnetic fields in young
protoplanetary discs, in particular whether this instability is able to sustain
a magnetic field via a dynamo. We conduct three-dimensional, stratified
shearing-box simulations using two independent codes, PLUTO and Athena++, to
characterise the GI dynamo in poorly ionised protostellar discs subject to
ambipolar diffusion. We find that the dynamo operates across a large range of
ambipolar Elssaser number Am (which characterises the strength of ambipolar
diffusion) and is particularly strong in the regime Am=10-100, with typical
magnetic to thermal energy ratios of order unity. The dynamo is only weakly
dependent on resolution (at least for Am <100), box size, and cooling law. The
magnetic field is produced by the combination of differential rotation and
large-scale vertical roll motions associated with spiral density waves. Our
results have direct implications for the dynamo process in young protoplanetary
discs and possibly some regions of AGN discs.
