cantera/interfaces/matlab/toolbox/@Mixture/Mixture.m
Ray Speth 2528df0f75 Reorganized source tree structure
These changes make it unnecessary to copy header files around during
the build process, which tends to confuse IDEs and debuggers. The
headers which comprise Cantera's external C++ interface are now in
the 'include' directory.

All of the samples and demos are now in the 'samples' subdirectory.
2012-02-12 02:27:14 +00:00

61 lines
1.8 KiB
Matlab

function m = Mixture(phases)
%
% MIXTURE - Multiphase mixtures.
%
% Class Mixture represents
% mixtures of one or more phases of matter. To construct a mixture,
% supply a cell array of phases and mole numbers:
%
% >> gas = importPhase('gas.cti');
% >> graphite = importPhase('graphite.cti');
% >> mix = Mixture({gas, 1.0; graphite, 0.1});
%
% Phases may also be added later using the addPhase method:
%
% >> water = importPhase('water.cti');
% >> addPhase(mix, water, 3.0);
%
% Note that the objects representing each phase compute only the
% intensive state of the phase -- they do not store any information
% on the amount of this phase. Mixture objects, on the other hand,
% represent the full extensive state.
%
% Mixture objects are 'lightweight' in the sense that they do not
% store parameters needed to compute thermodynamic or kinetic
% properties of the phases. These are contained in the
% ('heavyweight') phase objects. Multiple mixture objects may be
% constructed using the same set of phase objects. Each one stores
% its own state information locally, and synchronizes the phase
% objects whenever it requires phase properties.
%
if nargin > 1
error('Mixture: wrong number of arguments');
end
% create an empty mixture
m.mixindex = mixturemethods(0, 0, 0);
m.phases = phases;
m = class(m,'Mixture');
% if phases are supplied, add them
if nargin == 1
if ~isa(phases,'cell')
error('enter phases as a cell array');
end
% first column contains the phase objects, and the second column
% the mole numbers of each phase
[np nc] = size(phases);
if nc ~= 2
error('wrong size for phases cell array');
end
for n = 1:np
addPhase(m, phases{n,1}, phases{n,2});
end
setTemperature(m, temperature(phases{n,1}));
setPressure(m, pressure(phases{n,1}));
end