We demonstrate the practical feasibility of calculating transport coefficients such as the viscosity of liquids completely from first principles using the Green-Kubo relations. Results presented for liquid aluminum are shown to have a statistical error of only ca. 5%. The importance of such calculations is illustrated by results for a liquid iron-sulfur alloy under Earth's core conditions, which indicate that the viscosity of the liquid outer core is not substantially higher than that of typical liquid metals under ambient conditions. PACS numbers: 66.20.+d, 71.15.Pd Since the pioneering work of Car and Parrinello [1] first principles molecular dynamics (FPMD) has become a widely used technique for investigating condensed matter. For liquids and solids in thermal equilibrium many quantities of interest are readily calculated, including thermodynamic functions, structure factors, radial distribution functions, diffusion coefficients, bond lifetimes, etc. But transport coefficients such as viscosity and thermal conductivity are computationally more demanding, and have been little studied by FPMD. We demonstrate here the feasibility of calculating such quantities with useful accuracy, by presenting FPMD results for the viscosity of liquid aluminum near the triple point. We then illustrate the potential importance of this type of calculation by showing how FPMD calculations can be used to calculate the viscosity of liquid iron in the Earth's outer core. This is one of the key quantities in the theory of the Earth's deep interior, but also one of the most uncertain.There are basically two ways of calculating transport coefficients by simulation. The first is to subject the simulated system to an explicit external perturbation (e.g. a shear flow or a temperature gradient) and calculate the steady-state response. Alternatively, one can apply the Green-Kubo (GK) relations, i.e. the relations between transport coefficients and correlation functions involving fluxes of conserved quantities [2]. The shear viscosity η, for example, is given by:where · denotes the thermal average, V is the volume of the system, T is the temperature, k B is the Boltzmann factor, and P xy is the off-diagonal component of the stress tensor P αβ (α and β are Cartesian components). The relative merits of the two approaches have been much discussed, but the GK method has the virtues of simplicity and ease of application, and will be used here. For a simulation having a given duration, single particle properties, like the diffusion coefficient, can be calculated more accurately than collective properties, like the viscosity. In the former case the statistical average can be done over time and over the particles, while in the latter one loses the possibility of averaging over the particles. To obtain the same statistical accuracy, collective properties need much longer runs than single particle properties by a factor proportional to the size of the system.The first principles calculations presented here are based on density functional theory, pse...