CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Thomas algorithm - tridiagonal matrix

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 1, 2023, 19:29
Default Thomas algorithm - tridiagonal matrix
  #1
Member
 
Join Date: Aug 2012
Posts: 41
Rep Power: 14
cesarjets is on a distinguished road
Is there any other way to code and solve the tridiagonal matrix? the idea would be to try to get the plot shown. Matlab beginner, so, no sure how to do it. Any help will be greatly appreciated. Thanks


clear
cm=1/100;
delta = 1*cm;
nu=1e-6;
Uinf=1;
H=2*delta;
y=linspace(0,H,40);
u=Uinf*erf(3*y/delta);
dy=mean(diff(y));
dx=100*dy;
Q=nu*dx/Uinf/dy^2;
a=-Q;
c=-Q;
b=1+2*Q;
N=length(y)-2;
M = diag(b*ones(1,N)) + diag(c*ones(1,N-1),1) + diag(a*ones(1,N-1),-1);
%Constant Ue
Ue = @(x) Uinf;
u = u(2:end-1);
x=0;
uall=[0,u,Ue(x)];
cesarjets is offline   Reply With Quote

Old   March 1, 2023, 23:31
Default
  #2
Senior Member
 
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,747
Rep Power: 66
LuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura aboutLuckyTran has a spectacular aura about
If you are looking specifically for the tridiagonal matrix algorithm then:

Explained in detail on Wikipedia and you can interpret it as pseudo code. Actual VBA and C-variants also provided.

TDMA algorithm is a very popular shared repository on the Matlab exchange. You can just use it, it is licensed.

Note that you are not strictly limited to the tridiagonal matrix algorithm either. Any (more complicated and better) linear solver will do. For example, fsolve.

If the solution is unique (which is not always the case in CFD, but usually is when you are doing simple coding examples) then you can also use a computationally slow but semantically simple matrix division in matlab. That is, given A*x=b the solution found by solution=A\b. The left division will implicitly invoke the pseudo-inverse and in many cases still give the correct solution.
LuckyTran is offline   Reply With Quote

Reply

Tags
tridiagonal matrix


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenFOAM version 1.6 details lakeat OpenFOAM Running, Solving & CFD 42 August 26, 2009 22:47
thomas algorithm cvkeshav Main CFD Forum 2 March 29, 2009 06:37
Block-Block tridiagonal matrix inverse Abdulhafid Elfaghi Main CFD Forum 3 September 16, 2007 03:55
Thomas Algorithm Testing Out of Ideas Main CFD Forum 3 February 8, 2001 23:45
Why Thomas Algorithm for tridiagonal systems? Yogesh Talekar Main CFD Forum 6 July 15, 1999 14:56


All times are GMT -4. The time now is 23:37.