Numerical Analysis of Circuits Containing Resistors, Capacitors and Inductors

Tags

Numerical Analysis of Circuits Containing Resistors, Capacitors and Inductors

NUMERICAL ANALYSIS OF CIRCUITS CONTAINING RESISTORS, CAPACITORS AND INDUCTORS

Numerical methods are often used to study mechanical systems. However, these same methods can be employed to investigate the response of circuits containing resistors, capacitors and inductors. A wide range of phenomena can be studied such as the frequency response of filters and tuned circuits; resonance, damped and forced oscillations; voltage, current, power, energy and phase relationships.

Resistors, capacitors and inductors are basic components of circuits. These components are connected to a source of electrical energy. A simple model for the source of electrical energy is to consider it to be a voltage source called the emf vS and a series resistance called the internal resistance r. The potential difference applied to a circuit is called the terminal voltage v. If a current is supplied from the electrical energy source to a circuit, the terminal voltage is

v = vS – i r

In the computer modelling of circuit behaviour, the effects of internal resistance of the source can be considered. Suitable electrical sources include step, on/off/on, sinusoidal and pulsed functions.

For a resistorR, the voltage vR across it and the current iR through it are always in phase and related by the equation

vR(t) = R i(t)

A capacitor consists of two metal plates separated by an insulating material. When a potential difference vC exists across a capacitor, one plate has a positive charge +q and the other plate a charge –q. The charge q is proportional to the potential difference between the plates of the capacitor, the constant of proportionality is called the capacitance (farad F).

q(t) = CvC(t)

Differentiating both sides of this equation with respect to t and using the fact that

i = dq/dt we get dvC/dt = iC / C. We can write this equation in terms of differences rather than differentials

Thus, a capacitor will resist changes in the potential difference across it because it requires a time t for the potential difference to change by vC. The potential difference across the capacitor decreases when it discharges and increases when charging. The larger the value of C, the slower the change in potential. If t is “small”, then to a good approximation, the potential difference across the capacitor at time t is

An inductor can be considered to be a coil of wire. When a varying current passes through a coil, a varying magnetic flux is produced and this in turn induces a potential difference across the inductor. This induced potential difference opposes the change in current. The potential difference across the inductor is proportional to the rate of change of the current, where the constant of proportionality L is known as the inductance of the coil (henries H) and is given by the equation

vL = L di/dt

This equation can be expressed in terms of differences,

iL(t) = vL(t) t / L

Thus, an inductor will resist changes in the current through it because it requires a time t for the current to change by i. If t is “small”, then to a good approximation, the current through the inductor at time t is

SERIES RC CIRCUIT


Kirchhoff’s Laws with the equation

can be used to compute the response of a series RC circuit for different applied emfs. The first step is calculate the applied emf vs and then specify the initial values for the variables for voltage v, current i, powers p and energies u.

vS(0)

vC(0) = 0 assume capacitor is initially discharged

i(0) = { vS(0) – vC(0) } / R

vR(0) = i(0) R

pS(0) = vS(0) i(0) pR(0) = vR(0) i(0) pC(0) = vC(0) i(0)

uS(0) = 0 uR(0) = 0 uC(0) = 0

Values at all later times are found by implementing the routine in the order shown

For accurate results the time increment t should be chosen so that

tR C where R C is the capacitive time constant.

MATHLAB FILE FOR SERIES RC CIRCUIT

%m260ah.m

%1 feb 01

%numerical analysis of an RC circuit

tic

R = 500;

C = 1e-6;

tau = R*C; %time constnat

dt = 1e-5; %time increment dt < RC;

%construction of a rectangular pulse

num = 500; %number of points 1 to 500

T = 3; %number of periods

ontime = 50; %percentage of time pulse is on - must be less than 100;

numT = round(num/T-0.5); %number of points for period

ton = round(numT*ontime/100); %on time expressed as number of points

toff = numT - ton; %off time expressed as number of points

vs = zeros(num,1); %set voltages to zero

vmax = 2; %set max on voltage

for c = 1 : T

vs(toff+numT*(c-1):toff+numT*(c-1)+ton) = vmax;

end

%zero variables

t = zeros(num,1);

i = zeros(num,1);

vr = zeros(num,1);

vc = zeros(num,1);

ps = zeros(num,1);

pr = zeros(num,1);

pc = zeros(num,1);

us = zeros(num,1);

ur = zeros(num,1);

uc = zeros(num,1);

%calculations

time = 0:dt:dt*(num-1);

for c = 2 : num

