PATCH: bug in spice-3f5 mutual inductors

M

Martin Devera

Guest
Hi,

I'm rather programmer than electronics designer but I wanted to design wideband
LNA. Unfortunately when I created design with coupled inductors and run TRAN
and then AC I got bad results. When I run AC and then TRAN all was ok.
So I looked at sources and found (after 10 hours of learning spice
principles :-( ) something which looks as bug.
See patch below. I'm interested if someone can commit my fix...

------------------------
Martin Devera aka devik
Linux QoS/HTB maintainer

--- indload.c.orig Thu Feb 12 00:23:30 2004
+++ indload.c Thu Feb 12 00:24:51 2004
@@ -67,9 +67,14 @@
*(ckt->CKTstate0 + muthere->MUTind2->INDflux) +=
muthere->MUTfactor * *(ckt->CKTrhsOld+
muthere->MUTind1->INDbrEq);
- }
+ /* } devik@cdi.cz 12.2.2004: these probably should be loaded only if
+ transient analyse is run. It is because ckt->CKTag[0] remains set
+ after such prev transient run and this then loads nonsence value
+ into the admittance matrix for OP/DC analyses. I have circuit which
+ demonstrates it. */
*(muthere->MUTbr1br2) -= muthere->MUTfactor*ckt->CKTag[0];
*(muthere->MUTbr2br1) -= muthere->MUTfactor*ckt->CKTag[0];
+ }
}
}
itype = CKTtypelook("Inductor");
 
Martin,

I'm rather programmer than electronics designer but I wanted to design
wideband
LNA. Unfortunately when I created design with coupled inductors and run
TRAN
and then AC I got bad results. When I run AC and then TRAN all was ok.
So I looked at sources and found (after 10 hours of learning spice
principles :-( ) something which looks as bug.
See patch below. I'm interested if someone can commit my fix...

------------------------
Martin Devera aka devik
Linux QoS/HTB maintainer

--- indload.c.orig Thu Feb 12 00:23:30 2004
+++ indload.c Thu Feb 12 00:24:51 2004
@@ -67,9 +67,14 @@
*(ckt->CKTstate0 + muthere->MUTind2->INDflux) +=
muthere->MUTfactor * *(ckt->CKTrhsOld+
muthere->MUTind1->INDbrEq);
- }
+ /* } devik@cdi.cz 12.2.2004: these probably should be loaded
only if
+ transient analyse is run. It is because ckt->CKTag[0]
remains set
+ after such prev transient run and this then loads nonsence
value
+ into the admittance matrix for OP/DC analyses. I have
circuit which
+ demonstrates it. */
*(muthere->MUTbr1br2) -= muthere->MUTfactor*ckt->CKTag[0];
*(muthere->MUTbr2br1) -= muthere->MUTfactor*ckt->CKTag[0];
+ }
}
}
itype = CKTtypelook("Inductor");
ckt->CKTag[] is supposed to be initialized to all zeros. I think this is
done in SPICE3 sources as part of tmalloc(which is like calloc()). I've
never seen this bug in a commercial version of SPICE. You would need to
do a .ac after a .tran to see it in unmodified SPICE3 solvers.

--Mike
 
+ demonstrates it. */
*(muthere->MUTbr1br2) -= muthere->MUTfactor*ckt->CKTag[0];
*(muthere->MUTbr2br1) -= muthere->MUTfactor*ckt->CKTag[0];
+ }
}

ckt->CKTag[] is supposed to be initialized to all zeros. I think this is
done in SPICE3 sources as part of tmalloc(which is like calloc()). I've
never seen this bug in a commercial version of SPICE. You would need to
do a .ac after a .tran to see it in unmodified SPICE3 solvers.
Hi Mike,

thanks for your reply. It seems that in Berkeley 3f5 it is initialized to
zero when the circuit loads. If you use interactive interpreter and run
tran analysis and then another analysis (maybe tran again) the circuit
is left in its last state - thus with nonzero CKTag[].

