필터 지우기
필터 지우기

Solving ODE using discretization and Euler's method

조회 수: 9 (최근 30일)
Abdulrahman Odhah
Abdulrahman Odhah 2021년 1월 15일
편집: Abdulrahman Odhah 2021년 1월 15일
Hello there,
I have solved a PDE for a tank with heater using Euler's method as per the code below, I believe it is true and I got the expected results.
% mm model for the tank with heater
% Given
v_tank=2;%1 L
%v_in=1;v_out=1; 1liter / minute
v_in=0.0166667;v_out=1; %1liter / sec
p=1000;%1 watt @Steady State
T1in0=15;% 15 c degrees at t =0
%rho=1000; density kg/m^3
rho=1;%density kg/L
CS=4200;%J/kg*c
%assumption of integration step h=0.1
h=0.1;
%Steady state equation
T10=(T1in0+(p/(v_in*rho*CS))); %f(x,y) function, where dy/dx=f(x,y), x(x0)=y0.
n=1500;
T1in=T1in0;
Tvect=ones(n/h);
i=1;
for t=0:h:n
if t>=300
T1in=20;% 20 c degrees at t=5
end
if t>=900
p=1500;% 1500 watt at t=15
end
%Eurl's integral equation
T=T10+h*((v_in/v_tank)*(T1in-T10)+(p/(v_tank*rho*CS)));
T10=T;
Tvect(i)=T10;
i=i+1;
end
hold on;
t=(0.1:0.1:n);
plot(t,Tvect)
%axis([0,25,0,25])
grid on;
title('Tank with heater'); xlabel('Time [sec]'); ylabel('Temp ℃ ');
But now the second step is to solve PDE using the discretization and then Euler's method, the concept is quit clear, which is having two loops one for space discretization and the other for time (Euler's method) but I am stuck at this point. It should be two for loops (discretization loops) inside one loop (time loop). I am confused to how set the equations up inside the loops. The set of equations are attached and this is my try, it should look something like this
%time loop
for
%space loop to find ds value
for
end
%space loop to find the S value
for
end
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 Eigenvalue Problems에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by