Thermodynamics of metal-mediated assemblies of porphyrins