PySpice
PySpice copied to clipboard
B source : how to define a current-dependent voltage source
I'm trying to define a non linear component using current-dependent voltage source :
circuit = Circuit('Voltage Divider')
circuit.V('alim',circuit.gnd, 'n1', 10@u_V)
circuit.V('Vdummy','n1', 'n2', 0)
circuit.B('RNL','n2', 'n3', v="0.001*i(VVdummy)**2")
circuit.R('R', 'n3', circuit.gnd, 1@u_kΩ)
simulator = circuit.simulator(temperature=25, nominal_temperature=25)
analysis = simulator.operating_point()
i get the following message error : NameError: name 'i' is not defined. Did you mean: 'id'?
If i define a voltage dependant current source (i.e. using the expression i="(v(n2)-v(n1))**2") that works... what's the trick with current dependent voltage source ?
Hi, to my knowledge, a current-dependent voltage source is a CCVS : 4.2.4 Hxxxx: Linear Current-Controlled Voltage Sources (CCVS)
Though I have never tested it yet, according to PySpice documentation : CurrentControlledVoltageSource you can instantiate with :
circuit.H('Vout', 'node1', 'node2', source='nodetosensecurrent', transresistance=float(coefficient))