Device and method for liquefying a fluid such as hydrogen and/or helium