Energy can be built from lagrangian when considering the symmetry of time $(\frac{\partial L}{\partial t}=0)$. [Free energy](http://en.wikipedia.org/wiki/Free_energy) is a generalization of energy when the system exchanges heat with the environment. I can't find any sources that building free energy directly from lagrangian. Is there any way to do that? If it is, what symmetry is it based on?