Circuit for Practicing Numerical Solution

The series R L C RLC circuit shown below is solvable analytically, but I am posting this problem to give people an opportunity to try numerical solution methods on an easy practice circuit. The numerical techniques used to solve this problem apply equally well to more complex exercises.

The capacitor voltage is 10 10 at time t = 0 t = 0 , and the inductor is de-energized at that time. Determine the value of the local current maximum which occurs between t = 5 t = 5 and t = 10 t = 10 .

Details and Assumptions:
1) R = 0.2 R = 0.2
2) L = 1 L = 1
3) C = 1 C = 1
4) The state variables are the capacitor voltage and the inductor current, which also happens to be the current flowing in all three elements. Write the time derivatives of the state variables in terms of the state variables themselves.
5) The expected answer is a positive number


The answer is 4.587.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Steven Chase
Mar 4, 2020

The state variables are the capacitor voltage V C V_C and the inductor current I L I_L . The basic equations are:

V L = L I ˙ L I C = C V ˙ C V_L = L \dot{I}_L \\ I_C = C \dot{V}_C

Writing the left sides in terms of the state variables results in:

V C R I L = L I ˙ L I L = C V ˙ C V_C - R I_L = L \dot{I}_L \\ -I_L = C \dot{V}_C

The plot of the current is included below, along with simulation code. Note that the damped sinusoidal behavior emerges from some very simple math operations.

 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
import math

# Component values

R = 0.2
L = 1.0
C = 1.0

dt = 10.0**(-5.0)

###############################

# Initialize quantities

t = 0.0
count = 0

IL = 0.0
VC = 10.0

ILd = (VC-R*IL)/L
VCd = -IL/C

###############################

Imax = -99999999.0

while t <= 20.0:

    IL = IL + ILd * dt   # Numerical integration
    VC = VC + VCd * dt

    ILd = (VC-R*IL)/L   # Time derivatives
    VCd = -IL/C

    #if count % 1000 == 0:
        #print t,IL

    if (t > 5.0) and (t < 10.0) and (IL > Imax):  # Constrained max check
        Imax = IL

    t = t + dt
    count = count + 1

###############################

print ""
print ""
print dt
print Imax

#1e-05
#4.58750547921

@Steven Chase Sir I am getting local minima as I m i n = 4.569 I_{min}=-4.569 between t = 5 t=5 and t = 10 t=10 . Correct me if i am wrong? Please @Karan Chatrath

A Former Brilliant Member - 1 year, 1 month ago

Log in to reply

It looks like pretty much the right answer, aside from the sign convention

Steven Chase - 1 year, 1 month ago

Log in to reply

@Steven Chase Sir but how can sign convention affect it? And sir one more problem is there, I have checked several times but my graph is not passing through origin??

A Former Brilliant Member - 1 year, 1 month ago

Log in to reply

@A Former Brilliant Member I was thinking perhaps your answer was the same as mine, just negated. And the current is zero initially, as stated in the problem. So that is a requirement for the solution.

Steven Chase - 1 year, 1 month ago

@Steven Chase sir I have typed your whole code here but my answer was not coming

A Former Brilliant Member - 11 months, 3 weeks ago

Log in to reply

In general, you have to read the error messages to see what needs to be changed

Steven Chase - 11 months, 3 weeks ago

Log in to reply

@Steven Chase sir please give me one trajectory simulations after that I will do myself

A Former Brilliant Member - 11 months, 3 weeks ago

Log in to reply

@A Former Brilliant Member Check the notes section

Steven Chase - 11 months, 3 weeks ago

@Steven Chase sir what is the meaning of f line 26 in your code
Imax=99999999.0
??

A Former Brilliant Member - 11 months, 3 weeks ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...