####################################################################################################

#r# ============================
#r#  Thévenin and Norton Theorem
#r# ============================

#r# The Thévenin's theorem holds that:
#r#
#r#  * Any linear electrical network with voltage and current sources and only resistances can be
#r#    replaced at terminals A-B by an equivalent voltage source Vth in series connection with an
#r#    equivalent resistance Rth.
#r#
#r#  * This equivalent voltage Vth is the voltage obtained at terminals A-B of the network with
#r#    terminals A-B open circuited.
#r#
#r#  * This equivalent resistance Rth is the resistance obtained at terminals A-B of the network
#r#    with all its independent current sources open circuited and all its independent voltage
#r#    sources short circuited.
#r#
#r# The Norton's theorem holds that:
#r#
#r#  * Any linear electrical network with voltage and current sources and only resistances can be
#r#    replaced at terminals A-B by an equivalent current source INO in parallel connection with an
#r#    equivalent resistance Rno.
#r#
#r#  * This equivalent current Ino is the current obtained at terminals A-B of the network with
#r#    terminals A-B short circuited.
#r#
#r#  * This equivalent resistance Rno is the resistance obtained at terminals A-B of the network
#r#    with all its voltage sources short circuited and all its current sources open circuited.
#r#
#r# The Norton's theorem is the dual of the Thévenin's therorem and both are related by
#r# these equations:
#r#
#r#  .. math::
#r#
#r#       \begin{align}
#r#         R_{no} & = R_{th} \\
#r#         I_{no} & = V_{th} / R_{th} \\
#r#         V_{th} & = I_{No} R_{no}
#r#       \end{align}

#f# circuit_macros('thévenin-norton-theorem.m4')

#r# In circuit theory terms, these theorems allows any one-port network to be reduced to a single
#r# voltage or current source and a single impedance.
#r#
#r# For AC circuits these theorems can be applied to reactive impedances as well as resistances.

#?# These theorems also applies to frequency domain AC circuits consisting of reactive and resistive
#?# impedances.

####################################################################################################

import PySpice.Logging.Logging as Logging
logger = Logging.setup_logging()

####################################################################################################

from PySpice.Spice.Netlist import Circuit
from PySpice.Unit import *

####################################################################################################

thevenin_circuit = Circuit('Thévenin Representation')

thevenin_circuit.V('input', 1, thevenin_circuit.gnd, 10@u_V)

simulator = thevenin_circuit.simulator(temperature=25, nominal_temperature=25)
analysis = simulator.operating_point()

#o#

norton_circuit = Circuit('Norton Representation')

thevenin_circuit.Vinput.dc_value/thevenin_circuit.Rgenerator.resistance)

simulator = norton_circuit.simulator(temperature=25, nominal_temperature=25)
analysis = simulator.operating_point()

#o#


# 8.8.2. Thévenin and Norton Theorem¶

The Thévenin’s theorem holds that:

• Any linear electrical network with voltage and current sources and only resistances can be replaced at terminals A-B by an equivalent voltage source Vth in series connection with an equivalent resistance Rth.
• This equivalent voltage Vth is the voltage obtained at terminals A-B of the network with terminals A-B open circuited.
• This equivalent resistance Rth is the resistance obtained at terminals A-B of the network with all its independent current sources open circuited and all its independent voltage sources short circuited.

The Norton’s theorem holds that:

• Any linear electrical network with voltage and current sources and only resistances can be replaced at terminals A-B by an equivalent current source INO in parallel connection with an equivalent resistance Rno.
• This equivalent current Ino is the current obtained at terminals A-B of the network with terminals A-B short circuited.
• This equivalent resistance Rno is the resistance obtained at terminals A-B of the network with all its voltage sources short circuited and all its current sources open circuited.

The Norton’s theorem is the dual of the Thévenin’s therorem and both are related by these equations:

\begin{split}\begin{align} R_{no} & = R_{th} \\ I_{no} & = V_{th} / R_{th} \\ V_{th} & = I_{No} R_{no} \end{align}\end{split}

In circuit theory terms, these theorems allows any one-port network to be reduced to a single voltage or current source and a single impedance.

For AC circuits these theorems can be applied to reactive impedances as well as resistances.

