# Example 10.1
# Calculation of the non linear coeffifient.
# Page no 429
import math
#Given data
n2=2.5*10**-20; # Kerr coefficient
lambdaa=1550*10**-9; # Wavelength
A=80*10**-12; # Effective area
# Non linear coeffifient
g=(n2*2*math.pi)/(lambdaa*A);
g=g*10**3;
#Displaying results in the command window
print "\n Nonlinear coefficient = ",round(g,3)," W**-1m**-1 "
# Example 10.2
# Calculation of the lower limit on the effective area of the fiber.
# Page no 431
import math
#Given data
c=3*10**8; # Velocity of light
tl=1000*10**3; # Total length
asp=100*10**3; # Amplifier spacing
alpha=0.046*10**-3; # Loss coefficient
L=100*10**3;
n2=2.5*10**-20; # Kerr coefficient
p=0; # Peak power at the fiber input
lambdaa=1550*10**-9; # Operating frequency
# The peak power required to form a soliton
Le=(1-math.exp(-alpha*L))/alpha;
n=tl/asp;
p=10**(p/10);
r=0.5/(Le*p);
A=(2*math.pi*n2)/(lambdaa*r);
A=A*10**12;
# Displaying results in the command window
print "\n The lower limit on the effective area of the fiber = ",round(A*10**-2,2)," micrometer**2"
print "\n The effective area should be greater than 43.62 μm2 to have the peak nonlinear phase shift less than or equal to 0.5 rad."
# The answers vary due to round off error
# Example 10.3
# Calculation of the peak power required to form a soliton
# Page no 435
import math
from sympy.mpmath import asech
#Given data
b=-21*10**-27; # FWHM of a fundamental soliton
Tf=50*10**-12; # Fiber dispersion coefficient
r=1.1*10**-3; # Nonlinear coefficient
# The peak power required to form a soliton
Th=asech(math.sqrt(0.5));
f=2*Th;
T0=Tf/f;
n=(math.sqrt(-b))/T0;
P=(n**2)/r;
#P=P*10**2;
# Displaying results in the command window
print "\n The peak power required to form a soliton = ",round(P*10**2,1)," mW"
# Answer is wrong in book
# Example 10.4
# Calculation of the peak power required to form a soliton
# Page no 444
import math
# Given data
c=3*10**8; # Velocity of light
S=0.06*10**3; # Dispersion slope
D=17*10**-6; # Dispersion coefficient
lambdaa=1550*10**-9; # Signal Wavelength
lc=1550*10**-9; # Signal Wavelength
lp=1549.6*10**-9; # Pump wavelength
l=50*10**3; # Length
r=2*math.pi*10**10;
alpha=0.046*10**-3; # Loss coefficient
# The peak power required to form a soliton
b3=S*(lambdaa**2/(2*math.pi*c))+D*(lambdaa**3/(2*math.pi**2*c**2));
b2=-(D*lambdaa**2)/(2*math.pi*c);
o=2*math.pi*(c/lp-c/lc);
d=(b2*o)+(b3*o**2)/2;
n=alpha**2/alpha**2*r*4*d**2*(1+(4*(math.sin(r*d*l))**2*math.e**(-alpha*l))/(1-math.e**(-alpha*l)**2));
n=n*10**-18;
# Displaying results in the command window
print "\n XPM efficiency = ",round(n,3)," *10**-3"
# The answers vary due to round off error
# Example 10.5
# Calculate the efficiency of the non-degenerate FWM tone at −2Δf if (a) beta2 = −4ps**2/km, (b) beta2 = 0ps**2/km.
# Page no 453
import math
#Given data
f=50*10**9; # The bandwidth
alpha= 0.046*10**-3; # The fiber loss coefficient
L=40*10**3; # The fiber length
Leff=(1-math.exp(-(alpha*L)))/alpha; # Effective fiber length
# (a) Calculate the efficiency of the non-degenerate FWM tone at −2Δf beta2 = −4ps**2/km
bet21=-4*10**(-12);
j=-1;
k=0;
l=1;
n=j+k-l;
bet1=bet21*10**(-12)/10**(3)*(2*math.pi*f)**2*n;
#The efficiency of the non-degenerate FWM tone
neta1=(alpha**2+4*math.exp(-alpha*L*10**3)*(math.sin(radians(bet1*(L*10**3)/2))/Leff**2))/(alpha**2+bet1**2)
#Displaying results in the command window
print "\n The efficiency of the non-degenerate FWM tone at −2Δf (beta2 = −4ps**2/km) = ",round(neta1*10**3,1)," X 10**(-3) "
# (b) Calculate the efficiency of the non-degenerate FWM tone at −2Δf beta2 = 0ps**2/km
bet22=0*10**(-12);
j=-1;
k=0;
l=1;
n=j+k-l;
bet2=bet22*10**(-12)/10**(3)*(2*math.pi*f)**2*n;
#The efficiency of the non-degenerate FWM tone
neta2=(alpha**2+4*math.exp(-alpha*L*10**3)*(sin(radians(bet2*(L*10**3)/2))/Leff**2))/(alpha**2+bet2**2);
#Displaying results in the command window
print "\n\n The efficiency of the non-degenerate FWM tone at −2Δf (beta2 = 0ps**2/km) = ",round(neta2)
# Example 10.6
# to find the nonlinear phase shift at the center of the pulse. Compare the exact results with those obtained using first and second-order perturbation theory
# Page no 469
import math
#Given data
P=6*10**(-3); # The peak power of rectangular pulse
L=40*10**3; # Fiber of length
Floss=0.2; # The fiber loss (dB/Km)
gamm=1.1*10**(-3);
alpha=Floss/4.343; # Attenuation coefficient
Zeff=(1-math.exp(-alpha*10**(-3)*L))/alpha*10**3;
# The nonlinear phase shift at the center of the pulse
phi=gamm*P*Zeff; # Nonlinear phase shift
#Displaying results in the command window
print "\n The nonlinear phase shift at the center of the pulse = ",round(phi,4)," rad "
# Results using first order
B01=math.sqrt(1+gamm**2*P**2*(Zeff)**2); # Amplitude shift
thet1=math.atan(gamm*P*Zeff); # Non-linear phase shift
#Displaying results in the command window
print "\n\n Amplitude shift using first order = ",round(B01,3)
print "\n Non-linear shift using first order = ",round(thet1,5)," rad"
# Results using second order
x=1-((gamm)**2/2*P**2*Zeff**2);
y=gamm*P*Zeff;
thet2=math.atan(y/x); # Nonlinear phase shift
B02=x/math.cos(thet2); # Amplitude shift
#Displaying results in the command window
print "\n\n Amplitude shift using second order = ",round(B02,5) # Answer is varying due to round-off error
print "\n Non-linear shift using second order = ",round(thet2,5)," rad" # Answer is varying due to round-off error
# Example 10.7
# Calculation of the variance of (a) linear phase noise, (b) nonlinear phase noise at the receiver
# Page no 477
import math
#Given data
alpha=0.0461; # Loss coeffient
na=20; # No of amplifiers
L=80; # Amplifier spacing
tb=25*10**-12; # Pulse width
P=2*10**-3; # Peak power
c=3*10**8; # Velocity of light
lambdaa=1550*10**-9;
n=1.5; # Spontaneous emission factor
h=6.626*10**-34; # Planck constant
r0=1.1*10**-3; # Nonlinear coefficient
# a) linear phase noise at the receiver
G=math.exp(alpha*L);
f=c/lambdaa;
R=h*f*(G-1)*n;
E=P*tb;
rl=(na*R)/(2*E);
rl=rl*10**3;
# (b) nonlinear phase noise at the receiver
Le=(1-math.exp(-alpha*L))/alpha;
rnl=((na-1)*na*(2*na-1)*R*E*r0**2*Le**2)/(3*tb**2);
rnl=rnl*10**9;
t=rl+rnl;
#Displaying results in the command window
print "\n The linear phase noise at the receiver = ",round(rl,2)," rad**2 "
print "\n The nonlinear phase noise at the receiver = ",round(rnl,2)," rad**2 "
print "\n The total variance = ",round(t,2)," X 10**-3 rad**2 "
# Example 10.8
# Calculation of the Stokes signal power at the fiber output
# Page no 480
import math
#Given data
p1=20; # Input power pump
ps=-10; # Input Stokes’s signal power
alpha=0.08;
L=2; # Length of fiber
alpha1=0.046;
A=40*10**-12; # Effective area of fiber
g=1*10**-13; # Raman coefficient of the fiber
# The Stokes signal power at the fiber output
p1=10**(p1/10);
ps=10**(ps/10);
Le=(1-math.exp(-alpha*L))/alpha;
s=(g*p1*Le)/A;
d=alpha1*L;
pd=ps*math.e**(-d+s);
# Displaying results in the command window
print "\n The Stokes signal power at the fiber output = ",round(pd,15)," mW "