0% found this document useful (0 votes)
4 views19 pages

EEE204 Lab Task 2

EEE

Uploaded by

noorjalaljewel
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views19 pages

EEE204 Lab Task 2

EEE

Uploaded by

noorjalaljewel
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

​ ​ ​ ​ ​ Labtask

Course Code : EEE204

Course Title : Numerical Analysis for Electrical Engineering


[Lab]

Task no : 02

Section : 02

Name Mostofa Murad

ID 2023-2-80-031

Course Instructor : R
izwan Shaikh (RZS)

Date of submission : 27/4/2025


Answer to the question No.1

​ ​ ​ Figure 1 : circuit-1

R1 = R = 33 k ohm
Is = 10^-14 A
Fahrenheit temperature, T_F = (31+20) = 51℉
Kelvin temperature, T_K = 284 k
Vt = 0.0246
Vs = (31 + 5) = 36
p=3+1=4

k = 1.380649×10⁻²³ J/K, q = 1.602176634×10⁻¹⁹ C

Diode equation:

I = Is * (exp((Vs - IR)/(nVt)) - 1)

Code :

clc;

clear;
close all;

% Constants

k = 1.380649e-23; q = 1.602176634e-19;

% Given Values

Is = 1e-14; Vs = 36; R = 33e3;

Temperature_F = 51;

% Calculate Vt

T_K = (Temperature_F - 32)/1.8 + 273.15;

Vt = (k * T_K) / q;

% Define function

f = @(I) Is * (exp((Vs - I*R)/Vt) - 1) - I;

% Plot

I = linspace(0, 0.002, 1000);

figure;

plot(I, f(I), 'LineWidth', 2); grid on;

xlabel('Current (A)'); ylabel('f(I)');

title('f(I) vs I for Q1');

yline(0,'--r');
% Regula-Falsi Method (10 decimal places)

a = 0; b = 0.002; tol = 1e-10; max_iter = 1000;

iter = 0;

while iter < max_iter

​ iter = iter + 1;

​ c = (a*f(b) - b*f(a)) / (f(b) - f(a));

​ if abs(f(c)) < tol, break; end

​ if f(a)*f(c) < 0, b = c; else, a = c; end

end

% Regula-Falsi Method (relative 0.004%)

a = 0; b = 0.002; rel_tol = 6e-4; iter = 0; prev_c = 0;

while iter < max_iter

​ iter = iter + 1;

​ c = (a*f(b) - b*f(a)) / (f(b) - f(a));

​ if iter > 1 && abs((c - prev_c)/c) < rel_tol, break; end

​ if f(a)*f(c) < 0, b = c; else, a = c; end

​ prev_c = c;

end

% Fixed Point Iteration (10 decimal places)

g = @(I) Is * (exp((Vs - I*R)/Vt) - 1);

I_old = 0.0005; iter = 0;


while iter < max_iter

​ iter = iter + 1;

​ I_new = g(I_old);

​ if abs(I_new - I_old) < tol, break; end

​ I_old = I_new;

end

% Fixed Point Iteration (relative 0.004%)

I_old = 0.0005; iter = 0;

while iter < max_iter

​ iter = iter + 1;

​ I_new = g(I_old);

​ if iter>1 && abs((I_new-I_old)/I_new) < rel_tol, break; end

​ I_old = I_new;

end

The plot :
​ ​ ​ ​ ​ ​ ​ Figure 2

Answer to the question No.2


​ ​ ​ ​ ​ ​ ​

​ ​ ​ Figure-3 : circuit-2
R1 = R = 33 k ohm
R2 = Ra = 36 k ohm
Is = 10^-14 A
Fahrenheit temperature, T_F = (31+30) = 61℉
Kelvin temperature, T_K = 289 k
Vt = 0.0246
Vs = (31+ 5) = 36V
p = 3 + 1= 4
k = 1.380649×10⁻²³ J/K, q = 1.602176634×10⁻¹⁹ C

Same structure as Q1 but replace R with Ra.​


