Assessing the flexibility and loss of crystallinity in metal-organic frameworks from a thermodynamic point of view