Borrar filtros
Borrar filtros

Error in ode15s

25 visualizaciones (últimos 30 días)
N G
N G el 9 de Jul. de 2024 a las 5:05
Editada: Torsten el 9 de Jul. de 2024 a las 11:37
I'm trying to run a code but its showing an error for ode15s, where am I going wrong?
kfin=0.8;
hfin=7e-4;
Rin=3;
Rout=9;
b=1;
Ta=400;
Tu=30;
T0=35;
Nr=51;
rhofin=0.8;
cpfin=0.5;
%Step and Increment
r=linspace(Rin,Rout,Nr);
dr=r(2)-r(1); %delta-R
t=linspace(0,10,100); %time till 10 sec
%simplify calc
m=rhofin*cpfin/kfin;
n=2*hfin./kfin./b;
o=2*dr*hfin./kfin;
%Initial condition
IC=T0.*ones(Nr,1);
%Solver ODE15s
[t,T]=ode15s(@f,t,IC);
Not enough input arguments.

Error in solution>f (line 36)
dTdt=zeros(Nr,1);

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);
%recalculation
T(:,1)=Ts+30.*t-6.*t.^2; %BC-1
T(:,end)=(o.*Tu+4*T(:,end-1)-T(:,end-2))./(3+o); %BC-2
imagesc(r,t,T)
colormap jet
colorbar
grid on
title('Temp Profile')
xlabel('Radius')
ylabel('Time in sec')
%function
function dTdt=f(t,T,Rin,Rout,b,Ts,Tu,T0,Nr,m,n,o,dr,r)
dTdt=zeros(Nr,1);
T(1)=Ts+30.*t-6.*t.^2; %BC-1
T(end)=(o.*Tu+4*T(end-1)-T(end-2))./(3+o); %BC-2
%Interior
for i=2:Nr-1
d2Tdr2(i)=(T(i+1)-2*T(i)+T(i-1))./dr.^2;
dTdr(i)=(T(i+1)-T(i-1))./(2.*dr);
dTdr(i)=(d2Tdr2(i)+(1./r(i)).*dTdr(i)-n.*(T(i)-Tu))./m;
end
end
  1 comentario
Torsten
Torsten el 9 de Jul. de 2024 a las 8:42
Editada: Torsten el 9 de Jul. de 2024 a las 11:37
Note that you always return dTdt = zeros(Nr,1) in your function f. Thus the solution will always remain at its initial state.
You know that you can use "pdepe" to solve this problem ?

Iniciar sesión para comentar.

Respuesta aceptada

Sam Chak
Sam Chak el 9 de Jul. de 2024 a las 6:03
I suspect there is also a typo for Ta because the 'a' key is next to the 's' key.
If you follow the advice in Walter's Answer, you should get this figure.
Ts = 400; % originally Ta
[t, T] = ode15s(@(t, T) f(t, T, Rin, Rout, b, Ts, Tu, T0, Nr, m, n, o, dr, r), t, IC);
imagesc(r,t,T)

Más respuestas (1)

Walter Roberson
Walter Roberson el 9 de Jul. de 2024 a las 5:19
[t,T]=ode15s(@f,t,IC);
ode15s is to invoke function f, passing it time in the first parameter and passing initial conditions in the second parameter.
function dTdt=f(t,T,Rin,Rout,b,Ts,Tu,T0,Nr,m,n,o,dr,r)
but f needs lots of different parameters, that are not going to be provided by ode15s.
You need
[t,T]=ode15s(@(t,T)f(t,T,Rin,Rout,b,Ts,Tu,T0,Nr,m,n,o,dr,r), t, IC);

Etiquetas

Productos


Versión

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by