summaryrefslogtreecommitdiff
path: root/Optical_Fiber_Communication_by_A_Kalavar/4-Signal_Degradation_in_Fibers.ipynb
blob: 255f68be0308d078e4f819b5caa20b53ea3e0855 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
{
"cells": [
 {
		   "cell_type": "markdown",
	   "metadata": {},
	   "source": [
       "# Chapter 4: Signal Degradation in Fibers"
	   ]
	},
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.14_1: Compute_material_dispersio.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.14.1  page 4.31\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"lamda=1550d-9;\n",
"lamda0=1.3d-6;\n",
"s0=0.095;\n",
"\n",
"Dt=lamda*s0/4*(1-(lamda0/lamda)^4);     //computing material dispersion\n",
"Dt=Dt*10^9;\n",
"printf('\nMaterial dispersion at 1550 nm is %.1f ps/nm/km',Dt);\n",
"printf('\n\nNOTE - Slight deviation in the answer because of printig mistake\nIn problem they have given lamda0 as 1300 nanometer \nbut while solving they have taken it as 1330 nanometer');\n",
"\n",
"//answer in the book 15.6 ps/nm/km, deviaton due to printing mistake."
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.15_10: Estimate_bandwidth_pulse_broadening_and_bandwidth_length_product.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.15.10  page 4.42\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"tau=0.1d-6;     //pulse broadning\n",
"dist=18d3;      //distance\n",
"\n",
"Bopt=1/(2*tau);     //computing optical bandwidth\n",
"Bopt=Bopt*10^-6;\n",
"dispertion=tau/dist;        //computing dispersion\n",
"dispertion=dispertion*10^12;\n",
"BLP=Bopt*dist;      //computing Bandwidth length product\n",
"BLP=BLP*10^-3;\n",
"printf('\noptical bandwidth is %d MHz.\nDispersion per unit length is %.1f ns/km.\nBandwidth length product is %d MHz.km',Bopt,dispertion,BLP);\n",
"printf('\nNOTE - printing mistake in the book at dispersion per unit length.\nThey have printed ps/km; it should be ns/km');\n",
"\n",
"//printing mistake in the book at dispersion per unit length.They have printed ps/km; it should be ns/km.\n",
"//answer in the book 5.55 ps/km (incorrect)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.15_1: Find_maximum_possible_bandwidth_pulse_dispersion_and_bandwidth_length_product.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.15.1  page 4.35\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"tau=0.1d-6;     //pulse broadning\n",
"dist=20d3;      //distance\n",
"\n",
"Bopt=1/(2*tau);     //computing optical bandwidth\n",
"Bopt=Bopt*10^-6;\n",
"dispertion=tau/dist;        //computing dispersion\n",
"dispertion=dispertion*10^12;\n",
"BLP=Bopt*dist;      //computing Bandwidth length product\n",
"BLP=BLP*10^-3;\n",
"printf('\noptical bandwidth is %d MHz.\nDispersion per unit length is %d ns/km.\nBandwidth length product is %d MHz.km.',Bopt,dispertion,BLP);"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.15_2: Calculate_overall_signal_attenuation.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.15.2  page 4.36\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"L=10;       //fiber length in km\n",
"Pin=100d-6;     //input power\n",
"Pout=5d-6;      //output power\n",
"len=12;       //length of optical link\n",
"interval=1;     //splices after interval of 1 km\n",
"l=0.5;      //loss due to 1 splice\n",
"\n",
"attenuation=-10*log10(Pin/Pout);        //computing attenuation\n",
"alpha=attenuation/L;\n",
"signal_attenuation=-alpha*L;            //computing signal attenuation\n",
"splices_loss=(len-interval)*l;          //computing splices loss\n",
"attenuation_loss=-len*alpha             //computing attenuation loss\n",
"total_attenuation=attenuation_loss+splices_loss;        //computing total attenuation\n",
"\n",
"printf('\nSignal attenuation is %.1f dB/Km.\nOverall attenuation is %d dB for 10 km.\nTotal attenuation is %.1f dBs for 12km.',alpha,signal_attenuation,total_attenuation);"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.15_3: Calculate_bandwidth_dispersion_and_bandwidth_length_product.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.15.3  page 4.37\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"tau=0.1d-6;     //pulse broadning\n",
"dist=12d3;      //distance\n",
"\n",
"Bopt=1/(2*tau);     //computing optical bandwidth\n",
"Bopt=Bopt*10^-6;\n",
"dispertion=tau/dist;        //computing dispersion\n",
"dispertion=dispertion*10^12;\n",
"BLP=Bopt*dist;      //computing Bandwidth length product\n",
"BLP=BLP*10^-3;\n",
"printf('\noptical bandwidth is %d MHz.\nDispersion per unit length is %.1f ns/km.\nBandwidth length product is %d MHz.km',Bopt,dispertion,BLP);"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.15_4: Determine_maximum_bit_rate.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.15.4  page 4.38\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"tau01=10;     //pulse broadning ns/mm\n",
"L1=0.1;     //length in kilometer\n",
"tau02=20;    //pulse broadning ns/m\n",
"L2=1;    //length in kilometer\n",
"tau03=2000;  //pulse broadning ns/m\n",
"L3=2;       //length in kilometer\n",
"\n",
"tau1=10d-9/1d-6;\n",
"tau1=tau1*L1;\n",
"Bopt1=1/(2*tau1);     //computing optical bandwidth\n",
"tau2=20d-9/1d-3;\n",
"tau2=tau2*L2;\n",
"Bopt2=1/(2*tau2);     //computing optical bandwidth\n",
"Bopt2=Bopt2*10^-3;\n",
"tau3=2000d-9/1d-3;\n",
"tau3=tau3*L3;\n",
"Bopt3=1/(2*tau3);     //computing optical bandwidth\n",
"\n",
"\n",
"printf('\nWhen tau is %d ns/mm, over length %.1f km, optical bandwidth for RZ is %d MHz and for NRZ is %d MHz.',tau01,L1,Bopt1,Bopt1/2 );\n",
"printf('\nWhen tau is %d ns/m, over length %d km, optical bandwidth for RZ is %.1f KHz and for NRZ is %.1f KHz.',tau02,L2,Bopt2,Bopt2/2 );\n",
"printf('\nWhen tau is %d ns/m, over length %d km, optical bandwidth for RZ is %d Mz and for NRZ is %.1f Hz.',tau03,L3,Bopt3,Bopt3/2 );\n",
"\n",
"printf('\n NOTE - printing errors in the book.\nIn first two cases tau is not multiplied by 2');\n",
"\n",
"//Calculation error because, In first two cases tau is not multiplied by 2\n",
"//answers-\n",
"//When tau is 10 ns/mm, over length 0.1 km, optical bandwidth for RZ is 1000 MHz and for NRZ is 500 MHz.\n",
"//When tau is 20 ns/m, over length 1 km, optical bandwidth for RZ is 50 KHz and for NRZ is 25 KHz."
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.15_5: Calculate_maximum_possible_bandwidth_and_dispersion.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.15.5  page 4.39\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"tau=0.1d-6;     //pulse broadning\n",
"dist=15d3;      //distance\n",
"\n",
"Bopt=1/(2*tau);     //computing optical bandwidth\n",
"Bopt=Bopt*10^-6;\n",
"dispertion=tau/dist;        //computing dispersion\n",
"dispertion=dispertion*10^12;\n",
"printf('\noptical bandwidth is %d MHz.\nDispersion per unit length is %.2f ns/km.',Bopt,dispertion);"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.15_6: Compute_delay_difference_rms_pulse_broadening_and_maximum_bit_rate.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.15.6  page 4.39\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"L=5;        //length of optical link\n",
"n1=1.5      //refractive index\n",
"c=3d8;      //speed of light\n",
"delta=1/100;        //relative refractive index\n",
"\n",
"delTS=L*n1*delta/c;     //computing delay difference\n",
"delTS=delTS*10^12;\n",
"sigmaS=L*n1*delta/(2*sqrt(3)*c);    //computing rms pulse broadning\n",
"sigmaS=sigmaS*10^12;\n",
"B=1/(2*delTS);        //computing maximum bit rate\n",
"B=B*10^3;\n",
"B_acc=0.2/(sigmaS);     //computing accurate bit rate\n",
"B_acc=B_acc*10^3;\n",
"BLP=B_acc*L;      //computing Bandwidth length product\n",
"\n",
"printf('\nDelay difference is %d ns.\nRMS pulse broadning is %.2f ns.\nBit rate is %.1f Mbit/s.\nAccurate bit rate is %.2f Mbits/s.\nBandwidth length product is %.2f MHz.km.',delTS,sigmaS,B,B_acc,BLP);\n",
"\n",
"//answer in the book for RMS pulse broadning is 72.25 ns, deviation of 0.08ns.\n",
"//answer in the book for Bandwidth length product is 13.85 MHz.km, deviation of 0.01MHz.km."
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.15_7: Estimate_rms_pulse_broadening_and_bandwidth_length_product.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.15.7  page 4.40\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"NA=0.3;     //numerical aperture\n",
"n1=1.45;    //refractive index\n",
"M=250;      //material dispertion parameter in ps/nm/km\n",
"L=1;        //length\n",
"BW=50;      //Bandwidth in nm\n",
"c=3d8;      //speed of light\n",
"\n",
"sigmaLamda=BW*L;\n",
"sigmaM=sigmaLamda*L*M*10^-12;\n",
"sigmaS=10^3*L*(NA)^2/(4*sqrt(3)*n1*c);\n",
"sigmaT=sqrt(sigmaM^2+sigmaS^2);     //computing total RMS pulse broadning\n",
"BLP=0.2/sigmaT;     //computing bandwidth length product\n",
"sigmaT=sigmaT*10^9;\n",
"sigmaM=sigmaM*10^9;\n",
"sigmaS=sigmaS*10^9;\n",
"BLP=BLP/10^6;\n",
"printf('\nTotal RMS pulse broadning is %.1f ns/km.\nBandwidth length product is %.1f MHz.km',sigmaT,BLP);"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.15_8: Estimate_Bandwidth_dispersion_and_bandwidth_length_product.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.15.8  page 4.41\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"tau=0.1d-6;     //pulse broadning\n",
"dist=10d3;      //distance\n",
"\n",
"Bopt=1/(2*tau);     //computing optical bandwidth\n",
"Bopt=Bopt*10^-6;\n",
"dispertion=tau/dist;        //computing dispersion\n",
"dispertion=dispertion*10^12;\n",
"BLP=Bopt*dist;      //computing Bandwidth length product\n",
"BLP=BLP*10^-3;\n",
"printf('\noptical bandwidth is %d MHz.\nDispersion per unit length is %.1f ns/km.\nBandwidth length product is %d MHz.km.',Bopt,dispertion,BLP);"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.15_9: Estimate_rms_pulse_broadening.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.15.9  page 4.41\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"RSW=0.0012;     //relative spectral width\n",
"lamda=0.85d-6;  //wavelength\n",
"L=1;        //distance in km (assumed)\n",
"M=100;      //material dispersion parameter in ps/nm/km (assumed)\n",
"\n",
"sigma_lamda=RSW*lamda;\n",
"sigmaM=sigma_lamda*L*M*10^6;    //computing rms pulse broadning.\n",
"printf('\nRMS pulse broadning is %.3f ns/km.',sigmaM);"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.16_1: Estimate_rms_pulse_broadening.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.16.1  page 4.43\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"RSW=0.0012;     //relative spectral width\n",
"lamda=0.90d-6;  //wavelength\n",
"L=1;        //distance in km (assumed)\n",
"P=0.025;    //material dispersion parameter\n",
"c=3d5;      //speed of light in km/s\n",
"\n",
"M=10^3*P/(c*lamda);     //computing material dispersion\n",
"sigma_lamda=RSW*lamda;\n",
"sigmaM=sigma_lamda*L*M*10^7;        //computing RMS pulse broadning\n",
"sigmaB=25*L*M*10^-3;\n",
"\n",
"printf('\nMaterial dispersion parameter is %.2f ps/nm/km.\nRMS pulsr broadning when sigma_lamda is 25 is %.1f ns/km.\nRMS pulse broadning is %.1f ns/km.',M,sigmaB,sigmaM);\n",
"\n",
"//answer in the book for RMS pulse broadning is 0.99 ns/km, deviation of 0.01ns/km."
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.18_1: Find_delay_difference_and_rms_pulse_broadening.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.18.1  page 4.45\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"L=10;        //length of optical link\n",
"n1=1.49      //refractive index\n",
"c=3d8;      //speed of light\n",
"delta=1/100;        //relative refractive index\n",
"\n",
"delTS=L*n1*delta/c;     //computing delay difference\n",
"delTS=delTS*10^12;\n",
"sigmaS=L*n1*delta/(2*sqrt(3)*c);    //computing rms pulse broadning\n",
"sigmaS=sigmaS*10^12;\n",
"B=1/(2*delTS);        //computing maximum bit rate\n",
"B=B*10^3;\n",
"B_acc=0.2/(sigmaS);     //computing accurate bit rate\n",
"B_acc=B_acc*10^3;\n",
"BLP=B_acc*L;      //computing Bandwidth length product\n",
"\n",
"printf('\nDelay difference is %d ns.\nRMS pulse broadning is %.1f ns.\nBit rate is %.1f Mbit/s.\nAccurate bit rate is %.3f Mbits/s.\nBandwidth length product is %.1f MHz.km',delTS,sigmaS,B,B_acc,BLP);\n",
"\n",
"//answer for maximum bit rate is given as 1.008 Mb/s, deviation of 0.008 Mb/s."
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.3_1: Find_signal_attenuation_and_InputOutput_ratio.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"\n",
"\n",
"// Example 4.3.1  page 4.4\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"L=10;       //fiber length in km\n",
"Pin=150d-6;     //input power\n",
"Pout=5d-6;      //output power\n",
"len=20;       //length of optical link\n",
"interval=1;     //splices after interval of 1 km\n",
"l=1.2;      //loss due to 1 splice\n",
"\n",
"attenuation=10*log10(Pin/Pout);\n",
"alpha=attenuation/L;\n",
"attenuation_loss=alpha*20;\n",
"splices_loss=(len-interval)*l;\n",
"total_loss=attenuation_loss+splices_loss;\n",
"power_ratio=10^(total_loss/10);\n",
"\n",
"printf('\nSignal attenuation is %.2f dBs.\nSignal attenuation is %.3f dB/Km.\nTotal loss in 20 Km fiber is %.2f dbs.\nTotal attenuation is %.2f dBs.\ninput/output ratio is %e.',attenuation,alpha,attenuation_loss,total_loss,power_ratio);\n",
"printf('\nAs signal attenuation is approximately equal to 10^5, we can say that line is very lossy.');"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.4_1: Find_output_power.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.4.1  page 4.8\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"L=30;       //fiber length\n",
"Pin=200d-6;     //input power\n",
"alpha=0.8;      //signal attenuation per km\n",
"\n",
"Pout=Pin/(10^(alpha*L/10));     //computing output power\n",
"Pout=Pout*10^6;\n",
"printf('\nOutput power is %.3f microwatt.',Pout);\n",
"printf('\nNOTE - calculation error in the book.\nThey have taken 0.8*30=2.4 which actually is 24.');\n",
"\n",
"//calculation error in the book.They have taken 0.8*30=2.4 which actually is 24.\n",
"//answer in the book is 115.14 microwatt.(incorrect)"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.6_1: Find_attenuation_due_to_Rayleigh_scattering.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.6.1  page 4.12\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"beta_c=8d-11;        //isothermal compressibility\n",
"n=1.46;     //refractive index\n",
"P=0.286;    //photoelastic constat\n",
"k=1.38d-23; //Boltzmnn constant\n",
"T=1500;     //temperature\n",
"L=1000;     //length\n",
"lamda=1000d-9;  //wavelength\n",
"\n",
"gamma_r = 8*(3.14^3)*(P^2)*(n^8)*beta_c*k*T/(3*(lamda^4));      //computing coefficient\n",
"attenuation=%e^(-gamma_r*L);        //computing attenuation\n",
"printf('\nAttenuation due to Rayleigh scattering is %.3f.',attenuation);"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.6_2: Determine_attenuation_due_to_Rayleigh_scattering.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.6.2  page 4.13\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"beta_c=7d-11;        //isothermal compressibility\n",
"n=1.46;     //refractive index\n",
"P=0.29;    //photoelastic constat\n",
"k=1.38d-23; //Boltzmnn constant\n",
"T=1400;     //temperature\n",
"L=1000;     //length\n",
"lamda=0.7d-6;  //wavelength\n",
"\n",
"gamma_r = 8*(3.14^3)*(P^2)*(n^8)*beta_c*k*T/(3*(lamda^4));      //computing coefficient\n",
"attenuation=%e^(-gamma_r*L);        //computing attenuation\n",
"gamma_r=gamma_r*1000;\n",
"printf('\nRaleigh Scattering corfficient is %.3f * 10^-3 per meter\n',gamma_r);\n",
"printf('\nNOTE - in quetion they have asked for attenuation but in solution they have not calcualted\n');\n",
"printf('\nAttenuation due to Rayleigh scattering is %.3f',attenuation);\n",
"\n",
"//answer for Raleigh Scattering corfficient in the book is given as 0.804d-3, deviation of 0.003d-3"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.8_1: Compare_SRS_and_SBS_threshold_powers.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.8.1  page 4.17\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"d=5;     //core diameter\n",
"alpha=0.4;  //attenuation\n",
"B=0.5;    //Bandwidth\n",
"lamda=1.4;   //wavelength\n",
"PB=4.4d-3*d^2*lamda^2*alpha*B;      //computing threshold power for SBS\n",
"PR=5.9d-2*d^2*lamda*alpha;      //computing threshold power for SRS\n",
"PB=PB*10^3;\n",
"PR=PR*10^3;\n",
"printf('\nThreshold power for SBS is %.1f mW.\nThreshold power for SRS is %.3f mW.',PB,PR);\n",
"printf('\nNOTE - Calculation error in the book while calculating threshold for SBS.\nAlso, while calculating SRS, formula is taken incorrectly, Bandwidth is multiplied in second step, which is not in the formula.');\n",
"\n",
"//Calculation error in the book while calculating threshold for SBS. Also, while calculating SRS, formula is taken incorrectly,Bandwidth is multiplied in second step, which is not in the formula\n",
"//answers in the book\n",
"//PB=30.8mW\n",
"//PR=0.413mW"
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.9_1: Find_critical_radius_of_curvature.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.9.1  page 4.19\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"n1=1.5;     //refractive index of core\n",
"delta=0.03/100;     //relative refractive index\n",
"lamda=0.82d-6;      //wavelength\n",
"\n",
"n2=sqrt(n1^2-2*delta*n1^2);      //computing cladding refractive index\n",
"Rc=(3*n1^2*lamda)/(4*3.14*(n1^2-n2^2)^1.5);     //computing critical radius\n",
"Rc=Rc*10^3;\n",
"printf('\nCritical radius is %.1f micrometer.',Rc);\n",
"\n",
"//answer in the book is 9 micrometer, deviation of 0.1 micrometer."
   ]
   }
