# Chapter 8: Two-Port Networks¶

## Example 8.1, Page 285¶

In [1]:
#Variable declaration
#From the figure 8.2
I1=1     #A

#Calculations
V1=6*I1     #V
Z11=V1/I1   #ohms
V2=6*I1     #V
Z21=V2/I1   #ohms
I2=1        #A
V1=6*I2     #V
Z12=V1/I2   #ohms
V2=6*I2     #V
Z22=V2/I2   #V
A=[[Z11,Z12],[Z21,Z22]]

#Result
print "A=",A

A= [[6, 6], [6, 6]]


## Example 8.2, Page 286¶

In [2]:
#Variable declaration
#From figure 8.3
I1=1        #A
V2=0        #V

#Calculations
V1=12*I1        #V
Z21=V2/I1       #ohms
Z11=V1/I1       #ohms
I2=1            #A
V2=3*I2         #V
V1=0            #V
Z12=V1/I2       #ohms
V2=3*I2         #V
Z22=V2/I2       #ohms
A=[[Z11,Z12],[Z21,Z22]]

#Result
print "A=",A

A= [[12, 0], [0, 3]]


## Example 8.3, Page 286¶

In [3]:
#Variable declaration
#From figure 8.4
I1=1    #A
I2=1    #A

#Calculations
V1=18*I1    #V
V2=6*I1     #V
Z11=V1/I1   #ohms
Z21=V2/I1   #ohms
V2=9*I2     #V
V1=6*I2     #V
Z12=V1/I2   #ohms
Z22=V2/I2   #ohms
A=[[Z11,Z12],[Z21,Z22]]

#Result
print "A=",A

A= [[18, 6], [6, 9]]


## Example 8.5, Page 290¶

In [4]:
#Variable declaration
#From figure 8.7
V2=1    #V
V1=1    #V
V2=0    #V

#Calculations
I1=0.05*V1      #A
I2=-0.05*V1     #A
Y11=I1/V1       #mho
Y21=I2/V1       #mho
I2=0.05*V2      #A
I1=-0.05*V2     #A
Y12=-0.05       #mho
Y22=0.05        #mho
A=[[Y11,Y12],[Y21,Y22]]

#Result
print "A=",A

A= [[0.05, -0.05], [-0.05, 0.05]]


## Example 8.6, Page 291¶

In [5]:
#Variable declaration
#From figure 8.8
V1=1    #V
V2=1    #V

#Calculations
I1=0.0225/0.325*V1  #A
VN=I1/(0.2+0.025)   #V
I2=-0.2*VN          #A
Y11=I1/V1           #mho
Y21=I2/V1           #mho
I2=0.025/0.325*V2   #A
VM=I2/(0.1+0.025)   #V
I1=-0.1*VM          #A
Y12=I1/V2           #mho
Y22=I2/V2           #mho
A=[[Y11,Y12],[Y21,Y22]]

#Result
print "A=",A

A= [[0.06923076923076922, -0.06153846153846154], [-0.061538461538461535, 0.07692307692307693]]


## Example 8.7, Page 292¶

In [6]:
#Variable declaration
#From figure 8.9
V1=1    #V
V2=1    #V

#Calculations
I1=0.1192*V1        #A
IN=0.05*I1/(0.05+(0.1*(0.2+0.025)/(0.1+0.2+0.025))) #A
IM=0.2*0.0692*V1/(0.2+0.025)    #A
I2=-(IN+IM) #A
Y11=I1/V1   #mho
Y21=I2/V1   #mho
I2=(0.05+0.2*(0.1+0.025)/(0.2+0.1+0.025))*V2    #A
IN=0.05*I2/(0.05+(0.2*(0.1+0.025)/(0.2+.1+0.025)))  #A
IM=0.1*0.0769*V2/(0.1+0.025)    #A
I1=-(IN+IM) #A
Y12=I1/V2   #mho
Y22=I2/V2   #mho
A=[[Y11,Y12],[Y21,Y22]]

