Classically, if the magnetic moment of a particle is aligned with a time-varying magnetic field, can its spin flip?

Consider the time-varying magnetic field: $$\mathbf{B}=B \tanh{\Big(\frac{t}{\tau}\Big)}\hat{\mathbf{z}}.$$

If the magnetic moment (which is proportional to the angular momentum) of a particle at $$t=-\infty$$ is in the $$\hat{\mathbf{z}}$$-direction, will it change as soon as the direction of $$\mathbf{B}$$ flips from $$-\hat{\mathbf{z}}$$ to $$\hat{\mathbf{z}}$$ at $$t=0$$?

With the potential energy of the particle being $$U=-\vec{\mu}\cdot\mathbf{B}$$, it seems to me as if the moment, so as to minimize $$U$$, would change its direction with time to align with $$\mathbf{B}$$, but this seems to violate the principle of angular momentum conservation.

How can these two ways of thinking about angular momentum in this context be made consistent with one another?

Note that the potential energy $$U=-\vec{\mu}\cdot\mathbf{B}=-\mu B\cos\theta$$ has two equilibria, for $$\theta=0$$ (dipole and field aligned) and for $$\theta=\pi$$ (dipole and field antialigned). The equilibrium at $$\theta=0$$ is stable, while the equilibrium at $$\theta=\pi$$ is unstable. If the situation happens exactly as you describe (the external field is always precisely in the $$\hat{z}$$-direction, and the dipole is precisely aligned with the $$\hat{z}$$-direction), then there will never be any torque on the dipole, since the system jumped from one equilibrium to the other (from a stable equilibrium to an unstable equilibrium), so the dipole will not flip. But for $$t>0$$ (i.e. when the dipole and field are anti-aligned), if there is any perturbation of either the external field or the dipole, then the system will deviate from this unstable equilibrium and settle into the stable one. In other words, the dipole will flip if anything is perturbed even slightly, meaning that in any realistic situation, the dipole will flip for $$t>0$$.
• It takes time for a dipole to flip. It's not instantaneous. And energy is conserved, so in a constant field a dipole that is nearly anti-aligned will oscillate for a long time before it damps down and settles into the stable equilibrium. (And it only does so if there is some kind of friction acting on it.) But a time-varying magnetic field can add energy to the dipole, so you need to solve a differential equation to figure out what happens. It will eventually settle down in the stable equilibrium, but it will be at a $t$ larger than $0$. – Peter Shor Nov 2 '18 at 1:53