When to choose a ZDF

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

Z1202 wrote:
stratum wrote:For the voltage law, the use absolute potentials rather than potential differences in the equations does not solve the redundancy problem
Why not? In the example ABCD we have

Va-Vb=Iab*R5
Vb-Vc=Ibc*R1
Vc-Vd=Icd*R4
Va-Vd=1V
Vd=0
Iab-Ibc=0
Ibc-Icd=0
Icd-Ida=0

Looks to me like a well-defined system.
Well, it's correct that this is a well-defined system, but for the second example the cycle-finding algorithm would output a third equation that would need to be discarded using whatever means available. For convenience here is the same picture again:

Vda+Vab+Vbc+Vcd=0
Vdc+Vce+Vef+Vfd=0
Vda+Vab+Vbc+Vce+Vef+Vfd+Vda=0 (redundant)

If we rewrite these equations using absolute potentials, the third equation is still redundant.
You do not have the required permissions to view the files attached to this post.
~stratum~

Post

stratum wrote:Well, it's correct that this is a well-defined system, but for the second example the cycle-finding algorithm would output a third equation that would need to be discarded using whatever means available.
Hmm, let's try in the way I proposed.

The equations for absolute voltages:
Va-Vb=Iab*R1
Vb-Vc=Ibc*R6
Vd-Va=Ida*R4
Vc-Vd=Icd*R2
Vc-Ve=Ice*R8
Ve-Vf=Ief*R3
Vf-Vd=Ifd*R7
Vc=0

The Kirchhoff's equations:
Ida=Iab
Iab=Ibc
Icd=Ibc-Ice
Icd=Ida-Ifd
Ice=Ief
Ifd=Ief

Removing redundancy from Kirchhoff's equations (formally can be done as removing linearly dependent rows from Kirchhoff law matrix):
Ida=Iab=Ibc
Ice=Ief=Ifd
Icd=Ibc-Ifd
Icd=Ibc-Ifd
Thus the currents are expressible in terms of Ibc and Ifd:
Va-Vb=Ibc*R1
Vb=Ibc*R6
Vd-Va=Ibc*R4
-Vd=(Ibc-Ifd)*R2
-Ve=Ifd*R8
Ve-Vf=Ifd*R3
Vf-Vd=Ifd*R7
5 voltage variables, 2 current variables, 7 equations.

Post

Z1202 wrote: @mystran: I never took any serious look at nodal analysis, however, from what you're writing (everything expressed in terms of currents), I wonder whether that's the origin of using weird state variables (such as currents for capacitor based systems).
I'm not quite sure what you mean by weird state variables. Capacitors integrate currents so in order to actually simulate them you need to solve for the current either way. The point of nodal analysis is just that you don't need to do any fancy graph analysis.
It also looks like, given that we have an efficient way to eliminate the linearly dependent rows if the Kirchhoff's law matrix, we can perform the "natural analysis" in terms of absolute potentials and currents. Or, is there anything else that I'm missing?
Ultimately you just want to build some sort of DAE that describes your circuit. How you choose to do it is really just a matter of convenience. MNA is popular because it's simple to automate (no fancy graph-analysis required) and results in reasonably sized matrices (eg. compared to "sparse tableau approach" for example, which in some sense would be even easier to implement), but you can build other arithmetics into your matrices if you want to (eg. you can let the matrix solver figure out voltages over components like diodes automatically, or even encode the integration rule into the matrix directly; I've tried both, it works and reduces "scaffolding" if your matrix solver is good at throwing away stuff you don't need).
Last edited by mystran on Thu Nov 30, 2017 9:33 pm, edited 1 time in total.

Post

Hmm, let's try in the way I proposed.

The equations for absolute voltages:
Va-Vb=Iab*R1
Vb-Vc=Ibc*R6
Vd-Va=Ida*R4
Vc-Vd=Icd*R2
Vc-Ve=Ice*R8
Ve-Vf=Ief*R3
Vf-Vd=Ifd*R7
Vc=0

The Kirchhoff's equations:
Ida=Iab
Iab=Ibc
Icd=Ibc-Ice
Icd=Ida-Ifd
Ice=Ief
Ifd=Ief

Removing redundancy from Kirchhoff's equations (formally can be done as removing linearly dependent rows from Kirchhoff law matrix):
Ida=Iab=Ibc
Ice=Ief=Ifd
Icd=Ibc-Ifd
Icd=Ibc-Ifd
Thus the currents are expressible in terms of Ibc and Ifd:
Va-Vb=Ibc*R1
Vb=Ibc*R6
Vd-Va=Ibc*R4
-Vd=(Ibc-Ifd)*R2
-Ve=Ifd*R8
Ve-Vf=Ifd*R3
Vf-Vd=Ifd*R7
5 voltage variables, 2 current variables, 7 equations.
But you haven't done this the way a computer program would do it. A mindless machine following the voltage law regarding the node cycles would write:

