function f = objfun(u)
%Objective function for optimization of the drilling process
%Run script main.m
%DEH - 2010

global db Wdbmax tt0 K D WOB RPM

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

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

R = x(1); %ROP
td0 = K*(60/u(2))^1.7*(Wdbmax-u(1)/db)/(Wdbmax-71.433);
f = D*(1/R + tt0/(R*td0));