Avoid divergent curves of ODE solutions

6 Ansichten (letzte 30 Tage)
EldaEbrithil
EldaEbrithil am 24 Okt. 2020
Kommentiert: Julio Sanchez am 27 Okt. 2020
Hi all
I have solved a system of differential equations in an iterative way, as you can see from the graph I have several curves each of which is associated with a different combination of the iterative parameters. Again from the graph, it can be seen that some curves at a certain abscissa diverge; this is not acceptable so I would like to remedy it. Is it possible to create a new solution vector capable of avoiding the divergence as described below ?
I would like the solution not to diverge near the various cusp points and, on the contrary, to maintain the value immediately upstream of the latter, until the end of the domain. I'll explain: suppose we have the following solution values 1000 K,1020 K,2000 K,4000 K I would like instead: 1000 K,1020 K,1020 K,1020 K
Thank you for the help
Regards
T0=293;
delta_Thot=2500;%s
%%%%%%%%%%%%%
Nc_Thot=2;
[ya,sa,lea]=size(Aexposehot);
for y=1:yV%passo,altezza tubo,Rextbobbin,lunghezza cavo
for le=1:leV%lunghezza tubo equilibrio
for sv=1:sV%spessore parete3
% for k=1:km%Mach
for rf=1:length(Pressure_percentage_hot)
Rextbobb_cellhot(y)={Rextbobbin_fluxhot(y)};
Y0hot(y,le)={[T0,m0hot(y,le)]};
Dall_Th_hot ={[0:Nc_Thot:delta_Thot]};
Lequilibrium_cellhot(le)={Lequilibriumhot(le)};
Passo_cellhot(y)={Passo_fluxhot(y)};
hrad_cellhot(y)={Hradial_fluxhot(y)};
Spessore_parete3_cellhot(sv) ={Spessore_parete3hot(sv)};
Aexpose_cellhot(y,sv,le)={Aexposehot(y,sv,le)};
Volume_cell_Aisihot(le,y,sv)={Volume_Aisihot(le,y,sv)};
Volume_cell_gashot(y,le)={Volume_gashot(y,le)};
throat_cell_hot(y)={ThrtR_fluxhot(y)};
Pressure_end_chamber_hot_cell(rf)={Pressure_end_chamber_hot(rf)};
end
end
end
end
for iDom_Th = 1:numel(Dall_Th_hot)
for leLE=1:numel(Lequilibrium_cellhot)
for yY=1:numel(hrad_cellhot)
for rF=1:numel(Pressure_end_chamber_hot_cell)
for sS=1:numel(Spessore_parete3_cellhot)
TSol_hot(iDom_Th,yY,leLE,sS,rF)={zeros(length(Dall_Th_hot{iDom_Th}),2)};
end
end
end
end
end
opt_t_hot=odeset('NormControl','Refine','Stats','MaxStep');
for iDom_Th = 1:numel(Dall_Th_hot)
tRange_hot = Dall_Th_hot{iDom_Th};
for leLE=1:numel(Lequilibrium_cellhot)
for yY=1:numel(hrad_cellhot)
for rF=1:numel(Pressure_end_chamber_hot_cell)
for sS=1:numel(Spessore_parete3_cellhot)
Ltube_hot= Lequilibrium_cellhot{leLE};%L_cellhot{yY};
Leq_hot= Lequilibrium_cellhot{leLE} ;
Vol_Aisi_hot=Volume_cell_Aisihot{leLE,yY,sS};
Aexp_hot=Aexpose_cellhot{yY,sS,leLE};
Hradial_hot=hrad_cellhot{yY};
ThroatradiuS_hot=throat_cell_hot{yY};
Pressure_hot_end_chamber=Pressure_end_chamber_hot_cell{rF};
if Vol_Aisi_hot>0&&Leq_hot>0 &&Aexp_hot>0 &&Ltube_hot>0 && ThroatradiuS_hot>0&&Pressure_hot_end_chamber>0
[tSol{iDom_Th,yY,leLE,sS,rF},TSol_hot{iDom_Th,yY,leLE,sS,rF}]=ode23t(@(t,Y) ...
temperaturaheaterclassica(t,Y,Ltube_hot,Voltage1,Vol_Aisi_hot,Aexp_hot,ThroatradiuS_hot,Pressure_hot_end_chamber),tRange_hot,Y0hot{yY,leLE},opt_t_hot);
if(any(TSol_hot{iDom_Th,yY,leLE,sS,rF}(:,1)>1600))
% disp([ ' condizione verificata'])
%disp (iDom_Th)
disp(yY)
disp(leLE)
%disp(sS)
%disp(rF)
break
end
end
end
end
end
end
end
%end
[tT,yT,leT,sT,rFT]=size(TSol_hot);
for t = 1:tT
for y=1:yT
for le=1:leT
for s=1:sT
for rf=1:rFT
if TSol_hot{t,y,le,s,rf}(end,1)>0
figure(1);set(gcf,'Visible', 'on')
plot(tSol{t,y,le,s,rf}(:,1),TSol_hot{t,y,le,s,rf}(:,1))
xlabel('time [s]')
ylabel('Teq-transition/turbulent [K]')
hold on
end
end
end
end
end
end
  2 Kommentare
EldaEbrithil
EldaEbrithil am 24 Okt. 2020
So in summary:
Is it possible to convert diverging curves to horizontal curves?
Why are these diverging curves present from a certain abscissa onwards?
EldaEbrithil
EldaEbrithil am 24 Okt. 2020
Any help?

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Julio Sanchez
Julio Sanchez am 24 Okt. 2020
The divergence of an ode system could be due to two things: on one hand the system itself is devergent, this is due to the combination of parameter you are giving to the ode. On the other hand, it could be that the integrator is not suitable or correctly configurated to solve that syste. To test this you could use different integrators as: ode45, ode23, ode113, ode15s, ode23t, ode23b or ode23tb. I suggest ode15s is very robust.
  13 Kommentare
EldaEbrithil
EldaEbrithil am 27 Okt. 2020
something like that?
storage = {};
for t = 1:tT
for y=1:yT
for le=1:leT
for s=1:sT
for rf=1:rFT
for pE=1:pET
storage{t,y,le,s,rf,pE} = TSol_hot(t,y,le,s,rf,pE);
end
end
end
end
end
end
storage2=cell2mat(storage);
however TSol_hot is constituted by 1x1 cells each one is {2251×2 double}. It gives me error on storage2
Julio Sanchez
Julio Sanchez am 27 Okt. 2020
The problem here is that you defined the sorage cell as a multidimentional space with t, y, le,rf and pE as positions inside the cell. You could just do this for your problem:
storage(i) = {[t,y,le,s,rf,pE],Tsol_hot(t,y,le,s,rf,pE)}
That way each position in the storage cell has two components: a vector of parameters and a matrix with the solution of the ode system. The counter i length must be then the sum of the lengths of tT, yT, leT, sT, rfT and peT.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Numerical Integration and Differential Equations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by