How to find a current of a device which is defined in a subcircuit

58 views
Skip to first unread message

Roshni Uppala

unread,
Jun 18, 2014, 2:36:23 PM6/18/14
to xyce-...@googlegroups.com
Sample code :

X1 Na1 Nb1 Nc1 DEVICE_NAME
.SUBCKT DEVICE_NAME A B C

.ENDS

According to the reference guide it says :
I<lead abbreviation>(<device>) to output current into a par-
ticular lead of a three or more terminal device

.PRINT TRAN FORMAT=TECPLOT FILE=Output.dat IA(X1)
But this doesnot seem to work?
                                                                                        

xyce-users

unread,
Jun 18, 2014, 2:55:28 PM6/18/14
to
No, it won't work like that.

In Xyce, "lead currents" are not completely generalized and can only be output by devices that have had special code added to them to support the feature.  The only devices that support it are the basic compact model devices such as resistors, capacitors, transistors, etc., and not even all versions of those.  Mostly, you can tell which devices support lead currents by looking at the "LEAD_CURRENTS" test case in the Xyce regression suite.  Each device that supports that feature has it tested there.

Lead currents of subcircuit ports are not supported.  In fact, as far as Xyce is concerned, there *IS* no "X1" device --- by the time the circuit is actually run, the netlist has been flattened, and the only thing left of the hierarchy that you can access are things like specific node names  inside the subcircuit (e.g. X1:internal_node) or specific devices inside the subcircuit (X1:r1, X1:v3, etc.). 

So you have a few options to get what you actually want.  Here's one option:

[...circuitry connected to nodes 1 2 3 ...]
X1
1 2 3 mysubckt


.print tran I(X1:R1)


.subckt mysubckt A B C D
R1 A B
1  ; just an example, a device connected to node A
...
.ends




In this example, you're getting the current through node A indirectly by assuming it is the same as the current through the resistor R1 inside X1.

Or you can use in-line zero-volt voltage sources as ammeters:
[... circuitry connecting to nodes 1 2 3 exactly as before...]
Vmon1 1 1a 0 ; now this voltage source serves as an ammeter whose current can be printed.
X1
1a 2 3 mysubckt


.print tran I(VMON1)


.subckt mysubckt A B C D
R1 A B
1  ; just an example, a device connected to node A
...
.ends



Finally, if you're likely to need the current through the nodes in every instance of the subcircuit, you can put the monitor voltage sources inside the subcircuit:

[... circuitry connecting to nodes 1 2 3 exactly as before...]
X1
1 2 3 mysubckt


.print tran I(X1:VMON1)


.subckt mysubckt A B C D


Vmon1 A 1a 0 ; and from here on throughout the subcircuit, connect devices to "1a" instead of A
...
.ends


I hope that is clear.

Roshni Uppala

unread,
Jun 19, 2014, 12:01:37 PM6/19/14
to xyce-...@googlegroups.com, xyce-...@googlegroups.com
Well that works too !


On Wednesday, June 18, 2014 2:55:28 PM UTC-4, xyce-users wrote:




On Wednesday, June 18, 2014 12:36:23 PM UTC-6, Roshni Uppala wrote:

Reply all
Reply to author
Forward
0 new messages