Using the nodal method in ventilation analysis

2 views (last 30 days)
I am developing a script to find the internal pressures of 3 separate zones using the exterior pressures, using the Jacobi matrix and iterations.
However, I am receiving this error message: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN , with inaccurate results for the interior pressures.
This is my code:
clear all
%External Pressures
Pe1=-600;
Pe2=70;
Pe3=58;
E=0.01; %Error margin
Ke1=1.3;
Ke2=0.61;
Ke3=1.525;
K12=2.54;
K32=1.86;
Cde1=0.65;
Cde2=0.61;
Cde3=0.61;
Cd12=0.62;
Cd32=0.62;
Ae1=2;
Ae2=1;
Ae3=2.5;
A12=4;
A32=3;
P1=200;
P2=60;
P3=80;
N=4;
P=zeros(N,N);
P(1,1)=P1;
P(1,2)=P2;
P(1,3)=P3;
fP1=-Ke1*abs(Pe1-P1^0.5)-(K12*abs(P2-P1)^0.5);
fP2=Ke2*abs(Pe2-P2)^0.5+K12*abs(P1-P2)^0.5+K32*abs(P3-P2)^0.5;
fP3=-Ke3*abs(Pe3-P3)^0.5-K32*abs(P2-P3)^0.5;
fP=[fP1,fP2,fP3];
df1p1=(-0.5*(Ke1*(abs(Pe1-P1)))^-0.5)-(0.5*(K12*(abs(P2-P1)))^-0.5);
df1p2=-(0.5*(K12*(abs(P2-P1)))^-0.5);
df1p3=(0);
df2p1=(-0.5*(K12*(abs(P1-P2)))^-0.5);
df2p2=(-0.5*(Ke2*(abs(Pe2-P2)))^-0.5)-(0.5*(K12*(abs(P1-P2)))^-0.5)-(0.5*(K32*(abs(P3-P2)))^-0.5);
df2p3=(-0.5*(K32*(abs(P3-P2)))^-0.5);
df3p1=(0);
df3p2=(-0.5*(K32*(abs(P2-P3)))^-0.5);
df3p3=(-0.5*(Ke3*(abs(Pe3-P3)))^-0.5)-(0.5*(K32*(abs(P2-P3)))^-0.5);
%Jacobian Matrix
J=[df1p1,df1p2,df1p3;df2p1,df2p2,df2p3;df3p1,df3p2,df3p3];
J_inv=inv(J);
for j=2:N-1
for i=1:N-1
if abs(P(i+1)-P(i))>E
P(i+1,j)=P(i,j)-(J_inv(i,j)*fP(i));
end
end
end
%calculating the air exchange rate
m12=Cd12*A12*sqrt(2*1.225*(abs(P2-P1)));
m32=Cd32*A32*sqrt(2*1.225*(abs(P3-P2)));
me1=Cde1*Ae1*sqrt(2*1.225*(abs(Pe1-P1)));
me2=Cde2*Ae2*sqrt(2*1.225*(abs(Pe2-P2)));
me3=Cde3*Ae3*sqrt(2*1.225*(abs(Pe3-P3)));

Accepted Answer

Alan Stevens
Alan Stevens on 31 May 2022
Try removing
J_inv=inv(J);
and replacing
(J_inv(i,j)*fP(i))
by
J(i,j)\fP(i)

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!