import math
Beeta = 34.3 #in rad/m
# S=[0,0.5*math.e**(%i*53.13);0.5*math.e**(%i*53.13),0];
# S'=[0,0.5*math.e**(%i*53.13-x);0.5*math.e**(%i*53.13-x),0];
#For S12& S21 to be real ,
x = 53.5 #in degrees
#calculations
x_rad = 53.5*math.pi/180
l = x_rad/Beeta
#---output---#
print 'distance (in cm)=',round(l*100,4)
import math
D = 30 #in dB
VSWR = 1
C = 10
#p1_p4 = p1/p4
#calculations
p1_p4 = 10**(C/-10)
S_41 = round(math.sqrt(p1_p4),4)
S_14 = S_41 #As matched & lossless
S_31 = round(S_41**2/10**(D/10),4)
S_11 = round((VSWR-1)/(VSWR+1),4)
S_22 = S_11
S_44 = S_11
S_33 = S_11
S_21 = round(math.sqrt(1-0.1-10**-4),4)
S_12 = S_21
S_34 = round(math.sqrt(1-0.1-10**-4),4)
S_43 = S_34
S_24 = round(math.sqrt(1-0.1-S_34**2),4)
S_42 = S_24
S_23 = S_41
S_32 = S_23
S_13 = S_31
S=[[S_11,S_12,S_13,S_14],[S_21,S_22,S_23,S_24],[S_31,S_32,S_33,S_34],[S_41,S_42,S_43,S_44]]
#---output---#
print 'Required Scattering Parameters are \n', S
import math
a_2 = 0
a_3 = 0
a_1 = 32 #in mW
#calculations
b_1 = (a_1/2**2)+(a_2/-2)+(a_3/math.sqrt(2))
b_2 = (a_1/(-2)**2)+(a_2/-2)+(a_3/math.sqrt(2))
b_3 = (a_1/2)+(a_2/math.sqrt(2))+(a_3/-math.sqrt(2))
#---output---#
print 'Power at port1(in mW)=',b_1
print 'Power at port2(in mW) =',b_2
print 'Power at port3(in mW) =',b_3
import math
b_1 = 20
b_2 = 20
#calculations
p_1 = abs((60-50)/(60+50))
p_2 = abs((75-50)/(75+50))
P_1 = b_1*(1-p_1**2)/2
P_2 = b_2*(1-p_2**2)/2
#---output---#
print 'Power in port1 (in mW) =',round(P_1,4)
print 'Power in port2 (in mW) =',P_2
import math
p_1 = 0.5
p_2 = 0.6
p_4 = 0.8
b_1 = 0.6566
b_2 = 0.7576
b_3 = 0.6536
b_4 = 0.00797
#calculations
a_1 = p_1*b_1
a_2 = p_2*b_2
a_3 = 1 #in Watts
a_4 = p_4*b_4
#---output---#
print 'Power at port 1(in W)=',round(b_1**2,4)
print 'Power at port 2(in W)=',round(b_2**2,4)
print 'Power at port 3(in W)=',round(b_3**2,4)
print 'Power at port 4(in W)=',b_4**2
import math
In_loss = 0.5 #in dB
Isolation = 30 #in dB
S_11 = 0
S_22 = 0
#calculations
S_21 = 10**(-In_loss/20)
S_12 = 10**(-Isolation/20)
S = [S_11,S_12,S_21,S_22]
#output
print 'Scattering matrix = [',
for k in S:
print round(k,4),"," ,
print ']'
import math
VSWR = 1
In_loss = 0.5 #in dB
Isolation = 20 #in dB
#calculations
S_12 = round(10**(-Isolation/20),4)
S_21 = round(10**(-In_loss/20),4)
S_23 = S_12
S_31 = S_12
S_32 = S_21
S_13 = S_21
p=round((VSWR-1)/(VSWR+1),4)
S_11 = p
S_22 = p
S_33 = p
S = [S_11,S_12,S_13],[S_21,S_22,S_23],[S_31,S_32,S_33]
#---output---#
print 'Scattering matrix =',S
import math
In_loss = 0.5 #insertion loss(in dB)
C = 20 #in dB
D = 35 #in dB
Pi = 90 #in Watts
#calculations
Pi_Pf = 10**(C/10)
Pf = Pi/Pi_Pf
Pf_Pb = 10**(D/10)
Pb = Pf/Pf_Pb
P_rec = (Pi-Pf-Pb) #Power received (in Watts)
P_rec_dB = 10*math.log(Pi/P_rec)/math.log(10)
P_rec_eff = P_rec_dB-In_loss #Effective power received (in dB)
#---output---#
print 'Effective power received (in dB)=',round(P_rec_eff,4)
import math
S_13 = 0.1
S_14 = 0.05
#calculations
C = -20*math.log(S_13)/math.log(10)
D = 20*math.log(S_13/S_14)/math.log(10)
I = C+D
#---output---#
print 'Coupling (in dB) =',round(C,4)
print 'Directivity (in dB)) =',round(D,4)
print 'Isolation (in dB) =',round(I,4)
import math
D=3 #distance of seperation(in cm)
#calculations
w_l=2*D #wavelength
d2_d1=2.5 #d2-d1(in m)
S=w_l/(math.pi*d2_d1*10**-1)
#---output---#
print 'VSWR =',round(S,4)
import math
#---variables
w_l=7.2 #wavelength (in cm)
x=10.5-9.3
#calculations
Phase_shift=(2*math.pi*x)/(w_l)
#---output---#
print 'Phase Shift (in degree) =',round(Phase_shift*180/math.pi,4)