  Spectra of late-type stars are usually analyzed with static model atmospheres
in local thermodynamic equilibrium (LTE) and a homogeneous plane-parallel or
spherically symmetric geometry. The energy balance requires particular
attention, as two elements which are particularly difficult to model play an
important role: line blanketing and convection. Inversion techniques are able
to bypass the difficulties of a detailed description of the energy balance.
Assuming that the atmosphere is in hydrostatic equilibrium and LTE, it is
possible to constrain its structure from spectroscopic observations. Among the
most serious approximations still implicit in the method is a static and
homogeneous geometry. In this paper, we take advantage of a realistic
three-dimensional radiative hydrodynamical simulation of the solar surface to
check the systematic errors incurred by an inversion assuming a plane-parallel
horizontally-homogeneous atmosphere. The thermal structure recovered resembles
the spatial and time average of the three-dimensional atmosphere. Furthermore,
the abundances retrieved are typically within 10% (0.04 dex) of the abundances
used to construct the simulation. The application to a fairly complete dataset
from the solar spectrum provides further confidence in previous analyses of the
solar composition. There is only a narrow range of one-dimensional thermal
structures able to fit the absorption lines in the spectrum of the Sun. With
our carefully selected dataset, random errors are about a factor of two smaller
than systematic errors. A small number of strong metal lines can provide very
reliable results. We foresee no major difficulty in applying the technique to
other similar stars, and obtaining similar accuracies, using spectra with a
resolving power about 50,000 and a signal-to-noise ratio as low as 30.
