*** empty log message ***
This commit is contained in:
parent
deb25434b8
commit
2c4cf59ee7
13 changed files with 219 additions and 155 deletions
|
|
@ -38,13 +38,13 @@ ixml = hndl(r);
|
|||
% representing the phases participating in the mechanism.
|
||||
iphase = thermo_hndl(ph);
|
||||
if nargin > 2
|
||||
ineighbor1 = thermo_hndl(neighbor1)
|
||||
ineighbor1 = thermo_hndl(neighbor1);
|
||||
if nargin > 3
|
||||
ineighbor2 = thermo_hndl(neighbor2)
|
||||
ineighbor2 = thermo_hndl(neighbor2);
|
||||
if nargin > 4
|
||||
ineighbor3 = thermo_hndl(neighbor3)
|
||||
ineighbor3 = thermo_hndl(neighbor3);
|
||||
if nargin > 5
|
||||
ineighbor4 = thermo_hndl(neighbor4)
|
||||
ineighbor4 = thermo_hndl(neighbor4);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -169,6 +169,6 @@ elseif ntot == 2
|
|||
else
|
||||
error('unimplemented property pair');
|
||||
end
|
||||
else
|
||||
elseif ntot > 2
|
||||
error('too many properties specified');
|
||||
end
|
||||
|
|
|
|||
|
|
@ -6,4 +6,4 @@ function adddir(d)
|
|||
% adds 'directory' to the set of directories where Cantera looks for
|
||||
% input and data files.
|
||||
%
|
||||
ctmethods(0,3,d)
|
||||
ctmethods(0,3,d);
|
||||
|
|
|
|||
|
|
@ -4,4 +4,4 @@ function gas = air
|
|||
% Air is modeled as an ideal gas mixture, and several reactions
|
||||
% are defined. The specification is taked from file air.xml.
|
||||
%
|
||||
gas = IdealGasMix('air.xml');
|
||||
gas = importPhase('air.cti','air');
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Tutorial 1: Getting started
|
||||
%
|
||||
% Topics:
|
||||
% - creating a gas mixture
|
||||
% - setting the state
|
||||
% - cleaning up
|
||||
%
|
||||
% Getting started
|
||||
%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
help tut1
|
||||
|
||||
% Start MATLAB, and at the prompt type:
|
||||
|
||||
|
|
@ -173,7 +175,7 @@ set(gas1,'T',900.0,'P',1.e5,'X','CH4:1,O2:2,N2:7.52')
|
|||
% extensive properties must be entered *per unit mass*.
|
||||
|
||||
% Setting the enthalpy and pressure:
|
||||
set(gas1, 'Enthalpy', 2*enthalpy_mass(gas1), 2*oneatm);
|
||||
set(gas1, 'Enthalpy', 2*enthalpy_mass(gas1), 'Pressure', 2*oneatm);
|
||||
|
||||
|
||||
% The composition above was specified using a string. The format is a
|
||||
|
|
@ -195,6 +197,12 @@ set(gas1, 'X', x)
|
|||
set(gas1, 'Y', x)
|
||||
|
||||
|
||||
% This clears all Matlab objects created
|
||||
clear all
|
||||
|
||||
% and this clears all Cantera objects created
|
||||
cleanup
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% end of tutorial 1
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
|
|
|||
|
|
@ -1,84 +1,128 @@
|
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Tutorial 2: Working with input files
|
||||
%
|
||||
% Tutorial 2: Using your own reaction mechanism files
|
||||
% Topics:
|
||||
% - using functions 'importPhase' and 'importInterface'
|
||||
% - input files distributed with Cantera
|
||||
% - the Cantera search path
|
||||
% - CTML files
|
||||
% - converting from CK format
|
||||
%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
help tut2
|
||||
|
||||
|
||||
% Function 'IdealGasMix'
|
||||
% ----------------------
|
||||
t0 = cputime;
|
||||
|
||||
% In the last tutorial, we used function GRI30 to create an object
|
||||
% that models an ideal gas mixture with the species and reactions of
|
||||
% GRI-Mech 3.0. Another way to do this is shown here:
|
||||
% GRI-Mech 3.0. Another way to do this is shown here, with statements
|
||||
% added to measure how long this takes:
|
||||
|
||||
gas = IdealGasMix('gri30.cti')
|
||||
gas1 = importPhase('gri30.cti', 'gri30');
|
||||
msg = sprintf('time to create gas1: %f', cputime - t0)
|
||||
|
||||
% Function 'importPhase' constructs an object representing a phase of
|
||||
% matter by reading in attributes of the phase from a file, which in
|
||||
% this case is 'gri30.cti'. This file contains several phase
|
||||
% spcifications; the one we want here is 'gri30', which is specified
|
||||
% by the second argument. This file contains a complete specification
|
||||
% of the GRI-Mech 3.0 reaction mechanism, including element data
|
||||
% (name, atomic weight), species data (name, elemental composition,
|
||||
% coefficients to compute thermodynamic and transport properties), and
|
||||
% reaction data (stoichiometry, rate coefficient parameters). The file
|
||||
% is written in a format understood by Cantera, which is described in
|
||||
% the document "Defining Phases and Interfaces."
|
||||
|
||||
% On some systems, processing long CTI files like gri30.cti can be a
|
||||
% little slow. For example, using a typical laptop computer running
|
||||
% Windows 2000, the statement above takes more than 4 s, while on a
|
||||
% Mac Powerbook G4 of similar CPU speed it takes only 0.3 s. In any
|
||||
% case, running it again takes much less time, because Cantera
|
||||
% 'remembers' files it has already processed and doesn't need to read
|
||||
% them in again:
|
||||
|
||||
t0 = cputime;
|
||||
gas1b = importPhase('gri30.cti', 'gri30');
|
||||
msg = sprintf('time to create gas1b: %f', cputime - t0)
|
||||
|
||||
|
||||
% CTI files distributed with Cantera
|
||||
%-----------------------------------
|
||||
|
||||
% Function 'IdealGasMix' constructs an object representing an ideal
|
||||
% gas mixture by reading in attributes of the mixture from a file,
|
||||
% which in this case is 'gri30.cti'. This file contains a complete
|
||||
% specification of the GRI-Mech 3.0 reaction mechanism, including
|
||||
% element data (name, atomic weight), species data (name, elemental
|
||||
% composition, coefficients to compute thermodynamic and transport
|
||||
% properties), and reaction data (stoichiometry, rate coefficient
|
||||
% parameters). The file is written in a format understood by
|
||||
% Cantera, which is described in the document "Defining Phases and
|
||||
% Interfaces."
|
||||
%
|
||||
% Several reaction mechanism files in this format are included in the
|
||||
% Cantera distribution, including ones that model high-temperature air
|
||||
% and a hydrogen/oxygen reaction mechanism. Under Windows, the
|
||||
% installation program puts these files in 'C:\Program
|
||||
% File\Common Files\Cantera.' On a unix/linux machine, they are
|
||||
% kept in the 'data' subdirectory within the Cantera
|
||||
% installation directory.
|
||||
%
|
||||
%
|
||||
% CK-format files
|
||||
% ---------------
|
||||
%
|
||||
% Cantera also comes with a converter utility for reaction mechanism
|
||||
% files written in the format used in the Chemkin-II software package
|
||||
% [1], which we will refer to as 'CK format'. Many gas-phase reaction
|
||||
% mechanisms are available in this format. (See, for example,
|
||||
% http://www.galcit.caltech.edu/EDL/mechanisms/library/library.html)
|
||||
% Cantera distribution, including ones that model high-temperature
|
||||
% air, a hydrogen/oxygen reaction mechanism, and a few surface
|
||||
% reaction mechanisms. Under Windows, these files may be located in
|
||||
% 'C:\Program Files\Common Files\Cantera', or in 'C:\cantera\data',
|
||||
% depending on how you installed Cantera and the options you
|
||||
% specified. On a unix/linux/Mac OSX machine, they are usually kept
|
||||
% in the 'data' subdirectory within the Cantera installation
|
||||
% directory.
|
||||
|
||||
% To use a CK-format reaction mechanism file, from the command line
|
||||
% type:
|
||||
%
|
||||
% ck2cti -i mech.ck -t therm.dat -tr tran.dat -id mymechname > mech.cti
|
||||
%
|
||||
% Here therm.dat is a CK-format file containing species thermo
|
||||
% data, and tran.dat is a Chemkin-compatible transport database. If
|
||||
% transport properties are not needed, the transport database can
|
||||
% be omitted, and if all species thermo data are in the mechanism
|
||||
% file, the thermo database can also be omitted.
|
||||
% If for some reason Cantera has difficulty finding where these files
|
||||
% are on your system, set environment variable CANTERA_DATA to the
|
||||
% directory where they are located. Alternatively, you can call function
|
||||
% addDirectory to add a directory to the Cantera search path:
|
||||
addDirectory('/usr/local/cantera/my_data_files');
|
||||
|
||||
% How does Cantera find .cti input files? Cantera always looks in the
|
||||
% local directory first. If it is not there, Cantera looks for it on
|
||||
% its search path. It looks for it in the data directory specified
|
||||
% when Cantera was built (by default this is /usr/local/cantera/data
|
||||
% on unix systems). If you define environment variable
|
||||
% CANTERA_DATA_DIR, it will also look there, or else you can call
|
||||
% function addDirectory to add a directory to the search path.
|
||||
% Cantera input files are plain text files, and can be created with
|
||||
% any text editor. See the document 'Defining Phases and Interfaces'
|
||||
% for more information.
|
||||
|
||||
% Warning: when Cantera reads a .cti input file, wherever it is
|
||||
|
||||
% Importing multiple phases or interfaces
|
||||
% ---------------------------------------
|
||||
|
||||
% A Cantera input file may contain more than one phase specification,
|
||||
% or may contain specifications of interfaces (surfaces). Here we
|
||||
% import definitions of two bulk phases and the interface between them
|
||||
% from file diamond.cti:
|
||||
|
||||
gas2 = importPhase('diamond.cti', 'gas'); % a gas
|
||||
|
||||
diamond = importPhase('diamond.cti','diamond'); % bulk diamond
|
||||
|
||||
diamonnd_surf = importInterface('diamond.cti','diamond_100',...
|
||||
gas2, diamond);
|
||||
|
||||
% Note that the bulk (i.e., 3D) phases that participate in the surface
|
||||
% reactions must also be passed as arguments to importInterface.
|
||||
|
||||
|
||||
% CTML files
|
||||
% ----------
|
||||
|
||||
% Note that when Cantera reads a .cti input file, wherever it is
|
||||
% located, it always writes a file of the same name but with extension
|
||||
% .xml *in the local directory*. If you happen to have some other file
|
||||
% by that name, it will be overwritten. Once the XML file is created,
|
||||
% you can use it instead of the .cti file, which will result in
|
||||
% somewhat faster startup.
|
||||
|
||||
gas4 = importPhase('gri30.xml','gri30');
|
||||
|
||||
% Interfaces can be imported from XML files too.
|
||||
diamonnd_surf2 = importInterface('diamond.xml','diamond_100',...
|
||||
gas2, diamond);
|
||||
|
||||
|
||||
|
||||
%----------------------------------------------------------------
|
||||
% [1] R. J. Kee, F. M. Rupley, and J. A. Miller, Sandia National
|
||||
% Laboratories Report SAND89-8009 (1989).
|
||||
% Converting CK-format files
|
||||
% --------------------------
|
||||
|
||||
% Many existing reaction mechanism files are in "CK format," by which
|
||||
% we mean the input file format developed for use with the Chemkin-II
|
||||
% software package. [See R. J. Kee, F. M. Rupley, and J. A. Miller,
|
||||
% Sandia National Laboratories Report SAND89-8009 (1989).]
|
||||
|
||||
% Cantera comes with a converter utility program 'ck2cti' (or
|
||||
% 'ck2cti.exe') that converts CK format into Cantera format. This
|
||||
% program should be run from the command line first to convert any CK
|
||||
% files you plan to use into Cantera format. This utility program can
|
||||
% also be downloaded from the Cantera User's Group web site.
|
||||
%
|
||||
% Here's an example of how to use it:
|
||||
%
|
||||
% ck2cti -i mech.inp -t therm.dat -tr tran.dat -id mymech > mech.cti
|
||||
%
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% end of tutorial 2
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
clear all
|
||||
cleanup
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Tutorial 3: Getting Help
|
||||
%
|
||||
% Tutorial 3: Getting Help
|
||||
%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
help tut3
|
||||
|
||||
% Suppose you have created a Cantera object and want to know what
|
||||
% methods are available for it, and get help on using the methods.
|
||||
|
|
@ -48,7 +46,8 @@ help Solution
|
|||
% few more useful things to know, which are described in the next
|
||||
% few tutorials.
|
||||
|
||||
|
||||
clear all
|
||||
cleanup
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% end of tutorial 3
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Tutorial 4: Chemical Equilibrium
|
||||
%
|
||||
% Tutorial 4: Chemical Equilibrium
|
||||
% Topics:
|
||||
% - the equilibrate method
|
||||
% - specifying fixed TP, HP, UV, SV, or SP
|
||||
% - checking reaction rates of progress
|
||||
%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
help tut4
|
||||
|
||||
% To set a gas mixture to a state of chemical equilibrium, use the
|
||||
% 'equilibrate' method.
|
||||
|
|
@ -70,7 +73,8 @@ end
|
|||
% Cantera C++ class 'ChemEquil' at http://www.cantera.org.
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
clear all
|
||||
cleanup
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% end of tutorial 4
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
|
@ -1,8 +1,14 @@
|
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Tutorial 5: Reaction information and rates
|
||||
%
|
||||
% Tutorial 5: Reaction information and rates
|
||||
% Topics:
|
||||
% - stoichiometric coefficients
|
||||
% - reaction rates of progress
|
||||
% - species production rates
|
||||
% - reaction equations
|
||||
% - equilibrium constants
|
||||
% - rate multipliers
|
||||
%
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
help tut5
|
||||
|
||||
g = GRI30;
|
||||
set(g,'T',1500,'P',oneatm,'X',ones(nSpecies(g),1));
|
||||
|
|
@ -101,5 +107,6 @@ for i = 1:nReactions(g)
|
|||
m = multiplier(g, i);
|
||||
end
|
||||
|
||||
|
||||
clear all
|
||||
cleanup
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
|
|
|||
|
|
@ -1,7 +1,15 @@
|
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Tutorial 6: Transport properties
|
||||
%
|
||||
% Tutorial 5: Transport properties
|
||||
% Topics:
|
||||
% - mixture-averaged and multicomponent models
|
||||
% - viscosity
|
||||
% - thermal conductivity
|
||||
% - binary diffusion coefficients
|
||||
% - mixture-averaged diffusion coefficients
|
||||
% - multicomponent diffusion coefficients
|
||||
% - thermal diffusion coefficients
|
||||
%
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
% Methods are provided to compute transport properties. By
|
||||
|
|
@ -37,9 +45,11 @@ lambda = [thermalConductivity(g1), thermalConductivity(g2)]
|
|||
bdiff1 = binDiffCoeffs(g1)
|
||||
bdiff2 = binDiffCoeffs(g2)
|
||||
|
||||
% Mixture-averaged diffusion coefficients. These are only
|
||||
% implemented if the mixture-averaged model is used.
|
||||
dmix = mixDiffCoeffs(g2)
|
||||
% Mixture-averaged diffusion coefficients. For convenience, the
|
||||
% multicomponent model implements mixture-averaged diffusion
|
||||
% coefficients too.
|
||||
dmix2 = mixDiffCoeffs(g1)
|
||||
dmix1 = mixDiffCoeffs(g2)
|
||||
|
||||
% Multicomponent diffusion coefficients. These are only implemented
|
||||
% if the multicomponent model is used.
|
||||
|
|
@ -59,4 +69,5 @@ dt = thermalDiffCoeffs(g1)
|
|||
% fractions for the purpose of computing transport properties.
|
||||
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
clear all
|
||||
cleanup
|
||||
|
|
|
|||
|
|
@ -37,3 +37,5 @@ gmass = gibbs_mass(gas)
|
|||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
|
||||
clear all
|
||||
cleanup
|
||||
|
|
@ -280,11 +280,11 @@ gas1.set(Enthalpy = 2*gas1.enthalpy_mass(), Pressure = 2*OneAtm)
|
|||
# fractions to the same value, do this:
|
||||
|
||||
x = ones(53,'d'); # NumPy array of 53 ones
|
||||
set(gas1, X = x)
|
||||
gas1.set(X = x)
|
||||
print gas1
|
||||
|
||||
# To set the mass fractions to equal values:
|
||||
set(gas1, Y = x)
|
||||
gas1.set(Y = x)
|
||||
print gas1
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,127 +7,116 @@ print """
|
|||
####################################################################
|
||||
from Cantera import *
|
||||
from time import clock
|
||||
t0 = clock()
|
||||
|
||||
# In the last tutorial, we used function GRI30 to create an object
|
||||
# that models an ideal gas mixture with the species and reactions of
|
||||
# GRI-Mech 3.0. Another way to do this is shown here:
|
||||
# GRI-Mech 3.0. Another way to do this is shown here, with statements
|
||||
# added to measure how long this takes:
|
||||
|
||||
gas = importPhase('gri30.cti', 'gri30')
|
||||
gas1 = importPhase('gri30.cti', 'gri30')
|
||||
print 'time to create gas1 = ',clock() - t0
|
||||
|
||||
# Function 'importPhase' constructs an object representing a phase of
|
||||
# matter by reading in attributes of the phase from a file, which in
|
||||
# this case is 'gri30.cti'. This file contains a complete
|
||||
# specification of the GRI-Mech 3.0 reaction mechanism, including
|
||||
# element data (name, atomic weight), species data (name, elemental
|
||||
# composition, coefficients to compute thermodynamic and transport
|
||||
# properties), and reaction data (stoichiometry, rate coefficient
|
||||
# parameters). The file is written in a format understood by Cantera,
|
||||
# which is described in the document "Defining Phases and Interfaces."
|
||||
# this case is 'gri30.cti'. This file contains several phase
|
||||
# spcifications; the one we want here is 'gri30', which is specified
|
||||
# by the second argument. This file contains a complete specification
|
||||
# of the GRI-Mech 3.0 reaction mechanism, including element data
|
||||
# (name, atomic weight), species data (name, elemental composition,
|
||||
# coefficients to compute thermodynamic and transport properties), and
|
||||
# reaction data (stoichiometry, rate coefficient parameters). The file
|
||||
# is written in a format understood by Cantera, which is described in
|
||||
# the document "Defining Phases and Interfaces."
|
||||
|
||||
# On some systems, processing long CTI files like gri30.cti can be a
|
||||
# little slow. For example, using a typical laptop computer running
|
||||
# Windows 2000, the statement above takes more than 4 s, while on a
|
||||
# Mac Powerbook G4 of similar CPU speed it takes only 0.3 s. In any
|
||||
# case, running it again takes much less time, because Cantera
|
||||
# 'remembers' files it has already processed and doesn't need to read
|
||||
# them in again:
|
||||
|
||||
t0 = clock()
|
||||
gas1b = importPhase('gri30.cti', 'gri30')
|
||||
print 'time to create gas1 again = ',clock() - t0
|
||||
|
||||
|
||||
# CTI files distributed with Cantera
|
||||
#---------------------------------
|
||||
#-----------------------------------
|
||||
|
||||
# Several reaction mechanism files in this format are included in the
|
||||
# Cantera distribution, including ones that model high-temperature
|
||||
# air, a hydrogen/oxygen reaction mechanism, and a few surface
|
||||
# reaction mechanisms. Under Windows, the installation program puts
|
||||
# these files in 'C:\Program File\Common Files\Cantera.' On a
|
||||
# unix/linux/Mac OSX machine, they are usually kept in the 'data'
|
||||
# subdirectory within the Cantera installation directory.
|
||||
# reaction mechanisms. Under Windows, these files may be located in
|
||||
# 'C:\Program Files\Common Files\Cantera', or in 'C:\cantera\data',
|
||||
# depending on how you installed Cantera and the options you
|
||||
# specified. On a unix/linux/Mac OSX machine, they are usually kept
|
||||
# in the 'data' subdirectory within the Cantera installation
|
||||
# directory.
|
||||
|
||||
# If for some reason Cantera has difficulty finding where these files
|
||||
# are on your system, set environment variable CANTERA_DATA to the
|
||||
# directory where they are located. Alternatively, you can call function
|
||||
# addDirectory to add a directory to the Cantera search path:
|
||||
addDirectory('/usr/local/data')
|
||||
ggg = importPhase('dummy.cti')
|
||||
addDirectory('/usr/local/cantera/my_data_files')
|
||||
|
||||
# Cantera input files are plain text files, and can be created with
|
||||
# any text editor. See the document 'Defining Phases and Interfaces'
|
||||
# for more information.
|
||||
|
||||
from Cantera import *
|
||||
t0 = clock()
|
||||
gas1 = importPhase('gri30.cti')
|
||||
print 'time to create gas1 = ',clock() - t0
|
||||
# A Cantera input file may contain more than one phase specification,
|
||||
# or may contain specifications of interfaces (surfaces). Here we
|
||||
# import definitions of two bulk phases and the interface between them
|
||||
# from file diamond.cti:
|
||||
|
||||
# This statement creates a mixture that implements GRI-Mech 3.0, much
|
||||
# like function GRI30 does. File 'gri30.cti' is in the 'data'
|
||||
# directory. Under Windows, this directory is in C:\Program
|
||||
# Files\Common Files\Cantera and/or C:\CANTERA\DATA. On most other
|
||||
# platforms, it is usually in /usr/local/cantera/data.
|
||||
|
||||
|
||||
# A Cantera input file may contain more than one phase specification, or may
|
||||
# contain specifications of interfaces (surfaces).
|
||||
|
||||
# Use importPhase to import a phase:
|
||||
t0 = clock()
|
||||
gas2 = importPhase('diamond.cti', 'gas') # a gas
|
||||
print 'time to create gas2 = ',clock() - t0
|
||||
|
||||
t0 = clock()
|
||||
diamond = importPhase('diamond.cti','diamond') # bulk diamond
|
||||
print 'time to create diamond = ',clock() - t0
|
||||
|
||||
# Use importInterface to import a surface:
|
||||
t0 = clock()
|
||||
diamonnd_surf = importInterface('diamond.cti','diamond_100',
|
||||
phases = [gas2, diamond])
|
||||
print 'time to create diamond_surf = ',clock() - t0
|
||||
|
||||
# Note that the bulk (i.e., 3D) phases that participate in the surface
|
||||
# reactions must also be passed as arguments to importInterface.
|
||||
|
||||
# Multiple phases defined in the same input file can be imported with
|
||||
# one statement:
|
||||
t0 = clock()
|
||||
[gas3, diamond2] = importPhases('diamond.cti', ['gas','diamond'])
|
||||
print 'time to create both gas3 and diamond2 = ',clock() - t0
|
||||
|
||||
# Note that importing from a file is much faster the second time. This
|
||||
# is because the file is only read and converted to XML once. The XML
|
||||
# tree is kept in memory once it is read in case it is needed later.
|
||||
|
||||
# How does Cantera find input files like diamond.cti? Cantera always
|
||||
# looks in the local directory first. If it is not there, Cantera
|
||||
# looks for it on its search path. It looks for it in the data
|
||||
# directory specified when Cantera was built (by default this is
|
||||
# /usr/local/cantera/data on unix systems). If you define environment
|
||||
# variable CANTERA_DATA, it will also look there, or else you can
|
||||
# call function addDirectory to add a directory to the search path.
|
||||
|
||||
# Warning: when Cantera reads a .cti input file, wherever it is
|
||||
# Note that when Cantera reads a .cti input file, wherever it is
|
||||
# located, it always writes a file of the same name but with extension
|
||||
# .xml *in the local directory*. If you happen to have some other file
|
||||
# by that name, it will be overwritten. Once the XML file is created,
|
||||
# you can use it instead of the .cti file, which will result in
|
||||
# somewhat faster startup.
|
||||
|
||||
gas4 = IdealGasMix('gri30.xml')
|
||||
# Note that the function 'IdealGasMix' simply calls 'importPhase', and
|
||||
# checks that the phase represents an ideal gas mixture
|
||||
gas4 = importPhase('gri30.xml','gri30')
|
||||
|
||||
# Interfaces can be imported from XML files too.
|
||||
diamonnd_surf2 = importInterface('diamond.xml','diamond_100',
|
||||
phases = [gas2, diamond])
|
||||
|
||||
|
||||
|
||||
# Converting CK-format files
|
||||
# --------------------------
|
||||
|
||||
# Many existing reaction mechanism files are in "CK format," by
|
||||
# which we mean the input file format developed for use with the
|
||||
# Chemkin-II software package. [See R. J. Kee, F. M. Rupley, and
|
||||
# J. A. Miller, Sandia National Laboratories Report SAND89-8009
|
||||
# (1989).]
|
||||
# Many existing reaction mechanism files are in "CK format," by which
|
||||
# we mean the input file format developed for use with the Chemkin-II
|
||||
# software package. [See R. J. Kee, F. M. Rupley, and J. A. Miller,
|
||||
# Sandia National Laboratories Report SAND89-8009 (1989).]
|
||||
|
||||
# Cantera comes with a converter utility program 'ck2cti' (or
|
||||
# 'ck2cti.exe') that converts CK format into Cantera format. This
|
||||
# program should be run from the command line first to convert any CK
|
||||
# files you plan to use into Cantera format. This utility program can
|
||||
# also be downloaded from the Cantera User's Group web site.
|
||||
#
|
||||
# Here's an example of how to use it:
|
||||
#
|
||||
# ck2cti -i mech.inp -t therm.dat -tr tran.dat -id mymech > mech.cti
|
||||
#
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue