0% found this document useful (0 votes)
130 views87 pages

Scilab EM Engineering

This Scilab textbook companion provides code examples for Engineering Electromagnetics by W. H. Hayt and J. A. Buck. It contains 84 Scilab code examples organized across 14 chapters that correspond to topics in the textbook, including vector analysis, electric and magnetic fields, transmission lines, plane waves, wave reflection and dispersion, and guided waves and radiation. The codes are intended to help students and engineers solve electromagnetics problems numerically using the Scilab computing environment.

Uploaded by

Andrei Szilagyi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
130 views87 pages

Scilab EM Engineering

This Scilab textbook companion provides code examples for Engineering Electromagnetics by W. H. Hayt and J. A. Buck. It contains 84 Scilab code examples organized across 14 chapters that correspond to topics in the textbook, including vector analysis, electric and magnetic fields, transmission lines, plane waves, wave reflection and dispersion, and guided waves and radiation. The codes are intended to help students and engineers solve electromagnetics problems numerically using the Scilab computing environment.

Uploaded by

Andrei Szilagyi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 87

Scilab Textbook Companion for

Engineering Electromagnetics
by W. H. Hayt And J. A. Buck1

Created by
Prof. R. Senthilkumar
B.Tech. + M.Tech
Electronics Engineering
Institute of Road and Transport Technology
College Teacher
Na
Cross-Checked by

August 18, 2014

1 Funded by a grant from the National Mission on Education through ICT,

http://spoken-tutorial.org/NMEICT-Intro. This Textbook Companion and Scilab


codes written in it can be downloaded from the ”Textbook Companion Project”
section at the website http://scilab.in
Contents

st of Scilab Codes 4

Vector Analysis 7

Columbs Law and Electric Field Intensity 11

Electric Flux Density Gausss Law and Divergence 15

Energy and Potential 21

Current and Conductors 26

Dielectrics and Capacitance 30

Poissons and Laplaces Equation 33

The Steady Magnetic Field 39

Magnetic Forces Materials and Inductance 43

Transmission Lines 55

The Uniform Plane Wave 66

Plane Wave Reflection and Dispersion 73

Guided Wave and Radiation 84

3
List of Scilab Codes

Exa 1.1 Program to find the unit vector . . . . . . . . . . . . . 7


Exa 1.2 find the phase angle between two vectors . . . . . . . . 7
Exa 1.3 Rectangular coordinates into cylindrical . . . . . . . . 8
Exa 1.4 Rectangular coordinates into spherical . . . . . . . . 9
Exa 2.1 Caculate force exerted on Q2 by Q1 . . . . . . . . . . 11
Exa 2.2 Caculate Electric Field . . . . . . . . . . . . . . . . . 12
Exa 2.3 Total Charge Enclosed . . . . . . . . . . . . . . . . . . 13
Exa 3.1 find Electric Flux density ’D . . . . . . . . . . . . . . 15
Exa 3.2 calculate surface charge density . . . . . . . . . . . . 16
Exa 3.3 total charge enclosed in a volume . . . . . . . . . . . 17
Exa 3.4 Find the Divergence . . . . . . . . . . . . . . . . . . . 18
Exa 3.5 verify the Divergence theorem . . . . . . . . . . . . . . 19
Exa 4.1 find the work involved . . . . . . . . . . . . . . . . . 21
Exa 4.2 find the work involved ’W’ . . . . . . . . . . . . . . . 22
Exa 4.3 Program to calculate E, D and volume charge . . . . . 23
Exa 5.1 find the resistance, current and current density . . . . 26
Exa 5.2 find potential at point P . . . . . . . . . . . . . . . . . 27
Exa 5.3 equation of the streamline . . . . . . . . . . . . . . . . 28
Exa 6.1 calculate D,E and Polarization P . . . . . . . . . . . . 30
Exa 6.2 Program to calculate E and Polarization P . . . . . . 31
Exa 6.3 Program to calculate the capacitance . . . . . . . . . 31
Exa 7.1 Derivation of capacitance . . . . . . . . . . . . . . . . 33
Exa 7.2 Capacitance of a Cylindrical Capacitor . . . . . . . . . 34
Exa 7.3 Determine the electric field . . . . . . . . . . . . . . . 35
Exa 7.4 capacitance of a spherical capacito . . . . . . . . . . . 36
Exa 7.5 Potential in spherical coordinates . . . . . . . . . . . . 37
Exa 8.1 find the magnetic field intensity . . . . . . . . . . . . 39
Exa 8.2 to find the curl H . . . . . . . . . . . . . . . . . . . . 40

4
Exa 8.3 verify Stokes theorem . . . . . . . . . . . . . . . . . . 41
Exa 9.1 find magnetic field and force produced . . . . . . . . 43
Exa 9.2 determine the differential force . . . . . . . . . . . . . 44
Exa 9.3 calculate the total torque acting . . . . . . . . . . . . 45
Exa 9.4 find the torque and force acting . . . . . . . . . . . . 46
Exa 9.5 find Magnetic Susceptibility, H,Magentization M . . . 48
Exa 9.6 find the boundary conditions on magnetic field . . . . 49
Exa 9.7 magnetomotive force ’Vm’ . . . . . . . . . . . . . . . 50
Exa 9.8 total Magnetic Flux Density . . . . . . . . . . . . . . 52
Exa 9.9 self inductances and Mutual Inductances . . . . . . . . 52
Exa 11.1 determine the total voltage . . . . . . . . . . . . . . 55
Exa 11.2 characteristic impedance . . . . . . . . . . . . . . . . . 55
Exa 11.3 magnitude and phase of characteristic . . . . . . . . . 56
Exa 11.4 output power and attenuation coefficient . . . . . . . . 57
Exa 11.5 power dissipated in the lossless . . . . . . . . . . . . . 58
Exa 11.6 find the total loss . . . . . . . . . . . . . . . . . . . . 58
Exa 11.7 find the load impedance . . . . . . . . . . . . . . . . 59
Exa 11.8 find the input impedance and power delivered . . . . 60
Exa 11.9 find the input impedance . . . . . . . . . . . . . . . . 61
Exa 11.10 find the input impedance . . . . . . . . . . . . . . . . 62
Exa 11.11 Steady state voltage . . . . . . . . . . . . . . . . . . . 63
Exa 11.12 voltage and current through a resistor . . . . . . . . . 64
Exa 12.1 phasor of forward propagating field . . . . . . . . . . 66
Exa 12.2 determine the instanteous field . . . . . . . . . . . . . 66
Exa 12.3 find the Phase constant, Phase velocity, Electric Field 67
Exa 12.4 find the penetration depth and intrinsic impedance . 68
Exa 12.5 find the attenuation constant,propagation constant . . 69
Exa 12.6 find skin depth, loss tangent and phase velocity . . . . 70
Exa 12.7 Electric field . . . . . . . . . . . . . . . . . . . . . . . 71
Exa 13.1 electric field of incident, reflected and transmitted waves 73
Exa 13.2 maxima and minma electric field . . . . . . . . . . . . 74
Exa 13.3 determine the intrinsic impedance . . . . . . . . . . . 76
Exa 13.4 determine the required range of glass thickness . . . . 76
Exa 13.5 Index for coating . . . . . . . . . . . . . . . . . . . . . 77
Exa 13.6 phasor expression . . . . . . . . . . . . . . . . . . . . 78
Exa 13.7 find the fraction of incident power . . . . . . . . . . . 79
Exa 13.8 find the refractive index . . . . . . . . . . . . . . . . . 80
Exa 13.9 determine incident and transmitted anlges . . . . . . 81
Exa 13.10 group velocity and phase velocity . . . . . . . . . . . 82
Exa 13.11 pulse width at the optical fiber . . . . . . . . . . . . . 83
Exa 14.1 determine the cutoff frequency . . . . . . . . . . . . . 84
Exa 14.2 number of modes propagate in waveguide . . . . . . . 85
Exa 14.3 determine the group delay and difference . . . . . . . . 85
Exa 14.4 determine the operating range . . . . . . . . . . . . . 86
Exa 14.5 maximum allowable refractive index . . . . . . . . . . 87
Exa 14.6 find the V number of a step index fiber . . . . . . . . 87

6
Chapter 1

Vector Analysis

Scilab code Exa 1.1 Program to find the unit vector

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e u n i t v e c t o r
3 // Example1 . 1
4 // p a g e 8
5 G = [2 , -2 , -1]; // p o s i t i o n o f p o i n t G i n c a r t e s i a n
c o o r d i n a t e system
6 aG = UnitVector ( G ) ;
7 disp ( aG , ’ U n i t V e c t o r aG = ’ )
8 // R e s u l t
9 // U n i t V e c t o r aG =
10 // 0.6666667 − 0.6666667 − 0.3333333

Scilab code Exa 1.2 find the phase angle between two vectors

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e p h a s e a n g l e b e t w e e n
two v e c t o r s
3 // Example1 . 2

7
4 // p a g e 11
5 clc ;
6 Q = [4 ,5 ,2]; // p o i n t Q
7 x = Q (1) ;
8 y = Q (2) ;
9 z = Q (3) ;
0 G = [y , -2.5* x ,3]; // v e c t o r f i e l d
1 disp (G , ’G( rQ ) = ’ )
2 aN = [2/3 ,1/3 , -2/3]; // u n i t v e c t o r − d i r e c t i o n o f Q
3 G_dot_aN = dot (G , aN ) ; // d o t p r o d u c t o f G and aN
4 disp ( G_dot_aN , ’G. aN = ’ )
5 G_dot_aN_aN = G_dot_aN * aN ;
6 disp ( G_dot_aN_aN , ’ (G. aN ) aN= ’ )
7 teta_Ga = Phase_Angle (G , aN ) // p h a s e a n g l e b e t w e e n G
and u n i t v e c t o r aN
8 disp ( teta_Ga , ’ p h a s e a n g l e b e t w e e n G and u n i t v e c t o r
aN i n d e g r e e s = ’ )
9 // R e s u l t
0 // G( rQ ) = 5. − 10. 3.
1 // G. aN = − 2.
2 // (G. aN ) aN = − 1.3333333 − 0.6666667
1.3333333
3 // p h a s e a n g l e b e t w e e n G and u n i t v e c t o r aN i n
degrees = 99.956489

Scilab code Exa 1.3 Rectangular coordinates into cylindrical

1 // c l e a r //
2 // C a p t i o n : T r a n s f o r m t h e v e c t o r o f R e c t a n g u l a r
coordinates into cylindrical coordinates
3 // Example1 . 3
4 // p a g e 18
5 clc ;
6 y = sym ( ’ y ’ ) ;
7 x = sym ( ’ x ’ ) ;
8 z = sym ( ’ z ’ ) ;
9 ax = sym ( ’ ax ’ ) ;
10 ay = sym ( ’ ay ’ ) ;
11 az = sym ( ’ a z ’ ) ;
12 ar = sym ( ’ a r ’ ) ;
13 aphi = sym ( ’ a p h i ’ ) ;
14 phi = sym ( ’ p h i ’ ) ;
15 B = y * ax - x * ay + z * az ;
16 disp (B , ’ Given v e c t o r i n c a r t e s i a n co−o r d i a n t e s y s t e m
B= ’ )
17 Br = B * ar ;
18 Bphi = B * aphi ;
19 Bz = B * az ;
20 disp ( ’ Components o f c y l i n d r i c a l v e c t o r B ’ )
21 disp ( Br , ’ Br= ’ )
22 disp ( Bphi , ’ Bphi= ’ )
23 disp ( Bz , ’ Bz= ’ )
24 // R e s u l t
25 // Given v e c t o r i n c a r t e s i a n co−o r d i a n t e s y s t e m B=
26 // a z ∗ z+ax ∗y−ay ∗ x
27 // Components o f c y l i n d r i c a l v e c t o r B
28 // Br=
29 // a r ∗ ( a z ∗ z+ax ∗y−ay ∗ x )
30 // Bphi=
31 // a p h i ∗ ( a z ∗ z+ax ∗y−ay ∗ x )
32 // Bz=
33 // a z ∗ ( a z ∗ z+ax ∗y−ay ∗ x )
34 //

Scilab code Exa 1.4 Rectangular coordinates into spherical

1 // c l e a r //
2 // C a p t i o n : T r a n s f o r m t h e v e c t o r o f R e c t a n g u l a r
coordinates into spherical coordinates
3 // Example1 . 4
// p a g e 22
clc ;
y = sym ( ’ y ’ ) ;
x = sym ( ’ x ’ ) ;
z = sym ( ’ z ’ ) ;
ax = sym ( ’ ax ’ ) ;
ay = sym ( ’ ay ’ ) ;
az = sym ( ’ a z ’ ) ;
ar = sym ( ’ a r ’ ) ;
aTh = sym ( ’ aTh ’ ) ;
aphi = sym ( ’ a p h i ’ ) ;
G = ( x * z / y ) * ax ;
disp (G , ’ Given v e c t o r i n c a r t e s i a n co−o r d i a n t e s y s t e m
B= ’ )
r = sym ( ’ r ’ ) ;
teta = sym ( ’ t e t a ’ )
phi = sym ( ’ p h i ’ )
x1 = r * sin ( teta ) * cos ( phi ) ;
y1 = r * sin ( teta ) * sin ( phi ) ;
z1 = r * cos ( teta ) ;
G1 = ( x1 * z1 / y1 ) * ax ;
Gr = G1 * ar ;
GTh = G1 * aTh ;
Gphi = G1 * aphi ;
Gsph = [ Gr , GTh , Gphi ];
disp ( Gr , ’ Gr= ’ )
disp ( GTh , ’GTh= ’ )
disp ( Gphi , ’ Gphi= ’ )
// R e s u l t
// Given v e c t o r i n c a r t e s i a n co−o r d i a n t e s y s t e m B =
ax ∗ x ∗ z / y
// Gr = a r ∗ ax ∗ c o s ( p h i ) ∗ r ∗ c o s ( t e t a ) / s i n ( p h i )
//GTh = ax ∗ c o s ( p h i ) ∗ r ∗ c o s ( t e t a ) ∗aTh/ s i n ( p h i )
// Gphi = a p h i ∗ ax ∗ c o s ( p h i ) ∗ r ∗ c o s ( t e t a ) / s i n ( p h i )
//
Chapter 2

Columbs Law and Electric


Field Intensity

Scilab code Exa 2.1 Caculate force exerted on Q2 by Q1

1 // c l e a r //
2 // C a p t i o n : Program t o C a c u l a t e f o r c e e x e r t e d on Q2 b
Q1
3 // Example2 . 1
4 // p a g e 29
5 clc ;
6 r2 = [2 ,0 ,5];
7 r1 = [1 ,2 ,3];
8 R12 = norm ( r2 - r1 ) ;
9 aR12 = UnitVector ( r2 - r1 ) ;
10 disp ( R12 , ’ R12= ’ )
11 disp ( aR12 , ’ aR12= ’ )
12 Q1 = 3e -04; // c h a r g e 1 i n Coulombs
13 Q2 = -1e -04; // c h a r g e 2 i n Coulombs
14 Eps = 8.854 e -12; // f r e e s p a c e p e r m i t t i v i t y
15 F2 = (( Q1 * Q2 ) /(4* %pi * Eps * R12 ^2) ) * aR12 ;
16 F1 = - F2 ;
17 disp ( F2 , ’ F o r c e e x e r t e d on Q2 by Q1 i n N/m F2 = ’ )
18 disp ( F1 , ’ F o r c e e x e r t e d on Q1 by Q2 i n N/m F1 = ’ )

11
19 // R e s u l t
20 // R12=
21 // 3.
22 // aR12=
23 // 0.3333333 − 0.6666667 0.6666667
24 // F o r c e e x e r t e d on Q2 by Q1 i n N/m F2 =
25 // − 9 . 9 8 6 3 8 0 5 19.972761 − 19.972761
26 // F o r c e e x e r t e d on Q1 by Q2 i n N/m F1 =
27 // 9.9863805 − 19.972761 19.972761

Scilab code Exa 2.2 Caculate Electric Field

1 // c l e a r //
2 // C a p t i o n : Program t o C a c u l a t e E l e c t r i c F i e l d E a t P
due t o 4 i d e n t i c a l c h a r g e s
3 // Example2 . 2
4 // p a g e 33
5 clc ;
6 P = [1 ,1 ,1];
7 P1 = [1 ,1 ,0];
8 P2 = [ -1 ,1 ,0];
9 P3 = [ -1 , -1 ,0];
10 P4 = [1 , -1 ,0];
11 R1 = norm (P - P1 ) ;
12 aR1 = UnitVector (P - P1 ) ;
13 R2 = norm (P - P2 ) ;
14 aR2 = UnitVector (P - P2 ) ;
15 R3 = norm (P - P3 ) ;
16 aR3 = UnitVector (P - P3 ) ;
17 R4 = norm (P - P4 ) ;
18 aR4 = UnitVector (P - P4 ) ;
19 disp ( R1 , ’ R1= ’ )
20 disp ( aR1 , ’ aR1= ’ )
21 disp ( R2 , ’ R2= ’ )
22 disp ( aR2 , ’ aR2= ’ )
23 disp ( R3 , ’ R3= ’ )
24 disp ( aR3 , ’ aR3= ’ )
25 disp ( R4 , ’ R4= ’ )
26 disp ( aR4 , ’ aR4= ’ )
27 Q = 3e -09; // c h a r g e i n Coulombs
28 Eps = 8.854 e -12; // f r e e s p a c e p e r m i t t i v i t y
29 E1 = ( Q /(4* %pi * Eps * R1 ^2) ) * aR1 ;
30 E2 = ( Q /(4* %pi * Eps * R2 ^2) ) * aR2 ;
31 E3 = ( Q /(4* %pi * Eps * R3 ^2) ) * aR3 ;
32 E4 = ( Q /(4* %pi * Eps * R4 ^2) ) * aR4 ;
33 E = E1 + E2 + E3 + E4 ;
34 disp (E , ’ E l e c t r i c F i e l d I n t e s n i t y a t any p o i n t P due
t o f o u r i d e n t i c a l C h a r g e s i n V/m= ’ )
35 // R e s u l t
36 //R1= 1.
37 // aR1= 0. 0. 1.
38 //R2= 2.236068
39 // aR2= 0.8944272 0. 0.4472136
40 //R3= 3.
41 // aR3= 0.6666667 0.6666667 0.3333333
42 //R4= 2.236068
43 // aR4= 0. 0.8944272 0.4472136
44 // E l e c t r i c F i e l d I n t e s n i t y a t any p o i n t P due t o
f o u r i d e n t i c a l C h a r g e s i n V/m=
45 // 6 . 8 2 0 6 0 4 8 6.8206048 32.785194
46 //

