Equilibrium with charged species and multiple condensed phases#

An equilibrium example with charged species in the gas phase and multiple condensed phases.

Requires: cantera >= 2.5.0, matplotlib >= 2.0

Warning

The results of this example are incorrect due to known issues with the multiphase equilibrium solver. See GitHub Issue #270.

Tags: Python equilibrium multiphase plasma saving output

T = 350.0
T = 400.0
T = 450.0
T = 500.0
T = 550.0
T = 600.0
T = 650.0
T = 700.0
T = 750.0
T = 800.0
T = 850.0
T = 900.0
T = 950.0
T = 1000.0
T = 1050.0
T = 1100.0
T = 1150.0
T = 1200.0
T = 1250.0
T = 1300.0
T = 1350.0
T = 1400.0
T = 1450.0
T = 1500.0
T = 1550.0
T = 1600.0
T = 1650.0
T = 1700.0
T = 1750.0
T = 1800.0
T = 1850.0
T = 1900.0
T = 1950.0
T = 2000.0
T = 2050.0
T = 2100.0
T = 2150.0
T = 2200.0
T = 2250.0
T = 2300.0
T = 2350.0
T = 2400.0
T = 2450.0
T = 2500.0
T = 2550.0
T = 2600.0
T = 2650.0
T = 2700.0
T = 2750.0
T = 2800.0
T = 2850.0
T = 2900.0
T = 2950.0
T = 3000.0
T = 3050.0
T = 3100.0
T = 3150.0
T = 3200.0
T = 3250.0
T = 3300.0
T = 3350.0
T = 3400.0
T = 3450.0
T = 3500.0
T = 3550.0
T = 3600.0
T = 3650.0
T = 3700.0
T = 3750.0
T = 3800.0
T = 3850.0
T = 3900.0
T = 3950.0
T = 4000.0
T = 4050.0
T = 4100.0
T = 4150.0
T = 4200.0
T = 4250.0
T = 4300.0
T = 4350.0
T = 4400.0
T = 4450.0
T = 4500.0
T = 4550.0
T = 4600.0
T = 4650.0
T = 4700.0
T = 4750.0
T = 4800.0
T = 4850.0
T = 4900.0
T = 4950.0
T = 5000.0
T = 5050.0
T = 5100.0
T = 5150.0
T = 5200.0
T = 5250.0
T = 5300.0

import cantera as ct
import csv

# create objects representing the gas phase and the condensed phases. The gas
# is a mixture of multiple species, and the condensed phases are all modeled
# as incompressible stoichiometric substances. See file KOH.yaml for more
# information.
phases = ct.import_phases('KOH.yaml', ['K_solid', 'K_liquid', 'KOH_a', 'KOH_b',
                                       'KOH_liquid', 'K2O2_solid', 'K2O_solid',
                                       'KO2_solid', 'ice', 'liquid_water',
                                       'KOH_plasma'])

# create the Mixture object from the list of phases
mix = ct.Mixture(phases)
equil_data = []

# loop over temperature
for n in range(100):
    t = 350.0 + 50.0*n
    print('T = {0}'.format(t))
    mix.T = t
    mix.P = ct.one_atm
    mix.species_moles = "K:1.03, H2:2.12, O2:0.9"

    # set the mixture to a state of chemical equilibrium holding
    # temperature and pressure fixed
    # mix.equilibrate("TP",maxsteps=10000,loglevel=1)
    mix.equilibrate("TP", max_steps=10000, log_level=0)

    # store the moles of each species
    equil_data.append([t] + list(mix.species_moles))

with open("equil_koh.csv", "w", newline="") as csvfile:
    writer = csv.writer(csvfile)
    writer.writerow(['T'] + mix.species_names)

    writer.writerows(equil_data)

Total running time of the script: (0 minutes 0.316 seconds)

Gallery generated by Sphinx-Gallery