Vda+Vab+Vbc+Vcd=0
from this we have:
(-Ida*R4) +(-Iab*R1)+(-Ibc*R6)+(-Icd*R2)=0

Vdc+Vce+Vef+Vfd=0
from this we have:
(-Idc*R2) +(-Ice*R8)+(-Ief*R3)+(-Ifd*R7) = 0

Vda+Vab+Vbc+Vce+Vef+Vfd=0
from this we have:
(-Ida*R4)+(-Iab*R1)+(-Ibc*R6)+(-Ice*R8)+(-Ief*R3)+(-Ifd*R7) = 0

Because these are what the cycles in the graph are (D-A-B-C-D, D-C-E-F-D, D-A-B-C-E-F-D).

Since I have traversed the netlist in a consistent direction we don't need to do any swapping like Ixy=-Iyx but the third equation is still redundant.

Taking Vda = Va-Vd doesn't change anything because following the voltage law regarding the cycles we still write the same equations in terms of current and the third is still redundant.

This is apparently "mesh analysis" as mystran says and I wasn't aware that we aren't supposed to do this in nodal analysis. So we either use the voltage law or the current law, and not both.
You do not have the required permissions to view the files attached to this post.
Last edited by stratum on Thu Nov 30, 2017 9:35 pm, edited 1 time in total.
~stratum~

Post

stratum wrote:But you haven't done this the way a computer program would do it. A mindless machine following the voltage law regarding the node cycles would write:

Vda+Vab+Vbc+Vcd=0
No, it wouldn't! The "mindless machine" doesn't have to deal with relative voltages. It can equally good do absolute.

What I described is fully prepared to be done by a "mindless" machine.

Step 1: Introduce absolute voltage at every node and a current through every edge.
Step 2: Randomly choose one of the voltages to be zero (or any constant)
Step 3: Write Ohm equations for the edges (that's one half of the matrix rows)
Step 4: Write Kirchhoff's equations for the nodes (that's the other half)
Step 5: Eliminate redundancy in Kirchhoff's equations by deleting linearly dependent rows from the matrix (by a particular kind of Gaussian elimination process)
Step 6: Enjoy a well-defined equation system which can be solved using a linear algebra routine.
Last edited by Z1202 on Thu Nov 30, 2017 9:38 pm, edited 1 time in total.

Post

No, it wouldn't! The "mindless machine" doesn't have to deal with relative voltages. It can equally good do absolute.
Yeah, because it's doing mesh analysis, apparently.

The basic circuit theory book I have doesn't describe the automation of the process and from the text it's not apparent that the voltage and current rules are not supposed to be used simultaneously. The voltage rule always yields redundant equations if the graph is like the one above, regardless of whether we use absolute or relative potentials. This is because the graph has cycles D-A-B-C-D, D-C-E-F-D and D-A-B-C-E-F-D, and the third one isn't necessary but the 'mindless machine' needs to do something about it.
Last edited by stratum on Thu Nov 30, 2017 9:40 pm, edited 1 time in total.
~stratum~

Post

stratum wrote:
No, it wouldn't! The "mindless machine" doesn't have to deal with relative voltages. It can equally good do absolute.
Yeah, because it's doing mesh analysis, apparently.

The basic circuit theory book I have doesn't describe the automation of the process and from the text it's not apparent that the voltage and current rules are not supposed to be used simultaneously. The voltage rule always yields redundant equations if the graph is like the one above, regardless of whether we use absolute or relative potentials.
I feel a bit strange. You claim that _your_ method delivers redundant voltage equations. I claim that _my_ method doesn't. You argue that with the fact that _your_ method does. Etc.

PS. Maybe you didn't see the edit to the previous post.

Post

If feel a bit strange. You claim that _your_ method delivers redundant voltage equations. I claim that _my_ method doesn't. You argue that with the fact that _your_ method does. Etc.
Yes, I'm not arguing that your method is wrong, I'm saying that I was doing mesh analysis without realizing it, and absolute potentials do not fix it.
PS. Maybe you didn't see the edit to the previous post.
Perhaps, I'll look again.
~stratum~

Post

I have looked again, and yes indeed I haven't seen the edited version, but still:
Step 4: Write Kirchhoff's equations for the nodes (that's the other half)
This is Kirchhoff's current law, and I was using the voltage law, which is about cycles, not about nodes. In turn, this is apparently called 'mesh analysis' (i.e. apparently voltage and current laws together are redundant).

i.e. usage of the voltage law = mesh analysis
usage of the current law = nodal analysis

and using both together is apparently unnecessary.
~stratum~

Post

Maybe you should use voltage law in a different way, like I proposed? This way the cycles will be implicitly covered by the absolute variables. And I did detail an example showing how this happens (your ABCDEF circuit).
Last edited by Z1202 on Thu Nov 30, 2017 9:47 pm, edited 1 time in total.

Post