Scilab code Exa 2.3 Total Charge Enclosed

1 // c l e a r //
2 // Example2 . 3
3 // p a g e 35
4 clc ;
5 r = sym ( ’ r ’ ) ;
6 z = sym ( ’ z ’ ) ;
phi = sym ( ’ p h i ’ ) ;
rv = -5e -06* exp ( -1 e05 * r * z ) ;
disp ( rv , ’ Volume Charge d e n s i t y i n C/ c u b i c . m e t r e r v= ’
)
Q1 = integ ( rv *r , phi ) ;
Q1 = limit ( Q1 , phi ,2* %pi ) ;
Q2 = integ ( Q1 , z ) ;
Q2 = limit ( Q2 ,z ,0.04) - limit ( Q2 ,z ,0.02) ;
Q3 = integ ( Q2 , r ) ;
Q3 = limit ( Q3 ,r ,0.01) - limit ( Q3 ,r ,0) ;
disp ( Q1 , ’ Q1= ’ )
disp ( Q2 , ’ Q2= ’ )
disp ( Q3 , ’ T o t a l Charge E n c l o s e d i n a 2cm l e n g t h of
e l e c t r o n beam i n c o u l o m b s Q= ’ )
// R e s u l t
// Volume Charge d e n s i t y i n C/ c u b i c . m e t r e r v = −%e
ˆ −(100000∗ r ∗ z ) / 2 0 0 0 0 0
//Q1= −103993∗ r ∗%eˆ −(100000∗ r ∗ z ) / 3 3 1 0 2 0 0 0 0 0
//Q2= −103993∗%eˆ −(2000∗ r ) / 3 3 1 0 2 0 0 0 0 0 0 0 0 0 0
// T o t a l Charge E n c l o s e d i n a 2cm l e n g t h of electron
beam i n c o u l o m b s Q=
// 1 0 3 9 9 3 / 1 3 2 4 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 − 1 0 3 9 9 3 ∗ %e
ˆ −40/1324080000000000000
//Q a p p r o x i m a t e l y e q u a l t o
1 0 3 9 9 3 / 1 3 2 4 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 = 7 . 8 5 4D−14 c o u l o m b s
Chapter 3

Electric Flux Density Gausss


Law and Divergence

Scilab code Exa 3.1 find Electric Flux density ’D

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d E l e c t r i c Flux d e n s i t y ’D’
of a uniform l i n e charge
3 // Example3 . 1
4 // p a g e 54
5 clc ;
6 e0 = 8.854 e -12; // f r e e s p a c e p e r m i t t i v i t y i n F/m
7 rL = 8e -09; // l i n e c h a r g e d e n s i t y c /m
8 r = 3; // d i s t a n c e i n m e t r e
9 E = Electric_Field_Line_Charge ( rL , e0 , r ) ; // e l e c t r i c
f i e l d i n t e n s i t y of l i n e charge
10 D = e0 * E ;
11 disp (D , ’ E l e c t r i c Flu x D e n s i t y i n Coulombs p e r s q u a r e
metre D = ’ )
12 // R e s u l t
13 // E l e c t r i c Flu x D e n s i t y i n Coulombs p e r s q u a r e
metre D =
14 // 4 . 2 4 4 D−10

15
Scilab code Exa 3.2 calculate surface charge density

// c l e a r //
// C a p t i o n : Program t o c a l c u l a t e s u r f a c e c h a r g e
d e n s i t y , Flux d e n s i t y , F i e l d I n t e n s i t y o f c o a x i a l
cable
// Example3 . 2
// p a g e 64
clc ;
Q_innercyl = 30 e -09; // t o t a l c h a r g e on t h e i n n e r
conductor i n coulombs
a = 1e -03; // i n n e r r a d i u s o f c o a x i a l c a b l e i n m e t r e
b = 4e -03; // o u t e r r a d i u s o f c o a x i a l c a b l e i n m e t r e
L = 50 e -02; // l e n g t h o f c o a x i a l c a b l e
rs_innercyl = Q_innercyl /(2* %pi * a * L ) ;
rs_outercyl = Q_innercyl /(2* %pi * b * L ) ;
e0 = 8.854 e -12; // f r e e s p a c e r e l a t i v e p e r m i t t i v i t y F
/m
r = sym ( ’ r ’ ) ;
Dr = a * rs_innercyl / r ;
Er = Dr / e0 ;
disp ( rs_innercyl , ’ S u r f a c e c h a r g e d e n s i t y o f i n n e r
c y l i n d e r o f c o a x i a l c a b l e i n C/ s q u a r e . metre ,
r s i n n e r c y l= ’ )
disp ( rs_outercyl , ’ S u r f a c e c h a r g e d e n s i t y o f o u t e r
c y l i n d e r o f c o a x i a l c a b l e i n C/ s q u a r e . metre ,
r s o u t e r c y l= ’ )
disp ( Dr , ’ E l e c t r i c Flu x D e n s i t y i n C/ s q u a r e . m e t r e Dr=
’)
disp ( Er , ’ E l e c t r i c F i e l d I n t e n s i t y i n V/m Er= ’ )
// R e s u l t
// S u r f a c e c h a r g e d e n s i t y o f i n n e r c y l i n d e r o f
c o a x i a l c a b l e i n C/ s q u a r e . metre , r s i n n e r c y l =
// 0.0000095
3 // S u r f a c e c h a r g e d e n s i t y o f o u t e r c y l i n d e r o f
c o a x i a l c a b l e i n C/ s q u a r e . metre , r s o u t e r c y l =
4 // 0.0000024
5 // E l e c t r i c Flux D e n s i t y i n C/ s q u a r e . m e t r e Dr=
6 // 9 . 5 4 8 8 1 8 3 3 3 7 3 1 2 0 1 1 E−9/ r
7 // E l e c t r i c F i e l d I n t e n s i t y i n V/m Er=
8 // 1 0 7 8 . 4 7 5 0 7 7 2 2 2 8 6 / r

Scilab code Exa 3.3 total charge enclosed in a volume

1 // c l e a r //
2 // C a p t i o n : Program t o c a l c u l a t e t h e t o t a l c h a r g e
e n c l o s e d i n a volume a t t h e o r i g i n
3 // Example3 . 3
4 // p a g e 67
5 clc ;
6 V = 1e -09; // volume i n c u b i c m e t r e
7 x = sym ( ’ x ’ ) ;
8 y = sym ( ’ y ’ ) ;
9 z = sym ( ’ z ’ ) ;
0 // Components o f E l e c t r i c Flu x D e n s i t y i n c a r t e s i a n
c o o r d i n a t e system
1 Dx = exp ( - x ) * sin ( y ) ;
2 Dy = - exp ( - x ) * cos ( y ) ;
3 Dz = 2* z ;
4 // D i v e r g e n c e o f e l e c t r i c f l u x d e n s i t y ’D’
5 dDx = diff ( Dx , x ) ;
6 dDy = diff ( Dy , y ) ;
7 dDz = diff ( Dz , z ) ;
8 // T o t a l c h a r g e e n c l o s e d i n a g i v e n volume
9 del_Q = ( dDx + dDy + dDz ) * V ;
0 disp ( del_Q , ’ T o t a l c h a r g e e n c l o s e d i n an i n c r e m e n t a l
volume i n coulombs , d e l Q = ’ )
1 // T o t a l Charge e n c l o s e d i n a g i v e n volume a t o r i g i n
2 del_Q = limit ( del_Q ,x ,0) ;
3 del_Q = limit ( del_Q ,y ,0) ;
4 del_Q = limit ( del_Q ,z ,0) ;
5 disp ( del_Q *1 e09 , ’ T o t a l c h a r g e e n c l o s e d i n an
i n c r e m e n t a l volume i n nano c o u l o m b s a t o r i g i n ,
del Q = ’ )
6 // R e s u l t
7 // T o t a l c h a r g e e n c l o s e d i n an i n c r e m e n t a l volume i n
coulombs , d e l Q = 2 . 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 E−9
8 // T o t a l c h a r g e e n c l o s e d i n an i n c r e m e n t a l volume i n
nano c o u l o m b s a t o r i g i n , d e l Q =
9 // 2 . 0

Scilab code Exa 3.4 Find the Divergence

1 // c l e a r //
2 // C a p t i o n : Program t o Find t h e D i v e r g e n c e o f ’D’ a t
the o r i g i n
3 // Example3 . 4
4 // p a g e 70
5 clc ;
6 x = sym ( ’ x ’ ) ;
7 y = sym ( ’ y ’ ) ;
8 z = sym ( ’ z ’ ) ;
9 // Components o f E l e c t r i c Flu x D e n s i t y i n c a r t e s i a n
c o o r d i n a t e system
0 Dx = exp ( - x ) * sin ( y ) ;
1 Dy = - exp ( - x ) * cos ( y ) ;
2 Dz = 2* z ;
3 // D i v e r g e n c e o f e l e c t r i c f l u x d e n s i t y ’D’
4 dDx = diff ( Dx , x ) ;
5 dDy = diff ( Dy , y ) ;
6 dDz = diff ( Dz , z ) ;
7 divD = dDx + dDy + dDz
8 disp ( divD , ’ D i v e r g e n c e o f E l e c t r i c Flux D e n s i t y D i n
C/ c u b i c . metre , divD = ’ )
19 divD = limit ( divD ,x ,0) ;
20 divD = limit ( divD ,y ,0) ;
21 divD = limit ( divD ,z ,0) ;
22 disp ( divD , ’ D i v e r g e n c e o f E l e c t r i c Flux D e n s i t y D i n
C/ c u b i c . m e t r e a t o r i g i n , divD = ’ )
23 // R e s u l t
24 // D i v e r g e n c e o f E l e c t r i c Flu x D e n s i t y D i n C/ c u b i c .
metre , divD =
25 // 2
26 // D i v e r g e n c e o f E l e c t r i c Flu x D e n s i t y D i n C/ c u b i c .
m e t r e a t o r i g i n , divD =
27 // 2

Scilab code Exa 3.5 verify the Divergence theorem

1 // c l e a r //
2 // C a p t i o n : Program t o v e r i f y t h e D i v e r g e n c e t h e o r e m
f o r t h e f i e l d ’D’
3 // Example3 . 5
4 // p a g e 74
5 clc ;
6 x = sym ( ’ x ’ ) ;
7 y = sym ( ’ y ’ ) ;
8 z = sym ( ’ z ’ ) ;
9 // Components o f E l e c t r i c Flu x D e n s i t y i n c a r t e s i a n
c o o r d i n a t e system
10 Dx = 2* x * y ;
11 Dy = x ^2;
12 Dz = 0;
13 // D i v e r g e n c e o f e l e c t r i c f l u x d e n s i t y ’D’
14 dDx = diff ( Dx , x ) ;
15 dDy = diff ( Dy , y ) ;
16 dDz =0;
17 divD = dDx + dDy + dDz
disp ( divD , ’ D i v e r g e n c e o f E l e c t r i c Flux D e n s i t y D i n
C/ c u b i c . metre , divD = ’ )
// E v a l u a t e volume i n t e g r a l on d i v e r g e n c e o f ’D’
Vol_int_divD = integ ( divD , x ) ;
Vol_int_divD = limit ( Vol_int_divD ,x ,1) - limit (
Vol_int_divD ,x ,0) ;
Vol_int_divD = integ ( Vol_int_divD , y ) ;
Vol_int_divD = limit ( Vol_int_divD ,y ,2) - limit (
Vol_int_divD ,y ,0) ;
Vol_int_divD = integ ( Vol_int_divD , z ) ;
Vol_int_divD = limit ( Vol_int_divD ,z ,3) - limit (
Vol_int_divD ,z ,0) ;
disp ( Vol_int_divD , ’ Volume I n t e g r a l o f d i v e r g e n c e o f
D, i n c o u l o m b s v o l i n t ( divD )= ’ )
// E v a l u a t e s u r f a c e i n t e g r a l on f i e l d D
Dx = limit ( Dx ,x ,1) ;
sur_D = integ ( Dx , y ) ;
sur_D = limit ( sur_D ,y ,2) - limit ( sur_D ,y ,0) ;
sur_D = integ ( sur_D , z ) ;
sur_D = limit ( sur_D ,z ,3) - limit ( sur_D ,z ,0) ;
disp ( sur_D , ’ S u r f a c e I n t e g r a l o f f i e l d D, i n c o u l o m b s
s u r i n t (D . d s )= ’ )
if ( sur_D == Vol_int_divD )
disp ( ’ D i v e r g e n c e Theorem v e r i f i e d ’ )
end
// R e s u l t
// D i v e r g e n c e o f E l e c t r i c Flux D e n s i t y D i n C/ c u b i c .
metre , divD =
// 2∗ y
// Volume I n t e g r a l o f d i v e r g e n c e o f D, i n c o u l o m b s
v o l i n t ( divD )=
// 12
// S u r f a c e I n t e g r a l o f f i e l d D, i n c o u l o m b s s u r i n t (
D . d s )=
// 12
Chapter 4

Energy and Potential

Scilab code Exa 4.1 find the work involved

// c l e a r //
// C a p t i o n : Program t o f i n d t h e work i n v o l v e d ’W’ i n
moving a c h a r g e ’Q’ a l o n g s h o r t e r a r c o f a c i r c l e
// Example4 . 1
// p a g e 84
clc ;
x = sym ( ’ x ’ ) ;
y = sym ( ’ y ’ ) ;
z = sym ( ’ z ’ ) ;
y1 = sym ( ’ y1 ’ ) ;
y = sqrt (1 - x ^2) ;
Q = 2; // c h a r g e i n c o u l o m b s
Edot_dL1 = integ (y , x ) ;
disp ( Edot_dL1 , ’E . dx ∗ ax = ’ )
Edot_dL1 = limit ( Edot_dL1 ,x ,0.8) - limit ( Edot_dL1 ,x ,1)
;
disp ( Edot_dL1 , ’ V a l u e o f E . dx ∗ ax = ’ )
Edot_dL2 = 0;
disp ( Edot_dL2 , ’ V a l u e o f E . dz ∗ a z= ’ )
x = sqrt (1 - y1 ^2) ;
Edot_dL3 = integ (x , y1 )

21
0 disp ( Edot_dL3 , ’E . dy ∗ ay= ’ )
1 Edot_dL3 = limit ( Edot_dL3 , y1 ,0.6) - limit ( Edot_dL3 , y1
,0) ;
2 disp ( Edot_dL3 , ’ V a l u e o f E . dy ∗ ay = ’ )
3 W = -Q *( Edot_dL1 + Edot_dL2 + Edot_dL3 ) ;
4 disp (W , ’ Work done i n moving a p o i n t c h a r g e a l o n g
s h o r t e r a r c o f c i r c l e i n J o u l e s , W= ’ )
5 // R e s u l t
6 // E . dx ∗ ax = a s i n ( x ) /2+x ∗ s q r t (1−x ˆ 2 ) /2
7 // V a l u e o f E . dx ∗ ax = ( 2 5 ∗ a s i n ( 4 / 5 ) +12) /50−%pi /4
8 // V a l u e o f E . dz ∗ a z = 0.
9 // E . dy ∗ ay = a s i n ( y1 ) /2+ y1 ∗ s q r t (1− y1 ˆ 2 ) /2
0 // V a l u e o f E . dy ∗ ay = ( 2 5 ∗ a s i n ( 3 / 5 ) +12) /50
1 // Work done i n moving a p o i n t c h a r g e a l o n g s h o r t e r
arc of c i r c l e in Joules , W =
2 // −2∗((25∗ a s i n ( 4 / 5 ) +12) /50+(25∗ a s i n ( 3 / 5 ) +12) /50−%pi
/4)
3 // Which i s e q u i v a l e n t t o
4 // − 2 ∗ ( ( 2 5 ∗ 0 . 9 2 7 2 9 5 2 + 1 2 ) / 5 0 + ( 2 5 ∗ 0 . 6 4 3 5 0 1 1 + 1 2 ) /50−%pi
/ 4 ) = −0.96 J o u l e s

Scilab code Exa 4.2 find the work involved ’W’

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e work i n v o l v e d ’W’ i n
moving a c h a r g e ’Q’ a l o n g s t r a i g h t l i n e
3 // Example4 . 2
4 // p a g e 84
5 clc ;
6 x = sym ( ’ x ’ ) ;
7 y = sym ( ’ y ’ ) ;
8 z = sym ( ’ z ’ ) ;
9 y1 = sym ( ’ y1 ’ ) ;
0 y = -3*( x -1) ;
1 Q = 2; // c h a r g e i n c o u l o m b s
Edot_dL1 = integ (y , x ) ;
disp ( Edot_dL1 , ’E . dx ∗ ax = ’ )
Edot_dL1 = limit ( Edot_dL1 ,x ,0.8) - limit ( Edot_dL1 ,x ,1)
;
disp ( Edot_dL1 , ’ V a l u e o f E . dx ∗ ax = ’ )
Edot_dL2 = 0;
disp ( Edot_dL2 , ’ V a l u e o f E . dz ∗ a z= ’ )
x = (1 - y1 /3) ;
Edot_dL3 = integ (x , y1 )
disp ( Edot_dL3 , ’E . dy ∗ ay= ’ )
Edot_dL3 = limit ( Edot_dL3 , y1 ,0.6) - limit ( Edot_dL3 , y1
,0) ;
disp ( Edot_dL3 , ’ V a l u e o f E . dy ∗ ay = ’ )
W = -Q *( Edot_dL1 + Edot_dL2 + Edot_dL3 ) ;
disp (W , ’ Work done i n moving a p o i n t c h a r g e a l o n g
s h o r t e r a r c o f c i r c l e i n J o u l e s , W= ’ )
// R e s u l t
//E . dx ∗ ax = −3∗( x ˆ2/2− x )
// V a l u e o f E . dx ∗ ax = −3/50
// V a l u e o f E . dz ∗ a z = 0.
//E . dy ∗ ay = y1−y1 ˆ 2 / 6
// V a l u e o f E . dy ∗ ay = 27/50
// Work done i n moving a p o i n t c h a r g e a l o n g s h o r t e r
a r c o f c i r c l e i n J o u l e s , W = −24/25 = −0.96
Joules

