dbirch997 / cantera

Automatically exported from code.google.com/p/cantera
1 stars 0 forks source link

Mixing two gasses at different temperatures for equilbrum #58

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am new to cantera.  I am using windows 7 Cantera 1.8 python 2.6.6  matlab.  I 
am trying to do to eqilibrum calculation steam reforming for my research. I 
trying to mix two gas but they are each at different temperatures. To load 
files i only know input phase.   Is there another command that will let me put 
two objects at two different temperatures but share a common phase?  I saw some 
of the previous example but they have all the gasses at one temperature.   

I found this one code by Rodolfo Rodrigues.  It looked like it could work but i 
was unable to run it.    

Every time i try running the code from Rodolfo Rodrigues i get the following 
error. I tried a few other reactor codes and i cant find why they dont work?   

??? Cell contents reference from a non-cell array object.

Error in ==> ReactorNet.ReactorNet at 21
  addReactor(x,reactors{i});

Error in ==> example at 101
 process = ReactorNet(gasifier);

Is there an easier way to make a mixture with two gasses at different 
temperatures and get the new mixture temperature without going into different 
phases? 

% > > > % rgasifier.m 
% > > > % 
% > > > % Rodolfo Rodrigues - LPR/UFRGS 
% > > > % rodo...@enq.ufrgs.br 
% > > > % 
% > > > % 2009/11/26 
% 
% 
% > > > %% initial data 
% > > > % biomass (fuel) 
% > > > % ultimate analysis (%wt) 
 massfrac = [0.452 0.054 0.39 0.001 0]; % C H O N S 
 moisture = 0.094; % H2O 
 ash = 0.009*[0.5 0.5]; % CaO SiO2 
 LHV = 16.4e6; % J/kg 
   % massfrac + moisture + ash = 1 
     xmass = [massfrac moisture ash]./sum([massfrac moisture ash]); 
     Mw=[12.011 1.00794 15.9994 14.00674 32.066 2*1.00794+15.9994 40.078+15.999456 28.0855+2*15.9994]; % kg/kmol 
    xmol = xmass./Mw/sum(xmass./Mw); 

     % standard enthalpy of formation 
 HfCO2 = -393.777/44; % J/kmol/(kg/kmol) = J/kg 
     HfH2O = -241.988/18; % J/kmol/(kg/kmol) = J/kg 
     HfN2 = 0; HfO2 = 0; 
     HfSO2 = -297.012/64; % J/kmol/(kg/kmol) = J/kg 

 F_f = 100; % kg/h 
 T_f = 300.0; % temperature (K) 
 P_f = OneAtm; % pressure (Pa) % enthalpy (J/kg) 
 H_f = xmass(1)*HfCO2 + (0.5*xmass(2) + xmass(6))*HfH2O + 0.5*xmass(4)*HfN2 + xmass(5)*HfSO2 + LHV - (xmass(1) + 0.25*xmass(2)- 0.5*xmass(3)+ xmass(5))*HfO2; 

 % air (oxidant) 
 phi = 0.4; % equivalent ratio 

%% load components (Baratieri et al, 2008) 
 gas = IdealGasMix('baratieri2008.cti'); 
 nsp = nSpecies(gas); 

 % find component indices 
 iC = speciesIndex(gas,'C'); 
 iH = speciesIndex(gas,'H'); 
iO = speciesIndex(gas,'O'); 
 iN = speciesIndex(gas,'N'); 
 iS = speciesIndex(gas,'S'); 
 iH2O = speciesIndex(gas,'H2O'); 
 iCaO = speciesIndex(gas,'CaO'); 
 iSiO2 = speciesIndex(gas,'SiO2'); 
 iO2 = speciesIndex(gas,'O2'); 
 iN2 = speciesIndex(gas,'N2'); 

 % preallocate variable 
 x = zeros(nsp,1); 
 % attribute values 
 x(iC,1) = xmol(1); 
 x(iH,1) = xmol(2); 
 x(iO,1) = xmol(3); 
 x(iN,1) = xmol(4); 
x(iS,1) = xmol(5); 
 x(iH2O,1) = xmol(6); 
 x(iCaO,1) = xmol(7); 
 x(iSiO2,1) = xmol(8); 

 %% build devices 
 % 1. fuel 
 set(gas,'T',T_f,'P',P_f,'X',x); % LHV, where? 
 fuel_in = Reservoir(gas); 
 fuel_Mw = meanMolarMass(gas); 
 fuel_Fw = F_f/3600; % kg/s 

 % 2. air 
 set(air); 
 air_in = Reservoir(air); 
 air_Mw = meanMolarMass(air); 
 air_Fw = 4.76*fuel_Fw/fuel_Mw*phi*(xmol(1) + 0.25*xmol(2) - 0.5*xmol(3) + xmol(5))/3600; % kg/s 

% 3. gasifier 
 set(gas); 
 gasifier = Reservoir(gas); 
%gasifier = Reactor(gas); 

 %% build flowsheet 
% build connectors 
fuel2gas  = MassFlowController(fuel_in,gasifier); 
    setMassFlowRate(fuel2gas, fuel_Fw); 
air2gas   = MassFlowController(air_in,gasifier); 
     setMassFlowRate(air2gas, air_Fw); 

 process = ReactorNet(gasifier); 
 equilibrate(process,'TP') 

 % END 

Original issue reported on code.google.com by RSce...@gmail.com on 7 Oct 2011 at 8:24

GoogleCodeExporter commented 9 years ago
There are a number of problems with this approach, but the issue generating the 
error is that the ReactorNet function takes a cell array, so it should be 
called as:

    ReactorNet({gasifier});

I've modified the function in r1328 to accept the simpler syntax 
ReactorNet(gasifier) for the case of a single reactor.

To resolve some of the other issues, you should look at some of the examples 
that use reactor networks, and if you're still having problems, ask for help on 
the user's group.

Original comment by yarmond on 24 Mar 2012 at 1:37