Advertisement
Guest User

mn6

a guest
May 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. %NUMFLUX
  2.  
  3. function val = numflux(rho_i, rho_i_plus_1)
  4.  
  5. global rho_max;
  6.  
  7. if (rho_i <= rho_max/2 && rho_i_plus_1 <= rho_max/2)
  8. val=flux(rho_i);
  9. elseif (rho_i < rho_max/2 && rho_i_plus_1 > rho_max/2)
  10. A(1,1)=flux(rho_i);
  11. A(2,1)=flux(rho_i_plus_1);
  12. val=min(A);
  13. elseif (rho_i_plus_1 < rho_max/2 && rho_i > rho_max/2)
  14. val=flux(rho_max/2);
  15. elseif (rho_i >= rho_max/2 && rho_i_plus_1 >= rho_max/2)
  16. val=flux(rho_i_plus_1);
  17. end
  18. end
  19.  
  20.  
  21.  
  22. gordonov
  23.  
  24. zadanie 2
  25.  
  26. for i=1:Nx
  27. if i<= (Nx/2)
  28. rho(1,i) = rho_max;
  29. else
  30. rho(1,i)=rho_R;
  31. end
  32. end
  33.  
  34.  
  35. zadanie 3
  36.  
  37. for j=1:Ntraj
  38. traj(n,j) = traj(n-1,j) + delta_t*u_max*(1-interpolate_rho(traj(n-1,j), rho(n-1,:), xs)/rho_max);
  39. end
  40.  
  41. end
  42.  
  43.  
  44. [XX YY] = meshgrid(xs,ts);
  45. pcolor(XX,YY,rho);
  46. shading('interp');
  47.  
  48. hold on; plot(traj(:,1), ts', 'w-');
  49. hold on; plot(traj(:,2), ts', 'r-');
  50. hold on; plot(traj(:,3), ts', 'b-');
  51.  
  52.  
  53. zadanie 4
  54.  
  55. zmienic warunek poczatkowy
  56.  
  57. for i=1:Nx
  58. rho(1,i)=rho_max/2;
  59. end
  60.  
  61. if ((ts(n) >= 1/60 && ts(n) <= 2/60 && xs(i)==-1))
  62. flux_plus=0;
  63. elseif (ts(n) >= 4/60 && ts(n) <= 5/60 && xs(i)==0)
  64. flux_plus=0;
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement