  [Abridged] As is well known, in order to generate magnetic fields of observed
amplitudes during inflation, the conformal invariance of the electromagnetic
field has to be broken by coupling it either to the inflaton or to the scalar
curvature. Couplings to scalar curvature pose certain challenges even in slow
roll inflation and it seems desirable to consider couplings to the inflaton. It
can be shown that, in slow roll inflation, to generate nearly scale invariant
magnetic fields of adequate strengths, the non-conformal coupling to the
inflaton has to be chosen specifically depending on the inflationary model at
hand. In a recent work, we had found that, when there arise sharp departures
from slow roll inflation leading to strong features in the scalar power
spectra, there inevitably arise sharp features in the spectra of the
electromagnetic fields, unless the non-conformal coupling functions are
extremely fine tuned. In particular, we had found that, if there occurs an
epoch of ultra slow roll inflation, then the strength of the magnetic field
over large scales can be severely suppressed. In this work, we examine whether
these challenges can be circumvented in models of inflation involving two
fields. We show that the presence of the additional scalar field allows us to
construct coupling functions that lead to magnetic fields of required strengths
even when there arise intermediate epochs of ultra slow roll inflation.
However, we find that the features in the spectra of the magnetic fields that
are induced due to the departures from slow roll inflation cannot be completely
ironed out. We make use of the code MagCAMB to calculate the effects of the
magnetic fields on the anisotropies in the cosmic microwave background and
investigate if the spectra with features are broadly consistent with the
current constraints.