import PySpice.Logging.Logging as Logging
logger = Logging.setup_logging()

from PySpice.Spice.Netlist import Circuit
from PySpice.Unit import *

thevenin_circuit = Circuit('Thévenin Representation')

thevenin_circuit.V('input', 1, thevenin_circuit.gnd, 10@u_V)

simulator = thevenin_circuit.simulator(temperature=25, nominal_temperature=25)
analysis = simulator.operating_point()


[1;32m2019-03-10 18:51:06,021[0m - [1;34mPySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char[0m - [1;31mERROR[0m - Warning - approaching max data size: current size =  823.531 MB, limit =  798.043 MB

[1;32m2019-03-10 18:51:06,022[0m - [1;34mPySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char[0m - [1;31mERROR[0m - Warning - approaching max data size: current size =  823.531 MB, limit =  798.043 MB

[1;32m2019-03-10 18:51:06,023[0m - [1;34mPySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char[0m - [1;31mERROR[0m - Warning - approaching max data size: current size =  823.531 MB, limit =  798.043 MB

[1;32m2019-03-10 18:51:06,023[0m - [1;34mPySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char[0m - [1;31mERROR[0m - Warning - approaching max data size: current size =  823.531 MB, limit =  798.043 MB

[1;32m2019-03-10 18:51:06,024[0m - [1;34mPySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char[0m - [1;31mERROR[0m - Warning - approaching max data size: current size =  823.531 MB, limit =  798.043 MB

[1;32m2019-03-10 18:51:06,024[0m - [1;34mPySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char[0m - [1;31mERROR[0m - Warning - approaching max data size: current size =  823.555 MB, limit =  798.043 MB

[1;32m2019-03-10 18:51:06,025[0m - [1;34mPySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char[0m - [1;31mERROR[0m - Warning - approaching max data size: current size =  823.676 MB, limit =  798.043 MB

[1;32m2019-03-10 18:51:06,025[0m - [1;34mPySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char[0m - [1;31mERROR[0m - Warning - approaching max data size: current size =  823.836 MB, limit =  798.043 MB

[1;32m2019-03-10 18:51:06,026[0m - [1;34mPySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char[0m - [1;31mERROR[0m - Warning - approaching max data size: current size =  823.898 MB, limit =  798.043 MB

[1;32m2019-03-10 18:51:06,027[0m - [1;34mPySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char[0m - [1;31mERROR[0m - Warning - approaching max data size: current size =  823.930 MB, limit =  798.043 MB

[1;32m2019-03-10 18:51:06,027[0m - [1;34mPySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char[0m - [1;31mERROR[0m - Warning - approaching max data size: current size =  823.980 MB, limit =  798.043 MB

[1;32m2019-03-10 18:51:06,028[0m - [1;34mPySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char[0m - [1;31mERROR[0m - Warning - approaching max data size: current size =  823.980 MB, limit =  798.043 MB

[1;32m2019-03-10 18:51:06,032[0m - [1;34mPySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char[0m - [1;31mERROR[0m - Warning - approaching max data size: current size =  824.238 MB, limit =  798.043 MB

[1;32m2019-03-10 18:51:06,033[0m - [1;34mPySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char[0m - [1;31mERROR[0m - Warning - approaching max data size: current size =  824.238 MB, limit =  798.043 MB

[1;32m2019-03-10 18:51:06,034[0m - [1;34mPySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char[0m - [1;31mERROR[0m - Warning - approaching max data size: current size =  824.238 MB, limit =  798.043 MB

[1;32m2019-03-10 18:51:06,040[0m - [1;34mPySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char[0m - [1;31mERROR[0m - Warning - approaching max data size: current size =  824.438 MB, limit =  798.043 MB


norton_circuit = Circuit('Norton Representation')

thevenin_circuit.Vinput.dc_value/thevenin_circuit.Rgenerator.resistance)

[1;32m2019-03-10 18:51:06,062[0m - [1;34mPySpice.Spice.NgSpice.Shared.NgSpiceShared._send_char[0m - [1;31mERROR[0m - Warning - approaching max data size: current size =  824.820 MB, limit =  798.043 MB