PySpice icon indicating copy to clipboard operation
PySpice copied to clipboard

How can we measure voltage between two points to write expression in behavioral voltage source?

Open prajapatisantlal opened this issue 3 years ago • 2 comments

I writing an expression in a subcircuit with pyspice as V(x,y) where x and y are two nodes. How to fix it?

prajapatisantlal avatar Sep 10 '21 08:09 prajapatisantlal

It is quite hard to understand exactly what you are asking? Can you give an example?

The first thing that came to mind for me is the expressions you might write for a B source. For example, a step function:

Consider two nodes "in" and "out". Lets write out current defined equation (in this case an if statement) based on the voltages at these nodes: i_express = "((v(in)-v(out))>0) ? 1 : 0" # i.e., if V(in,out) > 0 then i=1, else i=0 Now, we use this to define the current of the B source component: self.B('myB1', 'in', 'out', i=i_express)

As far as I remember, when writing in the raw spice (which is what you are basically doing here) the voltage between two nodes is not defined as V(x,y) but as v(x)-v(y). Though you can look at the NGSpice manual to check this. I hope this helped?

benedictjones avatar Sep 13 '21 09:09 benedictjones

Thank you benedictjones. I exactally want this.

santlal123 avatar Sep 19 '21 13:09 santlal123