Forward and inverse modelling of thermal stratifications in confined spaces