320 likes | 451 Vues
This analysis investigates the salt concentration in five interconnected tanks over specified time intervals of 5, 10, 15, 20, and 30 minutes. Utilizing a mathematical approach, we determine the salt amount in each tank using given flow rates and initial conditions. We apply QR decomposition techniques and iterative methods to resolve the systems of equations generated by the mixing problem. Our results include the salt content functions plotted at each time step, providing insights into the dynamics of fluid mixing in these tanks.
E N D
Contents - Problem - Codes / Results - Conclusion - Further
Problem Find the amount of salt in each tank at time t = 5, 10, 15, 20, 30(min), and plot the salt content function at each time step t. r (gal/min) tank 1 tank 2 tank 3 tank 4 tank 5 r r r r r V1 (gal) V2 (gal) V3 (gal) V4 (gal) V5 (gal) With V1 = 20, V2 = 25, V3 = 30, V4 = 35, V5 = 40, r = 10(gal/min), and x1(0) = 10, x2(0) = x3(0) = x4(0) = x5(0) = 0
Problem where
QR - Code A=[-1/2,0,0,0,0;1/2,-2/5,0,0,0;0,2/5,-1/3,0,0; 0,0,1/3,-2/7,0;0,0,0,2/7,-1/4]; [Q,R]=qr(A); A(:,6:10)=R*Q; k=2; pause while norm(diag(A(:,5*k-4:5*k))-diag(A(:,5*k-9:5*k-5))) /norm(diag(A(:,5*k-4:5*k)))>0.0001 [Q,R]=qr(A(:,5*k-4:5*k)); A(:,5*k+1:5*k+5)=R*Q; k=k+1; end
QR - Result tol
QR - Result tol
QR - Result tol
QR - Result tol
QR - Result tol
Power - Code A=[-1/2,0,0,0,0;1/2,-2/5,0,0,0;0,2/5,-1/3,0,0; 0,0,1/3,-2/7,0;0,0,0,2/7,-1/4]; q=[1,1,1,1,1]'; eg=q'*A*q; z=A*q; q(:,2)=z/norm(z); eg(2)=q(:,2)'*A*q(:,2); E1=norm(q(:,2)-q(:,1))/norm(q(:,2)); E2=(eg(2)-eg(1))/eg(2); k=2; t=0
Power - Code whilet==0 z=A*q(:,k); q(:,k+1)=z/norm(z); eg(k+1)=q(:,k+1)'*A*q(:,k+1); k=k+1; if norm(q(:,k)-q(:,k-1))/norm(q(:,k))<0.0001 break elseif norm(q(:,k)+q(:,k-1))/norm(q(:,k))<0.0001 break end end end
Power - Result tol Conv. rate
Inverse - Code A=[-1/2,0,0,0,0;1/2,-2/5,0,0,0;0,2/5,-1/3,0,0; 0,0,1/3,-2/7,0;0,0,0,2/7,-1/4]; q=[1,1,1,1,1]'; eg=q'*A*q; z=A\q; q(:,2)=z/norm(z); eg(2)=q(:,2)'*A*q(:,2); k=2; t=0
Inverse - Code whilet==0 z=A\q(:,k); q(:,k+1)=z/norm(z); eg(k+1)=q(:,k+1)'*A*q(:,k+1); k=k+1; if norm(q(:,k)-q(:,k-1))/norm(q(:,k))<0.0001 break elseif norm(q(:,k)+q(:,k-1))/norm(q(:,k))<0.0001 break end end end
Inverse - Result tol Conv. rate
Shifted Inverse - Code A=[-1/2,0,0,0,0;1/2,-2/5,0,0,0;0,2/5,-1/3,0,0; 0,0,1/3,-2/7,0;0,0,0,2/7,-1/4]; q=[1,1,1,1,1]'; B=A+0.375*eye(5); eg=q'*A*q; z=B\q; q(:,2)=z/norm(z); eg(2)=q(:,2)'*A*q(:,2); k=2; t=0
Shifted Inverse - Code whilet==0 z=B\q(:,k); q(:,k+1)=z/norm(z); eg(k+1)=q(:,k+1)'*A*q(:,k+1); k=k+1; if norm(q(:,k)-q(:,k-1))/norm(q(:,k))<0.0001 break elseif norm(q(:,k)+q(:,k-1))/norm(q(:,k))<0.0001 break end end end
Shifted Inverse – Result1 sigma=-0.375 tol Conv. rate
Shifted Inverse – Result2 sigma=-0.325 tol Conv. rate
Shifted Inverse – Result3 sigma=-0.2915 tol Conv. rate
Conclusion Tank1
Conclusion Tank2
Conclusion Tank3
Conclusion Tank4
Conclusion Tank5
Further whilet==0 z=B\q(:,k); q(:,k+1)=z/norm(z); eg(k+1)=q(:,k+1)'*A*q(:,k+1); k=k+1; if norm(q(:,k)-q(:,k-1))/norm(q(:,k))<0.0001 break elseif norm(q(:,k)+q(:,k-1))/norm(q(:,k))<0.0001 break end end end
Further whilet==0 z=B\q(:,k); q(:,k+1)=z/norm(z); eg(k+1)=q(:,k+1)'*A*q(:,k+1); B=A-eg(k+1)*eye(5); k=k+1; if norm(q(:,k)-q(:,k-1))/norm(q(:,k))<0.0001 break elseif norm(q(:,k)+q(:,k-1))/norm(q(:,k))<0.0001 break end end end
Further tol = - Shifted Inverse with fixed sigma # of iterations = 21 - Shifted Inverse with updated sigma # of iterations = 9