  In Quantum Hydro-Dynamics the following problem is relevant: let
$(\sqrt{\rho},\Lambda) \in H^1(\R^d) \times L^2(\R^d,\R^d)$ be a finite energy
hydrodynamics state, i.e. $\Lambda = 0$ when $\rho = 0$ and \begin{equation*} E
= \int_{\R^d} \frac{1}{2} \big| \nabla \sqrt{\rho} \big|^2 + \frac{1}{2}
\Lambda^2 \mathcal L^d < \infty. \end{equation*} The question is under which
conditions there exists a wave function $\psi \in H^1(\R^d,\C)$ such that
\begin{equation*} \sqrt{\rho} = |\psi|, \quad J = \sqrt{\rho} \Lambda = \Im
\big( \bar \psi \nabla \psi). \end{equation*} The second equation gives for
$\psi = \sqrt{\rho} w$ smooth, $|w| = 1$, that $i \Lambda = \sqrt{\rho} \bar w
\nabla w$.
  Interpreting $\rho \mathcal L^d$ as a measure in the metric space $\R^d$,
this question can be stated in generality as follows: given metric measure
space $(X,d,\mu)$ and a cotangent vector field $v \in L^2(T^* X)$, is there a
function $w \in H^1(\mu,\mathbb S^1)$ such that \begin{equation*} dw = i w v.
\end{equation*} %dw = i w v$?
  We show that under some assumptions on the metric measure space $(X,d,\mu)$
(conditions which are verified on Riemann manifolds with the measure $\mu =
\rho \mathrm{Vol}$ or more generally on non-branching $MCP(K,N)$), we show that
the necessary and sufficient conditions for the existence of $w$ is that (in
the case of differentiable manifold) \begin{equation*} \int v(\gamma(t)) \cdot
\dot \gamma (t) dt \in 2\pi \Z \end{equation*} for $\pi$-a.e. $\gamma$, where
$\pi$ is a test plan supported on closed curves. This condition generalizes the
conditions that the vorticity is quantized. We also give a representation of
every possible solution.
  In particular, we deduce that the wave function $\psi = \sqrt{\rho} w$ is in
$W^{1,2}(X)$ whenever $\sqrt{\rho} \in W^{1,2}(X)$.
