Summarize the factors that affect the formation of magma?