Untitled
unknown
plain_text
a month ago
1.1 kB
1
Indexable
% Tank parameters A1 = 30; % First tank cross-sectional area [m²] r1 = 1.2; % First tank time constant [s/m²] A2 = 50; % Second tank cross-sectional area [m²] r2 = 0.7; % Second tank time constant [s/m²] Fin0 = 9.4; % Initial inlet flow rate [m³/s] h1_0=11.28; h2_0=6.58; opts = odeset('RelTol',1e-9,'AbsTol',1e-12); function df = noninteractingtanks(t, y) A1 = 30; % First tank cross-sectional area [m²] r1 = 1.2; % First tank time constant [s/m²] A2 = 50; % Second tank cross-sectional area [m²] r2 = 0.7; % Second tank time constant [s/m²] Fin0 = 9.4; % Initial inlet flow rate [m³/s] h1_0=11.28; h2_0=6.58; h1=y(1); h2=y(2); dh1dt=(Fin0-h1/r1)/A1; dh2dt=(h1/r1-h2/r2)/A2; df=[dh1dt; dh2dt]; end y0=[h1_0; h2_0]; tspan=[0 3600]; [t,y]=ode45(@noninteractingtanks, tspan, y0, opts); sol_nonint=[y(end,1); y(end,2)]; figure(1); plot(t,y(:,1), 'b-', 'LineWidth', 1.5); grid on; xlabel('Tempo(s)'); ylabel('h1(t)'); title('noninteractingtanks_1') figure(2); plot(t,y(:,2), 'r-', 'LineWidth', 1.5); grid on; xlabel('Tempo(s)'); ylabel('h2(t)'); title('noninteractingtanks_2');
Editor is loading...
Leave a Comment