|
[Sponsors] |
March 1, 2023, 19:29 |
Thomas algorithm - tridiagonal matrix
|
#1 |
Member
Join Date: Aug 2012
Posts: 41
Rep Power: 14 |
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)]; |
|
March 1, 2023, 23:31 |
|
#2 |
Senior Member
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,747
Rep Power: 66 |
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. |
|
Tags |
tridiagonal matrix |
|
|
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 |