Flux ropes are magnetic structures commonly found in the solar corona. They are thought to play an important role in solar flares and coronal mass ejections. Understanding their formation and eruption is of paramount importance for our understanding of space weather. In this thesis the magnetofrictional method is applied to simulate the formation of flux ropes and track their evolution up to eruption both in solar and stellar coronae.
Initially, the coronal magnetic field of a solar active region is simulated using observed magnetograms to drive the coronal evolution. From the sequence of magnetograms the formation of a flux rope is simulated, and compared with coronal observations.
Secondly a procedure to produce proxy SOLIS synoptic magnetograms from SDO/HMI and SOHO/MDI magnetograms is presented. This procedure allows SOLIS-like synoptic magnetograms to be produced during times when SOLIS magnetograms are not available.
Thirdly, a series of scaling laws for the formation and life-times of flux ropes in stellar coronae are determined as a function of stellar differential rotation and surface diffusion. These scaling laws can be used to infer the response of stellar coronae to the transport of magnetic fields at their surface.
Finally, global long-term simulations of stellar corona are carried out to determine the coronal response to flux emergence and differential rotation. A bipole emergence model is developed and is used in conjunction with a surface flux transport model in order to drive the global coronal evolution. These global simulations allow the flux, energy and flux rope distributions to be studied as a function of a star’s differential rotation and flux emergence rate