Magma is a mixture of rocks, metals, ores, salts, crystals and other solid materials that are molten beneath the earth’s crust. When magma is extruded out of the earth's surface, it becomes lava or explosives that can do certain damage in surrounding areas.
The factors that mainly affect in the formation of magma can be summarized into three: Temperature, Pressure and composition.
Temperature plays a role in the formation of the melts in the magma. Generally magma has a temperature range from 700-1300 degrees Celsius. Lower temperature in the earth's crust might solidify the components and magma may not be formed. Temperature should be consistent in order for a particular magma to pre produced. Higher temperature magma is less viscous and therefore more fluid. Magma is dependent on the rate of cooling which affects the formation of the end products. In this effect, the end products of magma such as rocks may vary in the structure based on how high the temperature has been and how long the cooling takes place.
Pressure can affect the shape and formation of melts. This goes hand in hand with the temperature in order to get a particular form of magma. At constant temperature, the fluidity of the magma can be dependent on the topographical location of the melts. As the pressure builds up, the magma will find a way in order to release it, thus destructive explosion happens.
Compositions of magma vary depending on the types of material present in the area. Some particles melt at lower temperature than the other. Also, volatile compounds such as water and carbon dioxide may be present in the melts and can affect the melting and formation of magma. Generally, the more volatile molecules present in the magma, the easier for it to melt at lower temperatures.