Numerical simulation of the eruptive dynamics of volatile-rich magma in magma chambers and volcanic conduits