## 5 Reputation

1 years, 234 days

## @Carl Love I appologise if I'm ...

I appologise if I'm pushing my luck here, but I'm trying to add to the plot the GainMin and Max value with the Q functions.

I've written the script as such :

> GainQ:= 8*wx^2*(m-1)/((Pi)^2*sqrt((m*wx^2-1)^2+Q^2*wx^2*(wx^2-1)^2*(m-1)^2)):
> params:= [m=6.3]:
> Qs:= [0.20, 0.30, 0.40, 0.70, 1.0, 6.6]:
> a:= subs(params, GainQ):
> da:= numer(diff(a, wx)):
> for q in Qs do x:= fsolve(subs(Q= q, da), wx= 0.01..infinity);
> Top:= evalf(subs(wx= x, Q= q, a));
> printf(`Q = %a, wx_max= %a, Top = %a\n`, q, x, Top)od:
Q = .20, wx_max= .4168417772, Top = 1.979210362
Q = .30, wx_max= .4434670970, Top = 1.374236432
Q = .40, wx_max= .4890380569, Top = 1.095887154
Q = .70, wx_max= .7610416979, Top = .8570691603
Q = 1.0, wx_max= .8945713661, Top = .8281966922
Q = 6.6, wx_max= .9978289806, Top = .8109020639
> d:=(q->subs(Q= q, a),Qs);

d := q -> subs(Q = q, a), [.20, .30, .40, .70, 1.0, 6.6]

> t:=map (d):
> semilogplot(([t,GainMax,GainMin, wx=0.2..2]), thickness=5, axes=boxed);

Plotting error, VIEW must contain numeric ranges

Note : GainMin and GainMax are define earlier as such :

GainMin:= Vnom/Vmax

GainMax:=Vnom/Vmin

Edit ... So now I've tryied the following, with the folowing result:

> semilogplot(({(map(q->subs(Q= q, a),Qs)),GainMax, GainMin}, wx=0.2..2), thickness=5, axes=boxed);

Edit...Edit ...

I think I got it :

> GainQ:= 8*wx^2*(m-1)/((Pi)^2*sqrt((m*wx^2-1)^2+Q^2*wx^2*(wx^2-1)^2*(m-1)^2)):
> params:= [m=6.3]:
> Qs:= [0.20, 0.30, 0.40, 0.70, 1.0, 6.6]:
> a:= subs(params, GainQ):
> da:= numer(diff(a, wx)):
> for q in Qs do x:= fsolve(subs(Q= q, da), wx= 0.01..infinity);
> Top:= evalf(subs(wx= x, Q= q, a));
> printf(`Q = %a, wx_max= %a, Top = %a\n`, q, x, Top)od:
Q = .20, wx_max= .4168417772, Top = 1.979210362
Q = .30, wx_max= .4434670970, Top = 1.374236432
Q = .40, wx_max= .4890380569, Top = 1.095887154
Q = .70, wx_max= .7610416979, Top = .8570691603
Q = 1.0, wx_max= .8945713661, Top = .8281966922
Q = 6.6, wx_max= .9978289806, Top = .8109020639
> d:=(q->subs(Q= q, a),Qs);

d := q -> subs(Q = q, a), [.20, .30, .40, .70, 1.0, 6.6]

> t:=map (d):
> h:=semilogplot((  (map(q->subs(Q= q, a),Qs))   , wx=0.2..2)):
> o:=semilogplot (GainMax, wx=0.2..2):
> display (h,o);

## @Carl Love  You're a genius. N...

You're a genius. Not sure exactly what you did, but it works.  I'd like to learn about the rational behind this part of the the expression:

map(q->sub(Q=q,a),Qs) ... what does " -> " do exactly ?

Thank you again.

Best regards.

## @Carl Love  I'm starting to do...

I'm starting to doubt that this is not possible under Maple V.

 > restart:
 > with(plots):

#Enter your design specifics in Vots, Hz, Watts

 > Vmin:=18:
 > Vnom:=33:
 > Vmax:=36:
 > Pmax:=250:
 > Vout:=400:
 > freq:=100000:
 > N1_over_N2:=(Vnom/Vout):
 > GainMin:= evalf(Vnom/Vmax);
 > GainMax:= evalf(Vnom/Vmin);
 (1)