Scilab code Exa 4.3 Program to calculate E, D and volume charge

// c l e a r //
// C a p t i o n : Program t o c a l c u l a t e E , D and volume
charge density using divergence of D
// Example4 . 3
// p a g e 100
7 y = 3;
8 z = 6;
9 V = 2*( x ^2) *y -5* z ;
10 disp ( float ( V ) , ’ P o t e n t i a l V a t p o i n t P( − 4 , 3 , 6 ) i n
v o l t s i s Vp = ’ )
11 x1 = sym ( ’ x1 ’ ) ;
12 y1 = sym ( ’ y1 ’ ) ;
13 z1 = sym ( ’ z 1 ’ ) ;
14 ax = sym ( ’ ax ’ ) ;
15 ay = sym ( ’ ay ’ ) ;
16 az = sym ( ’ a z ’ ) ;
17 V1 = 2*( x1 ^2) * y1 -5* z1 ;
18 // E l e c t r i c F i e l d I n t e n s i t y from g r a d i e n t o f V
19 Ex = - diff ( V1 , x1 ) ;
20 Ey = - diff ( V1 , y1 ) ;
21 Ez = - diff ( V1 , z1 ) ;
22 Ex1 = limit ( Ex , x1 , -4) ;
23 Ex1 = limit ( Ex1 , y1 ,3) ;
24 Ex1 = limit ( Ex1 , z1 ,6) ;
25 Ey1 = limit ( Ey , x1 , -4) ;
26 Ey1 = limit ( Ey1 , y1 ,3) ;
27 Ey1 = limit ( Ey1 , z1 ,6) ;
28 Ez1 = limit ( Ez , x1 , -4) ;
29 Ez1 = limit ( Ez1 , y1 ,3) ;
30 Ez1 = limit ( Ez1 , z1 ,6) ;
31 E = Ex1 * ax + Ey1 * ay + Ez1 * az ;
32 Ep = sqrt ( float ( Ex1 ^2+ Ey1 ^2+ Ez1 ^2) ) ;
33 disp ( Ep , ’ E l e c t r i c F i e l d I n t e n s i t y E a t p o i n t P
( −4 ,3 ,6) in v o l t s E = ’ )
34 aEp = float ( E / Ep ) ;
35 disp ( aEp , ’ D i r e c t i o n o f E l e c t r i c F i e l d E a t p o i n t P
( − 4 , 3 , 6 ) aEp= ’ )
36 Dx = float (8.854* Ex ) ;
37 Dy = float (8.854* Ey ) ;
38 Dz = float (8.854* Ez ) ;
39 D = Dx * ax + Dy * ay + Dz * az ;
40 disp (D , ’ E l e c t r i c Flu x D e n s i t y i n p i c o . C/ s q u a r e . m e t r e
D =’)

24
dDx = diff ( Dx , x1 ) ;
dDx = limit ( dDx , x1 , -4) ;
dDx = limit ( dDx , y1 ,3) ;
dDx = limit ( dDx , z1 ,6) ;
dDy = diff ( Dy , y1 ) ;
dDy = limit ( dDy , x1 , -4) ;
dDy = limit ( dDy , y1 ,3) ;
dDy = limit ( dDy , z1 ,6) ;
dDz = diff ( Dz , z1 ) ;
dDz = limit ( dDz , x1 , -4) ;
dDz = limit ( dDz , y1 ,3) ;
dDz = limit ( dDz , z1 ,6) ;
rV = dDx + dDy + dDz ;
disp ( rV , ’ Volume Charge d e n s i t y from d i v e r g e n c e o f D
i n pC/ c u b i c . m e t r e i s rV= ’ )
// R e s u l t
// P o t e n t i a l V a t p o i n t P( − 4 , 3 , 6 ) i n v o l t s i s Vp =
66.
// E l e c t r i c F i e l d I n t e n s i t y E a t p o i n t P( − 4 , 3 , 6 ) i n
v o l t s E = 57.9050947672137
// D i r e c t i o n o f E l e c t r i c F i e l d E a t p o i n t P( − 4 , 3 , 6 )
aEp=
// 0 . 0 1 7 2 6 9 6 3 7 5 6 8 5 1 ∗ ( 5 ∗ az −32∗ ay +48∗ ax )
// e q u i v a l e n t t o aEp= 0 . 0 8 6 3 4 8 2 ∗ az − 0 . 5 5 2 6 2 8 4 ∗ ay
+ 0 . 8 2 8 9 4 2 6 ∗ ax
// E l e c t r i c Flux D e n s i t y i n p i c o . C/ s q u a r e . m e t r e D =
// −35.416∗ ax ∗ x1 ∗ y1 − 1 7 . 7 0 8 ∗ ay ∗ x1 ˆ 2 + 4 4 . 2 7 ∗ a z
// Volume Charge d e n s i t y from d i v e r g e n c e o f D i n pC/
c u b i c . m e t r e i s rV=
// −106.248
Chapter 5

Current and Conductors

Scilab code Exa 5.1 find the resistance, current and current density

// c l e a r //
// C a p t i o n : Program t o f i n d t h e r e s i s t a n c e , c u r r e n t
and c u r r e n t d e n s i t y
// Example5 . 1
// p a g e 123
clc ;
clear ;
D = 0.0508; // d i a m e t e r o f c o n d u c t o r i n i n c h e s
D = 0.0508*0.0254; // d i a m e t e r i n m e t r e s
r = D /2; // r a d i u s i n m e t r e s
A = %pi * r ^2; // a r e a o f t h e c o n d u c t o r i n s q u a r e m e t r e
L = 1609; // l e n g t h o f t h e c o p p e r w i r e i n m e t r e
sigma = 5.80 e07 ; // c o n d u c t i v i t y i n s i e m e n s / m e t r e
R = L /( sigma * A ) ; // r e s i s t a n c e i n ohms
I = 10; // c u r r e n t i n a m p e r e s
J = I / A ; // c u r r e n t d e n s i t y i n amps / s q u a r e . m e t r e
disp (R , ’ R r e s i s t a n c e i n ohms o f g i v e n c o p p e r w i r e R =
’)
disp (J , ’ C u r r e n t d e n s i t y i n A/ s q u a r e . m e t r e J = ’ )
// R e s u l t
// R r e s i s t a n c e i n ohms o f g i v e n c o p p e r w i r e R =

26
20 // 21.215013
21 // C u r r e n t d e n s i t y i n A/ s q u a r e . m e t r e J =
22 // 7647425.6

Scilab code Exa 5.2 find potential at point P

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d p o t e n t i a l a t p o i n t P ,
E l e c t r i c f F i e l d I n t e n s i t y E , Flu x d e n s i t y D
3 // Example5 . 2
4 // p a g e 126
5 clc ;
6 x = sym ( ’ x ’ ) ;
7 y = sym ( ’ y ’ ) ;
8 z = sym ( ’ z ’ ) ;
9 ax = sym ( ’ ax ’ ) ;
10 ay = sym ( ’ ay ’ ) ;
11 az = sym ( ’ a z ’ ) ;
12 V = 100*( x ^2 - y ^2) ;
13 disp (V , ’ P o t e n t i a l i n V o l t s V = ’ )
14 Ex = diff (V , x ) ;
15 Ey = diff (V , y ) ;
16 Ez = diff (V , z ) ;
17 E = -( Ex * ax + Ey * ay + Ez * az ) ;
18 disp (E , ’ E l e c t r i c F i e l d I n t e n s i t y i n V/m E = ’ )
19 E = limit (E ,x ,2) ;
20 E = limit (E ,y , -1) ;
21 V = limit (V ,x ,2) ;
22 V = limit (V ,y , -1) ;
23 disp (V , ’ P o t e n t i a l a t p o i n t P i n V o l t s Vp = ’ )
24 disp (E , ’ E l e c t r i c F i e l d I n t e n s i t y a t p o i n t P i n V/m
Ep = ’ )
25 D = 8.854 e -12* E ;
26 disp ( D *1 e09 , ’ E l e c t r i c FLux D e n s i t y a t p o i n t P i n nC/
s q u a r e . m e t r e Dp = ’ )
7 // R e s u l t
8 // P o t e n t i a l i n V o l t s V = 1 0 0 ∗ ( xˆ2−y ˆ 2 )
9 // E l e c t r i c F i e l d I n t e n s i t y i n V/m E = 2 0 0∗ ay ∗y −200∗
ax ∗ x
0 // P o t e n t i a l a t p o i n t P i n V o l t s Vp = 300
1 // E l e c t r i c F i e l d I n t e n s i t y a t p o i n t P i n V/m Ep =
−200∗ ay −400∗ ax
2 // E l e c t r i c FLux D e n s i t y a t p o i n t P i n nC/ s q u a r e .
m e t r e Dp = 0 . 0 0 8 8 5 4 ∗ ( − 2 0 0 ∗ ay −400∗ ax )
3 // which i s e q u i v a l e n t t o Dp = −3.5416∗ ax −1.7708∗ ay

Scilab code Exa 5.3 equation of the streamline

1 // c l e a r //
2 // C a p t i o n : Program t o d e t e r m i n e t h e e q u a t i o n o f t h e
s t r e a m l i n e p a s s i n g t h r o u g h any p o i n t P
3 // Example5 . 3
4 // p a g e 128
5 clc ;
6 x = sym ( ’ x ’ ) ;
7 y = sym ( ’ y ’ ) ;
8 z = sym ( ’ z ’ ) ;
9 C1 = integ (1/ y , y ) + integ (1/ x , x ) ;
0 disp ( C1 , ’ C1 = ’ )
1 C2 = exp ( C1 ) ;
2 disp ( C2 , ’ The Stream l i n e E q u a t i o n C2 = ’ )
3 C2 = limit ( C2 ,x ,2) ;
4 C2 = limit ( C2 ,y , -1) ;
5 disp ( C2 , ’ The v a l u e o f c o n s t a n t i n t h e s t r e a m l i n e
e q u a t i o n p a s s i n g t h r o u g h t h e p o i n t P i s C2= ’ )
6 // R e s u l t
7 //C1 = l o g ( y )+l o g ( x )
8 // The Stream l i n e E q u a t i o n C2 = x ∗ y
9 // The v a l u e o f c o n s t a n t i n t h e s t r e a m l i n e e q u a t i o n
p a s s i n g t h r o u g h t h e p o i n t P i s C2 = −2
29
Chapter 6

Dielectrics and Capacitance

Scilab code Exa 6.1 calculate D,E and Polarization P

1 // c l e a r //
2 // C a p t i o n : Program t o c a l c u l a t e D, E and P o l a r i z a t i o
P for Teflon slab
3 // Example6 . 1
4 // p a g e 142
5 clc ;
6 ax = sym ( ’ ax ’ ) ;
7 e0 = sym ( ’ e 0 ’ ) ;
8 E0 = sym ( ’ E0 ’ ) ;
9 Ein = sym ( ’ Ein ’ ) ;
10 er = 2.1; // r e l a t i v e p e r m i t t i v i t y o f t e f l o n
11 chi = er -1; // e l e c t r i c s u s c e p t i b i l i t y
12 Eout = E0 * ax ;
13 Dout = float ( e0 * Eout ) ;
14 Din = float ( er * e0 * Ein ) ;
15 Pin = float ( chi * e0 * Ein ) ;
16 disp ( Dout , ’ Dout i n c / s q u a r e . m e t r e = ’ )
17 disp ( Din , ’ Din i n c / s q u a r e . m e t r e = ’ )
18 disp ( Pin , ’ P o l a r i z a t i o n i n c o u l o m b s p e r s q u a r e m e t r e
Pin = ’ )
19 // R e s u l t

30
0 // Dout i n c / s q u a r e . m e t r e = ax ∗ e 0 ∗E0
1 // Din i n c / s q u a r e . m e t r e = 2 . 1 ∗ e 0 ∗ Ein
2 // P o l a r i z a t i o n i n c o u l o m b s p e r s q u a r e m e t r e Pin =
1 . 1 ∗ e 0 ∗ Ein

Scilab code Exa 6.2 Program to calculate E and Polarization P

1 // c l e a r //
2 // C a p t i o n : Program t o c a l c u l a t e E and P o l a r i z a t i o n P
for Teflon slab
3 // Example6 . 2
4 // p a g e 146
5 clc ;
6 ax = sym ( ’ ax ’ ) ;
7 e0 = sym ( ’ e 0 ’ ) ;
8 E0 = sym ( ’ E0 ’ ) ;
9 er = 2.1; // r e l a t i v e p e r m i t t i v i t y o f t e f l o n
0 chi = er -1; // e l e c t r i c s u s c e p t i b i l i t y
1 Eout = E0 * ax ;
2 Ein = float ( Eout / er ) ;
3 Din = float ( e0 * Eout ) ;
4 Pin = float ( Din - e0 * Ein ) ;
5 disp ( Ein , ’ Ein i n V/m = ’ )
6 disp ( Pin , ’ P o l a r i z a t i o n i n c o u l o m b s p e r s q u a r e m e t r e
Pin = ’ )
7 // R e s u l t
8 // Ein i n V/m = 0 . 4 7 6 1 9 0 4 7 6 1 9 0 4 8 ∗ ax ∗E0
9 // P o l a r i z a t i o n i n c o u l o m b s p e r s q u a r e m e t r e Pin =
0 . 5 2 3 8 0 9 5 2 3 8 0 9 5 2 ∗ ax ∗ e 0 ∗E0

Scilab code Exa 6.3 Program to calculate the capacitance

1 // c l e a r //
2 // C a p t i o n : Program t o c a l c u l a t e t h e c a p a c i t a n c e o f a
parallel plate capacitor
3 // Example6 . 3
4 // p a g e 151
5 clc ;
6 S = 10; // a r e a i n s q u a r e i n c h
7 S = 10*(0.0254) ^2; // a r e a i n s q u a r e m e t r e
8 d = 0.01; // d i s t a n c e b e t w e e n t h e p l a t e s i n i n c h
9 d = 0.01*0.0254; // d i s t a n c e b e t w e e n t h e p l a t e s i n
metre
10 e0 = 8.854 e -12; // f r e e s p a c e p e r m i t t i v i t y i n F/m
11 er = 6; // r e l a t i v e p e r m i t t i v i t y o f mica
12 e = e0 * er ;
13 C = parallel_capacitor (e ,S , d ) ;
14 disp ( C *1 e09 , ’ C a p a c i t a n c e o f a p a r a l l e l p l a t e
capacitor in pico farads C =’)
15 // R e s u l t
16 // C a p a c i t a n c e o f a p a r a l l e l p l a t e c a p a c i t o r i n p i c o
farads C = 1.3493496
Chapter 7

Poissons and Laplaces Equation

Scilab code Exa 7.1 Derivation of capacitance

// c l e a r //
// C a p t i o n : D e r i v a t i o n o f c a p a c i t a n c e o f a p a r a l l e l
plate capacitor
// Example7 . 1
// p a g e 177
clc ;
x = sym ( ’ x ’ ) ;
d = sym ( ’ d ’ ) ;
Vo = sym ( ’ Vo ’ ) ;
e = sym ( ’ e ’ ) ;
ax = sym ( ’ ax ’ ) ;
A = sym ( ’A ’ ) ;
B = sym ( ’B ’ ) ;
S = sym ( ’ S ’ ) ;
V = integ (A , x ) + B ;
V = limit (V ,A , Vo / d ) ;
V = limit (V ,B ,0) ;
disp (V , ’ P o t e n t i a l i n V o l t s V = ’ )
E = - diff (V , x ) * ax ;
disp (E , ’ E l e c t r i c F i e l d i n V/m E = ’ )
D = e*E;

33
1 DN = D / ax ;
2 disp (D , ’ E l e c t r i c Flu x D e n s i t y i n C/ s q u a r e m e t r e D = ’
)
3 Q = - DN * S ;
4 disp (Q , ’ Charge i n Coulombs Q = ’ )
5 C = Q / Vo ;
6 disp (C , ’ C a p a c i t a n c e o f p a r a l l e l p l a t e capacitor C =’
)
7 // R e s u l t
8 // P o t e n t i a l i n V o l t s V = Vo∗ x / d
9 // E l e c t r i c F i e l d i n V/m E = −ax ∗Vo/ d
0 // E l e c t r i c Flux D e n s i t y i n C/ s q u a r e m e t r e D = −ax ∗ e
∗Vo/ d
1 // Charge i n Coulombs Q = e ∗Vo∗S / d
2 // C a p a c i t a n c e o f p a r a l l e l p l a t e c a p a c i t o r C = e ∗S / d

Scilab code Exa 7.2 Capacitance of a Cylindrical Capacitor

