##Two-Port Networks : example 11.16 :(pg11.39 )
V1s=25.;
import math
I1s=1.;
I2s=2.;
V1o=10.;
V2o=50.;
I2o=2.;
h11=(V1s/I1s);
h21=(I2s/I1s);
h12=(V1o/V2o);
h22=(I2o/V2o);
print"%s %.2f %s"%("\nh11 = V1/I1 = ",h11," Ohm");##when V2=0
print"%s %.2f %s"%("\nh21= I2/I1 = ",h21,"");##when V2=0
print"%s %.2f %s"%("\nh12 = V1/V2 =",h12,"");##when I1=0
print"%s %.2f %s"%("\nh22 = I2/V2 = ",h22," mho");##when I1=0
print("\nth h-parameters are");
print([[h11 ,h12],[h21, h22]]);
##Two-Port Networks : example 11.19 :(pg11.49 & 11.50)
Z11=20.;
import math
Z22=30.;
Z12=10.;
Z21=10.;
dZ=((Z11*Z22)-(Z12*Z21));
Y11=(Z22/dZ);
Y12=(-Z12/dZ);
Y21=(-Z21/dZ);
Y22=(Z11/dZ);
A=(Z11/Z21);
B=(dZ/Z21);
C=(1./Z21);
D=(Z22/Z21);
print("\nY-parameters");
print"%s %.2f %s"%("\nY11 = Z22/dZ = ",Y11," mho");
print"%s %.2f %s"%("\nY12 = -Z12/dZ = ",Y12," mho");
print"%s %.2f %s"%("\nY21 = -Z21/dZ = ",Y21," mho");
print"%s %.2f %s"%("\nY22 = Z11/dZ = ",Y22," mho");
print("\n Y-parameters are:");
print([[Y11, Y12],[Y21, Y22]]);##Y-parameters in matrix form
print("\nABCD parameters");
print"%s %.2f %s"%("\nA = Z11/Z21 = ",A,"");
print"%s %.2f %s"%("\nB = dZ/Z21 = ",B,"");
print"%s %.2f %s"%("\nC = 1/Z21 = ",C,"");
print"%s %.2f %s"%("\nD = Z22/Z21 = ",D,"");
print("\n ABCD parameters are:");
print([[A ,B],[C ,D]]);##ABCD parameters in matrix form
##Two-Port Networks : example 11.20 :(pg11.50 & 11.51)
a=0.5;
import math
b=-0.2;
d=1.
print("\nI1 =0.5V1-0.2V2 \nI2=-0.2V1+V2");
print"%s %.2f %s"%("\n Y11 =I1/V1 = ",a,"mho");##when V2 is 0 in the 1st eqn
print"%s %.2f %s"%("\n Y21 =I2/V1 = ",b," mho");##when V2 is 0 in the 1st eqn
print"%s %.2f %s"%("\n Y12 =I1/V2 = ",b," mho");##when V1 is 0 in the 2nd eqn
print"%s %.2f %s"%("\n Y22 =I2/V2 = ",d," mho");##when V1 is 0 in the 2nd eqn
print("\nY-parameters are");
print([[a, b],[b ,d]]);
dY=((a*d)-(b*b));
Z11=(d/dY);
Z12=(-b/dY);
Z21=(-b/dY);
Z22=(a/dY);
A=(-d/b);
C=(-dY/b);
D=(-a/b);
print"%s %.2f %s"%("\ndY=Y11.Y22-Y12.Y21 =",dY,"");
print"%s %.2f %s"%("\nZ11 = Y22/dY = ",Z11," Ohm");
print"%s %.2f %s"%("\nZ12 = -Y12/dY = ",Z12," Ohm");
print"%s %.2f %s"%("\nZ21 = -Y21/-dY = ",Z21," Ohm");
print"%s %.2f %s"%("\nZ22 = Y11/dY = ",Z22," Ohm");
print("\nZ-parameters :");
x=([[Z11, Z12],[Z21, Z22]])
print(x)
print"%s %.2f %s"%("\nA =-Y22/Y21 =",A,"");
print"%s %.2f %s"%("\nB = -1/Y21 =",A,"");
print"%s %.2f %s"%("\nC = -dY/Y21 =",C,"");
print"%s %.2f %s"%("\nD = -Y11/Y21 =",D,"");
print("\nABCD parameters :");
print([[A, A],[C ,D]]);
#due to round off error
##Two-Port Networks : example 11.22 :(pg11.52 & 11.53)
print("\nApplying KVL to Mesh 1 \nV1 = I1 - I3 - - - -(i)");
print("\nApplying KVL to Mesh 2 \nV2 = -4I2 + 2I3 - - - -(ii)");
print("\nApplying KVL to Mesh 3 \nI3 = (1/5)I1 + (4/5)I2 - - - -(iii)");
##substituting (iii) in (i) & (ii),we get
print("\nV1 = (4/5)I1 - (4/5)I2 \nV2 = (2/5)I1 - (12/5)I2");
print("\nZ-parameters:");
a=4./5.;b=-4/5.;c=2/5.;d=-12/5.;
print([[a, b],[c, d]]);
dZ=(a*d)-(b*c);
Y11=(d/dZ);
Y12=(-b/dZ);
Y21=(-c/dZ);
Y22=(a/dZ);
print("\nY-parameters are:");
print"%s %.2f %s"%("\ndZ = Z11.Z22 - Z12.Z21 = ",dZ,"");
print"%s %.2f %s"%("\nY11 = Z22/dZ = ",Y11," mho");
print"%s %.2f %s"%("\nY12 = -Z12/dY = ",Y12," mho");
print"%s %.2f %s"%("\nY21 = -Z21/-dY = ",Y21," mho");
print"%s %.2f %s"%("\nY22 = Z11/dY = ",Y22," mho");
print([[Y11, Y12],[Y21, Y22]]);
##Two-Port Networks : example 11.23 :(pg11.53 & 11.54)
print("\nApplying KVL to Mesh 1 \nV1 = 4I1 - 2I3 - - - -(i)");
print("\nApplying KVL to Mesh 2 \nV2 = 4I2 + 2I3 - - - -(ii)");
print("\nApplying KVL to Mesh 3 \n-2I3 = I1 + I2 - - - -(iii)");
##substituting (iii) in (i) & (ii),we get
print("\nV1 = 5I1 + I2 \nV2 = -I1 + 3I2");
print("\nZ-parameters:");
a=5.;b=1.;c=-1.;d=3.;
print([[a, b],[c ,d]]);
dZ=(a*d)-(b*c);
h11=(dZ/d);
h12=(b/d);
h21=(-c/d);
h22=(.1/d);
print"%s %.2f %s"%("\ndZ = Z11.Z22 - Z12.Z21 =",dZ,"");
print"%s %.2f %s"%("\nh11 = dZ/Z22 = ",h11,"");
print"%s %.2f %s"%("\nh12 = Z12/Z22 = ",h12,"");
print"%s %.2f %s"%("\nh21 = -Z21/Z22 = ",h21,"");
print"%s %.2f %s"%("\nh22 = 1/Z22 = ",h22,"");
print("\nh-parameters are:");
print([[h11 ,h12],[h21 ,h22]]);
##Two-Port Networks : example 11.24 :(pg11.54 & 11.55)
print("\nApplying KCL to Node 3 \nV3 = V2/3 - - - -(i)");
print("\nI1 = 2V1 - (2/3)V2 - - - -(ii)");
print("\nI2 = 3V2 - (V2/3) = (8/3)V2 - - - -(iii)");
##Comparing (iii) & (ii) ,we get
print("\nY-parameters:");
a=2;b=(-2/3.);c=0;d=(8/3.);
print([[a, b],[b ,d]]);
dY=((a*d)-(b*c));
Z11=(d/dY);
Z12=(-b/dY);
Z21=(c/dY);
Z22=(a/dY);
print"%s %.2f %s"%("\ndY=Y11.Y22-Y12.Y21 =",dY,"");
print"%s %.2f %s"%("\nZ11 = Y22/dY =",Z11," Ohm");
print"%s %.2f %s"%("\nZ12 = -Y12/dY = ",Z12," Ohm");
print"%s %.2f %s"%("\nZ21 = -Y21/-dY = ",Z21," Ohm");
print"%s %.2f %s"%("\nZ22 = Y11/dY = ",Z22," Ohm");
print("\nZ-parameters :");
print([[Z11, Z12],[Z21, Z22]]);
##Two-Port Networks : example 11.25 :(pg11.55 & 11.56)
print("\nApplying KCL to Node 1 \nI1 = (-3/2)V1 - V2- - -(i)");
print("\nApplying KCL to Node 2 \nI2 = 2V1 + 2V2 - - - -(ii)");
##observing (i) & (ii)
print("\nY-parameters:");
a=(-3/2.);b=(-1);c=2.;d=2.;
print([[a, b],[c ,d]]);
dY=((a*d)-(b*c));
Z11=(d/dY);
Z12=(-b/dY);
Z21=(-c/dY);
Z22=(a/dY);
print"%s %.2f %s"%("\ndY=Y11.Y22-Y12.Y21 =",dY,"");
print"%s %.2f %s"%("\nZ11 = Y22/dY = ",Z11," Ohm");
print"%s %.2f %s"%("\nZ12 = -Y12/dY =",Z12," Ohm");
print"%s %.2f %s"%("\nZ21 = -Y21/-dY = ",Z21," Ohm");
print"%s %.2f %s"%("\nZ22 = Y11/dY = ",Z22," Ohm");
print("\nZ-parameters :");
print([[Z11 ,Z12],[Z21, Z22]]);
##Two-Port Networks : example 11.22 :(pg11.52 & 11.53)
print("\nApplying KVL to Mesh 1 \nV1 = 2I1 + I2 - - - -(i)");
print("\nApplying KVL to Mesh 2 \nV2 = 10I1 + 11I2 - - - -(ii)");
##observing (i) & (ii)
print("\nV1 = (4/5)I1 - (4/5)I2 \nV2 = (2/5)I1 - (12/5)I2");
print("\nZ-parameters:");
a=2.;b=1.;c=10.;d=11.;
print([[a, b],[c ,d]]);
dZ=(a*d)-(b*c);
Y11=(d/dZ);
Y12=(-b/dZ);
Y21=(-c/dZ);
Y22=(a/dZ);
print("\nY-parameters are:");
print"%s %.2f %s"%("\ndZ = Z11.Z22 - Z12.Z21 = ",dZ,"");
print"%s %.2f %s"%("\nY11 = Z22/dZ = ",Y11," mho");
print"%s %.2f %s"%("\nY12 = -Z12/dY = ",Y12," mho");
print"%s %.2f %s"%("\nY21 = -Z21/-dY = ",Y21," mho");
print"%s %.2f %s"%("\nY22 = Z11/dY = ",Y22," mho");
print([[Y11, Y12],[Y21, Y22]]);
h11=(dZ/d);
h12=(b/d);
h21=(-c/d);
h22=(1/d);
print"%s %.2e %s"%("\ndZ = Z11.Z22 - Z12.Z21 =",dZ,"");
print"%s %.2e %s"%("\nh11 = dZ/Z22 = ",h11,"");
print"%s %.2f %s"%("\nh12 = Z12/Z22 = ",h12,"");
print"%s %.2e %s"%("\nh21 = -Z21/Z22 = ",h21,"");
print"%s %.2e %s"%("\nh22 = 1/Z22 = ",h22,"");
print("\nh-parameters are:");
print([[h11 ,h12],[h21 ,h22]]);
##Two-Port Networks : example 11.27 :(pg11.58)
print("\nApplying KCL to Node 1 \nI1 = 4V1 - 3V2- - -(i)");
print("\nApplying KCL to Node 2 \nI2 = -3V1 + 1.5V2 - - - -(ii)");
##observing (i) & (ii)
print("\nY-parameters:");
a=4.;b=(-3);c=(-3);d=1.5;
print([[a ,b],[c ,d]]);
dY=((a*d)-(b*c));
Z11=(d/dY);
Z12=(-b/dY);
Z21=(-c/dY);
Z22=(a/dY);
print"%s %.2f %s"%("\ndY=Y11.Y22-Y12.Y21 =",dY,"");
print"%s %.2f %s"%("\nZ11 = Y22/dY = ",Z11," Ohm");
print"%s %.2f %s"%("\nZ12 = -Y12/dY =",Z12," Ohm");
print"%s %.2f %s"%("\nZ21 = -Y21/-dY = ",Z21," Ohm");
print"%s %.2f %s"%("\nZ22 = Y11/dY = ",Z22," Ohm");
print("\nZ-parameters :");
print([[Z11 ,Z12],[Z21, Z22]]);
##Two-Port Networks : example 11.28 :(pg11.58 & 11.59)
("\nApplying KCL to Node 1 \nI1 = 1.5V1 - 0.5V2- - -(i)");
print("\nApplying KCL to Node 2 \nI2 = 4V1 - 0.5V2 - - - -(ii)");
##observing (i) & (ii)
print("\nY-parameters:");
a=1.5;b=(-0.5);c=(4);d=(-0.5);
print([[a ,b],[c ,d]]);
dY=((a*d)-(b*c));
Z11=(d/dY);
Z12=(-b/dY);
Z21=(-c/dY);
Z22=(a/dY);
print"%s %.2f %s"%("\ndY=Y11.Y22-Y12.Y21 =",dY,"");
print"%s %.2f %s"%("\nZ11 = Y22/dY = ",Z11," Ohm");
print"%s %.2f %s"%("\nZ12 = -Y12/dY =",Z12," Ohm");
print"%s %.2f %s"%("\nZ21 = -Y21/-dY = ",Z21," Ohm");
print"%s %.2f %s"%("\nZ22 = Y11/dY = ",Z22," Ohm");
print("\nZ-parameters :");
print([[Z11 ,Z12],[Z21, Z22]]);
##Two-Port Networks : example 11.29 :(pg11.59 & 11.60)
print("\nApplying KCL to Node 1 \nI1 = 3V1 - 2V2- - -(i)");
print("\nApplying KCL to Node 2 \nI2 = 3V2 - V3 - - - -(ii)");
print("\nApplying KCL to Node 3 \nV3 = (1/3)V2 - - - -(ii)");
##substituting (iii) in (i) & (ii),we get
print("\nI1 = 3V1 - (2/3)V2 \nI2 = 0V1 + (8/3)V2");
print("\nY-parameters:");
a=3.;b=(-2/3.);c=(0.);d=(8/3.);
print([[a ,b],[c ,d]]);
dY=((a*d)-(b*c));
Z11=(d/dY);
Z12=(-b/dY);
Z21=(c/dY);
Z22=(a/dY);
print"%s %.2f %s"%("\ndY=Y11.Y22-Y12.Y21 =",dY,"");
print"%s %.2f %s"%("\nZ11 = Y22/dY = ",Z11," Ohm");
print"%s %.2f %s"%("\nZ12 = -Y12/dY =",Z12," Ohm");
print"%s %.2f %s"%("\nZ21 = -Y21/-dY = ",Z21," Ohm");
print"%s %.2f %s"%("\nZ22 = Y11/dY = ",Z22," Ohm");
print("\nZ-parameters :");
print([[Z11 ,Z12],[Z21, Z22]]);
##Two-Port Networks : example 11.30 :(pg11.60 & 11.561)
print("\nApplying KVL to Mesh 1 \nV1 = 4I1 + (0.05)I2 - - - -(i)");
print("\nApplying KVL to Mesh 2 \nV2 = 2I1 - 10I2 - - - -(ii)");
##substituting (i) in (ii),
print("\nV2 = -40I1 + (1.5)I2");
print("\nZ-parameters:");
a=4;b=0.05;c=-40;d=1.5;
print([[a ,b],[c ,d]]);
dZ=(a*d)-(b*c);
Y11=(d/dZ);
Y12=(b/dZ);
Y21=(-c/dZ);
Y22=(a/dZ);
print("\nY-parameters are:");
print"%s %.2f %s"%("\ndZ = Z11.Z22 - Z12.Z21 = ",dZ,"");
print"%s %.2f %s"%("\nY11 = Z22/dZ = ",Y11," mho");
print"%s %.2f %s"%("\nY12 = -Z12/dY = ",Y12," mho");
print"%s %.2f %s"%("\nY21 = -Z21/-dY = ",Y21," mho");
print"%s %.2f %s"%("\nY22 = Z11/dY = ",Y22," mho");
print([[Y11, Y12],[Y21, Y22]]);
##Two-Port Networks : example 11.31 :(pg11.61 & 11.62)
print("\nApplying KVL to Mesh 1 \nV1 = 3I1 + 5I2 - - - -(i)");
print("\nApplying KVL to Mesh 2 \nV2 = 2I1 + 4I2 - 2I3 - - - -(ii)");
print("\nApplying KVL to Mesh 3 \nI3 = 2V3 - - - -(iii)");
##substituting (iii) in (i) & (ii),we get
print("\n2V3 = 4I1 + 4I2 \nV2 = -6I1 + 4I2");
print("\nZ-parameters:");
a=3.;b=5.;c=-6.;d=-4.;
print([[a ,b],[c ,d]]);
dZ=(a*d)-(b*c);
Y11=(d/dZ);
Y12=(-b/dZ);
Y21=(-c/dZ);
Y22=(a/dZ);
print("\nY-parameters are:");
print"%s %.2f %s"%("\ndZ = Z11.Z22 - Z12.Z21 = ",dZ,"");
print"%s %.2f %s"%("\nY11 = Z22/dZ = ",Y11," mho");
print"%s %.2f %s"%("\nY12 = -Z12/dY = ",Y12," mho");
print"%s %.2f %s"%("\nY21 = -Z21/-dY = ",Y21," mho");
print"%s %.2f %s"%("\nY22 = Z11/dY = ",Y22," mho");
print([[Y11, Y12],[Y21, Y22]]);