function y = drilling(u)
%Function calculating the drilling equations.
%Run script main.m
%DEH - 2010
global db dstring kc WOB RPM

y = zeros(6,1);

WOB = u(1);
RPM = u(2);

x0 = [15; 5];
x = fsolve(@drillsolve,x0);

y(1) = x(1); %ROP, m/hr
F = u(1)/db*kc*db^2*pi/4; %Force, N, function of WOB and rock strength
y(2) = F*dstring/2000; %Torque, kNm.
y(3) = y(2)*2*pi*u(2)/60; %Power, kW
y(4) = x(2); %Cuttings percent
y(5) = u(1);
y(6) = u(2);