Stars form by the gravitational collapse of interstellar gas . The thermodynamic response of the gas can be characterized by an effective equation of state . It determines how gas heats up or cools as it gets compressed , and hence plays a key role in regulating the process of stellar birth on virtually all scales , ranging from individual star clusters up to the galaxy as a whole . We present a systematic study of the impact of thermodynamics on gravitational collapse in the context of high-redshift star formation , but argue that our findings are also relevant for present-day star formation in molecular clouds . We consider a polytropic equation of state , P = k \rho ^ { \Gamma } , with both sub-isothermal exponents \Gamma < 1 and super-isothermal exponents \Gamma > 1 . We find significant differences between these two cases . For \Gamma > 1 , pressure gradients slow down the contraction and lead to the formation of a virialized , turbulent core . Weak magnetic fields are strongly tangled and efficiently amplified via the small-scale turbulent dynamo on timescales corresponding to the eddy-turnover time at the viscous scale . For \Gamma < 1 , on the other hand , pressure support is not sufficient for the formation of such a core . Gravitational contraction proceeds much more rapidly and the flow develops very strong shocks , creating a network of intersecting sheets and extended filaments . The resulting magnetic field lines are very coherent and exhibit a considerable degree of order . Nevertheless , even under these conditions we still find exponential growth of the magnetic energy density in the kinematic regime .