function u_t = f(t,u,k,lx,ltrunc,epsilon) 
% F gives right hand side of ODE for method of lines

%u_t = local_heat(u,k);

%u_t = local_burgers(u,k);

%u_t = local_benjamin_ono(u,k,lx);

%u_t = local_burgers_hilbert(u,k,lx);

u = u.';
u_t = local_hiz(u,k,lx);

if (epsilon>0)
    u_t = u_t + local_visc(u,k,lx,ltrunc,epsilon);
end

u_t = truncate (u_t, lx).';

end


%% Subfunction for heat equation
function u_t = local_heat(u,k)

  u_t = dderiv(u,k);                                    % Heat equation
end

%% Subfunction for burgers
function u_t = local_burgers(u,k)

  u_t = -deriv(0.5*u.*u, k);                            % Burgers
end

%% Subfunction for benjamin-ono
function u_t = local_benjamin_ono(u,k,lx)

  u_t = -deriv(0.5*u.*u,k) - hilbert(dderiv(u,k),lx);  % Benjamin-Ono
end

%% Subfunction for burgers-hilbert
function u_t = local_burgers_hilbert(u,k,lx)

  u_t = -deriv(0.5*u.*u, k)+hilbert(u,lx);           % Burgers-Hilbert  
end

%% Subfunction for hiz
function u_t = local_hiz(u,k,lx)

  h = hilbert(u,lx);
  u_t = -0.5*dderiv(hilbert(h.*h,lx),k)-h.*dderiv(u,k) ; % HIZ 
end

%% Subfunction for viscosity
function visc = local_visc(u,k,lx,ltrunc,epsilon)

visc = fft(u);
visc(1:ltrunc) = 0;
visc(lx-ltrunc+1:lx) = 0;
visc = epsilon*ifft(-(k.^2).*visc);
end