  We present an approach for eliminating the gauge freedom for derivative
couplings in nonadiabatic dynamics in the presence of geometric phase effects.
This approach relies on a bottom-up construction of a parametric quantum
Hamiltonian in terms of functions of a dynamical variable, which can be
associated with real and imaginary-valued contributions to the Hamiltonian in a
given diabatic basis. By minimizing the deviation of the imaginary functions
from a constant we identify a set of diabatic bases that recover the
real-valued gauge commonly used for topologically-trivial systems. This
minimization, however, also confines the gauge freedom in the
topologically-nontrivial case, opening a path towards finding gauge-invariant
derivative couplings under geometric phase effects. Encouraging results are
presented for fewest-switches surface hopping calculations of a nuclear
wavepacket traversing a single avoided crossing, for which fully
gauge-invariant derivative couplings are found.
