summaryrefslogtreecommitdiff
path: root/1319/CH1/EX1.38/1_38.sce
blob: 63b7979bb115f05d6f38991aaacfa19875c66b41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Determine the instantaneous energy stored in the capacitor and inductor

clc;
clear;

Vc=20*sqrt(2);
C=2; // Capacitor
L=1; // Inductor
w=poly(0,'w');

// Impedances in order from let to right (as a function of w)
R1=%i*w;
R2=1/(2*%i*w); // Top
R3=1;// Bottom

Rp=R2*R3/(R2+R3); // Effective resistance of the parallel path

Reff=R1+Rp; // Effective resistance

Reff(2)=Reff(2)*conj(Reff(3));
Reff(3)=Reff(3)*conj(Reff(3));

R=imag(Reff(2))/Reff(3); // Imaginary part of the above equation

//From the above equation we get five roots, three are zero and we take the positive value
w=roots(R(2));
w=abs(w(2)); // Numerical Value

// Impedances in order from let to right (Numerical Value)
R1=%i*w;
R2=1/(2*%i*w); // Top
R3=1;// Bottom

Vcrms=Vc/sqrt(2);

// Taking Vc as reference

Ic=Vcrms/R2; // Current through Capacitor
Ir=Vcrms/R3; // Current through Resistor

Il=Ic+Ir; // Rms value of Current through Inductor
tl=atand(imag(Il)/real(Il)); // Phase angle of Inductor Current

Ilmax=abs(Il)*sqrt(2); // Maximum Current

Eins=C*(Vc^2)/2; // Magnitude of Instaneous energy stored

Ein=L*(abs(Ilmax)^2)/2; // Energy through the inductor
Er=(Ir^2)*R3; // Loss in the resistor

Q0= w*Ein*(1+(1/sqrt(2)))/Er; // Q of the circuit

printf('a)  Instaneous Energy Stored in Capacitor = %g (sin(%gt)^2) \n',Eins,w)
printf('    Instaneous Energy Stored in Inductor = %g (sin( %gt + %g)^2) \n',Ein,w,tl)
printf('b)  Q of the circuit = %g \n',Q0)