HFSS optimisation question
I want to optimise a matching circuit to achieve mag 0.5 angle -97deg.
I am having problems trying to get a cost function..I tried this..
Mag = mag(s(1,1))
Ang = Ang_deg(s(1,1)
AngCost = Angle+97 so if the simulated angle is -97, AngCost =0
MagCost = mag(s(1,1))-0.5 so if simulated angle is 0.5, MagCost =0
I combine these two to give
CostFunc = AngCost+MagCost
In the optimisation block I set CostFunc goal = 0, weight 1 (I of course set the simulation frequency).
This should work as if simulated mag=0.5 and ang =-97 then both cost functions would equal 0 and so would CostFunc in the optimisation block? But it seems it doesn't really optimise?
Is there a better way that works?
Cheers
Ody
hello odyseus
I think the cost function you are choosing does not represent your case fully.The cost function might become Zero without the angcost and the magcost individualy becoming zero.
Instead of a costfunction with equal weightage you might use a if-else statement for the cost function.
(what I mean is like this:
if magcost==0 && anglecost==0
cost=0
else
cost=1;
then you might set the cost function goal 0.
It sort of works but keeps bombing out with some optimisation error?
It might be better to optimise for impedance? I wonder if there is a quick way to convert mag & ang_deg to re+im? Using the re & im doesn't yield the same result as the marker? I guess I could do it the long way?
You could modify your cost function to
CostFunc = (AngCost)^2+(MagCost)^2, thus avoiding the case (for example) AngCost=-10 and MagCost=10 =>CostFunc=0
For the benefit of others this is what I did to get it working..
I wanted to optimise a matching circuit for a LNA with an optimum noise match of mag=0.49, ang=-97deg.
I calculated the equivalent impedance to be 0.55894-j0.71546, this normalises to 27.947-j35.773 ohms
I then added the following variable in HFSS
RealZ = 50*re((1+S(1,1))/(1-S(1,1)))
ImajR = 50*im((1+S(1,1))/(1-S(1,1)))
CostR = abs(RealZ-27.947)
CostI = abs(ImajR+35.773)
CostFunc = CostR+CostI
Then in the optimisation block you solve CostFunc <= 0.01, weight 1
So when the HFSS simulator reaches 0.55894-j0.71546 all three cost functions should be zero and the optimisation solved
A small hint:
for RealZ you could use
RealZ=re(Z(1,1)) and for ImajR
ImajR=im(Z(1,1)).