1 // c l e a r //
2 // C a p t i o n : C a p a c i t a n c e o f a C y l i n d r i c a l C a p a c i t o r
3 // Example7 . 2
4 // p a g e 179
5 clc ;
6 A = sym ( ’A ’ ) ;
7 B = sym ( ’B ’ ) ;
8 r = sym ( ’ r ’ ) ;
9 ar = sym ( ’ a r ’ ) ;
0 ruo = sym ( ’ r u o ’ ) ;
1 a = sym ( ’ a ’ ) ;
2 b = sym ( ’ b ’ ) ;
3 L = sym ( ’ L ’ ) ;
4 Vo = sym ( ’ Vo ’ ) ;
5 V = integ ( A /r , r ) + B ;
6 disp (V , ’ P o t e n t i a l V = ’ )
7 V = limit (V ,A , Vo / log ( a / b ) ) ;
8 V = limit (V ,B , - Vo * log ( b ) / log ( a / b ) ) ;
9 disp (V , ’ P o t e n t i a l V by s u b s t i t u t e t h e v a l u e s of
constant A & B = ’)
0 V = Vo * log ( b / r ) / log ( b / a ) ;
1 E = - diff (V , r ) * ar ;
2 disp (E , ’E = ’ ) ;
3 E = limit (E ,r , a ) ;
4 disp (E , ’E a t r =a i s = ’ )
5 D = e*E;
6 DN = D / ar ;
7 disp ( DN , ’DN = ’ )
8 S = float (2* %pi * a * L ) ; // a r e a o f c y l i n d e r
9 Q = DN * S
0 disp (Q , ’Q = ’ )
1 C = Q / Vo ;
2 disp (C , ’ C a p a c i t a n c e o f a c y l i n d r i c a l C a p a c i t o r C = ’ )
3 // R e s u l t
4 // P o t e n t i a l V = B+l o g ( r ) ∗A
5 // P o t e n t i a l V by s u b s t i t u t e t h e v a l u e s o f c o n s t a n t
A & B =( l o g ( r )−l o g ( b ) ) ∗Vo/ l o g ( a / b )
6 // E = a r ∗Vo / ( l o g ( b / a ) ∗ r )
7 // E a t r =a i s = a r ∗Vo / ( a ∗ l o g ( b / a ) )
8 // DN = e ∗Vo / ( a ∗ l o g ( b / a ) )
9 // Q = 6 . 2 8 3 1 8 5 3 0 6 0 2 3 8 0 5 ∗ e ∗Vo∗L/ l o g ( b / a )
0 // C a p a c i t a n c e o f a c y l i n d r i c a l C a p a c i t o r C =
6 . 2 8 3 1 8 5 3 0 6 0 2 3 8 0 5 ∗ e ∗L/ l o g ( b / a )

Scilab code Exa 7.3 Determine the electric field

1 // c l e a r //
2 // C a p t i o n : Program t o D e t e r m i n e t h e e l e c t r i c f i e l d
o f a two i n f i n i t e r a d i a l p l a n e s w i t h an i n t e r i o r
angle alpha
3 // Example 7 . 3
4 // p a g e 180
phi = sym ( ’ p h i ’ ) ;
A = sym ( ’A ’ ) ;
B = sym ( ’B ’ ) ;
Vo = sym ( ’ Vo ’ ) ;
alpha = sym ( ’ a l p h a ’ ) ;
aphi = sym ( ’ a p h i ’ ) ;
r = sym ( ’ r ’ ) ;
V = integ (A , phi ) + B ;
disp (V , ’V = ’ ) ;
V = limit (V ,B ,0) ;
V = limit (V ,A , Vo / alpha ) ;
disp (V , ’ P o t e n t i a l V a f t e r a p p l y i n g boundary
conditions =’)
E = -(1/ r ) * diff (V , phi ) * aphi ;
disp (E , ’E = ’ )
// R e s u l t
// V = B+p h i ∗A
// P o t e n t i a l V a f t e r a p p l y i n g boundary c o n d i t i o n s =
p h i ∗Vo/ a l p h a
// E = −a p h i ∗Vo / ( a l p h a ∗ r )

Scilab code Exa 7.4 capacitance of a spherical capacito

// c l e a r //
// C a p t i o n : D e r i v a t i o n o f c a p a c i t a n c e o f a s p h e r i c a l
capacitor
// Example7 . 4
// p a g e 181
clc ;
a = sym ( ’ a ’ ) ;
b = sym ( ’ b ’ ) ;
Vo = sym ( ’ Vo ’ ) ;
r = sym ( ’ r ’ ) ;
e = sym ( ’ e ’ ) ;
11 V = Vo *((1/ r ) -(1/ b ) ) /((1/ a ) -(1/ b ) ) ;
12 disp (V , ’V = ’ )
13 E = - diff (V , r ) * ar ;
14 disp (E , ’E = ’ )
15 D = e*E;
16 DN = D / ar ;
17 disp ( DN , ’DN = ’ )
18 S = float (4* %pi * r ^2) ; // a r e a o f s p h e r e
19 Q = DN * S ;
20 disp (Q , ’Q = ’ )
21 C = Q / Vo ;
22 disp (C , ’ C a p a c i t a n c e o f a s p h e r i c a l c a p a c i t o r = ’ )
23 // R e s u l t
24 //V = ( 1 / r −1/b ) ∗Vo / ( 1 / a −1/b )
25 //E = a r ∗Vo / ( ( 1 / a −1/b ) ∗ r ˆ 2 )
26 //DN = e ∗Vo / ( ( 1 / a −1/b ) ∗ r ˆ 2 )
27 //Q = 1 2 . 5 6 6 3 7 0 6 0 4 6 9 6 4 3 ∗ e ∗Vo / ( 1 / a −1/b )
28 // C a p a c i t a n c e o f a s p h e r i c a l c a p a c i t o r =
1 2 . 5 6 6 3 7 0 6 0 4 6 9 6 4 3 ∗ e / ( 1 / a −1/b )

Scilab code Exa 7.5 Potential in spherical coordinates

1 // c l e a r //
2 // C a p t i o n : P o t e n t i a l i n s p h e r i c a l c o o r d i n a t e s a s a
f u n c t i o n o f t e t a V( t e t a )
3 // Example7 . 5
4 // p a g e 182
5 clc ;
6 teta = sym ( ’ t e t a ’ ) ;
7 A = sym ( ’A ’ ) ;
8 B = sym ( ’B ’ ) ;
9 V = integ ( A / float ( sin ( teta ) ) , teta ) + B ;
10 disp (V , ’V = ’ )
11 // R e s u l t
12 //V = B+( l o g ( c o s ( t e t a ) −1)/2− l o g ( c o s ( t e t a ) +1) / 2 ) ∗A
13 // E q u i v a l e n t t o V = B+l o g ( t a n ( t e t a / 2 ) ) ∗A
Chapter 8

The Steady Magnetic Field

Scilab code Exa 8.1 find the magnetic field intensity

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e m a g n e t i c f i e l d
intensity of a current carrying filament
3 // Example8 . 1
4 // p a g e 217
5 clc ;
6 I = 8; // c u r r e n t i n amps
7 alpha1x = -90/57.3; // p h a s e a n g l e a l o n g w i t h x−a x i
8 x = 0.4;
9 y = 0.3;
10 z =0;
11 alpha2x = atan ( x / y ) ;
12 aphi = sym ( ’ a p h i ’ ) ;
13 az = sym ( ’ a z ’ ) ;
14 rx = y ; // d i s t a n c e i n m e t r e s i n c y n l i n d r i c a l
c o o r d i a n t e system
15 H2x = float (( I /(4* %pi * rx ) ) *( sin ( alpha2x ) - sin ( alpha1
) ) ) * - az ;
16 disp ( H2x , ’ H2x = ’ )
17 alpha1y = - atan ( y / x ) ;
18 alpha2y = 90/57.3;

39
9 ry = 0.4;
0 H2y = float (( I /(4* %pi * ry ) ) *( sin ( alpha2y ) - sin ( alpha1y
) ) ) * - az ;
1 disp ( H2y , ’ H2y = ’ )
2 H2 = H2x + H2y ;
3 disp ( H2 , ’ H2 = ’ )
4 // R e s u l t
5 // H2x = −3.819718617079289∗ az
6 // H2y = −2.546479080730701∗ az
7 //H2 = −6.36619769780999∗ az

Scilab code Exa 8.2 to find the curl H

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e c u r l H o f a s q u a r e
path o f s i d e ’ d ’
3 // Example8 . 2
4 // p a g e 230
5 clc ;
6 ax = sym ( ’ ax ’ ) ;
7 az = sym ( ’ a z ’ ) ;
8 ay = sym ( ’ ay ’ ) ;
9 z = sym ( ’ z ’ ) ;
0 y = sym ( ’ y ’ ) ;
1 d = sym ( ’ d ’ ) ;
2 H = 0.2* z ^2* ax ;
3 Hx = float ( H / ax ) ;
4 HdL = float (0.4* z * d ^2) ;
5 // c u r l H e v a l u a t e d from t h e d e f i n i t i o n o f c u r l
6 curlH = ( HdL /( d ^2) ) * ay ;
7 // c u r l H e v a l u a t e d from t h e d e t e r m i n a n t
8 del_cross_H = - ay *( - diff ( Hx , z ) ) + az *( - diff ( Hx , y ) ) ;
9 disp ( curlH , ’ c u r l H = ’ )
0 disp ( del_cross_H , ’ d e l c r o s s H = ’ )
1 // R e s u l t
2 // c u r l H = 0 . 4 ∗ ay ∗ z
3 // d e l c r o s s H = 0 . 4 ∗ ay ∗ z

Scilab code Exa 8.3 verify Stokes theorem

1 // c l e a r //
2 // C a p t i o n : Program t o v e r i f y S t o k e s t h e o r e m
3 // Example8 . 3
4 // p a g e 233
5 clc ;
6 teta = sym ( ’ t e t a ’ ) ;
7 phi = sym ( ’ p h i ’ ) ;
8 ar = sym ( ’ a r ’ ) ;
9 aphi = sym ( ’ a p h i ’ ) ;
0 az = sym ( ’ a z ’ ) ;
1 r = sym ( ’ r ’ ) ;
2 curlH = float (36* cos ( teta ) * cos ( phi ) * r ^2* sin ( teta ) ) ;
3 curlH_S = integ ( curlH , teta ) ;
4 curlH_S = float ( limit ( curlH_S ,r ,4) ) ;
5 curlH_S = float ( limit ( curlH_S , teta ,0.1* %pi ) ) - float (
limit ( curlH_S , teta ,0) ) ;
6 curlH_S = integ ( curlH_S , phi ) ;
7 curlH_S = float ( limit ( curlH_S , phi ,0.3* %pi ) ) - float (
limit ( curlH_S , phi ,0) ) ;
8 disp ( curlH_S , ’ S u r f a c e I n t e g r a l o f c u r l H i n Amps = ’ )
9 Hr = 6* r * sin ( phi ) ;
0 Hphi = 18* r * sin ( teta ) * cos ( phi ) ;
1 HdL = float ( limit ( Hphi * r * sin ( teta ) ,r ,4) ) ;
2 HdL = float ( limit ( HdL , teta ,0.1* %pi ) ) ;
3 HdL = float ( integ ( HdL , phi ) )
4 HdL = float ( limit ( HdL , phi ,0.3* %pi ) ) ;
5 disp ( HdL , ’ C l o s e d L i n e I n t e g r a l o f H i n Amps = ’ )
6 // R e s u l t
7 // S u r f a c e I n t e g r a l o f c u r l H i n Amps =
22.24922359441324
28 // C l o s e d L i n e I n t e g r a l o f H i n Amps =
22.24922359441324
Chapter 9

Magnetic Forces Materials and


Inductance

Scilab code Exa 9.1 find magnetic field and force produced

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d m a g n e t i c f i e l d and f o r c e
produced in a square loop
3 // Example9 . 1
4 // p a g e 263
5 clc ;
6 x = sym ( ’ x ’ ) ;
7 y = sym ( ’ y ’ ) ;
8 z = sym ( ’ z ’ ) ;
9 ax = sym ( ’ ax ’ ) ;
10 ay = sym ( ’ ay ’ ) ;
11 az = sym ( ’ a z ’ ) ;
12 I = 15; // f i l a m e n t c u r r e n t i n amps
13 I1 = 2e -03; // c u r r e n t i n s q u a r e l o o p
14 u0 = 4* %pi *1 e -07; // f r e e s p a c e p e r m e a b i l i t y i n H/m
15 H = float ( I /(2* %pi * x ) ) * az ;
16 disp (H , ’ M a g n e t i c F i e l d I n t e n s i t y i n A/m H = ’ )
17 B = float ( u0 * H ) ;
18 disp (B , ’ M a g n e t i c Flu x D e n s i t y i n T e s l a B = ’ )

43
19 Bz = B / az ;
20 // B c r o s s d L = ay ∗ d i f f ( Bz , x ) ;
21 F1 = float ( - I1 * integ ( ay * Bz , x ) ) ;
22 F1 = float ( limit ( F1 ,x ,3) - limit ( F1 ,x ,1) ) ;
23 F2 = float ( - I1 * integ ( ax * - Bz , y ) ) ;
24 F2 = float ( limit ( F2 ,x ,3) ) ;
25 F2 = float ( limit ( F2 ,y ,2) - limit ( F2 ,y ,0) ) ;
26 F3 = float ( - I1 * integ ( ay * Bz , x ) ) ;
27 F3 = float ( limit ( F3 ,x ,1) - limit ( F3 ,x ,3) ) ;
28 F4 = float ( - I1 * integ ( ax * - Bz , y ) ) ;
29 F4 = float ( limit ( F4 ,x ,1) ) ;
30 F4 = float ( limit ( F4 ,y ,0) - limit ( F4 ,y ,2) ) ;
31 F = float (( F1 + F2 + F3 + F4 ) *1 e09 ) ;
32 disp (F , ’ T o t a l F o r c e a c t i n g on a s q u a r e l o o p i n nN F
= ’)
33 // R e s u l t
34 // M a g n e t i c F i e l d I n t e n s i t y i n A/m H =
2.387324146817574∗ az /x
35 // M a g n e t i c Flu x D e n s i t y i n T e s l a B =
3 . 0 0 0 0 0 0 0 0 0 3 3 4 0 7 7 1 E−6∗ a z / x
36 // T o t a l F o r c e a c t i n g on a s q u a r e l o o p i n nN F =
− 8 . 0 0 0 0 0 0 0 0 0 8 9 0 8 7 3 ∗ ax

Scilab code Exa 9.2 determine the differential force

1 // c l e a r //
2 // C a p t i o n : Program t o d e t e r m i n e t h e d i f f e r e n t i a l
f o r c e b e t w e e n two d i f f e r e n t i a l c u r r e n t e l e m e n t s
3 // Example9 . 2
4 // p a g e 265
5 clc ;
6 ax = sym ( ’ ax ’ ) ;
7 ay = sym ( ’ ay ’ ) ;
8 az = sym ( ’ a z ’ ) ;
9 // p o s i t i o n o f f i l a m e n t i n c a r t e s i a n c o o r d i n a t e
system
0 P1 = [5 ,2 ,1];
1 P2 = [1 ,8 ,5];
2 // d i s t a n c e b e t w e e n f i l a m e n t 1 and f i l a m e n t 2
3 R12 = norm ( P2 - P1 ) ;
4 disp ( R12 , ’ R12 = ’ )
5 I1dL1 = [0 , -3 ,0]; // c u r r e n t c a r r y i n g f i r s t f i l a m e n t
1
6 I2dL2 = [0 ,0 , -4]; // c u r r e n t c a r r y i n g s e c o n d f i l a m e n t
2
7 u0 = 4* %pi *1 e -07; // f r e e s p a c e p e r m e a b i l i t y i n H/m
8 aR12 = UnitVector ( P2 - P1 ) ; // u n i t v e c t o r
9 disp ( aR12 , ’ aR12 = ’ )
0 C1 = cross_product ( I1dL1 , aR12 ) ;
1 C2 = cross_product ( I2dL2 , C1 ) ;
2 dF2 = ( u0 /(4* %pi * R12 ^2) ) * C2 ;
3 dF2_y = float ( dF2 (2) *1 e09 ) ;
4 disp ( dF2_y * ay , ’ t h e d i f f e r e n t i a l f o r c e b e t w e e n two
d i f f e r e n t i a l c u r r e n t e l e m e n t s i n nN = ’ )
5 // R e s u l t
6 // R12 = 8 . 2 4 6 2 1 1 3
7 // aR12 = − 0 . 4 8 5 0 7 1 3 0.7276069 0.4850713
8 // t h e d i f f e r e n t i a l f o r c e b e t w e e n two d i f f e r e n t i a l
c u r r e n t e l e m e n t s i n nN = 8 . 5 6 0 0 8 0 8 7 8 1 0 5 1 4 2 ∗ ay

Scilab code Exa 9.3 calculate the total torque acting

1 // c l e a r //
2 // C a p t i o n : Program t o c a l c u l a t e t h e t o t a l t o r q u e
a c t i n g on a p l a n a r r e c t a n g u l a r c u r r e n t l o o p
3 // Example9 . 3
4 // p a g e 271
5 clc ;
6 ax = sym ( ’ ax ’ ) ;
7 ay = sym ( ’ ay ’ ) ;
az = sym ( ’ a z ’ ) ;
x = 1; // l e n g t h i n m e t r e
y = 2; // w i d e i n m e t r e
S = [0 ,0 , x * y ]; // a r e a o f c u r r e n t l o o p i n s q u a r e
metre
I = 4e -03; // c u r r e n t i n Amps
B = [0 , -0.6 ,0.8];
T = I * cross_product (S , B ) ;
Tx = float ( T (1) ) ;
disp ( Tx * ax *1 e03 , ’ T o t a l Torque a c t i n g on t h e
r e c t a n g u l a r c u r r e n t l o o p i n m i l l i N/m= ’ )
// R e s u l t
// T o t a l Torque a c t i n g on t h e r e c t a n g u l a r c u r r e n t
l o o p i n m i l l i N/m = 4 . 8 ∗ ax

Scilab code Exa 9.4 find the torque and force acting