Equation:​
f(I) = Is * (exp((Vs - IRa)/Vt) - 1) - I​
Using Regula-Falsi and Fixed Point methods.

Code :

clc;

clear;

close all;

% Constants

k = 1.380649e-23; q = 1.602176634e-19;

% Given Values

Is = 1e-14; Vs = 36; Ra = 36e3;

Temperature_F = 61;

% Calculate Vt

T_K = (Temperature_F - 32)/1.8 + 273.15;

Vt = (k * T_K) / q;

% Define function

f = @(I) Is * (exp((Vs - I*Ra)/Vt) - 1) - I;


% Plot

I = linspace(0, 0.002, 1000);

figure;

plot(I, f(I), 'LineWidth', 2); grid on;

xlabel('Current (A)'); ylabel('f(I)');

title('f(I) vs I for Q2');

yline(0,'--r');

% Regula-Falsi Method (10 decimal places)

a = 0; b = 0.002; tol = 1e-10; max_iter = 1000;

iter = 0;

while iter < max_iter

​ iter = iter + 1;

​ c = (a*f(b) - b*f(a)) / (f(b) - f(a));

​ if abs(f(c)) < tol, break; end

​ if f(a)*f(c) < 0, b = c; else, a = c; end

end

% Regula-Falsi Method (relative 0.004%)

a = 0; b = 0.002; rel_tol = 6e-4; iter = 0; prev_c = 0;

while iter < max_iter

​ iter = iter + 1;

​ c = (a*f(b) - b*f(a)) / (f(b) - f(a));

​ if iter > 1 && abs((c - prev_c)/c) < rel_tol, break; end

​ if f(a)*f(c) < 0, b = c; else, a = c; end

​ prev_c = c;
end

% Fixed Point Iteration (10 decimal places)

g = @(I) Is * (exp((Vs - I*Ra)/Vt) - 1);

I_old = 0.0005; iter = 0;

while iter < max_iter

​ iter = iter + 1;

​ I_new = g(I_old);

​ if abs(I_new - I_old) < tol, break; end

​ I_old = I_new;

end

% Fixed Point Iteration (relative 0.004%)

I_old = 0.0005; iter = 0;

while iter < max_iter

​ iter = iter + 1;

​ I_new = g(I_old);

​ if iter>1 && abs((I_new-I_old)/I_new) < rel_tol, break; end

​ I_old = I_new;

end
The plot :

​ ​ ​ ​ ​ Figure-4

Answer to the question No.3


​ ​ ​ Figure-5 : circuit-3
R1 = R = 33 k ohm
R2 = Ra = 36 k ohm
Is = 10^-14 A
Fahrenheit temperature, T_F = (31+30) = 61℉
Kelvin temperature, T_K = 289 k
Vt = 0.0246
Vs = (31 + 5) = 36V
p = 3 + 1 =4

k = 1.380649×10⁻²³ J/K, q = 1.602176634×10⁻¹⁹ C

Code :

clc;

clear;

close all;

% Constants

k = 1.380649e-23; q = 1.602176634e-19;

% Given Values

Is = 1e-14; Vs = 36; R = 33e3;

Temperature_F = 61;
% Calculate Vt

T_K = (Temperature_F - 32)/1.8 + 273.15;

Vt = (k * T_K) / q;

% Define function

f = @(I) Is * (exp((Vs - I*R)/Vt) - 1) - I;

% Plot

I = linspace(0, 0.002, 1000);

figure;

plot(I, f(I), 'LineWidth', 2); grid on;

xlabel('Current (A)'); ylabel('f(I)');

title('f(I) vs I for Q3');

yline(0,'--r');

% Regula-Falsi Method (10 decimal places)

a = 0; b = 0.002; tol = 1e-10; max_iter = 1000;

iter = 0;

while iter < max_iter

​ iter = iter + 1;

​ c = (a*f(b) - b*f(a)) / (f(b) - f(a));

​ if abs(f(c)) < tol, break; end

​ if f(a)*f(c) < 0, b = c; else, a = c; end

end
% Regula-Falsi Method (relative 0.004%)