,
{
		   "cell_type": "markdown",
		   "metadata": {},
		   "source": [
			"## Example 4.9_2: Find_critical_radius_for_both_single_mode_and_multi_mode_fiber.sce"
		   ]
		  },
  {
"cell_type": "code",
	   "execution_count": null,
	   "metadata": {
	    "collapsed": true
	   },
	   "outputs": [],
"source": [
"// Example 4.9.2  page 4.20\n",
"\n",
"clc;\n",
"clear;\n",
"\n",
"n1=1.45;     //refractive index of core\n",
"delta=3/100;     //relative refractive index\n",
"lamda=1.5d-6;      //wavelength\n",
"a=5d-6;     //core radius\n",
"\n",
"n2=sqrt(n1^2-2*delta*n1^2);      //computing cladding refractive index\n",
"Rc=(3*n1^2*lamda)/(4*3.14*(n1^2-n2^2)^0.5);     //computing critical radius for single mode\n",
"Rc=Rc*10^6;\n",
"printf('\nCritical radius is %.2f micrometer',Rc);\n",
"\n",
"lamda_cut_off= 2*3.14*a*n1*sqrt(2*delta)/2.405;\n",
"\n",
"RcSM= (20*lamda/(n1-n2)^1.5)*(2.748-0.996*lamda/lamda_cut_off)^-3;      //computing critical radius for single mode\n",
"RcSM=RcSM*10^6;\n",
"printf('\nCritical radius for single mode fiber is %.2f micrometer.',RcSM);\n",
"printf('\nNOTE - Calculation error in the book.\n(2.748-0.996*lamda/lamda_cut_off)^-3; in this term raised to -3 is not taken in the book.');\n",
"\n",
"//Calculation error in the book.(2.748-0.996*lamda/lamda_cut_off)^-3; in this term raised to -3 is not taken in the book.\n",
"//answer in the book is 7.23mm.(incorrect)"
   ]
   }
],
"metadata": {
		  "kernelspec": {
		   "display_name": "Scilab",
		   "language": "scilab",
		   "name": "scilab"
		  },
		  "language_info": {
		   "file_extension": ".sce",
		   "help_links": [
			{
			 "text": "MetaKernel Magics",
			 "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
			}
		   ],
		   "mimetype": "text/x-octave",
		   "name": "scilab",
		   "version": "0.7.1"
		  }
		 },
		 "nbformat": 4,
		 "nbformat_minor": 0
}