#Start doing the itteration. Enter the parameters (params) m and Quality factors (Qs=Q1, Q2,...). The idea is to find the best curve that will best fit the value of GainMin and GainMax.

This curve will be the Qmax value which will use later.

 > GainQ:= 8*wx^2*(m-1)/((Pi)^2*sqrt((m*wx^2-1)^2+Q^2*wx^2*(wx^2-1)^2*(m-1)^2)):
 > params:= [m=6]:
 > Qs:= [0.20, 0.30, 0.40, 0.70, 1.0, 6.0]:
 > a:= subs(params, GainQ):
 > da:= numer(diff(a, wx)):
 > for q in Qs do x:= fsolve(subs(Q= q, da), wx= 0.01..infinity);
 > Top:= evalf(subs(wx= x, Q= q, a));
 > printf(`Q = %a, wx_max= %a, Top = %a\n`, q, x, Top)od:
 Q = .20, wx_max= .4257659439, Top = 2.043988898 Q = .30, wx_max= .4507684910, Top = 1.415858397 Q = .40, wx_max= .4927877155, Top = 1.124695001 Q = .70, wx_max= .7476605392, Top = .8641647891 Q = 1.0, wx_max= .8878848311, Top = .8306147084 Q = 6.0, wx_max= .9972137076, Top = .8110221768
 >
 > plots[semilogplot]([seq](subs(Q=Qs[k], a), k=1...nops(Qs)));
 Error, (in unknown) wrong number (or type) of parameters in function seq

#Change Qmax by using the "best" Q value from the graph, you will now obtain the value of Cr, Lr and Lm.

 > Qmax:=0.4:
 > Rac:=evalf((8/Pi^2)*((N1_over_N2)^2)*((Vout^2)/Pmax));
 > w:=m=((Lr+Lm)/Lr):
 > x:=subs(params, w):
 > y:=Qmax=(((sqrt(Lr/Cr))/Rac)):
 > z:=freq=((1/(2*Pi*(sqrt(Lr*Cr))))):
 (2)
 > fsolve ({x,y,z},{Cr,Lr,Lm},{Cr=-1..infinity});
 (3)
 >
 >

## @Carl Love  As requested: ...

As requested:

 > restart:
 > with(plots):

#Enter your design specifics in Vots, Hz, Watts

 > Vmin:=18:
 > Vnom:=33:
 > Vmax:=36:
 > Pmax:=250:
 > Vout:=400:
 > freq:=100000:
 > N1_over_N2:=(Vnom/Vout):
 > GainMin:= evalf(Vnom/Vmax);
 > GainMax:= evalf(Vnom/Vmin);
 (1)

#Start doing the itteration. Enter the parameters (params) m and Quality factors (Qs=Q1, Q2,...). The idea is to find the best curve that will best fit the value of GainMin and GainMax. This curve will be the Qmax value which will use later.

 > GainQ:= 8*wx^2*(m-1)/((Pi)^2*sqrt((m*wx^2-1)^2+Q^2*wx^2*(wx^2-1)^2*(m-1)^2)):
 > params:= [m=6]:
 > Qs:= [0.20, 0.30, 0.40, 0.70, 1.0, 6.0]:
 > a:= subs(params, GainQ):
 > da:= numer(diff(a, wx)):
 > for q in Qs do x:= fsolve(subs(Q= q, da), wx= 0.01..infinity);
 > Top:= evalf(subs(wx= x, Q= q, a));
 > printf(`Q = %a, wx_max= %a, Top = %a\n`, q, x, Top)od:
 Q = .20, wx_max= .4257659439, Top = 2.043988898 Q = .30, wx_max= .4507684910, Top = 1.415858397 Q = .40, wx_max= .4927877155, Top = 1.124695001 Q = .70, wx_max= .7476605392, Top = .8641647891 Q = 1.0, wx_max= .8878848311, Top = .8306147084 Q = 6.0, wx_max= .9972137076, Top = .8110221768
 >
 > plot ([semilogplot]([seq](subs(Q=Qs[k], a)), k=1...nops(Qs)));
 Error, (in unknown) wrong number (or type) of parameters in function seq

