Numerical analysis of key factors for the appearance of grassy ELMs in tokamak plasmas