  We investigate a simple and robust scheme for choosing the phases of
adiabatic electronic states smoothly (as a function of geometry) so as to
maximize the performance of ab initio non-adiabatic dynamics methods. Our
approach is based upon consideration of the overlap matrix ($\mathbf{U}$)
between basis functions at successive points in time and selecting the phases
so as to minimize the matrix norm of $\log(\mathbf{U})$. In so doing, one can
extend the concept of parallel transport to cases with sharp curve crossings.
We demonstrate that this algorithm performs well under extreme situations where
dozens of states cross each other either through trivial crossings (where there
is zero effective diabatic coupling), or through nontrivial crossings (when
there is a nonzero diabatic coupling), or through a combination of both. In all
cases, we compute the time-derivative coupling matrix elements (or equivalently
non-adiabatic derivative coupling matrix elements) that are as smooth as
possible. Our results should be of interest to all who are interested in either
non-adiabatic dynamics, or more generally, parallel transport in large systems.