#Change Qmax by using the "best" Q value from the graph, you will now obtain the value of Cr, Lr and Lm.

 > Qmax:=0.4:
 > Rac:=evalf((8/Pi^2)*((N1_over_N2)^2)*((Vout^2)/Pmax));
 > w:=m=((Lr+Lm)/Lr):
 > x:=subs(params, w):
 > y:=Qmax=(((sqrt(Lr/Cr))/Rac)):
 > z:=freq=((1/(2*Pi*(sqrt(Lr*Cr))))):
 (2)
 > fsolve ({x,y,z},{Cr,Lr,Lm},{Cr=-1..infinity});
 (3)
 >
 >

## @Carl Love  i just tryied and inte...

i just tryied and integer index is not working either.

Error, (in unknown) wrong number (for type) of parameters in function seq

## @Carl Love  Thank you very much fo...

Thank you very much for the assistance. I tryied the following statement, but without luck :

plots[semilogplot]([seq](subs(Q= q, a), q = Qs), wx= 0.2..2, thickness= 5, axes= boxed,labels= [w, Gain], title= `Gain(w, Q, m)`);

Error, (in unknown) wrong number (or type) of parameters in function seq

## @Carl Love  I get the following me...

I get the following message : reserved word `in` unexpected, ...and the currsor goes directly to the "in" argument.

>plots[semilogplot]([seq](subs(Q= q, a), q in Qs), wx= 0.2..2, thickness= 5, axes= boxed,labels= [w, Gain], title= `Gain(w, Q, m)`);

reserved word `in` unexpected

## @Carl Love  Yes it works also. On...

Yes it works also.

On that note, what is best way to plot G(Q,w,m) ?

It use to work when I had each function listed individualy but now with the parameter "for q in Qs", it gets a little challenging. I tried this but without results :

for q in Qs do semilogplot({a},wx=0.2...2,Gain,axes=boxed,thickness=5,title=`Gain (w, Q, m)`);

Warning, premature end of input

where a:= subs(params, GainQ):

...not sur if I'm making any sense by trying it this way.

Best regards,

## @Carl Love  I understand what you ...

I understand what you are explaining, e.i. finding the value of the function GainQ where slope = 0, but it seems that it can't finalise the calculation at the value of the Top of the GainQ function. The number at the top of the fjunction match with yours, except that it puts it related pi()^2. This what I receive when runing the script you provided.

> restart:
> GainQ:= 8*wx^2*(m-1)/(Pi^2*sqrt((m*wx^2-1)^2+Q^2*wx^2*(wx^2-1)^2*(m-1)^2)):
> params:= [m=6];
> Qs:= [0.20, 0.30, 0.40, 0.70, 1.0, 6.0];
> a:= subs(params, GainQ):
> da:= numer(diff(a, wx)):
> for q in Qs do x:= fsolve(subs(Q= q, da), wx= 0.01..infinity);
> Top:= subs(wx= x, Q= q, a);
> printf(`Q = %a, wx_max= %a, Top = %a\n`, q, x, Top)od:

params := [m = 6]
Qs := [.20, .30, .40, .70, 1.0, 6.0]

Q = .20, wx_max= .4257659439, Top = 20.17336183/Pi^2
Q = .30, wx_max= .4507684910, Top = 13.97396227/Pi^2
Q = .40, wx_max= .4927877155, Top = 11.10029474/Pi^2
Q = .70, wx_max= .7476605392, Top = 8.528964609/Pi^2
Q = 1.0, wx_max= .8878848311, Top = 8.197838585/Pi^2
Q = 6.0, wx_max= .9972137076, Top = 8.004468049/Pi^2

So in order to solve this issue, this is what I did ... I know it looks very od doing this like that but it seems to work. I just replaced the Pi command with evalf(pi). So it looks like that :

