  The dynamics of GRB jets during the afterglow phase is most reliably and
accurately modelled using hydrodynamic simulations. All published simulations,
however, have considered only a uniform external medium, while a stratified
external medium is expected around long duration GRB progenitors. Here we
present simulations of the dynamics of GRB jets and the resulting afterglow
emission for both uniform and stratified external media with $\rho \propto
r^{-k}$ for k = 0, 1, 2. The simulations are performed in 2D using the special
relativistic version of the Mezcal code. The dynamics for stratified external
media are broadly similar to those derived for expansion into a uniform
external medium. The jet half-opening angle start increasing logarithmically
with time once the Lorentz factor drops below 1/theta_0. For larger k values
the lateral expansion is faster at early times and slower at late times with
the jet expansion becoming Newtonian and slowly approaching spherical symmetry
over progressively longer timescales. We find that contrary to analytic
expectations, there is a reasonably sharp jet break in the lightcurve for k = 2
although the shape of the break is affected more by the viewing angle than by
the slope of the external density profile. Steeper density profiles are found
to produce more gradual jet breaks while larger viewing angles cause smoother
and later appearing jet breaks. The counter-jet becomes visible as it becomes
sub-relativistic, and for k=0 this results in a clear bump-like feature in the
light curve. However, for larger k values the jet decelerates more gradually,
causing only a mild flattening in the radio light curve that might be hard to
discern when k=2. Late time radio calorimetry is likely to consistently
over-estimate the true energy by up to a factor of a few for k=2, and either
over-predict or under-predict it by a smaller factor for k = 0,1.
