Find answers, ask questions, and connect with our <br>community around the world.

Home Forums CFD foundation course: Forum Any Course About FVM with Matlab

• # Any Course About FVM with Matlab

Posted by on July 10, 2023 at 11:43 am

Hi

I Try do learn CFD with matlab.

Do you have any resource for that and Could you share any matlab code for 1D , SS, heat transfer for any input( change n, iteration, funcktion)

Thanks

2 Members · 4 Replies
• 4 Replies
• ### Sandeep

July 10, 2023 at 12:52 pm

Hi,

Please enroll in the CFD Foundation course on the platform. You have all details with FVM and Matlab there.

Regards

• ### secxdxeren

Member
July 11, 2023 at 4:47 pm

Thanks for answer Sir Sandeep Mouvanal

I finished that course and I’m trying to re-solve the assigned assignments.

Any chance to help with this question?
I create matlab code that

clc
clear
T=zeros(1,5);
ae=zeros(5,1);
aw=zeros(5,1);
Sp=zeros(5,1);
Su=zeros(5,1);
ap=zeros(5,1);
TA=100;
TB=500;
k=1000;
A=0.01;
dx=0.5/5;
resultTable = table();

for i=1:5
if (i==1)
aw=0;
ae(i)=k*A/dx;
Sp(i)=-2*k*A/dx;
Su(i)=TA*2*k*A/dx;
ap(i)=aw(i)+ae(i)-Sp(i);
else if (i==5)
aw(i)=k*A/dx;
ae(i)=0;
Sp(i)=-2*k*A/dx;
Su(i)=TB*2*k*A/dx;
ap(i)=aw(i)+ae(i)-Sp(i);
else
aw(i)=k*A/dx;
ae(i)=k*A/dx;
ap(i)=aw(i)+ae(i);
end
end
resultTable = [resultTable; table(aw(i), ae(i), Sp(i), Su(i), ap(i))];

end
resultTable.Properties.VariableNames = {‘aw’, ‘ae’, ‘Sp’, ‘Su’, ‘ap’};
disp(resultTable);

% when calculate T value, it dont calculate it depend on variable (T2 T3 T4)

for i=1:5
if (i==1)
T(i)=(T(i+1)*ae(i)+Su(i))/ap(i);
else if (i==5)
T(i)=(T(i-1)*ae(i)+Su(i))/ap(i);
else
T(i)=(aw(i)*T(i-1)+ae(i)+T(i+1))/ap(i);
end
end
end

When code calculate T values for example T(1)= Su(i))/ap(i) and code Take T2 zero, therefore I take error (every coefficients are true), could u have any code to disegn it. For example I want to find T1=T2+T3 ,T2=T3+T4 …… then solve with solve commend. Morever if you have any code to solve with gause etc can u add to redisgn it.

Thanks

• ### secxdxeren

Member
July 11, 2023 at 4:56 pm
``````clc
clear
T=zeros(1,5);
ae=zeros(5,1);
aw=zeros(5,1);
Sp=zeros(5,1);
Su=zeros(5,1);
ap=zeros(5,1);
TA=100;
TB=500;
k=1000;
A=0.01;
dx=0.5/5;
resultTable = table();

for i=1:5
if (i==1)
aw=0;
ae(i)=k*A/dx;
Sp(i)=-2*k*A/dx;
Su(i)=TA*2*k*A/dx;
ap(i)=aw(i)+ae(i)-Sp(i);
else if (i==5)
aw(i)=k*A/dx;
ae(i)=0;
Sp(i)=-2*k*A/dx;
Su(i)=TB*2*k*A/dx;
ap(i)=aw(i)+ae(i)-Sp(i);
else
aw(i)=k*A/dx;
ae(i)=k*A/dx;
ap(i)=aw(i)+ae(i);
end
end
resultTable = [resultTable; table(aw(i), ae(i), Sp(i), Su(i), ap(i))];

end
resultTable.Properties.VariableNames = {'aw', 'ae', 'Sp', 'Su', 'ap'};
disp(resultTable);

for i=1:5
if (i==1)
T(i)=(T(i+1)*ae(i)+Su(i))/ap(i);
else if (i==5)
T(i)=(T(i-1)*ae(i)+Su(i))/ap(i);
else
T(i)=(aw(i)*T(i-1)+ae(i)+T(i+1))/ap(i);
end
end
end

``````
• ### secxdxeren

Member
July 12, 2023 at 9:09 am

i got it done, i don’t need it anymore thanks