> restart:
> GainQ:= 8*wx^2*(m-1)/((evalf(Pi))^2*sqrt((m*wx^2-1)^2+Q^2*wx^2*(wx^2-1)^2*(m-1)^2)):
> params:= [m=6];
> Qs:= [0.20, 0.30, 0.40, 0.70, 1.0, 6.0];
> a:= subs(params, GainQ):
> da:= numer(diff(a, wx)):
> for q in Qs do x:= fsolve(subs(Q= q, da), wx= 0.01..infinity);
> Top:= subs(wx= x, Q= q, a);
> printf(`Q = %a, wx_max= %a, Top = %a\n`, q, x, Top)od:

params := [m = 6]

Qs := [.20, .30, .40, .70, 1.0, 6.0]

Q = .20, wx_max= .4257659438, Top = 2.043988897
Q = .30, wx_max= .4507684910, Top = 1.415858397
Q = .40, wx_max= .4927877156, Top = 1.124695001
Q = .70, wx_max= .7476605392, Top = .8641647888
Q = 1.0, wx_max= .8878848311, Top = .8306147086
Q = 6.0, wx_max= .9972137076, Top = .8110221768

Where:
> evalf (Pi);

3.141592654

## @Carl Love  Thanks, these are good...

Thanks, these are good results. They are defenetly not "unexpected". I will try to run your script on my end and see what it gives me. Oddly enough when runing the script the way I've provided it, by changing the value of m from 6.3 to 6 didn't give me a result that was "solved" for wx. I was receiving an "fsolvef=...." and that specifically for wx at Gain for Q2. The rest of the Gain functions (Q1,Q3,Q4,Q5,Q6) were calculated for wx without issues. Not sure that why that behaviour.

## All, Ref : params:=[m=6,Q1=0.2,Q2=...

All,

Ref : params:=[m=6,Q1=0.2,Q2=0.3,Q3=0.4,Q4=0.7,Q5=1,Q6=6]:

I'm sorry to revive this old thread but why when I replace the value of m from 6.3. to 6 I get some unexpected result for the value of wx.

Best regards.

## @C_R , @Carl Love , @Preben Al...

All, thank you very much with the assistance.

I'm attaching the final result code. This is usefull in the LLC resonant converter design in order to calculate the resonant capacitor, resonant inductor and magnetizing inductor. Unfortunately I can't do an electrical engineering course over a couple of lines of posts, but the idea behing LLC converter is to obtain a sin wave from a H-Bridge design (Full or Half) for power application. Here is some good reading about the topic, there is a good example at the end that is usuable with the code provided. Application Note Resonant mode controller (infineon.com)

Don't hesitate to let me know if you notice something wrong in the code.

Best regards,

LLC_Converter.mws

## @Carl Love quote" The fun...

quote" The function GainQ1 is an even function of wx, i.e., GainQ1(wx) = GainQ1(-wx) for any real wx. So, any solution has a corresponding negative solution. The way that you used fsolve in your last command caused it to return a single real root of its choosing. It happened to choose a negative. But you can force it to give a positive root by making the 2nd argument {wx= 0..infinity}. "

...is working. Thank you very much.

In conclusion, the argument "maximize" is not optimized in Maple V. Is this correct to say so ?

## @Carl Love  Yup! I think you got i...

Yup! I think you got it. It works.

So to complete the problem would this make sense:

> restart:
> GainQ1:= 8*wx^2*(m-1)/(Pi^2*sqrt((m*wx^2-1)^2+Q1^2*wx^2*(wx^2-1)^2*(m-1)^2)):
> params:= [m= 6.3, Q1= 1]:
> a:= subs(params, GainQ1):
> Top_of_Q1:= evalf(max(seq(subs(wx= x, a), x= [fsolve](numer(diff(a, wx)))))):

> subs(a=Top_of_Q1);

> fsolve(%,{wx});

... solving for wx is not the exact same answer as provided by @C_R , but it is very close...

With respect to using Maple V, unfortunately this is what I have in hand. Didn't know that there would have been such discrepencies into the results.

## @Carl Love @Preben Alsholm Using M...

Using Maple V here, from an office computer.

So I think the approach with the best probability of result is using the derivative of the function, like mentioned above. For some reason, maximize doesn't output a consistent value. It changes everytime I run the script.

I will try it later today and give you feedback.

 1 2 Page 1 of 2
﻿