Thermodynamic variational principle, its connections to the phenomenological laws and its applications to the derivation of microstructural models