---
# System prepended metadata

title: '***Computational Hydraulics***'
tags: [HW4.3]

---

---
tags: HW4.3
---
# ***Computational Hydraulics***
## **Group 01:** N88071053 洪豪男 N88091011 黃彥鈞
## **HW4.3:** Please use any one of the conventional scheme (listed in Unit 02) to simulate the hydraulic jump problem as used in the m-code “code_20191106a_SWE_jump.m”. Does it satisfy the shock speed condition?

```
%% Traveling Wave Problem ( jump ) : Lax - Wendroff
% Sam Y. J. Huang 2020.10.09

if 01

% initial condition :
% Function : u_t + a u_x = 0 ; a = 1.0
%
x = -100:1:100 ; % range of x
dx = x(2) - x(1) ; 
nx = length(x) ;
u = zeros(size(x)) ;
a = 1.0 ;
A = 1.2 ; % amplitude

% Function :

for i = 1:length(u)
if x(i)>=10.0
    h(i) = 0.5 ;
    u(i) = 0.1 ;
else
    h(i) = 0.05 ;
    u(i) = 1 ;
end
end


% initial : 
figure(1);
plot(x,u,'b--');
xlabel('x');
ylabel('u');
axis([-100 100 -1.4 2]);


u0 = u ; % initial velocity
u_new = zeros(size(u));
stepNo = 0 ; 
TotalStep = 100 ;
TotalT = 0.0 ;
CFL = 0.8 ; % CFL condition : max CFL < 1.0
    
figure(2)
for s = 1:TotalStep
    stepNo = stepNo +1 ;
    % a = max(abs(u)) ; 
    dt = CFL*dx/a ;
    TotalT = TotalT + dt ;
    for j = 2:nx-1 ;
        %  Lax - Wendroff :
        upls = u(j+1) ;
        umns = u(j-1) ; 
        AA = (dt/dx)*u(j) ;
        u_new(j) = u(j) - 0.5*AA*(upls - umns) + 0.5*(AA^2)*(upls-2*u(j) + umns) ;
        
    end
    
    % Boundary conditions : 
    u_new(1) = u_new(nx-1);
    u_new(nx) = u_new(2) ;
    u = u_new ;
    
    % plot figure : 
    plot(x,u0,'b--',x,u,'r-')
    xlabel('x')
    ylabel('u')
    axis([-100 100 -1.4 2])
    text(40,1.5,['Step No.= ',num2str(stepNo)]);
    text(40,1.6,['Time = ',num2str(TotalT)]);
    title(' Lax - Wendroff ')
    pause(0.1)
    
end

end
```

![](https://i.imgur.com/J2k4HNU.png)

* We see that a curve of discontinuity is a shock curve satisfies the Rankine-Hugoniot jump condition and the entropy condition for that solution u. 
