cantera/interfaces/matlab/toolbox/conuv.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

27 lines
804 B
Matlab
Executable file

function dydt = conuv(t,y,gas,mw)
% CONUV ODE system for a constant-volume, adiabatic reactor.
%
% Function CONUV evaluates the system of ordinary differential
% equations for an adiabatic, constant-volume,
% zero-dimensional reactor. It assumes that the 'gas' object
% represents a reacting ideal gas mixture.
% Set the state of the gas, based on the current solution vector.
set(gas, 'T', y(1), 'Rho', density(gas), 'Y', y(2:end));
nsp = nSpecies(gas);
% energy equation
wdot = netProdRates(gas);
tdot = - temperature(gas) * gasconstant * (enthalpies_RT(gas) - ones(nsp,1))' ...
* wdot / (density(gas)*cv_mass(gas));
% set up column vector for dydt
dydt = [ tdot
zeros(53,1) ];
% species equations
rrho = 1.0/density(gas);
for i = 1:nsp
dydt(i+1) = rrho*mw(i)*wdot(i);
end