  Magnetic flux ropes are a bundle of twisted magnetic field lines produced by
internal electric currents, which are responsible for solar eruptions and are
the major drivers of geomagnetic storms. As such, it is crucial to develop a
numerical model that can capture the entire evolution of a flux rope, from its
birth to death, in order to predict whether adverse space weather events might
occur or not. In this paper, we develop a data-driven modeling that combines a
time-dependent magneto-frictional approach with a thermodynamic
magnetohydrodynamic model. Our numerical modeling successfully reproduces the
formation and confined eruption of an observed flux rope, and unveils the
physical details behind the observations. Regarding the long-term evolution of
the active region, our simulation results indicate that the flux cancellation
due to collisional shearing plays a critical role in the formation of the flux
rope, corresponding to a substantial increase in magnetic free energy and
helicity. Regarding the eruption stage, the deformation of the flux rope during
its eruption can cause an increase in the downward tension force, which
suppresses it from further rising. This finding may shed light on why some
torus-unstable flux ropes lead to failed eruptions after large-angle rotations.
Moreover, we find that twisted fluxes can accumulate during the confined
eruptions, which would breed the subsequent eruptive flares.
