Thermodynamic theory of polymer elasticity