def obj_func(xdict):
    global dia
    global tsr
    global solidity
    global Cp
    global dens
    global velf
    global funcs
    
    Vars = xdict['xvars']
    x = xdict['xvars']
    y = xdict['yvars']
    funcs = {}
    
    veleff = np.zeros_like(x)
    power_turb = np.zeros_like(x)
    
    for i in range(np.size(x)):
        xp = np.delete(x,i)
        yp = np.delete(y,i)
        diap = np.delete(dia,i)
        tsrp = np.delete(tsr,i)
        solidityp = np.delete(solidity,i)
        veleff[i] = overlap(xp,yp,diap,tsrp,solidityp,x[i],y[i],dia[i],velf,True,False)
        power_turb[i] = powerval(Cp,dens,veleff[i],dia[i])
        # print i+1
    
    power = np.sum(power_turb)
    print power 
    funcs['obj'] = (-1.0*power)
    
    sep = sep_func(np.append(x,y))
    funcs['sep'] = sep
    funcs['veleff'] = veleff
    funcs['power_turb'] = power_turb
    
    fail = False

    return funcs, fail
 plt.xlim(points[0]-spacing*area,points[-1]+spacing*area)
 plt.ylim(points[0]-spacing*area,points[-1]+spacing*area)
 
 
 if contour == True:
 
     N = 10
     xplot = np.linspace(points[0]-spacing*area,points[-1]+spacing*area,N)
     yplot = np.linspace(points[0]-spacing*area,points[-1]+spacing*area,N)
     [X,Y] = np.meshgrid(xplot,yplot)
     Vel = np.zeros((N,N))
     
     k = 0
     for i in range(N):
         for j in range(N):
             Vel[i,j] = overlap(xf,yf,dia,tsr,solidity,X[i,j],Y[i,j],turb_dia,velf,True,False)
             k += 1
             print k
     
     plt.figure(2)
     lb = 0.0 # lower bound on velocity to display
     ub = velf # upper bound on velocity to display
     ran = 200 # number of contours between the velocity bounds
     bounds = np.linspace(lb,ub,ran)
     v = np.linspace(lb,ub,4) # setting the number of tick marks on colorbar
     CS = plt.contourf(X,Y,Vel,ran,vmax=ub,vmin=lb,levels=bounds,cmap=plt.cm.jet) # plotting the contour plot
     CB = plt.colorbar(CS, ticks=v) # creating colorbar
     for i in range(np.size(xt)):
         circ = plt.Circle((xt[i],yt[i]),dia[i]/2.,color='g',edgecolor='k',fill=True)
         plt.gca().add_patch(circ)