From: trung trinh on 10 Apr 2010 04:21 I have problem. We have equation system below du1/dt = u2 and du2/dt = d(du/dx)/dx with initial conditions u1(x,0) = 0 , u2(x,0) = 0 boundary conditions u1(0,t) = 0 , u2(0,t) =0 u1(1,t) =0 , u2(1,t) =0 I used command pdepe to solve this problem, and my code is: /////////////////////////////////////////////////////////////////////////// function pdex1 m = 0; x = [0:0.05:1]; t = [0:0.1:2]; sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t); u1 = sol(:,:,1); figure %plot(u1); surf(x,t,u1); title('u1(x,t)') xlabel('Distance x') ylabel('Time t') % -------------------------------------------------------------- function [c,f,s] = pdex1pde(x,t,u,DuDx) c = [1 0; 0 1]; f = [0 0; 1 0] * DuDx; s = [u(2); 0]; % -------------------------------------------------------------- function u0 = pdex1ic(x) u0 = [0; 1]; % -------------------------------------------------------------- function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t) pl = [ul(1); ul(2)]; ql = [0; 0]; pr = [ur(1); ur(2)]; qr = [0; 0]; ////////////////////////////////////////////////////////////////////////// But have error: ??? Error using ==> daeic12 at 77 This DAE appears to be of index greater than 1. Help me. Thank a lot.
From: Torsten Hennig on 10 Apr 2010 02:26 > I have problem. We have equation system below > du1/dt = u2 and du2/dt = d(du/dx)/dx > I think you mean du2/dt = d/dx(du1/dx) > with initial conditions > u1(x,0) = 0 , u2(x,0) = 0 > boundary conditions > u1(0,t) = 0 , u2(0,t) =0 > u1(1,t) =0 , u2(1,t) =0 > That's easy - the solution is u1=u2=0 for all times t. (From what you programmed below I think you meant u2(x,0) = 1 :-) ). Furthermore, you don't need boundary conditions for u1 - it's an ordinary differential equation. > I used command pdepe to solve this problem, and my > code is: > > ////////////////////////////////////////////////////// > ///////////////////// > function pdex1 > m = 0; > x = [0:0.05:1]; > t = [0:0.1:2]; > > > sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t); > u1 = sol(:,:,1); > > figure > %plot(u1); > surf(x,t,u1); > title('u1(x,t)') > xlabel('Distance x') > ylabel('Time t') > > % > ------------------------------------------------------ > -------- > function [c,f,s] = pdex1pde(x,t,u,DuDx) > c = [1 0; 0 1]; > f = [0 0; 1 0] * DuDx; > s = [u(2); 0]; > > % > ------------------------------------------------------ > -------- > function u0 = pdex1ic(x) > u0 = [0; 1]; > % Set u0(2) to 0 if x equals 1. Otherwise initial conditions and boundary conditions are not consistent (which often causes the error from below). > ------------------------------------------------------ > -------- > function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t) > pl = [ul(1); ul(2)]; > ql = [0; 0]; > pr = [ur(1); ur(2)]; > qr = [0; 0]; > ////////////////////////////////////////////////////// > //////////////////// > > But have error: > > ??? Error using ==> daeic12 at 77 > This DAE appears to be of index greater than 1. > > Help me. Thank a lot. Best wishes Torsten.
From: Torsten Hennig on 11 Apr 2010 22:55 > > I have problem. We have equation system below > > du1/dt = u2 and du2/dt = d(du/dx)/dx > > > > I think you mean du2/dt = d/dx(du1/dx) > > > with initial conditions > > u1(x,0) = 0 , u2(x,0) = 0 > > boundary conditions > > u1(0,t) = 0 , u2(0,t) =0 > > u1(1,t) =0 , u2(1,t) =0 > > > > That's easy - the solution is u1=u2=0 for all times > t. > (From what you programmed below I think you meant > u2(x,0) = 1 :-) ). > > Furthermore, you don't need boundary conditions for > u1 - it's an ordinary differential equation. > > > I used command pdepe to solve this problem, and > my > > code is: > > > > > ////////////////////////////////////////////////////// > > > ///////////////////// > > function pdex1 > > m = 0; > > x = [0:0.05:1]; > > t = [0:0.1:2]; > > > > > > sol = pdepe(m,@pdex1pde,@pdex1ic,@pdex1bc,x,t); > > u1 = sol(:,:,1); > > > > figure > > %plot(u1); > > surf(x,t,u1); > > title('u1(x,t)') > > xlabel('Distance x') > > ylabel('Time t') > > > > % > > > ------------------------------------------------------ > > > -------- > > function [c,f,s] = pdex1pde(x,t,u,DuDx) > > c = [1 0; 0 1]; > > f = [0 0; 1 0] * DuDx; > > s = [u(2); 0]; > > > > % > > > ------------------------------------------------------ > > > -------- > > function u0 = pdex1ic(x) > > u0 = [0; 1]; > > % > > Set u0(2) to 0 if x equals 1. Correction : Set u0(2) to 0 if x equals 0 or 1. > Otherwise initial conditions and boundary conditions > are not consistent (which often causes the error > from > below). > > > > > ------------------------------------------------------ > > > -------- > > function [pl,ql,pr,qr] = pdex1bc(xl,ul,xr,ur,t) > > pl = [ul(1); ul(2)]; > > ql = [0; 0]; > > pr = [ur(1); ur(2)]; > > qr = [0; 0]; > > > ////////////////////////////////////////////////////// > > > //////////////////// > > > > But have error: > > > > ??? Error using ==> daeic12 at 77 > > This DAE appears to be of index greater than 1. > > > > Help me. Thank a lot. > > > Best wishes > Torsten.
From: trung trinh on 12 Apr 2010 08:15 hi helper, boundary is not important, if i change boundary and make it more complex, i can't solve this problem. i can try that and check. Thank for your answer
|
Pages: 1 Prev: How to use matlab in terminal in ubuntu? Next: question on 'subs' command |