How can I loop PDE time dependent problem over time ?
Show older comments
Hi guys
I have problem how can I solve the PDE for 2D flow Laplace equation using Galerkien finite element method (FEM) in transient state condition using iteration method ?
I iterate using the Gauss Seidel method. but how can I loop for the next time step DT ( time domain)
*** this code is modefide after Wang & Anderson 1982 Fortran code for groundwater flow example
Here is my main iteration code
DT = 5;
KOUNT = 1;
KPRINT = 2;
TIME = DT;
for NSTEP = 1:100
for L = 1:NNODE
B(L) = 0.0;
for JJ = 1:NNODE
B(L) = B(L) + (P(L,JJ)*HOLD(JJ))/DT;
end
end
AMAX = 0.0;
for L = 1:NNODE
if (L == 1) || (L == 2) || (L == 21) || (L == 22)
continue
else
OLDVAL = HNEW(L);
SUM = 0.0;
for JJ = 1:NNODE
if (JJ == L)
continue
else
SUM = SUM + (G(L,JJ) + P(L,JJ)/DT)*HNEW(JJ);
end
end
end
HNEW(L) = (-SUM + B(L))/(G(L,L)+P(L,L)/DT);
ERR = abs(OLDVAL-HNEW(L));
if (ERR > AMAX)
AMAX = ERR;
elseif (AMAX > 0.01)
AMAX = 0.0;
HOLD(L) = HNEW(L);
end
if (KOUNT ~= KPRINT)
KOUNT = 0;
TIME = TIME + DT;
KOUNT = KOUNT + 1;
end
end
end
In other words, how to fix my code to run loop over time and show the solution at different time?
Answers (0)
Categories
Find more on Geometry and Mesh in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!