I'm trying to solve a forces equilibrium consisting of three equations as constraints (Fx=0,Fy=0,Mx=0) and maximize the variable Vb, for which I set the objective function as -Vb. There are 4 variables that I don't know [phi, beta, gamma, delta_r] which form my vector of variables that corresponds to the guess x0. Two more values are to be fixed, those are (beta,Vw)*
beta,Vw=rad(40),10
def fuerza_x(xs,beta,Vw):
gamma,phi,Vb,delta_r = xs[0],xs[1],xs[2],xs[3]
(beta,Vw)=args
return Fuerzasx(phi,beta,gamma,Vb,Vw,delta_r)
def fuerza_y(xs,beta,Vw):
gamma,phi,Vb,delta_r = xs[0],xs[1],xs[2],xs[3]
beta,Vw=arguments
return Fuerzasy(phi,beta,gamma,Vb,Vw,delta_r)
def momento_1(xs,beta,Vw):
gamma,phi,Vb,delta_r = xs[0],xs[1],xs[2],xs[3]
beta,Vw=arguments
return mom(phi,beta,gamma,Vb,Vw,delta_r)
def objective(xs,beta, Vw):
gamma,phi,Vb,delta_r = xs[0],xs[1],xs[2],xs[3]
return -Vb
eq_cons = (
{'type': 'eq', 'fun' : fuerza_x(xs,beta,Vw),'args': (beta,Vw) },
{'type': 'eq', 'fun' : fuerza_y(xs, beta, Vw),'args': (beta,Vw) },
{'type': 'eq', 'fun' : momento_1(xs,beta, Vw),'args': (beta,Vw) } )
x0 = np.array([ rad(4), rad(20),6, 0.2])
res = minimize(objective, x0,args=(beta,Vw), method='SLSQP',
constraints=eq_cons, options={'ftol': 1e-9, 'disp': True})
I suppose that the mistake lies with the syntax used in the arguments tuple. I've researched lots of simmilar questions (Structure of inputs to scipy minimize function) but they don't fit for my case. Any help is greatly appreciated.