#Result
print "A=",A

A= [[0.1192, -0.11152000000000001], [-0.11149820788530465, 0.12692307692307692]]


## Example 8.9, Page 297¶

In [7]:
#Variable declaration
#From figure 8.12
I1=1        #A

#Calculations
V1=14*I1    #V
I2=-2./3*I1  #A
h11=V1/I1
h21=I2/I1
V2=9*I2     #V
V1=6*I2     #V
h12=V1/V2
h22=I2/V2
A=[[h11,h12],[h21,h22]]

#Result
print "A=",A

A= [[14, 0.6666666666666666], [-0.6666666666666666, 0.1111111111111111]]


## Example 8.10, Page 299¶

In [8]:
#Variable declaration
#From figure 8.13
I1=1    #A

#Calculations
I2=-I1      #A
V1=I1       #V
B=-V1/I2
D=-I1/I2
V2=V1       #V
I1=0        #A
A=V1/V2
C=I1/V2
M=[[A,B],[C,D]]

#Result
print "A=",M

A= [[1, 1], [0, 1]]


## Example 8.14, Page 313¶

In [9]:
import math
import cmath

#Calculations&Results
V1in=0.5*((10*cmath.exp(complex(0,math.pi/180*0)))+(50*(.1*cmath.exp(complex(0,math.pi/180*40)))))
print "V1in=",V1in

V1ref=0.5*((10*cmath.exp(complex(0,math.pi/180*0)))-(50*(.1*cmath.exp(complex(0,math.pi/180*40)))))
print "V1ref=",V1ref

V2in=0.5*((12*cmath.exp(complex(0,math.pi/180*30)))+(50*(.15*cmath.exp(complex(0,math.pi/180*100)))))
print "V2in=",V2in

V2ref=0.5*((12*cmath.exp(complex(0,math.pi/180*30)))-(50*(.15*cmath.exp(complex(0,math.pi/180*100)))))
print "V2ref=",V2ref

V1in= (6.9151111078+1.60696902422j)
V1ref= (3.0848888922-1.60696902422j)
V2in= (4.54497175646+6.6930290738j)
V2ref= (5.84733308896-0.693029073796j)


## Example 8.17, Page 317¶

In [10]:
from fractions import Fraction

#Variable declaration
n=10.

#Calculations
S11=(n**2-1)/(n**2+1)
S11 = str(Fraction(S11).limit_denominator())
S21=2*n/(n**2+1)
S21 = str(Fraction(S21).limit_denominator())
S22=(1-n**2)/(1+n**2)
S22 = str(Fraction(S22).limit_denominator())
S12=2*n/(n**2+1)
S12 = str(Fraction(S12).limit_denominator())
A=[[S11,S12],[S21,S22]]

#Result
print "The S-parameters are:\n",A

The S-parameters are:
[['99/101', '20/101'], ['20/101', '-99/101']]


## Example 8.19, Page 319¶

In [11]:
#Variable declaration
Zo1=50  #ohms
Zo2=50  #ohms
Vs1=1   #V
Vs2=1   #V

#Calculations
Z1=complex(0,50)+(50*complex(0,-25)/complex(50,-25))
S11=(Z1-Zo1)/(Z1+Zo1)
Z2=(complex(50,50)*complex(0,-25))/complex(50,(50-25))
S22=(Z2-Zo2)/(Z2+Zo2)
V2=complex(10,-20)/complex(50,50)+complex(10,-20)*Vs1
S21=2*V2/Vs1
V2=complex(10,-30)/complex((50+10),-30)*Vs2
V1=50/complex(50,50)*V2
S12=2*V1/Vs2
A=[[S11,S12],[S21,S22]]

#Result
print "The Scattering parameters are:\n",A

The Scattering parameters are:
[[(-0.3333333333333333+0.6666666666666666j), -0.6666666666666666j], [(19.8-40.6j), (-0.3333333333333333-0.6666666666666666j)]]