On Tuesday 12 August 2008, a r wrote: > Last time I tried Gnucap I've been told that it does not > support mutual inductance. So, I guess, you will not be able > to model any kind of transformers in Gnucap.
Yes it does, always has .. but only pairs. There is an easy work-around, and now I see a way to remove the limit of pairs only. > Is it a fundamental limitation of Gnucap or its parser simply > cannot handle "K" devices? The historical reason for the limit of pairs is that they all need to find each other and build a composite hooking them all together. > It is perfectly possible to write > a mutual inductor model in veriloga, so if Gnucap is going to > support veriloga it should be able to cope with all the maths > internally. It is a lot easier in Verilog-A. Verilog-A does not support the spice way with the "K" pseudo-element. In Verilog-A, you need to define a "module" .. and the module for two is different from the one for three. It really makes a lot more sense, because I think of a pair (or more) of coupled inductors as a single unit. .. a "transformer" ... Let's look at it that way ... .subckt trans2a (a1 a2 b1 b2) l1 (a1 a2) 'L1' l2 (b1 b2) 'L2' k1 (l1 l2) 'K12' .ends Call it: Xt1 (p1 p2 s1 s2) trans2a L1=.75 L2=.9 K12=.95 Because of a bug, if you use parameters like this you must put the L's before the K, but I fixed it for the next release. The problem is that this one doesn't work: .subckt trans3a (a1 a2 b1 b2 c1 c2) l1 (a1 a2) 'L1' l2 (b1 b2) 'L2' l3 (c1 c2) 'L3' k12 (l1 l2) 'K12' k23 (l2 l3) 'K23' k13 (l1 l3) 'K13' .ends If you look at the definition of mutual inductance you see ... v1 = L11 * di1/dt + L21 * di2/dt v2 = L22 * di2/dt + L12 * di1/dt .... and this can be extended to as many as you want. note that: L12 = L21 = K12 * sqrt(L11 * L22) So we can change the formula... define .. v11 = L11 * di1/dt v22 = L22 * di2/dt then .. v1 = v11 + (L12/L22)*v22 v2 = v22 + (L21/L11)*v11 .. and we can make a subckt for this: .subckt trans2c (a1 a2 b1 b2) .param M12 = 'K12*sqrt(L1*L2)' l1 (a3 a2) 'L1' l2 (b3 b2) 'L2' e21 (a1 a3 b3 b2) 'M12/L2' e12 (b1 b3 a3 a2) 'M12/L1' .ends This gives the same results as trans2a above, except that it has internal nodes. (and the parameters work as they are supposed to.) This model even lets you have nonlinear inductors. So, try extending to 3 inductors ... .subckt trans3 (a1 a2 b1 b2 c1 c2) .param M12 = 'K12*sqrt(L1*L2)' .param M23 = 'K23*sqrt(L2*L3)' .param M13 = 'K13*sqrt(L1*L3)' l1 (a3 a2) 'L1' l2 (b3 b2) 'L2' l3 (c3 c2) 'L3' e21 (a4 a3 b3 b2) 'M12/L2' e31 (a1 a4 c3 c2) 'M13/L3' e12 (b4 b3 a3 a2) 'M12/L1' e32 (b2 b4 c3 c2) 'M23/L3' e13 (c4 c3 a3 a2) 'M13/L1' e23 (c2 c4 b3 b2) 'M23/L2' .ends Now call it: Xtrans (a1 a2 b1 b2 c1 c2) trans3 L1=.667 L2=.57 L3=.88 + K12=.8 K23=.98 K13=.85 ..... and there's your "trifilar transformer". You can specify either the K's or M's. Either will work. _______________________________________________ Help-gnucap mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-gnucap
