WICHTIG: Der Betrieb von goMatlab.de wird privat finanziert fortgesetzt. - Mehr Infos...

Mein MATLAB Forum - goMatlab.de

Mein MATLAB Forum

 
Gast > Registrieren       Autologin?   

Partner:




Forum
      Option
[Erweitert]
  • Diese Seite per Mail weiterempfehlen
     


Gehe zu:  
Neues Thema eröffnen Neue Antwort erstellen

Problem mit ode45 solver - verstehe die error nicht

 

Dennis M.

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 20.04.2015, 17:55     Titel: Problem mit ode45 solver - verstehe die error nicht
  Antworten mit Zitat      
Hallo ich arbeite an einem Uni-Project zum Reaktordesign. Ich arbeite zum ersten mal mit dem ode solver und bin auch sonst recht neu mit dem Umgang mit Matlab. Ich habe einen Hauptcode und einen Funktionscode geschrieben. Bei der Ausführung kommen folgende Fehlermeldungen, die wie ich denke mit der Art zu tun haben wie Matlab den Code verarbeitet bzw. funktionen ausführt.:

Error in pr1fct (line 4)
P_0=1;

Error using feval
Output argument "pr1fct" (and maybe others) not assigned during call to "C:\Users\Dennis\Documents\Bogazici\reactor
design\RD_Project 1\pr1fct.m>pr1fct".

Error in odearguments (line 87)
f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.

Error in ode15s (line 148)
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...

Error in Project1 (line 22)
[w,y] = ode15s(@pr1fct, [w_i w_f], [F0_CH4 F0_CO2 0 0 0 F0_N2 T_i 0]);



Und hier meine codes: (sorry für die langen codes, aber ich denke besser ausführlich als etwas wegzulassen)
Hauptcode:

Code:
%ChE 642 Catalytic Reactor Analysis and Design
%Project 1: Kinetic study of the catalytic carbon dioxide reforming of
%methane to synthesis gas over Ni-K/CeO2-Al2O3 catalyst

clc;
clear all;

%Initial temperature for the system, (K)
T_i=873;

% Catalyst weight, (kg)
w_i=0;
w_f=5E-3;
 
% Initial molar flow rates, (mol/s)
F0_CH4=(3.33E-4)/(0.0821*T_i);
F0_CO2=(3.33E-4)/(0.0821*T_i);
F0_N2=(1E-3)/(0.0821*T_i);
 
% ode45 solver (w and y represents catalyst weight and flow rates, temperature and CH4 conversion)
[w,y] = ode15s(@pr1fct, [w_i w_f], [F0_CH4 F0_CO2 0 0 0 F0_N2 T_i 0]);

% Graph of flow rates and temperature with respect to catalyst weight
plot(w,y(:,1),w,y(:,2),w,y(:,3),w,y(:,4),w,y(:,5),'linewidth',2)
legend('CH4','CO2','H2','H2O','CO')
xlabel('Catalyst Weight (Kg)')
ylabel('Flow Rate (mol/s)')
figure
plot(w,y(:,7),w,y(:,8), 'linewidth',2)
xlabel('Catalyst Weight (Kg)','FontSize',14)
ylabel(hAx(1),'Temperature (K)','FontSize',14)
ylabel(hAx(2),'CH4 Conversion (-)','FontSize',14)



Funktionscode:

function pr1fct=dy_dw(w,y)

% Initial pressure (atm)
P_0=1;
% Initial temperature for the system (K)
T_i=873;
% Total flow rate (mol/s)
FT=y(1)+y(2)+y(3)+y(4)+y(5)+y(6);

F0_CH4=y(1);

% Change in total flow rate, (atm s/mol)
FT_change=P_0/FT;
% Change in partial pressures, (atm)
P_CH4=FT_change*y(1);
P_CO2=FT_change*y(2);
P_H2=FT_change*y(3);
P_H2O=FT_change*y(4);
P_CO=FT_change*y(5);
P_N2=FT_change*y(6);

% y(1)-y(6) represents the flow rates of the species, (mol/s)
 
% Universal gas constant, (J/mol K)
R=8.3144621;

%Parameters for reaction rate
k1L=1292*exp(-12894/y(7)); % (gmol/gcat s atm)
k7L=(3.8*2.71828)-(3*exp(-220/y(7))); %(gmol/gcat s)
Ka=7.4*exp(-4145/y(7)); %(atm^-2)
Kb=2.3*2.71828*exp(-15998/y(7));%(atm^-2.5)
c=5.8*exp(8605/y(7));%(-)

%Reaction Rate CH4, (gmol/gcat s)
if P_CO2 < 0.75
    r_CH4=(k1L*P_CH4)/(((k1L*P_CH4*P_CO)/(k7L*Ka*P_CO2))+((Kb*P_CO2*P_H2^0.5)/P_CO)+((k1L*P_CH4)/k7L)+1);
else
    r_CH4=c*k1L*P_CH4;
end

%Reaction rate CO2, (gmol/gcat s)
r_CO2 = 2*r_CH4;
%Reaction rate H2, (gmol/gcat s)
r_H2 = -r_CH4;
%Reaction rate H2O, (gmol/gcat s)
r_H2O= -r_CH4;
%Reaction rate CO, (gmol/gcat s)
r_CO=-3*r_CH4;