// c l e a r //
// C a p t i o n : Program t o f i n d t h e t o r q u e and f o r c e
a c t i n g on e a c h s i d e o f p l a n a r l o o p
// Example9 . 4
// p a g e 271
clc ;
ax = sym ( ’ ax ’ ) ;
ay = sym ( ’ ay ’ ) ;
az = sym ( ’ a z ’ ) ;
I = 4e -03; // c u r r e n t i n Amps
B = [0 , -0.6 ,0.8]; // M a g e n t i c F i e l d a c t i n g on c u r r e n t
loop in Tesla
L1 = [1 ,0 ,0]; // l e n g t h a l o n g x−a x i s
L2 = [0 ,2 ,0]; // l e n g t h a l o n g y−a x i s
F1 = I * cross_product ( L1 , B ) ;
F3 = - F1 ;
F2 = I * cross_product ( L2 , B ) ;
17 R1 = [0 , -1 ,0]; // d i s t a n c e from c e n t e r o f l o o p f o r
side1
18 R2 = [0.5 ,0 ,0]; // d i s t a n c e from c e n t e r o f l o o p f o r
side2
19 R3 = [0 ,1 ,0]; // d i s t a n c e from c e n t e r o f l o o p f o r
side3
20 R4 = [ -0.5 ,0 ,0]; // d i s t a n c e from c e n t e r o f l o o p f o r
side4
21 T1 = cross_product ( R1 , F1 ) ;
22 T2 = cross_product ( R2 , F2 ) ;
23 T3 = cross_product ( R3 , F3 ) ;
24 T4 = cross_product ( R4 , F4 ) ;
25 T = T1 + T2 + T3 + T4 ;
26 Tx = float ( T (1) *1 e03 ) ;
27 disp ( F1 , ’ F1 = ’ )
28 disp ( F2 , ’ F2 = ’ )
29 disp ( F3 , ’ F3 = ’ )
30 disp ( F4 , ’ F4 = ’ )
31 disp ( T1 , ’ T1 = ’ )
32 disp ( T2 , ’ T2 = ’ )
33 disp ( T3 , ’ T3 = ’ )
34 disp ( T4 , ’ T4 = ’ )
35 disp ( Tx * ax , ’ T o t a l t o r q u e a c t i n g on t h e r e c t a n g u l a r
p l a n a r l o o p i n m i l l i N/m T = ’ )
36 // R e s u l t
37 // F1 =
38 // 0.
39 // − 0 . 0 0 3 2
40 // − 0 . 0 0 2 4
41 // F2 =
42 // 0.0064
43 // 0.
44 // 0.
45 // F3 =
46 // 0.
47 // 0.0032
48 // 0.0024
49 // F4 =
0 // − 0.0064
1 // 0.
2 // 0.
3 // T1 =
4 // 0.0024
5 // 0.
6 // 0.
7 // T2 =
8 // 0.
9 // 0.
0 // 0.
1 // T3 =
2 // 0.0024
3 // 0.
4 // 0.
5 // T4 =
6 // 0.
7 // 0.
8 // 0.
9 // T o t a l t o r q u e a c t i n g on t h e r e c t a n g u l a r p l a n a r
l o o p i n m i l l i N/m T = 4 . 8 ∗ ax

Scilab code Exa 9.5 find Magnetic Susceptibility, H,Magentization M

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d M a g n e t i c S u s c e p t i b i l i t y ,
H, M a g e n t i z a t i o n M
3 // Example9 . 5
4 // p a g e 279
5 clc ;
6 ur = 50; // r e l a t i v e p e r m e a b i l i t y o f f e r r i t e m a t e r i a l
7 u0 = 4* %pi *1 e -07; // f r e e s p a c e p e r m e a b i l i t y i n H/m
8 chim = ur -1; // m a g n e t i c s u s c e p t i b i l i t y
9 B = 0.05; // m a g n e t i c f l u x d e n s i t y i n t e s l a
0 u = u0 * ur ;
11 H = B / u ; // m a g n e t i c f i e l d i n t e n s i t y i n A/m
12 M = chim * ceil ( H ) ; // m a g n e t i z a t i o n i n A/m
13 disp ( chim , ’ chim = ’ )
14 disp (H , ’H = ’ )
15 disp (M , ’M = ’ )
16 // R e u s l t
17 // chim = 4 9 .
18 //H = 795.77472
19 //M = 39004.

Scilab code Exa 9.6 find the boundary conditions on magnetic field

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e boundary c o n d i t i o n s
on m a g n e t i c f i e l d
3 // Example9 . 6
4 // p a g e 283
5 clc ;
6 ax = sym ( ’ ax ’ ) ;
7 ay = sym ( ’ ay ’ ) ;
8 az = sym ( ’ a z ’ ) ;
9 u1 = 4e -06; // r e l a t i v e p e r m e a b i l i t y i n medium1
10 u2 = 7e -06; // r e l a t i v e p e r m e a b i l i t y i n medium2
11 k = [80 ,0 ,0]; // i n A/m
12 B1 = [2 e -03 , -3 e -03 ,1 e -03]; // f i e l d i n r e g i o n 1
13 aN12 = [0 ,0 , -1];
14 //To f i n d Normal Components o f M a g n e t i c F i e l d
15 Bz = dot ( B1 , aN12 ) ;
16 BN1 = [0 ,0 , - Bz ];
17 BN1 = float ( BN1 ) ;
18 BN2 = float ( BN1 ) ;
19 //To Find t h e T a n g e n t i a l Components o f M a g n e t i c
Field
20 Bt1 = float ( B1 - BN1 ) ;
21 Ht1 = float ( Bt1 / u1 ) ;
2 v = cross_product ( aN12 , k ) ;
3 Ht2 = float ( Ht1 -v ’) ;
4 Bt2 = float ( u2 * Ht2 ) ;
5 disp ( BN1 (1) * ax + BN1 (2) * ay + BN1 (3) * az , ’BN1 = ’ )
6 disp ( BN2 (1) * ax + BN2 (2) * ay + BN2 (3) * az , ’BN2 = ’ )
7 disp ( Bt1 (1) * ax + Bt1 (2) * ay + Bt1 (3) * az , ’ Bt1 = ’ ) ;
8 disp ( Ht1 (1) * ax + Ht1 (2) * ay + Ht1 (3) * az , ’ Ht1 = ’ ) ;
9 disp ( Ht2 (1) * ax + Ht2 (2) * ay + Ht2 (3) * az , ’ Ht2 = ’ ) ;
0 disp ( Bt2 (1) * ax + Bt2 (2) * ay + Bt2 (3) * az , ’ Bt2 = ’ ) ;
1 // T o t a l M a g n e t i c F i e l d R e g i o n 2
2 B2 = ( BN2 + Bt2 ) *1 e03 ;
3 B2 = B2 (1) * ax + B2 (2) * ay + B2 (3) * az ;
4 disp ( B2 , ’ T o t a l M a g n e t i c F i e l d R e g i o n 2 i n m i l l i T e s l a
B2 = ’ )
5 // R e s u l t
6 // BN1 =
7 // 0 . 0 0 1 ∗ a z
8 //BN2 =
9 // 0 . 0 0 1 ∗ a z
0 // Bt1 =
1 // 0 . 0 0 2 ∗ ax − 0 . 0 0 3 ∗ ay
2 // Ht1 =
3 // 5 0 0 . 0 ∗ ax − 7 5 0 . 0 ∗ ay
4 // Ht2 =
5 // 5 0 0 . 0 ∗ ax − 6 7 0 . 0 ∗ ay
6 // Bt2 =
7 // 0 . 0 0 3 5 ∗ ax − 0 . 0 0 4 6 9 ∗ ay
8 // T o t a l M a g n e t i c F i e l d R e g i o n 2 i n m i l l i T e s l a B2 =
9 // 1 . 0 ∗ az −4.69∗ ay +3.5∗ ax

Scilab code Exa 9.7 magnetomotive force ’Vm’

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d f i n d m a g n e t o m o t i v e f o r c e
’Vm’ and r e l u c t a n c e ’R ’
3 // Example9 . 7
4 // p a g e 288
5 clc ;
6 u0 = 4* %pi *1 e -07 ; // f r e e s p a c e p e r m e a b i l i t y i n H/m
7 ur = 1; // r e l a t i v e p e r m e a b i l i t y
8 u = u0 * ur ;
9 dair = 2e -03; // a i r gap i n t o r o i d
0 dsteel = 0.3* %pi ;
1 S = 6e -04; // a r e a o f c r o s s s e c t i o n i n s q u a r e m e t r e
2 B = 1; // f l u x d e n s i t y 1 t e s l a
3 N = 500; // number o f t u r n s
4 Rair = dair /( u * S ) ;
5 disp ( Rair , ’ R e l u c t a n c e i n A . t /Wb R a i r = ’ )
6 phi = B * S ;
7 disp ( phi , ’ M a g n e t i c Flu x i n weber p h i = ’ )
8 Vm_air = S * Rair ;
9 disp ( Vm_air , ’mmf r e q u i r e d f o r t h e a i r gap i n A . t
Vm air = ’ )
0 Hsteel = 200; // m a g n e t i c f i e l d i n t e n s i t y o f s t e e l i n
A/m
1 Vm_steel = Hsteel * dsteel ;
2 disp ( Vm_steel , ’mmf r e q u i r e d f o r t h e s t e e l i n A . t
Vm steel =’ )
3 disp ( Vm_steel + Vm_air , ’ T o t l a mmf r e q u i r e d f o r t o r o i d
i n A . t Vm = ’ )
4 I = ( Vm_steel + Vm_air ) / N ;
5 disp (I , ’ T o t a l c o i l c u r r e n t i n Amps I = ’ )
6 // R e s u l t
7 // R e l u c t a n c e i n A . t /Wb R a i r = 2 6 5 2 5 8 2 . 4
8 // M a g n e t i c Flu x i n weber p h i = 0 . 0 0 0 6
9 //mmf r e q u i r e d f o r t h e a i r gap i n A . t Vm air =
1591.5494
0 //mmf r e q u i r e d f o r t h e s t e e l i n A . t V m s t e e l =
188.49556
1 // T o t l a mmf r e q u i r e d f o r t o r o i d i n A . t Vm =
1780.045
2 // T o t a l c o i l c u r r e n t i n Amps I = 3.56009
Scilab code Exa 9.8 total Magnetic Flux Density

// c l e a r //
// C a p t i o n : Program t o f i n d t o t a l M a g n e t i c Flux
D e n s i t y i n Weber
// Example9 . 8
// p a g e 289
clc ;
I = 4; // c u r r e n t t h r o u g h t o r o i d i n Amps
r = 1e -03; // a i r gap r a d i u s i n m e t r e
Hphi = I /(2* %pi * r ) ;
u0 = 4* %pi *1 e -07 ; // f r e e s p a c e p e r m e a b i l i t y i n H/m
ur = 1; // r e l a t i v e p e r m e a b i l i t y
u = u0 * ur ;
N = 500; // number o f t u r n s
S = 6e -04; // c r o s s s e c t i o n a r e a i n s q u a r e m e t r e
Rair = 2.65 e06 ; // r e l u c t a n c e i n a i r A . t /Wb
Rsteel = 0.314 e06 ; // r e l u c t a n c e i n s t e e l A . t /Wb
R = Rair + Rsteel ; // t o t a l r e l u c t a n c e i n A . t /Wb
Vm = I *500; // t o t a l mmf i n A . t
phi = Vm / R ; // t o t a l f l u x i n w e b e r s
B = phi / S ; // f l u x d e n s i t y i n Wb/ S q u a r e m e t r e
disp (B , ’ M a g e n t i c Flu x D e n s i t y i n t e s l a B = ’ )
// R e s u l t
// M a g e n t i c Flu x D e n s i t y i n t e s l a B = 1 . 1 2 4 6 0 6 4

Scilab code Exa 9.9 self inductances and Mutual Inductances

// c l e a r //
// C a p t i o n : Program t o c a l c u l a t e s e l f i n d u c t a n c e s and
Mutual I n d u c t a n c e s b e t w e e n two c o a i x a l s o l e n o i d s
// Example9 . 9
4 // p a g e 297
5 clc ;
6 n1 = sym ( ’ n1 ’ ) ;
7 n2 = sym ( ’ n2 ’ ) ;
8 I1 = sym ( ’ I 1 ’ ) ;
9 I2 = sym ( ’ I 2 ’ ) ;
10 az = sym ( ’ a z ’ ) ;
11 R1 = sym ( ’ R1 ’ ) ;
12 R2 = sym ( ’ R2 ’ ) ;
13 u0 = sym ( ’ u0 ’ ) ;
14 H1 = n1 * I1 * az ;
15 disp ( H1 , ’ H1 = ’ ) ;
16 H2 = n2 * I2 * az ;
17 disp ( H2 , ’ H2 = ’ ) ;
18 S1 = float ( %pi * R1 ^2) ;
19 S2 = float ( %pi * R2 ^2) ;
20 Hz = float ( H1 / az ) ;
21 phi12 = float ( u0 * Hz * S1 ) ;
22 disp ( phi12 , ’ p h i 1 2 = ’ )
23 M12 = n2 * phi12 / I1 ;
24 disp ( M12 , ’ M12 = ’ )
25 //R1 = 2 e −02;
26 //R2 = 3 e −02;
27 // n1 = 5 0 ∗ 1 0 0 ; // number o f t u r n s /m
28 // n2 = 8 0 ∗ 1 0 0 ; // number o f t u r n s /m
29 // u0 = 4∗ %pi ∗1 e −07;
30 M12 = float ( limit ( M12 , R1 ,2 e -02) ) ;
31 M12 = float ( limit ( M12 , R2 ,3 e -02) ) ;
32 M12 = float ( limit ( M12 , n1 ,5000) ) ;
33 M12 = float ( limit ( M12 , n2 ,8000) ) ;
34 M12 = float ( limit ( M12 , u0 ,4* %pi *1 e -07) ) ;
35 disp ( M12 *1 e03 , ’ Mutual I n d u c t a n c e i n mH/m M12= ’ )
36 L1 = u0 * n1 ^2* S1 ;
37 L1 = float ( limit ( L1 , u0 ,4* %pi *1 e -07) ) ;
38 L1 = float ( limit ( L1 , n1 ,5000) ) ;
39 L1 = float ( limit ( L1 , R1 ,2 e -02) ) ;
40 disp ( L1 *1 e3 , ’ S e l f I n d u c t a n c e o f s o l e n o i d 1 i n mH/m
L1 = ’ )
L2 = u0 * n2 ^2* S2 ;
L2 = float ( limit ( L2 , u0 ,4* %pi *1 e -07) ) ;
L2 = float ( limit ( L2 , n2 ,8000) ) ;
L2 = float ( limit ( L2 , R2 ,3 e -02) ) ;
disp ( L2 *1 e3 , ’ S e l f I n d u c t a n c e o f s o l e n o i d 1 i n mH/m
L2 = ’ )
// R e s u l t
// H1 = a z ∗ n1 ∗ I 1
// H2 = a z ∗ n2 ∗ I 2
// p h i 1 2 = 3 . 1 4 1 5 9 2 6 5 3 0 1 1 9 0 3 ∗ n1 ∗ u0 ∗ I 1 ∗R1ˆ2
// M12 = 3 . 1 4 1 5 9 2 6 5 3 0 1 1 9 0 3 ∗ n1 ∗ n2 ∗ u0 ∗R1ˆ2
// Mutual I n d u c t a n c e i n mH/m M12= 63.16546815077
// S e l f I n d u c t a n c e o f s o l e n o i d 1 i n mH/m L1 =
39.47841759423
// S e l f I n d u c t a n c e o f s o l e n o i d 1 i n mH/m L2 =
227.39568534276
Chapter 11

Transmission Lines

Scilab code Exa 11.1 determine the total voltage

1 // c l e a r //
2 // C a p t i o n : Program t o d e t e r m i n e t h e t o t a l v o l t a g e a s
a function
3 // o f t i m e and p o s i t i o n i n a l o s s l e s s t r a n s m i s s o n
line
4 // Example11 . 1
5 // p a g e 3 4 2
6 // syms z , t , B , w , Vo ;
7 VST = sym ( ’ 2∗Vo∗ c o s (B∗ z ) ’ ) ;
8 V_zt = VST * sym ( ’ c o s (w∗ t ) ’ ) ;
9 disp ( V_zt , ’V( z , t )= ’ )
10 // R e s u l t
11 //V( z , t )= 2∗Vo∗ c o s ( t ∗w) ∗ c o s ( z ∗B)

Scilab code Exa 11.2 characteristic impedance

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e c h a r a c t e r i s t i c

55
impedance , t h e p h a s e c o n s t a n t an t h e p h a s e
velocity
3 // Example11 . 2
4 // p a g e 3 4 4
5 clear ;
6 clc ;
7 close ;
8 L = 0.25 e -6; // 0 . 2 5 uH/m
9 C = 100 e -12; // 100 pF/m
0 f = 600 e06 ; // f r e q u e n c y f = 100MHz
1 W = 2* %pi * f ; // a n g u l a r f r e q u e n c y
2 Zo = sqrt ( L / C ) ;
3 B = W * sqrt ( L * C ) ;
4 Vp = W / B ;
5 disp ( Zo , ’ C h a r a c t e r i s t i c Impedance i n ohms Zo = ’ )
6 disp (B , ’ Phase c o n s t a n t i n r a d /m B= ’ )
7 disp ( Vp , ’ Phase v e l o c i t y i n m/ s Vp= ’ )
8 // R e s u l t
9 // C h a r a c t e r i s t i c Impedance i n ohms Zo =
0 // 50.
1 // Phase c o n s t a n t i n r a d /m B=
2 // 18.849556
3 // Phase v e l o c i t y i n m/ s Vp=
4 // 2 . 0 0 0D+08

Scilab code Exa 11.3 magnitude and phase of characteristic

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e m a g n i t u d e and p h a s e o f
characteristic
3 // i m p e d a n c e Zo
4 // Example11 . 3
5 // p a g e 3 4 7
6 Zo = sym ( ’ s q r t ( L/C) ∗(1 − s q r t ( −1) ∗R/ ( 2 ∗W∗L ) ) ’ ) ;
7 teta = sym ( ’ a t a n (−R/ ( 2 ∗W∗L ) ) ’ ) ;
8 disp ( Zo , ’ C h a r a c t e r i s t i c i m p e d a n c e Zo = ’ )
9 disp ( teta , ’ The p h a s e a n g l e t e t a= ’ )
0 // R e s u l t
1 // C h a r a c t e r i s t i c i m p e d a n c e Zo =
2 // s q r t ( L/C) ∗(1 − %i ∗R/ ( 2 ∗ L∗W) )
3 // The p h a s e a n g l e t e t a=
4 // −a t a n (R/ ( 2 ∗ L∗W) )

