This paper documents the numerical formulations, thermochemical data base, and possible applications of computer programs, SOLVGAS and GASWORKS, for calculating multicomponent chemical equilibria in gas-solid-liquid systems. SOLVGAS and GASWORKS compute simultaneous equilibria by solving simultaneously a set of mass balance and mass action equations written for all gas species and for all gas-solid or gas-liquid equilibria. The programs interface with a thermo-chemical data base, GASTHERM, which contains coefficients for retrieval of the equilibrium constants from 25[degrees] to 1200[degrees]C. The programs and data base model dynamic chemical processes in 30- to 40-component volcanic-gas systems. The authors can model gas evaporation from magma, mixing of magmatic and hydrothermal gases, precipitation of minerals during pressure and temperature decrease, mixing of volcanic gas with air, and reaction of gases with wall rock. Examples are given of the gas-evaporation-from-magma and precipitation-with-cooling calculations for volcanic gases collected from Mt. St. Helens in September 1981. The authors predict: (1) the amounts of trace elements volatilized from shallow magma, deep magma, and wall rock, and (2) the solids that precipitate from the gas upon cooling. The predictions are tested by comparing them with the measured trace-element concentrations in gases and the observed sublimate sequence. This leads to themore » following conclusions: (1) most of the trace elements in the Mt. St. Helens gases are volatilized from shallow magma as simple chlorides; (2) some elements (for example, Al, Ca) exist dominantly in rock aerosols, not gases, in the gas stream; (3) near-surface cooling of the gases triggers precipitation of oxides, sulfides, halides, tungstates, and native elements; and (4) equilibrium cooling of the gases to 100[degrees]C causes most trace elements, except for Hg, Sb, and Se, to precipitate from the gas. 94 refs., 30 figs., 7 tabs.« less