vc(c) = vc(c-1)+i(c-1)*dt/C;

i(c)= (vs(c)-vc(c))/R;

vr(c) = i(c)*R;

end

ps = vs .* i;

pc = vc .* i;

pr = vr .* i;

for c = 2 : num

us(c) = us(c-1)+ps(c)*dt;

uc(c) = uc(c-1)+pc(c)*dt;

ur(c) = ur(c-1)+pr(c)*dt;

end

%graphing

figure(1);

plot(time',vs);

axis([0 dt*num -2.5, 2.5]);

title('RC CIRCUIT');

xlabel('time t (s)');

ylabel('voltage (V)');

grid on;

hold on;

plot(time',vc,'m');

plot(time',vr,'k');

legend('Vs','Vc','Vr');

figure(2);

plot(time',ps);

title('RC CIRCUIT');

xlabel('time t (s)');

ylabel('power P (W)');

grid on;

hold on;

plot(time',pc,'m');

plot(time',pr,'k');

legend('Ps','Pc','Pr');

figure(3);

plot(time',us);

title('RC CIRCUIT');

xlabel('time t (s)');

ylabel('energy U (J)');

grid on;

hold on;

plot(time',uc,'m');

plot(time',ur,'k');

legend('Us','Uc','Ur');

toc


PARALLEL TUNED LC CIRCUIT

Kirchhoff’s Laws with the equations

can be used to compute the response of a parallel tuned LC circuit for difference applied emfs. The first step is calculate the applied emf vS and then specify the initial values for the variables for voltages v, current i, powers p and energies u.

vS(0) = vR(0) vp(0) = 0 assume capacitor is initially discharged

iR(0) = vR(0) / R iRL(0) = vp(0) / RL = 0 iL(0) = 0 iC(0) = iR(0)

pS(0) = vS(0) i(0) pR(0) = vR(0) i(0) pC(0) = vC(0) i(0) pRL(0) = vRL(0) i(0)

uS(0) = 0 uR(0) = 0 uC(0) = 0 uR(0) = 0

Values at all later times are found by implementing the routine in the order shown

For accurate results the tine increment t should be chosen so that

t < 1 / f where f is the frequency of the emf.

MATLAB FILE FOR PARALLEL TUNERD CIRCUIT

%m260aj.m

%2 feb 00

%parallel tuned LC circuit with load resistor

%numerical analysis - leap frog method

%sinusoidal emf

tic

clear;

%data

R = 1000;

RL = 1e3;

C = 1e-8;

L = 3.8e-3;

vSo = 10; %emf amplitude

f = 25e3; %emf frequency

period = 1/f;

tmax = 4/f; %max time interval for calculations and graphs

num = 500; %number of data points 1 to 500

dt = tmax / (num-1);

t = 0 : dt : tmax;

vS = vSo .*sin((2*pi*f).*t);

%initialise values

vR(1) = vS(1);

vp(1) = 0; %voltage across parallel combination

iR(1) = vR(1)/R;

iC(1) = iR(1);

iL(1) = 0;

iRL(1) = 0;

%calculations

for c = 2 : num

vp(c) = vp(c-1) + iC(c-1)*dt/C;

vR(c) = vS(c) - vp(c);

iR(c) = vR(c)/R;

iRL(c) = vp(c)/RL;

iL(c) = iL(c-1) + (vp(c-1))*dt/L;

iC(c) = iR(c)-iRL(c)-iL(c);

end

pRL = vp .*iRL;

pR = vR .*iR;

pS = vS .*iR;

pC = vp .*iC;

pL = vp .*iL;

figure(1);

plot(t,vp);

title('Parallel LC Tuned Circuit');

xlabel('time t (s)');

ylabel('potential difference V (V)')

hold on;

plot(t,vS,'m');

figure(2);

plot(t,pRL,'k');

title('Parallel LC Tuned Circuit');

xlabel('time t (s)');

ylabel('power P (W)')

hold on;

plot(t,pS,'b');

plot(t,pR,'m');

plot(t,pC,'g');

plot(t,pL,'c');

legend('RL','S','R','C','L');

%accuracy of model dt < period

fo = 1/(2*pi*sqrt(L*C))

period

dt

%max power transferred to load Thevenin circuit theorem

w = 2*pi*f;

z1 = R;

z2 = -j/(w*C);

z3 = j*w*L;

z4 = 1/(1/z2+1/z3);

zth = 1/(1/z1+1/z4);

zthreal = real(zth)

toc

1

260ah.doc 16/12/18 8:27 PM