I'm trying to use optimization to tackle an antenna matching problem where I want to minimize the phase of the resulting matched impedance (through a pi-matching network), subject to Q > 100 (for example), and the real of the impedance =50.
Strangely, it only gives a solution if my initial guesses are 50 for the three variables. Furthermore, it finds a solution when the inequality constraint is >10, but not >1.....I don't understand this since if it >10, it is greater than 1....
If I change the upper and lower bounds, that also affects the solver. With lb=-1000 and ub=1000, I get , x2=1000, x3= -125.57, x4=22.53. But, if I change the lower bound to -200, which should still allow the -125.57 solution, the solver cannot find a solution.
Perhaps I'm setting up the optimization problem incorrectly? This is my problem statement: objective function: minimize the imaginary part of Zin (for resonance) inequality constraint: subject to Q > some number equality constraint: and real part of Zin =50
Here's the simple python script I wrote:
from gekko import GEKKO
m = GEKKO()
x2,x3,x4, = m.Array(m.Var,3,lb=-1000,ub=1000) # upper and lower bounds for unknowns
x2.value = 50; x3.value =50; x4.value =50; # initial guess
#equations
m.Equation((-9.84*x2**2*x4)/(96.786*(x2+x3)*(x2+x3+4)+(120.11*x3+x2*(120.11+x3))*(120.11*(x3+x4)+x2*(120.11+x3+x4))) > 10) # inequality constraint
m.Equation((9.84*(x2**2)*(x4**2))/((9.84*(x2+x3+x4))**2+(120.11*(x2+x3+x4)+x2*(x3+x4))**2) ==50) # equality constraint
#objective
m.Obj((x4*(96.79*(x2+x3)*(x2+x3+x4)+(120.109*x3+ x2*(120.11+x3))*(120.11*(x3+x4)+x2*(120.11+x3+x4))))/(96.9*(x2+x3+x4)**2+(120.11*(x3+x4)+x2*(120.11+x3+x4))**2))
#m.options.IMODE=3
m.options.SOLVER=3
#Solve
#m.solve(disp=False)
m.solve()
print('x2 =' ,x2.value,'x3 =',x3.value,'x4 =',x4.value)
Here's a schematic of the circuit analyzed (jX1==0),
and the equations derived:
ReZinpi=(R1 X2^2 X4^2)/(R1^2 (X2 + X3 + X4)^2 + ((X3 + X4) XL + X2 (X3 + X4 + XL))^2)
ImZinpi = (X4 (R1^2 (X2 + X3) (X2 + X3 + X4) +
(X3 XL + X2 (X3 + XL)) ((X3 + X4) XL + X2 (X3 + X4 + XL))))
/(R1^2 (X2 + X3 + X4)^2 + ((X3 + X4) XL + X2 (X3 + X4 + XL))^2)
Qpi= -((R1 X2^2 X4)/(R1^2 (X2 + X3) (X2 + X3 + X4) +
(X3 XL + X2 (X3 + XL)) ((X3 + X4) XL + X2 (X3 + X4 + XL))))
Is this approach to optimize the component values in my pi matching network to maximize the match (minimize the phase) while achieving a high Q wrong?
I can't verify your equations but can give some insight on the problem characteristics. It appears that your problem is very nonlinear. The interior point algorithm may take a different route because of different bounds. Here is a contour plot of your solution with x2=1000 to reduce it down to just x3 and x4 as variables.
There is the objective function, inequality constraint (>10) as the black lines and the equality constraint (=50) as the blue line. The variables in the denominator may be getting small (approaching zero). Sometimes it helps to multiply a denominator term to the other side of the equation such as
x/y==50
tox=y*50
.