Azzera filtri
Azzera filtri

Results are not as expected ode15s

3 visualizzazioni (ultimi 30 giorni)
Iris
Iris il 7 Dic 2023
Commentato: Torsten il 7 Dic 2023
Hi, so i am trying to calculate x(1), x(2) and x(3) over area but my x(1) is increasing instead of decreasing.
The code is below:
s0 = 0;
sfinal = 900000000;
x0 = [0.02308, 0.97692, 3, 0];
[s, x] = ode15s(@crossflowODE, [s0, sfinal], x0);
Unrecognized function or variable 'y'.

Error in solution>crossflowODE (line 25)
-1*(((permH2O* ((ph * x(1)) - (pl * yH2O)))/ z) + ((permN2* ((ph * x(2)) - (pl * y))) / z));

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

Error in ode15s (line 148)
odearguments(odeIsFuncHandle, odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
plot(s, x)
title('Cross flow model over area')
xlabel('area')
ylabel('mole fraction')
legend('xH20', 'xN2', 'q')
And the referenced function is below:
function dxds = crossflowODE (s, x)
% CROSSFLOW cross flow model
c1=0.00000000004;
c2=0.9695;
z=0.0023876;
ph= 1;
pl= 0.001;
permN2 = 0.00000000000000104836;
permH2O = c1*(exp(c2*ph*x(1)));
jH2O = (permH2O* ((ph * x(1)) - (pl * x(1)))) / z;
jN2= (permN2* ((ph * x(2)) - (pl * x(2)))) / z;
yH2O= jH2O/(jH2O+ jN2);
yN2= jN2/(jH2O+ jN2);
dxds= [((x(1)*((permH2O/z)*(ph*x(1)-pl*yH2O)+((permN2/z)*(ph*x(2)-pl*yN2))))+((permH2O/z)*(ph*x(1)-pl*yH2O)))/x(3);
((x(2)*((permH2O/z)*(ph*x(1)-pl*yH2O)+ ((permN2/z)*(ph*x(2)-pl*yN2))))+((permN2/z)*(ph*x(2)-pl*yN2)))/x(3);
-1*(((permH2O* ((ph * x(1)) - (pl * yH2O)))/ z) + ((permN2* ((ph * x(2)) - (pl * y))) / z));
x(1) + x(2) - 1];
end
I am also getting the following errors:
Error in odearguments (line 92)
f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode15s (line 148)
odearguments(odeIsFuncHandle, odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Error in untitled2 (line 4)
[s, x] = ode15s(@crossflowODE, [s0, sfinal], x0);
Please help and thanks in advance!
  1 Commento
Torsten
Torsten il 7 Dic 2023
You don't use x(4) in your derivatives, and the 4th differential equation given as dx(4)/dt = x(1)+x(2)-1 looks strange to me.
So I suggest you include the equations you are trying to solve in a mathematical notation to chack against your implementation.

Accedi per commentare.

Risposte (1)

Walter Roberson
Walter Roberson il 7 Dic 2023
dxds= [((x(1)*((permH2O/z)*(ph*x(1)-pl*yH2O)+((permN2/z)*(ph*x(2)-pl*yN2))))+((permH2O/z)*(ph*x(1)-pl*yH2O)))/x(3);
((x(2)*((permH2O/z)*(ph*x(1)-pl*yH2O)+ ((permN2/z)*(ph*x(2)-pl*yN2))))+((permN2/z)*(ph*x(2)-pl*yN2)))/x(3);
-1*(((permH2O* ((ph * x(1)) - (pl * yH2O)))/ z) + ((permN2* ((ph * x(2)) - (pl * y))) / z));
x(1) + x(2) - 1];
You have a variable named yN2, and a variable named yH2O, but you do not have a variable named y even though you use y at the end of that third line.

Categorie

Scopri di più su Historical Contests in Help Center e File Exchange

Prodotti

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by