  X-ray afterglow light curves have been collected for over 400 Swift gamma-ray
bursts with nearly half of them having X-ray flares superimposed on the regular
afterglow decay. Evidence suggests that gamma-ray prompt emission and X-ray
flares share a common origin and that at least some flares can only be
explained by long-lasting central engine activity. We have developed a shell
model code to address the question of how X-ray flares are produced within the
framework of the internal shock model. The shell model creates randomized GRB
explosions from a central engine with multiple shells and follows those shells
as they collide, merge and spread, producing prompt emission and X-ray flares.
We pay special attention to the time history of central engine activity,
internal shocks, and observed flares, but do not calculate the shock dynamics
and radiation processes in detail. Using the empirical E_p - E_iso (Amati)
relation with an assumed Band function spectrum for each collision and an
empirical flare temporal profile, we calculate the gamma-ray (Swift/BAT band)
and X-ray (Swift/XRT band) lightcurves for arbitrary central engine activity
and compare the model results with the observational data. We show that the
observed X-ray flare phenomenology can be explained within the internal shock
model. The number, width and occurring time of flares are then used to diagnose
the central engine activity, putting constraints on the energy, ejection time,
width and number of ejected shells. We find that the observed X-ray flare time
history generally reflects the time history of the central engine, which
reactivates multiple times after the prompt emission phase with progressively
reduced energy...