Scilab code Exa 11.4 output power and attenuation coefficient

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e o u t p u t power and
attenuation c o e f f i c i e n t
3 // Example11 . 4
4 // p a g e 3 4 9
5 clear ;
6 clc ;
7 close ;
8 z = 20; // d i s t a n c e i n m e t e r s
9 Pz_P0_dB = -2; // f r a c t i o n o f power d r o p i n dB
0 Pz_P0 = 10^( Pz_P0_dB /10) ;
1 disp ( Pz_P0 , ’ F r a c t i o n o f i n p u t power r e a c h e s o u t p u t P
( z ) /P ( 0 )= ’ )
2 P0_mid_dB = -1; // f r a c t i o n o f power d r o p a t m i d p o i n t
i n dB
3 P0_mid = 10^( P0_mid_dB /10) ;
4 disp ( P0_mid , ’ F r a c t i o n o f t h e i n p u t power r e a c h e s t h e
m i d p o i n t P ( 1 0 ) /P ( 0 )= ’ )
5 alpha = - Pz_P0_dB /(8.69* z ) ;
6 disp ( alpha , ’ a t t e n u a t i o n i n Np/m a l p h a= ’ )
7 // R e s u l t
8 // F r a c t i o n o f i n p u t power r e a c h e s o u t p u t P( z ) /P ( 0 )=
9 // 0.6309573
0 // F r a c t i o n o f t h e i n p u t power r e a c h e s t h e m i d p o i n t P
( 1 0 ) /P ( 0 )=
21 // 0.7943282
22 // a t t e n u a t i o n i n Np/m a l p h a=
23 // 0.0115075

Scilab code Exa 11.5 power dissipated in the lossless

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e power d i s s i p a t e d i n
the l o s s l e s s
3 // t r a n s m i s s i o n l i n e
4 // Example11 . 5
5 // p a g e 3 5 2
6 clc ;
7 close ;
8 ZL = 50 - %i *75; // l o a d i m p e d a n c e i n ohms
9 Zo = 50; // c h a r a c t e r i s t i c i m p e d a n c e i n ohms
10 R = reflection_coeff ( ZL , Zo ) ;
11 Pi = 100 e -03; // i n p u t power i n m i l l i w a t t s
12 Pt = (1 - abs ( R ) ^2) * Pi ; // power d i s s i p a t e d by t h e l o a d
13 disp (R , ’ R e f l e c t i o n c o e f f i c i e n t R = ’ )
14 disp ( Pt *1000 , ’ power d i s s i p a t e d by t h e l o a d i n m i l l i
w a t s s Pt= ’ )
15 // R e s u l t
16 // R e f l e c t i o n c o e f f i c i e n t R = 0.36 − 0.48 i
17 // power d i s s i p a t e d by t h e l o a d i n m i l l i w a t s s Pt =
64.

Scilab code Exa 11.6 find the total loss

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e t o t a l l o s s i n l o s s y
lines
3 // Example11 . 6
// pa ge 35 2 −353
clc ;
close ;
L1 = 0.2*10; // l o s s ( dB ) i n f i r s t l i n e o f l e n g t h =10 m
L2 = 0.1*15; // l o s s ( dB ) i n s e c o n d l i n e o f l e n g t h =15m
R = 0.3; // r e f l e c t i o n c o e f f i c i e n t
Pi = 100 e -03; // i n p u t power i n m i l l i w a t t s
Lj = 10* log10 (1/(1 - abs ( R ) ^2) ) ;
Lt = L1 + L2 + Lj ;
Pout = Pi *(10^( - Lt /10) ) ;
disp ( Lt , ’ The t o t a l l o s s o f t h e l i n k i n dB i s Lt= ’ )
disp ( Pout *1000 , ’ The o u t p u t power w i l l be i n m i l l i
w a t s s Pout = ’ )
// R e s u l t
// The t o t a l l o s s o f t h e l i n k i n dB i s Lt=
// 3.9095861
// The o u t p u t power w i l l be i n m i l l i w a t s s Pout =
// 40.648207

Scilab code Exa 11.7 find the load impedance

// c l e a r //
// C a p t i o n : Program t o f i n d t h e l o a d i m p e d a n c e o f a
slotted line
// Example11 . 7
// p a g e 3 5 7
clear ;
clc ;
close ;
S = 5; // s t a n d i n g wave r a t i o
T = (1 - S ) /(1+ S ) ; // r e f l e c t i o n c o e f f i c i e n t
Zo = 50; // c h a r a c t e r i s t i c i m p e d a n c e
ZL = Zo *(1+ T ) /(1 - T ) ;
disp ( ZL , ’ Load i m p e d a n c e o f a s l o t t e d l i n e i n ohms ZL
3 // R e s u l t
4 // Load i m p e d a n c e o f a s l o t t e d l i n e i n ohms ZL = 1 0 .

Scilab code Exa 11.8 find the input impedance and power delivered

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e i n p u t i m p e d a n c e and
power d e l i v e r e d t o
3 // t h e l o a d
4 // Example11 . 8
5 // p a g e 3 6 3
6 clc ;
7 close ;
8 ZR1 = 300; // i n p u t i m p e d a n c e o f f i r s t r e c e i v e r
9 ZR2 = 300; // i n p u t i m p e d a n c e o f s e c o n d r e c e i v e r
0 Zo = ZR1 ; // c h a r a c t e r i s t i c i m p e d a n c e = 300 ohm
1 Zc = - %i *300; // c a p a c i t i v e i m p e d a n c e
2 L = 80 e -02; // l e n g t h = 80 cm
3 Lambda = 1; // w a v e l e n g t h = 1m
4 Vth = 60; // v o l t a g e 300 v o l t s
5 Zth = Zo ;
6 ZL1 = parallel ( ZR1 , ZR2 ) ;
7 ZL = parallel ( ZL1 , Zc ) ; // n e t l o a d impedane
8 T = reflection_coeff ( ZL , ZR2 ) ; // r e f l e c t i o n
coefficient
9 [R , teta1 ] = polar ( T ) ; // r e f l e c t i o n c o e f f i c i e n t i n
p o l a r form
0 teta1 = real ( teta1 ) *57.3; // t e t a v a l u e i n d e g r e e s
1 S = VSWR ( R ) ; // v o l t a g e s t a n d i n g wave r a t i o
2 EL = electrical_length (L , Lambda ) ;
3 EL = EL /57.3; // e l e c t r i c a l l e n g t h i n d e g r e e s
4 Zin = Zo *( ZL * cos ( EL ) + %i * Zo * sin ( EL ) ) /( Zo * cos ( EL ) + %i *
ZL * sin ( EL ) ) ;
5 disp ( Zin , ’ I n p u t Impedance i n ohms Z i n = ’ )
6 Is = Vth /( Zth + Zin ) ; // s o u r c e c u r r e n t i n amps
7 [ Is , teta2 ] = polar ( Is ) ; // s o u r c e current in polar
form
8 Pin = (1/2) *( Is ^2) * real ( Zin ) ;
9 PL = Pin ; // f o r l o s s l e s s l i n e
0 disp ( Pin , ’ Power d e l i v e r e d t o a l o s s l e s s l i n e i n
w a t s s PL = ’ )
1 // R e s u l t
2 // I n p u t Impedance i n ohms Z i n = 755.49551 −
138.46477 i
3 // Power d e l i v e r e d t o a l o s s l e s s l i n e i n w a t s s PL =
1.2

Scilab code Exa 11.9 find the input impedance

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e i n p u t i m p e d a n c e f o r a
l i n e t e r m i n a t e d with pure c a p a c i t i v e impedance
3 // Example11 . 9
4 // p a g e 3 6 3
5 clc ;
6 close ;
7 ZL = - %i *300; // l o a d impdance i s p u r e l y c a p a c i t i v e
impedance
8 ZR = 300;
9 T = reflection_coeff ( ZL , ZR ) ; // r e f l e c t i o n c o e f f i c i e n t
i n r e c t a n d u l a r form
0 [R , teta ] = polar ( T ) ; // r e f l e c t i o n c o e f f i c i e n t i n
p o l a r form
1 S = VSWR ( R )
2 if ( S == %inf )
3 Zo = ZR ;
4 end
5 Zin = Zo *( ZL * cos ( EL ) + %i * Zo * sin ( EL ) ) /( Zo * cos ( EL ) + %i * ZL
* sin ( EL ) ) ;
6 disp (T , ’ R e f l e c t i o n c o e f f i c i e n t i n r e c t a n g u l a r form ’ )
7 disp (S , ’ V o l t a g e S t a n d i n g Wave R a t i o S= ’ )
8 disp ( Zin , ’ I n p u t i m p e d a n c e i n ohms Z i n = ’ )
9 // R e s u l t
0 // R e f l e c t i o n c o e f f i c i e n t i n r e c t a n g u l a r form
1 // − i
2 // V o l t a g e S t a n d i n g Wave R a t i o S=
3 // Inf
4 // I n p u t i m p e d a n c e i n ohms Z i n =
5 // 588.78315 i

Scilab code Exa 11.10 find the input impedance

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e i n p u t i m p e d a n c e f o r a
l i n e t e r m i n a t e d with impedance ( with i n d u c t i v e
reactance )
3 // Example11 . 1 0
4 // p a g e 3 6 9
5 clc ;
6 close ;
7 ZL = 25+ %i *50; // l o a d impdance i n ohms
8 Zo = 50; // c h a r a c t e r i s t i c i m p e d a n c e i n ohms
9 T = reflection_coeff ( ZL , Zo ) ; // r e f l e c t i o n c o e f f i c i e n t
i n r e c t a n d u l a r form
0 [R , teta ] = polar ( T ) ; // r e f l e c t i o n c o e f f i c i e n t i n
p o l a r form
1 L = 60 e -02; // l e n g t h 60 cm
2 Lambda = 2; // w a v e l e n g t h = 2m
3 EL = electrical_length (L , Lambda ) ;
4 EL = EL /57.3; // e l e c t r i c a l l e n g t h i n r a d i a n s
5 Zin =(1+ T * exp ( - %i *2* EL ) ) /(1 - T * exp ( - %i *2* EL ) ) ;
6 disp ( Zin , ’ I n p u t i m p e d a n c e i n ohms Z i n = ’ )
7 // R e s u l t
8 // I n p u t i m p e d a n c e i n ohms Z i n =
9 // 0.2756473 − 0.4055013 i
Scilab code Exa 11.11 Steady state voltage

// c l e a r //
// C a p t i o n :
// Example11 . 1 1
// p a g e 3 8 1
clc ;
close ;
Rg = 50; // s e r i e s r e s i s t a n c e w i t h b a t t e r y i n ohms
Zo = Rg ; // c h a r a c t e r i s t i c i m p e d a n c e
RL = 25; // l o a d r e s i s t a n c e
Vo = 10; // b a t t e r y v o l t a g e i n v o l t s
V1_S = ( Rg /( Zo + Rg ) ) * Vo ;
T = reflection_coeff ( RL , Zo ) ;
V1_R = T * V1_S ;
I1_S = V1_S / Zo ;
I1_R = - V1_R / Zo ;
IB = Vo /( Zo + RL ) ;
VL = Vo *( RL /( Rg + RL ) ) ;
disp ( V1_S , ’ V o l t a g e a t s o u r c e i n v o l t s V 1 p l u s = ’ )
disp ( V1_R , ’ V o l t a g e r e t u r n s t o b a t t e r y i n v o l t s
V1minus= ’ )
disp ( I1_S , ’ C u r r e n t a t b a t t e r y i n amps I 1 p l u s= ’ )
disp ( I1_R , ’ C u r r e n t a t b a t t e r y i n amps I 1 m i n u s= ’ )
disp ( IB , ’ S t e a d y s t a t e c u r r e n t t h r o u g h b a t t e r y i n
amps IB= ’ )
disp ( VL , ’ S t e a d y s t a t e l o a d v o l t a g e i n v o l t s VL= ’ )
// R e s u l t
// V o l t a g e a t s o u r c e i n v o l t s V 1 p l u s =
// 5.
// V o l t a g e r e t u r n s t o b a t t e r y i n v o l t s V1minus=
// − 1 . 6 6 6 6 6 6 7
// C u r r e n t a t b a t t e r y i n amps I 1 p l u s=
// 0.1
// C u r r e n t a t b a t t e r y i n amps I 1 m i n u s=
// 0.0333333
// S t e a d y s t a t e c u r r e n t t h r o u g h b a t t e r y i n amps IB=
// 0.1333333
// S t e a d y s t a t e l o a d v o l t a g e i n v o l t s VL=
// 3.3333333

Scilab code Exa 11.12 voltage and current through a resistor

// c l e a r //
// C a p t i o n : Program t o p l o t t h e v o l t a g e and c u r r e n t
through a r e s i s t o r
// Example11 . 1 2
// p a g e 386
clear ;
close ;
clc ;
t1 = 0:0.1:2;
t2 = 2:0.1:4;
t3 = 4:0.1:6;
t4 = 6:0.1:8;
VR =[40* ones (1 , length ( t1 ) ) , -20* ones (1 , length ( t2 ) ) ,10*
ones (1 , length ( t3 ) ) , -5* ones (1 , length ( t4 ) ) ];
IR =[ -1.2* ones (1 , length ( t1 ) ) ,0.6* ones (1 , length ( t2 ) )
, -0.3* ones (1 , length ( t3 ) ) ,0.15* ones (1 , length ( t4 ) )
];
subplot (2 ,1 ,1)
a = gca () ;
a . x_location = ” o r i g i n ” ;
a . y_location = ” o r i g i n ” ;
a . data_bounds = [0 , -100;10 ,100];
plot2d ([ t1 , t2 , t3 , t4 ] , VR ,5)
xlabel ( ’
ylabel ( ’ VR ’ )
title ( ’ R e s i s t o r V o l t a g e a s a f u n c t i o n o f t i m e ’ )
subplot (2 ,1 ,2)
a = gca () ;
a . x_location = ” o r i g i n ” ;
a . y_location = ” o r i g i n ” ;
a . data_bounds = [0 , -1.4;10 ,1.4];
plot2d ([ t1 , t2 , t3 , t4 ] , IR ,5)
xlabel ( ’

t ’)
ylabel ( ’ IR ’ )
title ( ’ C u r r e n t t h r o u g h R e s i s t o r a s a f u n c t i o n o f
time ’ )
Chapter 12

The Uniform Plane Wave

Scilab code Exa 12.1 phasor of forward propagating field

1 // c l e a r //
2 // C a p t i o n : Program t o d e t e r m i n e t h e p h a s o r o f f o r w a r d
propagating f i e l d
3 // Example12 . 1
4 // p a g e 4 0 0
5 clc ;
6 close ;
7 Eyzt = sym ( ’ 1 0 0∗ exp ( %i ∗ 1 0 ˆ 8 ∗ t−%i ∗ 0 . 5 ∗ z +30) ’ ) ;
8 Eysz = sym ( ’ 1 0 0∗ exp ( %i ∗ 1 0 ˆ 8 ∗ t−%i ∗ 0 . 5 ∗ z +30) ∗ exp (−%i
∗10ˆ8∗ t ) ’ );
9 disp ( Eyzt )
10 disp ( Eysz , ’ Forward P r o p a g a t i n g F i e l d i n p h a s o r form
=’)
11 // R e s u l t
12 // 1 0 0∗ exp ( −0.5∗ %i ∗ z +100000000∗ %i ∗ t +30)
13 // Forward P r o p a g a t i n g F i e l d i n p h a s o r form =100∗ exp
( 3 0 − 0 . 5 ∗ %i ∗ z )

Scilab code Exa 12.2 determine the instanteous field

66
1 // c l e a r //
2 // C a p t i o n : Program t o d e t e r m i n e t h e i n s t a n t e o u s f i e l d
o f a wave
3 // Example12 . 2
4 // pa ge 40 0 −401
5 clc ;
6 t = sym ( ’ t ’ ) ;
7 z = sym ( ’ z ’ ) ;
8 Ezt1 = sym ( ’ 1 0 0∗ c o s ( − 0 . 2 1 ∗ z +2∗%pi ∗1 e 0 7 ∗ t ) ’ ) ;
9 Ezt2 = sym ( ’ 20∗ c o s ( − 0 . 2 1 ∗ z +30+2∗%pi ∗1 e 0 7 ∗ t ) ’ ) ;
10 ax = sym ( ’ ax ’ ) ;
11 ay = sym ( ’ ay ’ ) ;
12 Ezt = Ezt1 * ax + Ezt2 * ay ;
13 disp ( Ezt , ’ The r e a l i n s t a n t a n e o u s f i e l d Ezt = ’ )
14 // R e s u l t
15 // The r e a l i n s t a n t a n e o u s f i e l d Ezt =
16 // 1 0 0∗ ax ∗ c o s ( 0 . 2 1 ∗ z −2.0E+7∗%pi ∗ t ) +20∗ ay ∗ c o s ( 0 . 2 1 ∗ z
−2.0E+7∗%pi ∗ t −30)
17 //

Scilab code Exa 12.3 find the Phase constant, Phase velocity, Electric
Field

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e Phase c o n s t a n t , Phase
v e l o c i t y , E l e c t r i c F i e l d I n t e n s i t y and I n t r i n s c i
ratio .
3 // Example12 . 3
4 // p a g e 4 0 8
5 clc ;
6 syms t ;
7 z = %z ;
8 [ uo , eo ] = muo_epsilon () ;
9 ur = 1;
10 f = 10^6;
1 er1 = 81;
2 er2 =0;
3 etta0 = 377;
4 Ex0 = 0.1;
5 beta1 = phase_constant_dielectric ( uo , eo ,f , er1 , er2 , ur
);
6 disp ( beta1 , ’ p h a s e c o n s t a n t i n r a d /m b e t a= ’ )
7 Lambda = 2* %pi / beta1 ;
8 Vp = phase_velocity (f , beta1 ) ;
9 disp ( Vp , ’ Phase v e l o c i t y i n m/ s e c ’ )
0 etta = intrinsic_dielectric ( etta0 , er1 , er2 )
1 disp ( etta , ’ I n t r i n s i c i m p e d a n c e i n ohms = ’ )
2 Ex = 0.1* cos (2* %pi * f *t - beta1 * z )
3 disp ( Ex , ’ E l e c t r i c f i e l d i n V/m Ex= ’ )
4 Hy = Ex / etta ;
5 disp ( Hy , ’ M a g n e t i c F i e l d i n A/m Hy= ’ )
6 // R e s u l t
7 // p h a s e c o n s t a n t i n r a d /m b e t a= 0.1886241
8 // Phase v e l o c i t y i n m/ s e c = 33310626.
9 // I n t r i n s i c i m p e d a n c e i n ohms = 41.888889
0 // E l e c t r i c f i e l d i n V/m Ex= cos (58342∗ z
/309303 −81681409∗ t / 1 3 ) /10
1 // e q u i v a l e n t t o Ex = 0 . 1 ∗ c o s ( 0 . 1 9 ∗ z − 6 2 8 3 1 8 5 . 3 ∗ t )
2 // M a g n e t i c F i e l d i n A/m Hy = 9∗ c o s ( 5 8 3 4 2 ∗ z
/309303 −81681409∗ t / 1 3 ) / 3 7 7 0
3 // e q u i v a l e n t t o Hy = 0 . 0 0 2 3 8 7 3 ∗ c o s ( 0 . 1 9 ∗ z − 6 2 8 3 1 8 5 . 3 ∗
t)