a = 0; b = 0.002; rel_tol = 6e-4; iter = 0; prev_c = 0;

while iter < max_iter

​ iter = iter + 1;

​ c = (a*f(b) - b*f(a)) / (f(b) - f(a));

​ if iter > 1 && abs((c - prev_c)/c) < rel_tol, break; end

​ if f(a)*f(c) < 0, b = c; else, a = c; end

​ prev_c = c;

end

% Fixed Point Iteration (10 decimal places)

g = @(I) Is * (exp((Vs - I*R)/Vt) - 1);

I_old = 0.0005; iter = 0;

while iter < max_iter

​ iter = iter + 1;

​ I_new = g(I_old);

​ if abs(I_new - I_old) < tol, break; end

​ I_old = I_new;

end

% Fixed Point Iteration (relative 0.004%)

I_old = 0.0005; iter = 0;

while iter < max_iter

​ iter = iter + 1;

​ I_new = g(I_old);
​ if iter>1 && abs((I_new-I_old)/I_new) < rel_tol, break; end

​ I_old = I_new;

end

The plot :

​ ​ ​ ​ ​ ​ figure-6

Answer to the question No.4


​ ​ ​ ​ Figure-7 : circuit-4

R1 = R = 33 k ohm
R2 = Ra = 36 k ohm
Is = 10^-14 A
Fahrenheit temperature, T_F = (31+30) = 61℉
Kelvin temperature, T_K = 289k
Vt = 0.0246
Vs = (31 + 5) = 36V
p=3+1=4

k = 1.380649×10⁻²³ J/K, q = 1.602176634×10⁻¹⁹ C

Dual diode current equation:


I = (Is1 + Is2) * (exp((Vs - IR)/Vt) - 1) - I

Code :

clc;

clear;

close all;
% Constants

k = 1.380649e-23; q = 1.602176634e-19;

% Given Values

Is1 = 1e-14; Is2 = 2e-14; Vs = 36; R = 33e3;

Temperature_F = 61;

% Calculate Vt

T_K = (Temperature_F - 32)/1.8 + 273.15;

Vt = (k * T_K) / q;

% Define function (Dual Diode)

f = @(I) (Is1+Is2) * (exp((Vs - I*R)/Vt) - 1) - I;

% Plot

I = linspace(0, 0.002, 1000);

figure;

plot(I, f(I), 'LineWidth', 2); grid on;

xlabel('Current (A)'); ylabel('f(I)');

title('f(I) vs I for Q4');

yline(0,'--r');

% Regula-Falsi Method (10 decimal places)

a = 0; b = 0.002; tol = 1e-10; max_iter = 1000;

iter = 0;

while iter < max_iter


iter = iter + 1;

​ c = (a*f(b) - b*f(a)) / (f(b) - f(a));

​ if abs(f(c)) < tol, break; end

​ if f(a)*f(c) < 0, b = c; else, a = c; end

end

% Regula-Falsi Method (relative 0.004%)

a = 0; b = 0.002; rel_tol = 6e-4; iter = 0; prev_c = 0;

while iter < max_iter

​ iter = iter + 1;

​ c = (a*f(b) - b*f(a)) / (f(b) - f(a));

​ if iter > 1 && abs((c - prev_c)/c) < rel_tol, break; end

​ if f(a)*f(c) < 0, b = c; else, a = c; end

​ prev_c = c;

end

% Fixed Point Iteration (10 decimal places)

g = @(I) (Is1+Is2) * (exp((Vs - I*R)/Vt) - 1);

I_old = 0.0005; iter = 0;

while iter < max_iter

​ iter = iter + 1;

​ I_new = g(I_old);

​ if abs(I_new - I_old) < tol, break; end

​ I_old = I_new;

end
% Fixed Point Iteration (relative 0.004%)

I_old = 0.0005; iter = 0;

while iter < max_iter

​ iter = iter + 1;

​ I_new = g(I_old);

​ if iter>1 && abs((I_new-I_old)/I_new) < rel_tol, break; end

​ I_old = I_new;

end

The plot :

​ ​ ​ ​ ​ figure-8

You might also like