  We introduce a finite-volume numerical scheme for solving stochastic
gradient-flow equations. Such equations are of crucial importance within the
framework of fluctuating hydrodynamics and dynamic density functional theory.
Our proposed scheme deals with general free-energy functionals, including, for
instance, external fields or interaction potentials. This allows us to simulate
a range of physical phenomena where thermal fluctuations play a crucial role,
such as nucleation and other energy-barrier crossing transitions. A
positivity-preserving algorithm for the density is derived based on a hybrid
space discretization of the deterministic and the stochastic terms and
different implicit and explicit time integrators. We show through numerous
applications that not only our scheme is able to accurately reproduce the
statistical properties (structure factor and correlations) of the physical
system, but, because of the multiplicative noise, it allows us to simulate
energy barrier crossing dynamics, which cannot be captured by mean-field
approaches.