Scilab code Exa 12.4 find the penetration depth and intrinsic impedance

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e p e n e t r a t i o n d e p t h and
i n t r i n s i c impedance
3 // Example12 . 4
4 // p a g e 4 0 9
f = 2.5 e09 ; // h i g h m i c r o w a v e f r e q u e n c y = 2 . 5 GHz
er1 = 78; // r e l a t i v e p e r m i t t i v i t y
er2 = 7;
C = 3 e08 ; // f r e e s p a c e v e l o c i t y i n m/ s e c
[ uo , eo ] = muo_epsilon () ; // f r e e s p a c e p e r m i t t i v i t y
and p e r m e a b i l i t y
ur = 1; // r e l a t i v e p e r m e a b i l i t y
etta0 = 377; // f r e e s p a c e i n t r i n s i c i m e d a n c e i n ohms
alpha = attenuation_constant_dielectric ( uo , eo ,f , er1 ,
er2 , ur ) ;
etta = intrinsic_dielectric ( etta0 , er1 , er2 ) ;
disp ( alpha , ’ a t t e n u a t i o n c o n s t a n t i n Np/m a l p h a= ’ )
disp ( etta , ’ I n t r i n s i c c o n s t a n t i n ohms e t t a= ’ )
// R e s u l t
// a t t e n u a t i o n c o n s t a n t i n Np/m a l p h a= 20.727602
// I n t r i n s i c c o n s t a n t i n ohms e t t a= 42.558673
+ 1.9058543 i

Scilab code Exa 12.5 find the attenuation constant,propagation constant

// c l e a r //
// C a p t i o n : Program t o f i n d t h e a t t e n u a t i o n c o n s t a n t ,
p r o p a g a t i o n c o n s t a n t and i n t r i n s i c i m p e d a n c e
// Example12 . 5
// p a g e 4 1 2
clc ;
f = 2.5 e09 ; // h i g h m i c r o w a v e f r e q u e n c y = 2 . 5 GHz
er1 = 78; // r e l a t i v e p e r m i t t i v i t y
er2 = 7;
C = 3 e08 ; // f r e e s p a c e v e l o c i t y i n m/ s e c
[ uo , eo ] = muo_epsilon () ; // f r e e s p a c e p e r m i t t i v i t y
and p e r m e a b i l i t y
ur = 1; // r e l a t i v e p e r m e a b i l i t y
etta0 = 377; // f r e e s p a c e i n t r i n s i c i m e d a n c e i n ohms
3 alpha = attenuation_constant_gooddie ( uo , eo ,f , er1 , er2
, ur ) ;
4 etta = intrinsic_good_dielectric ( etta0 , er1 , er2 ) ;
5 beta1 = phase_constant_gooddie ( uo , eo ,f , er1 , er2 , ur ) ;
6 disp ( alpha , ’ a t t e n u a t i o n c o n s t a n t p e r cm a l p h a= ’ )
7 disp ( beta1 , ’ p h a s e c o n s t a n t i n r a d /m b e t a 1 = ’ )
8 disp ( etta , ’ I n t r i n s i c c o n s t a n t i n ohms e t t a= ’ )
9 // R e s u l t
0 // a t t e n u a t i o n c o n s t a n t p e r cm a l p h a=
1 // 20.748417
2 // p h a s e c o n s t a n t i n r a d /m b e t a 1 =
3 // 462.3933
4 // I n t r i n s i c c o n s t a n t i n ohms e t t a=
5 // 42.558673 + 1.9058543 i

Scilab code Exa 12.6 find skin depth, loss tangent and phase velocity

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d s k i n depth , l o s s t a n g e n t
and p h a s e v e l o c i t y
3 // Example12 . 6
4 // p a g e 4 1 9
5 clc ;
6 f1 = 1 e06 ; // f r e q u e n c y i n Hz
7 // e r 1 = 8 1 ;
8 ur = 1;
9 [ uo , eo ] = muo_epsilon () ; // f r e e s p a c e p e r m i t t i v i t y
and p e r m e a b i l i t y
0 sigma = 4; // c o n d u c t i v i t y o f a c o n d u c t o r i n s /m
1 [ del ] = SkinDepth ( f1 , uo , ur , sigma ) ;
2 pi = 22/7;
3 Lambda = 2* pi * del ;
4 Vp = 2* pi * f1 * del ;
5 disp ( del *100 , ’ s k i n d e p t h i n cm d e l t a = ’ )
6 disp ( Lambda , ’ Wavelength i n m e t r e Lambda = ’ )
7 disp ( Vp , ’ Phase v e l o c i t y i n m/ s e c Vp = ’ )
8 // R e s u l t
9 // s k i n d e p t h i n cm d e l t a =
0 // 25.17737
1 // Wavelength i n m e t r e Lambda =
2 // 1.5825775
3 // Phase v e l o c i t y i n m/ s e c Vp =
4 // 1582577.5

Scilab code Exa 12.7 Electric field

1 // c l e a r //
2 //
3 clc ;
4 s = sym ( ’ s ’ ) ;
5 B = sym ( ’B ’ ) ;
6 Eo = sym ( ’ Eo ’ ) ;
7 z = sym ( ’ z ’ ) ;
8 ax = sym ( ’ ax ’ ) ;
9 EsL = Eo *( ax + %i * ay ) * exp ( %i * s ) * exp ( - %i * B * z ) ;
0 EsR = Eo *( ax - %i * ay ) * exp ( - %i * B * z ) ;
1 Est = Eo * exp ( %i * s /2) *(2* cos ( s /2) * ax - %i *2* %i * sin ( s /2)
* ay ) * exp ( - %i * B * z ) ;
2 disp ( EsL , ’ L e f t c i r c u l a r l y p o l a r i z e d f i e l d EsL= ’ )
3 disp ( EsR , ’ R i g h t c i r c u l a r l y p o l a r i z e d f i e l d EsR= ’ )
4 disp ( Est , ’ T o t a l E l e c e t r i c f i e l d o f a l i n e a r l y
p o l a r i z e d wave EsT = ’ )
5 // R e s u l t
6 // L e f t c i r c u l a r l y p o l a r i z e d f i e l d EsL=
7 // ( %i ∗ ay+ax ) ∗Eo∗ exp ( %i ∗ s−%i ∗ z ∗B)
8 // R i g h t c i r c u l a r l y p o l a r i z e d f i e l d EsR=
9 // ( ax−%i ∗ ay ) ∗Eo∗%eˆ−(%i ∗ z ∗B)
0 // T o t a l E l e c e t r i c f i e l d o f a l i n e a r l y p o l a r i z e d wave
EsT =
1 // Eo ∗ ( 2 ∗ ay ∗ s i n ( s / 2 ) +2∗ ax ∗ c o s ( s / 2 ) ) ∗ exp ( %i ∗ s /2−%i ∗ z ∗
B)

72
Chapter 13

Plane Wave Reflection and


Dispersion

Scilab code Exa 13.1 electric field of incident, reflected and transmitted
waves

1 // c l e a r //
2 // C a p t i o n : Program t o f i n i d t h e e l e c t r i c f i e l d o f
i n c i d e n t , r e f l e c t e d and t r a n s m i t t e d waves
3 // Example13 . 1
4 // p a g e 4 3 9
5 etta1 = 100;
6 etta2 = 300; // i n t r i n s i c i m p e d a n c e i n ohms
7 T = reflection_coefficient ( etta1 , etta2 ) ;
8 Ex10_i = 100; // i n c i d e n t e l e c t r i c f i e l d i n v /m
9 Ex10_r = T * Ex10_i ; // r e f l e c t e d e l e c t r i c f i e l d i n v /m
10 Hy10_i = Ex10_i / etta1 ; // i n c i d e n t m a g n e t i c f i e l d A/m
11 Hy10_r = - Ex10_r / etta1 ; // r e f l e c t e d m a g n e t i c f i e l d A
/m
12 Si = (1/2) * Ex10_i * Hy10_i ; // a v e r a g e i n c i d e n t power
d e n s i t y i n W/ s q u a r e m e t r e
13 Sr = -(1/2) * Ex10_r * Hy10_r ; // a v e r a g e r e f l e c t e d power
d e n s t i y i n W/ s q u a r e m e t r e
14 tuo = 1+ T ; // t r a n s m i s s i o n c o e f f i c i e n t

73
5 Ex20_t = tuo * Ex10_i ; // t r a n s m i t t e d e l e c t r i c f i e l d v /
m
6 Hy20_t = Ex20_t / etta2 ; // t r a n s m i t t e d m a g n e t i c f i e l d
A/m
7 St = (1/2) * Ex20_t * Hy20_t ; // a v e r a g e power d e n s i t y
transmitted
8 disp (T , ’ r e f l e c t i o n c o e f f i c i e n t t = ’ ) ;
9 disp ( Ex10_i , ’ i n c i d e n t e l e c t r i c f i e l d i n v /m E x 1 0 i =
’)
0 disp ( Ex10_r , ’ r e f l e c t e d e l e c t r i c f i e l d i n v /m E x 1 0 r
=’)
1 disp ( Hy10_i , ’ i n c i d e n t m a g n e t i c f i e l d A/m H y 1 0 i = ’ )
2 disp ( Hy10_r , ’ r e f l e c t e d m a g n e t i c f i e l d A/m H y 1 0 r= ’ )
3 disp ( Si , ’ a v e r a g e i n c i d e n t power d e n s i t y i n W/ s q u a r e
m e t r e S i= ’ )
4 disp ( Sr , ’ a v e r a g e r e f l e c t e d power d e n s t i y i n W/ s q u a r e
m e t r e S r= ’ )
5 disp ( St , ’ a v e r a g e power d e n s i t y t r a n s m i t t e d i n W/
s q u a r e m e t r e S t= ’ )
6 // R e s u l t
7 // r e f l e c t i o n c o e f f i c i e n t t = 0.5
8 // i n c i d e n t e l e c t r i c f i e l d i n v /m E x 1 0 i = 100.
9 // r e f l e c t e d e l e c t r i c f i e l d i n v /m E x 1 0 r = 50.
0 // i n c i d e n t m a g n e t i c f i e l d A/m H y 1 0 i = 1.
1 // r e f l e c t e d m a g n e t i c f i e l d A/m H y 1 0 r= − 0.5
2 // a v e r a g e i n c i d e n t power d e n s i t y i n W/ s q u a r e m e t r e
S i= 50.
3 // a v e r a g e r e f l e c t e d power d e n s t i y i n W/ s q u a r e m e t r e
S r= 1 2 . 5
4 // a v e r a g e power d e n s i t y t r a n s m i t t e d i n W/ s q u a r e
m e t r e S t= 37.5

Scilab code Exa 13.2 maxima and minma electric field

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e maxima and minma
electric field
3 // Example13 . 2
4 // p a g e 4 4 3
5 clc ;
6 er1 = 4;
7 ur1 = 1;
8 er2 = 9;
9 ur2 = 1;
0 [ uo , eo ] = muo_epsilon () ; // f r e e s p a c e p e r m i t t i v i t y
and p e r m e a b i l i t y
1 u1 = uo * ur1 ; // p e r m e a b i l i t y o f medium 1
2 u2 = uo * ur2 ; // p e r m e a b i l i t y o f medium 2
3 e1 = eo * er1 ; // p e r m i t t i v i t y o f medium 1
4 e2 = eo * er2 ; // p e r m i t t i v i t y o f medium 2
5 etta1 = sqrt ( u1 / e1 ) ;
6 etta2 = sqrt ( u2 / e2 ) ;
7 T = reflection_coefficient ( etta1 , etta2 )
8 Exs1_i = 100; // i n c i d e n t e l e c t r i c f i e l d i n v /m
9 Exs1_r = -20; // r e f l e c t e d e l e c t r i c f i e l d i n v /m
0 Ex1T_max = (1+ abs ( T ) ) * Exs1_i ; //maximum t r a n s m i t t e d
e l e c t r i c f i e l d i n v /m
1 Ex1T_min = (1 - abs ( T ) ) * Exs1_i ; // minimum t r a n s m i t t e d
e l e c t r i c f i e l d i n v /m
2 S = VSWR ( T ) ; // v o l t a g e s t a n d i n g wave r a t i o
3 disp ( Ex1T_max , ’ maximum t r a n s m i t t e d e l e c t r i c f i e l d i n
v /m = ’ )
4 disp ( Ex1T_min , ’ minimum t r a n s m i t t e d e l e c t r i c f i e l d i n
v /m = ’ )
5 disp (S , ’ v o l t a g e s t a n d i n g wave r a t i o S= ’ )
6 // R e s u l t
7 //maximum t r a n s m i t t e d e l e c t r i c f i e l d i n v /m =
8 // 120.
9 // minimum t r a n s m i t t e d e l e c t r i c f i e l d i n v /m =
0 // 80.
1 // v o l t a g e s t a n d i n g wave r a t i o S=
2 // 1.5
Scilab code Exa 13.3 determine the intrinsic impedance

1 // c l e a r //
2 // C a p t i o n : Program t o d e t e r m i n e t h e i n t r i n s i c
i m p e d a n c e o f t h e unkonwn m a t e r i a l
3 // Eample13 . 3
4 // p a g e 4 4 1
5 clc ;
6 maxima_spacing = 1.5; // Lambda /2 i n m e t r e s
7 Lambda = 2* maxima_spacing ; // w a v e l e n g t h i n m e t r e s
8 C = 3 e08 ; // f r e e s p a c e v e l o c i t y i n m/ s e c
9 f = C / Lambda ; // f r e q u e n c y i n Hz
10 S = 5; // v o l t a g e s t a n d i n g wave r a t i o
11 T = (1 - S ) /(1+ S ) ; // r e f l e c t i o n c o e f f i c i e n t
12 etta0 = 377; // i n t r i n s i c i m p e d a n c e i n ohms
13 ettau = etta0 / S ; // i n t r i n s i c i m p e d a n c e o f unkonwn
m a t e r i a l i n ohms
14 disp (T , ’ r e f l e c t i o n c o e f f i c i e n t T= ’ )
15 disp ( ettau , ’ i n t r i n s i c i m p e d a n c e i n ohms = ’ )
16 // R e s u l t
17 // r e f l e c t i o n c o e f f i c i e n t T = − 0.6666667
18 // i n t r i n s i c i m p e d a n c e i n ohms = 75.4

Scilab code Exa 13.4 determine the required range of glass thickness

1 // c l e a r //
2 // C a p t i o n : Program t o d e t e r m i n e t h e r e q u i r e d r a n g e o f
g l a s s t h i c k n e s s f o r Fabry−p e r o t i n t e r f e r o m e t e r
3 // Example13 . 4
4 // p a g e 4 5 0
5 clear ;
6 clc ;

76
7 Lambda0 = 600 e -09; // w a v e l e n g t h o f r e d p a r t o f
v i s i b l e s p e c t r u m 600nm
8 n = 1.45; // r e f r a c t i v e i n d e x o f g l a s s p l a t e
9 delta_Lambda = 50 e -09; // o p t i c a l s p e c t r u m o f f u l l
w i d t h = 50nm
0 l = Lambda0 ^2/(2* n * delta_Lambda ) ;
1 disp ( l *1 e06 , ’ r e q u i r e d r a n g e o f g l a s s t h i c k n e s s i n
m i c r o m e t e r l= ’ )
2 // R e s u l t
3 // r e q u i r e d r a n g e o f g l a s s t h i c k n e s s i n m i c r o m e t e r l
= 2.4827586

Scilab code Exa 13.5 Index for coating

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e r e q u i r e d i n d e x f o r t h e
c o a t i n g and i t s t h i c k n e s s
3 // Example13 . 5
4 // p a g e 4 5 1
5 clear ;
6 clc ;
7 etta1 = 377; // i n t r i n s i c i m p e d a n c e o f f r e e s p a c e i n
ohms
8 n3 = 1.45; // r e f r a c t i v e i n d e x o f g l a s s
9 etta3 = etta1 / n3 ; // i n t r i n s i c i m p e d a n c e i n g l a s s
0 etta2 = sqrt ( etta1 * etta3 ) ; // i n t r i n s i c i m p e d a n c e i n
ohms f o r c o a t i n g
1 n2 = etta1 / etta2 ; // r e f r a c t i v e i n d e x o f r e g i o n 2
2 Lambda0 = 570 e -09; // f r e e s p a c e w a v e l e n g t h
3 Lambda2 = Lambda0 / n2 ; // w a v e l e n g t h i n r e g i o n 2
4 l = Lambda2 /4; // minimum t h i c k n e s s o f t h e d i e l e c t r i c
layer
5 disp ( l *1 e06 , ’ minimum t h i c k n e s s o f t h e d i e l e c t r i c
l a y e r i n um = ’ )
6 // R e s u l t
7 // minimum t h i c k n e s s o f t h e d i e l e c t r i c l a y e r i n um =
8 // 0.1183398

