0% found this document useful (0 votes)
399 views2 pages

ME140 Cantera Function Guide

1. The document provides instructions for using the Cantera software to model ideal gas mixtures in MATLAB. 2. It describes how to initialize a gas object using a chemical mechanism, set the gas properties like temperature, pressure and mole fractions, and equilibrate the gas. 3. It also explains how to obtain various gas properties and species properties using functions like temperature, enthalpy, and mass fractions.

Uploaded by

Ben Wolk
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
399 views2 pages

ME140 Cantera Function Guide

1. The document provides instructions for using the Cantera software to model ideal gas mixtures in MATLAB. 2. It describes how to initialize a gas object using a chemical mechanism, set the gas properties like temperature, pressure and mole fractions, and equilibrate the gas. 3. It also explains how to obtain various gas properties and species properties using functions like temperature, enthalpy, and mass fractions.

Uploaded by

Ben Wolk
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

ME140 CANTERA FUNCTION GUIDE MATLAB 1. Initializing the Gas Object In General: gas_variable_name = IdealGasMix(chemical_mechanism) Some Examples: g = IdealGasMix('gri30.

.cti') %creates gas object g using GRI3.0 mechanism gas1 = IdealGasMix(ch3oh.inp,nasathermo.dat) %creates gas object gas1 using ch3oh.inp mechanism and nasathermo.dat thermodynamic data (these are not included with the Cantera installation) 2. Setting the Attributes of the Gas Object In General: set(gas_variable_name,T,temperature_in_K,P,pressure_in_Pa,X,reactant_string) Some Examples: set(g,T,300,P,1e5,X,CH4:1.0001,O2:2,N2:7.52) %sets the gas as a stoichiometric methane-air mixture, e.g. 1.0001CH4 + 2(O2 + 3.76N2) Products set(gas1,T,1000,P,10e5,X,CH4:1,O2:3,N2:11.28) %sets the gas as a lean methane-air mixture, e.g. CH4 + 3(O2 + 3.76N2) Products 3. Equilibrate In General: equilibrate(gas_variable_name,XY) XY -- A two-letter string, which must be one of the set ['TP','TV','HP','SP','SV','UV', 'PT','VT','PH','PS','VS','VU']. If H, U, S, or V is specified, the value must be the specific value (per unit mass) Some Examples: equilibrate(g,HP) equilibrate(gas1,UV) 4. Getting Gas Properties temperature(g) pressure(g) density(g) molarDensity(g) meanmolecularweight(g) %temperature in K %pressure in Pa %mass density in kg/m3 %number density in kmol/m3 %mean molecular weight in kg/kmol

%equilibrate at constant enthalpy and pressure %equilibrate at constant internal energy and specific volume

enthalpy_mole(g) intEnergy_mole(g) entropy_mole(g) gibbs_mole(g) cp_mole(g) cv_mole(g) enthalpy_mass(g) intEnergy_mass(g) entropy_mass(g) gibbs_mass(g) cp_mass(g) cv_mass(g) 5. Getting Species Properties

%enthalpy per unit mole in J/kmol %internal energy per unit mole in J/kmol %entropy per unit mole in J/kmol-K %gibbs function per unit mole in J/kmol %heat capacity at constant pressure in J/kmol-K %heat capacity at constant volume in J/kmol-K %enthalpy per unit mass in J/kg %internal energy per unit mole in J/kg %entropy per unit mole in J/kg-K %gibbs function per unit mole in J/kg %heat capacity at constant pressure in J/kg-K %heat capacity at constant volume in J/kg-K

speciesindex(g,species) massfractions(g) molefractions(g) molarMasses(g); enthalpies_RT(g)

%get the index of a particular species in the mechanism %vector of yk %vector of xk %vector of MMk %vector of hk/(RT)

Example: %Find the mass fraction of CO2 in the gas object iCO2=speciesindex(g,CO2); massFracVector=massfractions(g); yCO2=massFracVector(iCO2); 6. Shortcuts oneatm = 101325 %Pa gasconstant = 8314 %J/kmol-K

You might also like