stratum wrote: This is apparently "mesh analysis" as mystran says and I wasn't aware that we aren't supposed to do this in nodal analysis. So we either use the voltage law or the current law, and not both.
For nodal analysis of your circuit, you'd specify the currents like this:

(G1+G4)*vA - G1*vB - G4*vD = 0
(G1+G6)*vB - G1*vA - G6*vC = 0
(G2+G6+G8)*vC - G2*vD - G6*vB - G8*vE = 0
(G4+G2+G7)*vD - G4*vA - G2*vC - G7*vF = 0
(G8+G3)*vE - G8*vC - G3*vF = 0
(G7+G3)*vF - G3*vE - G7*vD = 0

where G1 = 1/R1, G2 = 1/R2 ...

[edit: I wrote it in this way (rather than in terms of voltage differences) to make it easier to see how to put the whole thing into a matrix equation, where the voltages are the unknown vector; I opted not to write it in matrix form to spare you from the ASCII art]

In other words, we're trying to solve v from G*v = i, instead of trying to solve i from R*i=v (where R=G^-1).

Observe that when a computer sees a resistor in the netlist, it just adds a stamp like [[G,-G],[-G,G]] in the system matrix to connect the two nodes of interest. For components with more pins, the stamps get larger, but the same idea applies.

edit: note that in order to actually solve the system (which is "floating" right now) we should pick some node as a "reference ground" and drop the relevant row/column, otherwise there are infinitely many valid solutions.
Last edited by mystran on Thu Nov 30, 2017 9:55 pm, edited 2 times in total.

Post

mystran wrote:
Z1202 wrote: @mystran: I never took any serious look at nodal analysis, however, from what you're writing (everything expressed in terms of currents), I wonder whether that's the origin of using weird state variables (such as currents for capacitor based systems).
I'm not quite sure what you mean by weird state variables. Capacitors integrate currents so in order to actually simulate them you need to solve for the current either way.
I was referring to the choice of currents as state variables of the system (those which end up as differential variables of the state-space representation). IMHO this is natural for inductors, but not so natural for capacitors.

Edit: it might be even incorrect, if the equations are solved under time-invariant assumption and then the parameters are varied in realtime.
mystran wrote:Ultimately you just want to build some sort of DAE that describes your circuit. How you choose to do it is really just a matter of convenience. MNA is popular because it's simple to automate (no fancy graph-analysis required) and results in reasonably sized matrices (eg. compared to "sparse tableau approach" for example, which in some sense would be even easier to implement), but you can build other arithmetics into your matrices if you want to (eg. you can let the matrix solver figure out voltages over components like diodes automatically, or even encode the integration rule into the matrix directly; I've tried both, it works and reduces "scaffolding" if your matrix solver is good at throwing away stuff you don't need).
It's not that I'm trying to claim that MNA doesn't work. And as long as it's happening fully under the hood of a software piece, it doesn't matter. It's that I'm regularly hearing of people doing this by hand, and I can't figure out the reason why, except maybe inavailability of descriptions of other "more human-friendly" methods :D

Edit: also see the "time-varying" edit comment above.
Last edited by Z1202 on Thu Nov 30, 2017 9:59 pm, edited 1 time in total.

Post

Z1202 wrote:Maybe you should use voltage law in a different way, like I proposed? This way the cycles will be implicitly covered by the absolute variables. And I did detail an example showing how this happens (your ABCDEF circuit).
Step 4 ('Write Kirchhoff's equations for the nodes') implies the usage of the current law. The voltage law always yields 3 equations (one being redundant) for that circuit because the corresponding graph has 3 cycles. The algorithm needs to proceed from that point and needs to figure out what to do about the third equation.

The fact that cycles are implicitly covered when one proceeds from the current law means Kirchhoff's laws are redundant.
Last edited by stratum on Thu Nov 30, 2017 10:02 pm, edited 1 time in total.
~stratum~

Post

stratum wrote:
Z1202 wrote:Maybe you should use voltage law in a different way, like I proposed? This way the cycles will be implicitly covered by the absolute variables. And I did detail an example showing how this happens (your ABCDEF circuit).
Step 4 implies the usage of the current law. The voltage law always yields 3 equations (one being redundant) for that circuit because the corresponding graph has 3 cycles. The algorithm needs to proceed from that point and needs to figure out what to do about the third equation.
Again. I propose to abandon the way how you use the voltage law, and address it differently, in the way I showed. The absolute voltages are the thing which does the trick here (lets you do without your version of voltage law, which becomes implicitly contained in your choice of variables).

Post

Z1202 wrote:It's not that I'm trying to claim that MNA doesn't work. And as long as it's happening fully under the hood of a software piece, it doesn't matter. It's that I'm regularly hearing of people doing this by hand, and I can't figure out the reason why, except maybe inavailability of descriptions of other "more human-friendly" methods :D
I think people just have irrational fear of code-generators, even though there are problems (like this one) where anything else is just utter non-sense.

Post Reply

Return to “DSP and Plugin Development”