Scilab code Exa 13.6 phasor expression

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e p h a s o r e x p r e s s i o n f o r
the e l e c t r i c f i e l d
3 // Example13 . 6
4 // p a g e 4 5 6
5 clc ;
6 ax = sym ( ’ ax ’ ) ;
7 ay = sym ( ’ ay ’ ) ;
8 az = sym ( ’ a z ’ ) ;
9 x = sym ( ’ x ’ ) ;
0 y = sym ( ’ y ’ ) ;
1 z = sym ( ’ z ’ ) ;
2 teta = 30; // p h a s e a n g l e i n d e g r e e s
3 teta = 30/57.3; // p h a s e a n g l e i n r a d i a n s
4 Eo = 10; // E l e c t r i c f i e l d i n v /m
5 f = 50 e06 ; // f r e q u e n c y i n Hz
6 er = 9.0; // r e l a t i v e p e r m i t t i v i t y
7 ur = 1; // r e l a t i v e p e r m e a b i l i t y
8 [ uo , eo ] = muo_epsilon () ;
9 k = propagation_constant (f , uo , ur , eo , er ) ;
0 K = k *( cos ( teta ) * ax + sin ( teta ) * ay ) ;
1 r = x * ax + y * ay ;
2 Es = Eo * exp ( - sqrt ( -1) * K * r ) * az ;
3 disp (K , ’ p r o p a g a t i o n c o n s t a n t p e r m e t r e K= ’ )
4 disp (r , ’ d i s t a n c e i n m e t r e r= ’ )
5 disp ( Es , ’ P h a s o r e x p r e s s i o n f o r t h e e l e c t r i c f i e l d o f
t h e u n i f o r m p l a n e wave Es= ’ )
6 // R e s u l t
7 //K= 5 6 0 7 ∗ ( 1 4 9 6 9 ∗ ay /29940+25156∗ ax / 2 9 0 4 7 ) / 1 7 8 4
8 // r= ay ∗ y+ax ∗ x
9 // Es =10∗ a z ∗%eˆ −(5607∗ %i ∗ ( 1 4 9 6 9 ∗ ay /29940+25156∗ ax
/ 2 9 0 4 7 ) ∗ ( ay ∗ y+ax ∗ x ) / 1 7 8 4 )

Scilab code Exa 13.7 find the fraction of incident power

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e f r a c t i o n o f i n c i d e n t
power t h a t i s r e f l e c t e d and t r a n s m i t t e d
3 // Example13 . 7
4 // p a g e 4 6 0
5 clc ;
6 teta1 = 30; // i n c i d e n t a n g l e i n d e g r e e s
7 n2 = 1.45; // r e f r a c t i v e i n d e x o f g l a s s
8 teta2 = snells_law ( teta1 , n2 ) ;
9 etta1 = 377* cos ( teta1 /57.3) ; // i n t r i n s i c i m p e d a n c e
i n medium 1 i n ohms
0 etta2 = (377/ n2 ) * cos ( teta2 ) ; // i n t r i n s i c i m p e d a n c e
i n medium2 i n ohms
1 Tp = reflection_coefficient ( etta1 , etta2 ) ; //
r e f l e c t i o n c o e f f i c i e n t f o r p− p o l a r i z a t i o n
2 Reflected_Fraction_p = ( abs ( Tp ) ) ^2;
3 Transmitted_Fraction_p = 1 -( abs ( Tp ) ) ^2;
4 etta1s = 377* sec ( teta1 /57.3) ; // i n t r i n s i c i m p e d a n c e
f o r s− p o l a r i z a t i o n
5 etta2s = (377/ n2 ) * sec ( teta2 ) ;
6 Ts = reflection_coefficient ( etta1s , etta2s ) ; //
r e f l e c t i o n c o e f f i c i e n t f o r s− p o l a r i z a t i o n
7 Reflected_Fraction_s = ( abs ( Ts ) ) ^2;
8 Transmitted_Fraction_s = 1 -( abs ( Ts ) ) ^2;
9 disp ( teta2 *57.3 , ’ T r a n s m i s s i o n a n g l e u s i n g s n e l l s law
in degrees teta2 =’)
0 disp ( Tp , ’ R e f l e c t i o n c o e f f i c i e n t f o r p− p o l a r i z a t i o n
Tp= ’ )
1 disp ( Reflected_Fraction_P , ’ F r a c t i o n o f i n c i d e n t
power t h a t i s r e f l e c t e d f o r p− p o l a r i z a t i o n = ’ )
disp ( Transmitted_Fraction_p , ’ F r a c t i o n o f power
t r a n s m i t t e d f o r p− p o l a r i z a t i o n = ’ )
disp ( Ts , ’ R e f l e c t i o n c o e f f i c i e n t f o r s− p o l a r i z a t i o n
Tp= ’ )
disp ( Reflected_Fraction_s , ’ F r a c t i o n o f i n c i d e n t
power t h a t i s r e f l e c t e d f o r s− p o l a r i z a t i o n = ’ )
disp ( Transmitted_Fraction_s , ’ F r a c t i o n o f power
t r a n s m i t t e d f o r s− p o l a r i z a t i o n = ’ )
// R e s u l t
// T r a n s m i s s i o n a n g l e u s i n g s n e l l s law i n d e g r e e s
teta2 =
// 20.171351
// R e f l e c t i o n c o e f f i c i e n t f o r p− p o l a r i z a t i o n Tp=
// − 0 . 1 4 4 4 9 7 2
// F r a c t i o n o f i n c i d e n t power t h a t i s r e f l e c t e d f o r p
−p o l a r i z a t i o n =
// 0.0337359
// F r a c t i o n o f power t r a n s m i t t e d f o r p− p o l a r i z a t i o n =
// 0.9791206
// R e f l e c t i o n c o e f f i c i e n t f o r s− p o l a r i z a t i o n Tp=
// − 0.2222748
// F r a c t i o n o f i n c i d e n t power t h a t i s r e f l e c t e d f o r s
− p o l a r i z a t i o n = // 0.0494061
// F r a c t i o n o f power t r a n s m i t t e d f o r s− p o l a r i z a t i o n =
// 0.9505939

Scilab code Exa 13.8 find the refractive index

// c l e a r //
// C a p t i o n : Program t o f i n d t h e r e f r a c t i v e i n d e x o f
the prism m a t e r i a l
// Example13 . 8
// p a g e 4 6 3
7 n2 =1.00; // r e f r a c t i v e i n d e x o f a i r
8 teta1 = 45; // i n c i d e n t a n g l e i n d e g r e e s
9 teta1 = 45/57.3; // i n c i d e n t a n g l e i n r a d i a n s
0 n1 = n2 / sin ( teta1 ) ;
1 disp ( n1 , ’ r e f r a c t i v e i n d e x o f p r i s m m a t e r i a l n1= ’ )
2 // R e s u l t
3 // r e f r a c t i v e i n d e x o f p r i s m m a t e r i a l n1=
4 // 1.4142954

Scilab code Exa 13.9 determine incident and transmitted anlges

1 // c l e a r //
2 // C a p t i o n : Program t o d e t e r m i n e i n c i d e n t and
transmitted anlges
3 // Example13 . 9
4 // p a g e 4 6 4
5 clear ;
6 clc ;
7 n1 =1.00; // r e f r a c t i v e i n d e x o f a i r
8 n2 =1.45; // r e f r a c t i v e i n d e x o f g l a s s
9 teta1 = asin ( n2 / sqrt ( n1 ^2+ n2 ^2) ) ;
0 teta2 = asin ( n1 / sqrt ( n1 ^2+ n2 ^2) ) ;
1 Brewster_Condition = teta1 + teta2 ;
2 disp ( teta1 *57.3 , ’ I n c i d e n t a n g l e i n d e g r e e s t e t a 1 = ’ )
3 disp ( teta2 *57.3 , ’ t r a n s m i t t e d a n g l e i n d e g r e e s t e t a 2=
’)
4 disp ( Brewster_Condition *57.3 , ’ sum o f t h e i n c i d e n t
a n g l e and t r a n s m i t t e d a n g l e , B r e w s t e r C o n d i t i o n= ’
)
5 // R e s u l t
6 // I n c i d e n t a n g l e i n d e g r e e s t e t a 1 = 5 5 . 4 1 1 7 9 3
7 // t r a n s m i t t e d a n g l e i n d e g r e e s t e t a 2 = 3 4 . 5 9 4 8 3 7
8 // sum o f t h e i n c i d e n t a n g l e and t r a n s m i t t e d a n g l e ,
B r e w s t e r C o n d i t i o n= 90.00663
Scilab code Exa 13.10 group velocity and phase velocity

// c l e a r //
// C a p t i o n : Program t o d e t e r m i n e g r o u p v e l o c i t y and
p h a s e v e l o c i t y o f a wave
// Example13 . 1 0
// p a g e 4 7 0
clc ;
w = sym ( ’w ’ ) ;
wo = sym ( ’ wo ’ ) ;
no = sym ( ’ no ’ ) ;
c = sym ( ’ c ’ ) ;
beta_w = ( no * w ^2) /( wo * c ) ;
disp ( beta_w , ’ Phase c o n s t a n t= ’ )
d_beta_w = diff ( beta_w , w ) ;
disp ( d_beta_w , ’ D i f f e r e n t i a t i o n o f p h a s e c o n s t a n t w . r
. to w =’ )
Vg = 1/ d_beta_w ;
Vg = limit ( Vg ,w , wo ) ;
Vp = w / beta_w ;
Vp = limit ( Vp ,w , wo ) ;
disp ( Vg , ’ Group v e l o c i t y = ’ )
disp ( Vp , ’ Phase v e l o c i t y = ’ )
// R e s u l t
// Phase c o n s t a n t=
// no ∗wˆ 2 / ( c ∗wo )
// D i f f e r e n t i a t i o n o f p h a s e c o n s t a n t w . r . t o w =
// 2∗ no ∗w/ ( c ∗wo )
// Group v e l o c i t y =
// c / ( 2 ∗ no )
// Phase v e l o c i t y =
// c / no
Scilab code Exa 13.11 pulse width at the optical fiber

1 // c l e a r //
2 // C a p t i o n : Program t o d e t e r m i n e t h e p u l s e w i d t h a t
the o p t i c a l f i b e r output
3 // Example13 . 1 1
4 // p a g e 4 7 4
5 clear ;
6 clc ;
7 T = 10; // w i d t h o f l i g h t p u l s e a t t h e o p t i c a l f i b e r
input in pico secs
8 beta2 = 20; // d i s p e r s i o n i n p i c o s e c o n d s s q u a r e p r e
kilometre
9 z = 15; // l e n g t h o f o p t i c a l f i b e r i n k i l o m e t r e
10 delta_t = beta2 * z / T ;
11 T1 = sqrt ( T ^2+ delta_t ^2) ;
12 disp ( delta_t , ’ P u l s e s p r e a d i n p i c o s e c o n d s d e l t a t =
’)
13 disp ( ceil ( T1 ) , ’ Output p u l s e w i d t h i n p i c o s e c o n d s T1
=’)
14 // R e s u l t
15 // P u l s e s p r e a d i n p i c o s e c o n d s d e l t a t =
16 // 30.
17 // Output p u l s e w i d t h i n p i c o s e c o n d s T1 =
18 // 32.

83
Chapter 14

Guided Wave and Radiation

Scilab code Exa 14.1 determine the cutoff frequency

1 // c l e a r //
2 // C a p t i o n : Program t o d e t e r m i n e t h e c u t o f f f r e q u e n c y
f o r t h e f i r s t w a v e g u i d e mode (m=1)
3 // Example14 . 1
4 // p a g e 499
5 clear ;
6 clc ;
7 er1 = 2.1; // d i e l e c t r i c c o n s t a n t o f t e f l o n m a t e r i a l
8 er0 = 1; // d i e l e c t r i c c o n s t a n t o f a i r
9 d = 1e -02; // p a r a l l e l p l a t e w a v e g u i d e s e p a r a t i o n i n
metre
10 C = 3 e08 ; // f r e e s p a c e v e l o c i t y i n m/ s e c
11 n = sqrt ( er1 / er0 ) ; // r e f r a c t i v e i n d e x
12 fc1 = C /(2* n * d ) ;
13 disp ( fc1 , ’ c u t o f f f r e q u e n c y f o r t h e f i r s t w a v e g u i d e
mode i n Hz f c 1 = ’ )
14 // R e s u l t
15 // c u t o f f f r e q u e n c y f o r t h e f i r s t w a v e g u i d e mode i n
Hz f c 1 =
16 // 1 . 0 3 5D+10

84
Scilab code Exa 14.2 number of modes propagate in waveguide

1 // c l e a r //
2 // C a p t i o n : Program t o d e t e r m i n e t h e number o f modes
propagate in waveguide
3 // Example14 . 2
4 // p a g e 499
5 clear ;
6 clc ;
7 er1 = 2.1; // d i e l e c t r i c c o n s t a n t o f t e f l o n m a t e r i a l
8 er0 = 1; // d i e l e c t r i c c o n s t a n t o f a i r
9 n = sqrt ( er1 / er0 ) ; // r e f r a c t i v e i n d e x
10 Lambda_cm = 2e -03; // o p e r a t i n g c u t o f f w a v e l e n g t h i n
metre
11 d = 1e -02; // p a r a l l e l −p l a t e w a v e g u i d e s e p a r a t i o n
12 m = (2* n * d ) / Lambda_cm ;
13 disp ( floor ( m ) , ’ Number o f w a v e g u i d e s modes p r o p a g a t e
m =’)
14 // R e s u l t
15 // Number o f w a v e g u i d e s modes p r o p a g a t e m =
16 // 14.

Scilab code Exa 14.3 determine the group delay and difference

1 // c l e a r //
2 // C a p t i o n : Program t o d e t e r m i n e t h e g r o u p d e l a y and
d i f f e r e n c e in propagation times
3 // Example14 . 3
4 // p a g e 502
5 clc ;
6 C = 3 e08 ; // f r e e s p a c e v e l o c i t y i n m/ s e c
7 er = 2.1; // d i e l e c t r i c c o n s t a n t o f t e f l o n m a t e r i a l

85
8 fc1 = 10.3 e09 ; // c u t o f f f r e q u e n c y f o r mode m =1
9 fc2 = 2* fc1 ; // c u t o f f f r e q u e n c y f o r mode m =2
0 f = 25 e09 ; // o p e r a t i n g f r e q u e n c y i n Hz
1 Vg1 = group_delay (C , er , fc1 , f ) ; // g r o u p d e l a y f o r mode
m = 1
2 Vg2 = group_delay (C , er , fc2 , f ) ; // g r o u p d e l a y f o r mode
m = 2
3 del_t = group_delay_difference ( Vg1 , Vg2 ) ;
4 disp ( ceil ( del_t *1 e10 ) , ’ g r o u p d e l a y d i f f e r e n c e i n p s /
cm d e l t = ’ )
5 // R e s u l t
6 // g r o u p d e l a y d i f f e r e n c e i n p s /cm d e l t =
7 // 33.

Scilab code Exa 14.4 determine the operating range

1 // c l e a r //
2 // C a p t i o n : Program t o d e t e r m i n e t h e o p e r a t i n g r a n g e
o f f r e q u e n c y f o r TE10 mode o f a i r f i l l e d
r e c t a n g u l a r waveguide
3 // Example14 . 4
4 // p a g e 509
5 clear ;
6 clc ;
7 // d i m e n s i o n s o f a i r f i l l e d r e c t a n g u l a r w a v e g u i d e
8 a = 2e -02;
9 b = 1e -02;
0 // F r e e s p a c e v e l o c i t y i n m/ s e c
1 C = 3 e08 ;
2 // t h e v a l u e o f m f o r TE10 mode
3 m = 1;
4 n = 1; // r e f r a c t i v e i n d e x f o r a i r f i l l e d w a v e g u i d e
5 fc = ( m * C ) /(2* n * a ) ;
6 disp ( fc *1 e -09 , ’ O p e r a t i n g r a n g e o f f r e q u e n c y f o r TE10
mode i n GHz f c= ’ )
17 // R e s u l t
18 // O p e r a t i n g r a n g e o f f r e q u e n c y f o r TE10 mode i n GHz
f c=
19 // 7.5

Scilab code Exa 14.5 maximum allowable refractive index

1 // c l e a r //
2 // C a p t i o n : Program t o d e t e r m i n e t h e maximum
allowable r e f r a c t i v e index of the slab material
3 // Example14 . 5
4 // p a g e 517
5 clear ;
6 clc ;
7 Lambda = 1.30 e -06; // w a v e l e n g t h r a n g e o v e r which
s i n g l e −mode o p e r a t i o n
8 d = 5e -06; // s l a b t h i c k n e s s i n m e t r e
9 n2 = 1.45; // r e f r a c t i v e i n d e x o f t h e s l a b m a t e r i a l
10 n1 = sqrt (( Lambda /(2* d ) ) ^2+ n2 ^2) ;
11 disp ( n1 , ’ The maximum a l l o w a b l e r e f r a c t i v e i n d e x o f
t h e s l a b m a t e r i a l n1= ’ )
12 // R e s u l t
13 // The maximum a l l o w a b l e r e f r a c t i v e i n d e x o f t h e s l a b
m a t e r i a l n1=
14 // 1.4558159

Scilab code Exa 14.6 find the V number of a step index fiber

1 // c l e a r //
2 // C a p t i o n : Program t o f i n d t h e V number o f a s t e p
index f i b e r
3 // Example14 . 6
4 // p a g e 524
5 clear ;
6 clc ;
7 Lambda = 1.55 e -06; // o p e r a t i n g w a v e l e n g t h i n m e t r e
8 LambdaC = 1.2 e -06; // c u t o f f w a v e l e n g t h i n m e t r e
9 V = ( LambdaC / Lambda ) *2.405;
10 disp (V , ’ t h e V number o f a s t e p i n d e x f i b e r V= ’ )
11 // R e s u l t
12 // t h e V number o f a s t e p i n d e x f i b e r V=
13 // 1.8619355

You might also like