# Example 7.1
# Compuatation of the lower limit on the transmitter power
#
# Page no. 305
import math
#Given data
q=1.6*10**-19;
R=1;
B=7*10**9;
c=3*10**8; # Velocity of light
h=6.62*10**-34; # Planck constant
Q=6;
k=1.38*10**-23; # Boltzman constant
T=298;
Rl=50;
alpha=0.046; # Fiber loss coefficient
L=130; # Length
# The lower limit on the transmitter power
a=2*q*R*B;
b=(4*k*T*B)/Rl;
p=(2*math.sqrt(b)/R*Q)+((a*Q**2)/R**2);
Pi=p*math.exp(alpha*L);
#Displaying the result in command window
print "\n The lower limit on the transmitter power = ",round(Pi*10**3,2)," mW"
print "\n The lower limit on the transmitter peak power is 7.23mW. If the transmitter peak power < 7.23mW, Q < 6."
# The answer vary due to round off error
# Example no. 7.2
# To calculate exact and approximate Q-factor if the signal is (a)OOK, (b) PSK
# Page no. 311
import math
# Given data
lambdaa=1.55*10**(-6); # Wavelength of given signal
meanPin=1; # Mean fiber launch power in dBm
alpha=0.2; # fiber loss in dB/km
l=240; # fiber length in km
neta=0.7; # quantum efficiency
T = 290; # Tempearture in K
RL=100; # Length resistance in Ω
PLOdBm = 10; # Power at local oscillator in dBm
Be = 7.5*10**9; # Efficient bandwidth of filter in Hz
c=3*10**8; # Speed of ligth in air in m/s
loss=alpha*l; # Total fiber loss
q=1.602*10**(-19); # Charge of electron
h=6.626*10**(-34); # Planck constant
kB=1.38*10**(-23); # Bolzman constant
f=c/lambdaa; # mean frequency
R=(neta*q)/(h*f); # Responsivity
#For OOK
Pin=10*math.log10(2)+meanPin; # peak power in dBm
P1rdBm=Pin-loss; # received peak power in dBm
P1r=(10**(P1rdBm/10))*10**(-3); # received peak power in W
PLO=(10**(PLOdBm/10))*10**(-3); # Power at local oscillator in W
I1=2*R*math.sqrt(P1r*PLO); # mean of bit 1
sigma1=2*q*Be*R*(P1r+PLO)+(4*kB*T*Be)/RL; # Square of variance of bit 1
I0=0; # mean of bit 0
sigma0=sigma1; # Square of variance of bit 0
Q1=(I1-I0)/(2*math.sqrt(sigma1)); # Exact Q-factor
Q2=math.sqrt((neta*P1r)/(2*h*f*Be)); # Approximate Q-factor
# Displaying the result in command window
print "\n Exact Q-factor if the signal is OOK = ",round(Q1,1)
print "\n Approximate Q-factor if the signal is OOK = ",round(Q2,1)
# For PSK
P1rdBm=meanPin-loss; # received peak power in dBm
P1r=(10**(P1rdBm/10))*10**(-3); # received peak power in W
I1=2*R*math.sqrt(P1r*PLO); # mean of bit 1
sigma1=2*q*Be*R*(P1r+PLO)+(4*kB*T*Be)/RL; # Square of variance of bit 1
I0=-I1; # mean of bit 0
sigma0=sigma1; # Square of variance of bit 0
Q1=I1/math.sqrt(sigma1); # Exact Q-factor
Q2=math.sqrt((2*neta*P1r)/(h*f*Be)); # Approximate Q-factor
# Displaying the result in command window
print "\n Exact Q-factor if the signal is PSK = ",round(Q1,2)
print "\n Approximate Q-factor if the signal is PSK = ",round(Q2,2)
# Example 7.3
# Calculation of the distance.
# Page no 315
import math
#Given data
B1=2.5*10**9; # Mean optical power
B2=10*10**9; # Split loss
L1=160*10**3; # Total system margin
# Distance
L2=((B1/B2)**2*L1);
L2=L2*10**-3;
#Displaying results in the command window
print "\n Distance = ",round(L2)," Km "
# The answers vary due to round off error
# Example 7.4
# Compuatation of (a) OSNR in a reference bandwidth of 0.1 nm, (b) Q-factor.
# Page no. 321
import math
# Given data
f=10*10**9;
n=1.5; #Refractive index
h=6.63*10**-34; # Planck constant
c=3*10**8; # Velocity of light
lambdaa=1.55*10**-6; #
q=1.6*10**-19; # Electron charge
d=0.1*10**-9; # Reference bandwidth
alpha=0.0461; # Fiber loss coefficient
L=80; # Spacing
Pi=-3; # Mean fiber launch power
N=80; # Identical amplifers
fe=7*10**9; # Electrical filter bandwidth
# Signal calculation
df=-((c*d)/lambdaa**2); #Reference frequency
G=math.exp(alpha*L);
G1=10*math.log10(G);
N1=10*math.log10(N);
Fn=2*n; #Noise figure
Fn=10*math.log10(Fn);
O=Pi-N1-G1-Fn+58; #OSNR
Pi1=2*10**(-(3/10.0)); # Peak power in mW
f=c/lambdaa;
Q=math.sqrt((Pi1*10**-3)/(4*N*n*h*f*(G-1)*fe)); #Q-factor
# Displaying the result in command window
print "\n OSNR is = ",round(O,2)," dB"
print "\n Q-factor is = ",round(Q,2)
# The answer vary due to round off error
# Example 7.5
# Compuatation of the transmission distance
# Page no. 325
import math
#Given data
fl=0.2 # Fiber loss
L=100; # Amplifeir spacing
n=1.4;
h=6.63*10**-34; # Planck constant
c=3*10**8; # Velocity of light
lambdaa=1.55*10**-6;
q=1.6*10**-19; # Electron charge
R=0.9;
d=0.1*10**-9;
alpha=0.0461;
L=100; # Spacing
Pi=-3; # Mean fiber launch power
#N=80; # Identical amplifers
fe=7*10**9; # Electrical filter bandwidth
q=6;
B=5*10**9;
# The transmission distance
l=fl*L;
G=10**(l/10.0);
f=c/lambdaa;
# r=N*n*h*f*(G-1);
Pi=10**(-(2/10.0));
N=Pi/(q**2*n*h*f*(G-1)*B);
Td=N*L;
Td=Td*10**-3;
#Displaying the result in command window
print "\n The transmission distance is = ",round(Td)," km"
# Example 7.6
# Compuatation of the Q-factor.
# Page no. 327
import math
#Given data
alpha=0.18; # Fiber loss coefficient
L=190; # Fiber length
G=20; # Gain of preamplifier
lambdaa=1.55*10**-6; # Operating wavelength
h=6.63*10**-34; # Planck constant
n=1.409;
G1=10**(G/10.0);
f0=20*10.0**9;
R=1.1;
q=1.6*10.0**-19;
fe=7.5*10.0**9;
Pi=1; # Input power
c=3*10.0**8; # Velocity of light
k=1.38*10**-23;
T=298;
Rl=200;
# The Q factor
l=alpha*L;
Po=Pi-l+G;
Po=10**(Po/10.0)*10**-3;
f=c/lambdaa;
r=h*f*(G1-1)*n;
fn=2*n;
fn=10**(fn/10.0);
I1=R*Po+2*r*f0;
I0=2*R*r*f0;
o1=(2*q*I1*fe)+((4*k*T*fe)/Rl)+(2*R**2*r*(2*Po*fe+r*(2*f0-fe)*fe));
o2=(2*q*I0*fe)+((4*k*T*fe)/Rl)+(2*R**2*r**2*(2*f0-fe)*fe);
Q=(I1-I0)/(math.sqrt(o1)+math.sqrt(o2));
#Displaying the result in command window
print "\n Q factor= ",round(Q,3)
# The answer vary due to round off error
# Example 7.7
# Compuatation of the optimum amplifier configuration
# Page no. 329
import math
#Given data
G1=8.0; # Amplifier gain 1
G2=16.0; # Amplifier gain 2
fn1=7.0; # Noise figure of amplifier 1
fn2=5.5; # Noise figure of amplifier 2
H=7.0; # Insertion loss of the DCF
#N=80.0; # Identical amplifers
fe=7*10.0**9; # Electrical filter bandwidth
# q=6;
# The optimum amplifier configuration
fn1=10**(fn1/10);
fn2=10**(fn2/10);
G2=10**(G2/10);
H=10**(H/10);
Fna=fn2+(fn1/(G2*H));
Fna=10*math.log10(Fna);
G=G2+G1+H;
Fnb=fn1+(fn2/(G1*H));
Fnb=10*math.log10(Fnb);
#Displaying the result in command window
print "\n The optimum amplifier configuration by choosing Amp2 as the first amplifier = ",round(Fna,3)," dB"
print "\n The optimum amplifier configuration by choosing Amp1 as the first amplifier = ",round(Fnb,3)," dB"
# The answer vary due to round off error
# Example 7.9
# Compuatation of the (a) the length of the DCF (b) the gain G2 and (c) the Q-factor.
# Page no. 331
import math
#Given data
b=-21*10.0**-27;
L=100.0*10**3;
Lt=100.0;
l=0.18; # Loss
l1=0.5; # Dispersion coefficients of the TF
G1=16.0; # Amplifier gain
p=-2; # Mean transmitter output power
fe=7*10.0**9;
c=3*10.0**8; # Velocity of light
h=6.62*10**-34; # Planck constant
fn1=5.5; # Noise figure of amplifier 1
fn2=7.5; # Noise figure of amplifier 2
lambdaa=1.55*10**-6;
bd=145.0*10**-27; # Dispersion coefficients of the DCF
# (a) The length of the DCF
st=b*L;
sd=-0.9*st;
Ld=sd/bd;
Ld=Ld*10**-3;
# (b) Gain G2
Ht=l*Lt;
Hd=l1*Ld;
G2=Ht+Hd-G1;
# (c) Q factor
Ge=G1+G2+-Hd;
Ge=10**(Ge/10);
fn1=10**(fn1/10);
fn2=10**(fn2/10);
G1=10**(G1/10);
Hd=10**(-Hd/10);
Fe=fn1+(fn2/(G1*Hd))-(1/G1);
f=c/lambdaa;
r=70*h*f*(((Ge*Fe)-1)/2.0);
Pi=2*10**(p/10.0)*10**-3;
Q=math.sqrt(Pi/(4*r*fe));
#Displaying the result in command window
print "\n The length of the DCF = ",round(Ld,2)," km"
print "\n Gain G2 = ",round(G2,2)," dB"
print "\n Q factor= ",round(Q,1)
# The answer vary due to round off error