Please can I take this oportunity and ask you about spice ? I can't find
any information what is CKTag[] supposed to contain (and why it is named
"ag"). From sources I understand that it is set to "some" coefficients
of predictor-corrector integration method (along with CKTagp).
If I use trapezoid method then the first two elements are +/- 1/time_delta.
Because CKTag[0] is often read on other places than ni/* solver package
I guess that at least CKTag[0] must be some well defined value in any case
(when transient analysis is in progress). Am I correct ?

Other question would be about NIintegrate. From its name I'd tell that it
will integrate something. But when I followed trapezoid part of it (I don't
know Gear's algorithm so I ignored that part) I found that it really computes
differencial. For example for CAP model it computes dynamic g and i from
Q difference between current and last state of CAP.
So that is it correct that NIintegrate doesn't integrate ?

Thanks again a much, Martin
 
Martin,

thanks for your reply. It seems that in Berkeley 3f5 it
is initialized to zero when the circuit loads. If you use
interactive interpreter and run tran analysis and then
another analysis (maybe tran again) the circuit
is left in its last state - thus with nonzero CKTag[].
There are other initialization errors when using the
interactive c-shell of SPICE3.

Please can I take this oportunity and ask you about spice?
I can't find any information what is CKTag[] supposed to
contain (and why it is named "ag"). From sources I understand
that it is set to "some" coefficients of predictor-corrector
integration method (along with CKTagp). If I use trapezoid
method then the first two elements are +/- 1/time_delta.
Because CKTag[0] is often read on other places than ni/*
solver package I guess that at least CKTag[0] must be some
well defined value in any case (when transient analysis is
in progress). Am I correct ?

Other question would be about NIintegrate. From its name I'd
tell that it will integrate something. But when I followed
trapezoid part of it (I don't know Gear's algorithm so I
ignored that part) I found that it really computes
differencial. For example for CAP model it computes dynamic
g and i from Q difference between current and last state of
CAP. So that is it correct that NIintegrate doesn't integrate?
Integrate can mean not only summing the area/volume under a
curve/surface but simply solving any form of differential
equation. Here it allows you to integrate(i.e. solve) the
differential equations describing transient currents in
reactances. I won't worry about the naming "conventions"
used in SPICE3.

--Mike
 
In article <c0epsn$rkr@dispatch.concentric.net>, Mike Engelhardt
<pmte@concentric.net> writes
Martin,

I'm rather programmer than electronics designer but I wanted to design
wideband
LNA. Unfortunately when I created design with coupled inductors and run
TRAN
and then AC I got bad results. When I run AC and then TRAN all was ok.
So I looked at sources and found (after 10 hours of learning spice
principles :-( ) something which looks as bug.
See patch below. I'm interested if someone can commit my fix...

------------------------
Martin Devera aka devik
Linux QoS/HTB maintainer

--- indload.c.orig Thu Feb 12 00:23:30 2004
+++ indload.c Thu Feb 12 00:24:51 2004
@@ -67,9 +67,14 @@
*(ckt->CKTstate0 + muthere->MUTind2->INDflux) +=
muthere->MUTfactor * *(ckt->CKTrhsOld+
muthere->MUTind1->INDbrEq);
- }
+ /* } devik@cdi.cz 12.2.2004: these probably should be loaded
only if
+ transient analyse is run. It is because ckt->CKTag[0]
remains set
+ after such prev transient run and this then loads nonsence
value
+ into the admittance matrix for OP/DC analyses. I have
circuit which
+ demonstrates it. */
*(muthere->MUTbr1br2) -= muthere->MUTfactor*ckt->CKTag[0];
*(muthere->MUTbr2br1) -= muthere->MUTfactor*ckt->CKTag[0];
+ }
}
}
itype = CKTtypelook("Inductor");

ckt->CKTag[] is supposed to be initialized to all zeros. I think this is
done in SPICE3 sources as part of tmalloc(which is like calloc()). I've
never seen this bug in a commercial version of SPICE. You would need to
do a .ac after a .tran to see it in unmodified SPICE3 solvers.

--Mike


May or may not be relevant but in LT spice I investigated the effect of
mutual coupling of inductors in the resonant frequency of 2 LCR series
resonant circuit.
The effect of coupling a higher resonant frequency circuit to the lower
resonant frequency circuit was to lower the lower resonant frequency
this was counter intuitive and rather than worry about this I employed
capacitive coupling whereapon the pulling raised the lower resonant
frequency circuit as expected.


--
ddwyer
 
I read in sci.electronics.design that ddwyer <dd@ddwyer.demon.co.uk>
wrote (in <xHXMpuAksKMAFw8h@ddwyer.demon.co.uk>) about 'PATCH: bug in
spice-3f5 mutual inductors', on Mon, 16 Feb 2004:

The effect of coupling a higher resonant frequency
circuit to the lower resonant frequency circuit was to lower the lower
resonant frequency
You change the L in the lower resonance circuit to L + M, so the
frequency goes down.
--
Regards, John Woodgate, OOO - Own Opinions Only.
The good news is that nothing is compulsory.
The bad news is that everything is prohibited.
http://www.jmwa.demon.co.uk Also see http://www.isce.org.uk
 

Welcome to EDABoard.com

Sponsor

Back
Top