Open quantum systems in and out of equilibrium theory and applications