%Conversion from calories to joule
cal_to_joule=4.184;
% Heat capacity constants, (J/gmol °C)
CH4=[3.381 18.044E3 -4.300e6]/cal_to_joule;
CO2=[6.214 10.396E3 -3.545E6]/cal_to_joule;
H2=[6.945 -0.200E3 0.481E6]/cal_to_joule;
H2O=[7.256 2.298E3 0.283E6]/cal_to_joule;
CO=[6.420 1.665E3 -0.196E6]/cal_to_joule;
N2=[6.524 1.250E3 -0.001E6]/cal_to_joule;
 
% Heat capacity constants multiplied by flow rates, (J /s °C)
delta_A=(y(1)*CH4(1))+(y(2)*CO2(1))+(y(3)*H2(1))+(y(4)*H2O(1))+(y(5)*CO(1))+(y(6)* N2(1));
delta_B=(y(1)*CH4(2))+(y(2)*CO2(2))+(y(3)*H2(2))+(y(4)*H2O(2))+(y(5)*CO(2))+(y(6)* N2(2));
delta_C=(y(1)*CH4(3))+(y(2)*CO2(3))+(y(3)*H2(3))+(y(4)*H2O(3))+(y(5)*CO(3))+(y(6)* N2(3));

Cp =R*(delta_A+delta_B*y(7)+delta_C*y(7)^2);

%Heats of formation at 298 K,(J/mol)
Hf_CH4=-74520;
Hf_CO2=-393509;
Hf_H2=0;
Hf_H2O=-241818;
Hf_CO=-110525;

% Enthalpy of reaction at 298 K, (J/mol)
delta_Hrxn=(Hf_H2+Hf_H2O+3*Hf_CO)-(Hf_CH4+2*Hf_CO2);

% Reference temperature, (K)
T0=298;
% For initial system temperature to reference temperature
Tau_i=T_i/T0;
% For temperature at some catalyst weight to reference temperature
Tau_f=y(7)/T0;
 
% Constant change for reaction
delta_constants=H2+H2O+3*CO-2*CO2-CH4;
% Initial enthalpy change from initial system temperature to reference temperature
delta_Hinitial=delta_constants(1)*T0*(Tau_i-1)+(delta_constants(2)/2)*(T0^2)*((Tau_i^2)-1)+(delta_constants(3)/3)*(T0^3)*((Tau_i^3)-1);
% Final enthalpy change from reference temperature to the temperature at some catalyst weight
delta_Hfinal=delta_constants(1)*T0*(Tau_f-1)+(delta_constants(2)/2)*(T0^2)*((Tau_f^2)-1)+(delta_constants(3)/3)*(T0^3)*((Tau_f^3)-1);
% Enthalpy change in the system for reaction
delta_H=delta_Hrxn+R*delta_Hfinal+R*delta_Hinitial;


dy_dw=zeros(8,1);
 
dy_dw(1)=r_CH4; %CH4
dy_dw(2)=r_CO2; %CO2
dy_dw(3)=r_H2; %H2
dy_dw(4)=r_H2O; %H2O
dy_dw(5)=r_CO; %CO
dy_dw(7)=((-delta_H)*r_CH4)/(Cp); %T
dy_dw(8)=(y(1)-F0_CH4)/F0_CH4; % X_CH4
end
 





Falls mir jemand bei den Fehlermeldungen weiterhelfen kann, währe ich sehr dankbar.

Dennis
edit winkow: bitte code umgebung verwenden.

pr1fct.m
 Beschreibung:
Funktionscode

Download
 Dateiname:  pr1fct.m
 Dateigröße:  3.12 KB
 Heruntergeladen:  244 mal
Project1.m
 Beschreibung:
Hauptcode

Download
 Dateiname:  Project1.m
 Dateigröße:  1.05 KB
 Heruntergeladen:  234 mal


Winkow
Moderator

Moderator



Beiträge: 3.842
Anmeldedatum: 04.11.11
Wohnort: Dresden
Version: R2014a 2015a
     Beitrag Verfasst am: 20.04.2015, 18:02     Titel:
  Antworten mit Zitat      
bitte code umgebung verwenden wenn du code postest.
habs jetzt nicht laufen lassen aber du hast funktionsnamen und ausgabevariable vertauscht. das fällt mir jedenfalls so auf die schnelle auf.
_________________

richtig Fragen
Private Nachricht senden Benutzer-Profile anzeigen
 
Dennis M.

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 20.04.2015, 18:54     Titel:
  Antworten mit Zitat      
Danke, das hat mein Problem gelöst. Manchmal sieht man den Wald vor lauter Bäumen nicht.
 
Neues Thema eröffnen Neue Antwort erstellen



Einstellungen und Berechtigungen
Beiträge der letzten Zeit anzeigen:

Du kannst Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.
Du kannst Dateien in diesem Forum posten
Du kannst Dateien in diesem Forum herunterladen
.





 Impressum  | Nutzungsbedingungen  | Datenschutz | FAQ | goMatlab RSS Button RSS

Hosted by:


Copyright © 2007 - 2025 goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks

MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.