Presentation is loading. Please wait.

Presentation is loading. Please wait.

MATHEMATICA – Computer Simulation R.C. Verma Physics Department Punjabi University Patiala – 147 002 PART IX- Computer Simulation RC - Circuit LR-Circuit.

Similar presentations


Presentation on theme: "MATHEMATICA – Computer Simulation R.C. Verma Physics Department Punjabi University Patiala – 147 002 PART IX- Computer Simulation RC - Circuit LR-Circuit."— Presentation transcript:

1 MATHEMATICA – Computer Simulation R.C. Verma Physics Department Punjabi University Patiala – 147 002 PART IX- Computer Simulation RC - Circuit LR-Circuit LC-Circuit: Harmonic Oscillations LCR-Circuit: Damped Oscillations Nonlinearity: Rectifier’s Output Resonance in Driven LCR Circuit

2 Charging and Discharging Capacitor (RC – Circuit )

3 Equations of Motion Kirchoff's loop law gives:

4 RC- Circuit Clear["Global`*"] r = 0.85; c = 1.2; (* inputs:- R & C *) v= 0.1; q0=0; (* voltage applied & initial charge *) tmin = 0; tmax = 5; ndsol = NDSolve[ Join[ {r q'[t]+q[t]/c -v==0}, {q[0]==q0}], q[t], {t, tmin, tmax} ] Plot[ q[t]/.ndsol, {t, tmin, tmax}, PlotLabel->"Charging of a Capacitor", AxesLabel->{"t", "q"} ]

5

6 RC- Circuit: Charge and Current Clear["Global`*"] r = 0.85; c = 1.2; (* R & C *) v= 0.1; q0=0;(* voltage applied & initial charge *) tmin = 0; tmax = 5; dsol = DSolve[ Join[ {r q'[t]+q[t]/c -v==0}, {q[0]==q0}], q[t], t ]//Flatten Plot[ q[t]/.dsol, {t, tmin, tmax}, PlotLabel->"Charging of a Capacitor", AxesLabel->{"t", "q"} ] i[t_]= D[ q[t]/.dsol, t] Plot[ i[t], {t, tmin, tmax}, PlotLabel->"Current while charging a Capacitor", AxesLabel->{"t", "i"} ]

7

8

9 RC- Circuit: Resistance changes with time Clear["Global`*"] r=0.85; res[t_]:= r*(1+0.8*t) c = 1.2; (* R & C *) v= 0.1; q0=0;(* voltage applied & initial charge *) tmin = 0; tmax = 8; ndsol = NDSolve[ Join[ {r*q'[t]+q[t]/c -v==0}, {q[0]==q0}], q[t], {t, tmin, tmax}] ndsol1 = NDSolve[ Join[ {res[t]*qv'[t]+qv[t]/c -v==0}, {qv[0]==q0}], qv[t], {t, tmin, tmax}] i[t_]= D[ q[t]/.ndsol, t] iv[t_]= D[ qv[t]/.ndsol1, t] Plot[ {q[t]/.ndsol, qv[t]/.ndsol1}, {t, tmin, tmax}, PlotLabel->"Charging of a Capacitor", AxesLabel->{"t", "q"}, PlotStyle-> {Dashing[{}], Dashing[{0.02}]} Plot[ {i[t], iv[t]}, {t, tmin, tmax}, PlotLabel->"Current while charging a Capacitor", AxesLabel->{"t", "i"}, PlotStyle-> {Dashing[{}], Dashing[{0.02}]} ]

10

11

12 Growth of Current in RL – Circuit

13 RL- Circuit Clear["Global`*"] r = 0.85; ind = 1.2; (* R & L *) v= 0.1; i0=0; (* voltage applied & initial current *) tmin = 0; tmax = 5; dsol = DSolve[ Join[ { i'[t]+i[t]*r/ind -v/ind==0}, {i[0]==i0}], i[t], t]//Flatten Plot[ i[t]/.dsol, {t, tmin, tmax}, PlotLabel->"Current in RL Circuit", AxesLabel->{"t", "i"}]

14

15 RL- Circuit: Energy Analysis Clear["Global`*"] r = 0.85; ind = 1.2; (* R & L *) v= 0.1; i0=0;(* voltage applied & initial current *) tmin = 0; tmax = 5; ndsol = NDSolve[ Join[ { i'[t]+i[t]*r/ind -v/ind==0}, {i[0]==i0}], i[t], {t, tmin, tmax}] n=10;h=(tmax-tmin)/n//N; Print["Energy Analysis in RL Circuit"] Print["time in L in R in R+L Supplied"] Do[ energy=v*NIntegrate[ Evaluate[i[t]/.ndsol], {t, tmin, tup}] ; indener= 0.5*ind*((i[t]/.ndsol/.t->tup)^2-(i[t]/.ndsol/.t->tmin)^2); resener= r*NIntegrate[ Evaluate[(i[t]/.ndsol)^2],{t, tmin, tup}]; Print[tup," ",indener," ",resener," ",indener+resener," ",energy], {tup, tmin, tmax, 0.5} ]

16 Energy Analysis in RL Circuit time in L in R in R+L Supplied 0. {0.} {0} {0.} {0} 0.5 {0.000738671} {0.000190181} {0.000928853} {0.000928852} 1. {0.00213918} {0.00119587} {0.00333505} {0.00333505} 1.5 {0.00355641} {0.00322156} {0.00677798} {0.00677798} 2. {0.00476491} {0.00618354} {0.0109484} {0.0109484} 2.5 {0.00571834} {0.00991114} {0.0156295} {0.0156295} 3. {0.00643929} {0.0142295} {0.0206688} {0.0206688} 3.5 {0.00697079} {0.0189887} {0.0259595} {0.0259595} 4. {0.00735635} {0.0240704} {0.0314267} {0.0314267} 4.5 {0.00763311} {0.0293846} {0.0370177} {0.0370177} 5. {0.00783039} {0.0348652} {0.0426956} {0.0426956}

17 RL- Circuit: Resistance changes with time Clear["Global`*"] r = 0.85; ind = 1.2; (* R & L *) v= 0.1; i0=0;(* voltage applied & initial current *) tmin = 0; tmax = 5; res[t_]:= r*(1+0.8 *t) ndsol = NDSolve[ Join[ { i'[t]+i[t]*r/ind -v/ind==0}, {i[0]==i0}], i[t], {t, tmin, tmax}]//Flatten ndsol1 = NDSolve[ Join[ { iv'[t]+iv[t]*res[t]/ind -v/ind==0}, {iv[0]==i0}], iv[t], {t, tmin, tmax}]//Flatten Plot[ {i[t]/.ndsol, iv[t]/.ndsol1}, {t, tmin, tmax}, PlotLabel->"Current in RL Circuit", AxesLabel->{"t", "i"}, PlotStyle->{Dashing[{}],Dashing[{0.02}] }]

18

19 LC- Circuit: Harmonic Oscillations

20

21 LC- Circuit Clear["Global`*"] ind = 1.2;cap=0.85; (* L C *) i0=1.0;q0=1.0;(* initial conditions *) tmin = 0; tmax = 15; dsol = DSolve[ Join[ { q''[t]+ q[t]/(ind*cap)==0}, {q[0]==q0, q'[0]==i0}], q[t], t]//Flatten//Chop i[t_]=D[ q[t]/.dsol, t] Plot[ {q[t]/.dsol, i[t]}, {t, tmin, tmax}, PlotLabel->"Oscillations in LC-Circuit", AxesLabel- >{"t", "q"}, PlotStyle->{Dashing[{}], Dashing[{0.01}]}, PlotPoints->50 ] Print[" ----------------------------"] Print[" Energy Analysis in LC Circuit"] Print[" in L in C total"] Print[" ----------------------------"] Do[ indener = 0.5*ind*i[t]^2; capener = 0.5*(q[t]/.dsol)^2/cap; Print[ indener," ",capener," ",indener+capener], {t, tmin, tmax, 1.0} ] Print[" ----------------------------"]

22 {q[t]®1. Cos[0.990148 t]+1.00995 Sin[0.990148 t]}

23 Energy Analysis in LC Circuit in L in C total ---------------------------- 0.6 0.588235 1.18824 0.046806 1.14143 1.18824 1.02406 0.164176 1.18824 0.799067 0.389168 1.18824 0.0009749 1.18726 1.18824 0.861487 0.326748 1.18824 0.974354 0.213881 1.18824 0.0239661 1.16427 1.18824 0.667892 0.520343 1.18824 1.10552 0.0827127 1.18824 0.113112 1.07512 1.18824 0.465737 0.722498 1.18824 1.17735 0.0108826 1.18824 0.258068 0.930167 1.18824 0.278478 0.909757 1.18824 1.18151 0.00672513 1.18824 ----------------------------

24 LCR-Circuit: Damped Oscillations

25

26 LCR- Circuit Clear["Global`*"] ind = 1.2;cap=0.85;res=0.5; (* L C R *) i0=1.0;q0=1.0;(* initial conditions *) tmin = 0; tmax = 15; dsol = DSolve[ Join[ { q''[t]+q'[t]*res/ind+ q[t]/(ind*cap)==0}, {q[0]==q0, q'[0]==i0}], q[t], t ]//Flatten i[t_]=D[ q[t]/.dsol, t] Plot[ {q[t]/.dsol, i[t]}, {t, tmin, tmax}, PlotLabel->"Damped Oscillations in LCR-Circuit", AxesLabel->{"t", "q & i"}, PlotStyle->{Dashing[{}], Dashing[{0.01}]}, PlotPoints->50 ]

27 {q[t]®ã(-0.208333 t (1. Cos[0.967982 t]+1.2483 Sin[0.967982 t])}

28 LCR- Circuit: time-varying resistance Clear["Global`*"] ind = 1.2;cap=0.85;res=0.02; (* L C R *) r[t_]:= res*(1+0.3*t^2) i0=1.0;q0=1.0;(* initial conditions *) tmin = 0; tmax = 25; dsolv = NDSolve[ Join[ { q''[t]+q'[t]*r[t]/ind+ q[t]/(ind*cap)==0}, {q[0]==q0, q'[0]==i0}], q[t], {t, tmin, tmax}]//Flatten p1= Plot[ {q[t]/.dsolv}, {t, tmin, tmax}, PlotLabel->"Time Varying R in LCR-Circuit: ", AxesLabel->{"t", "q"}, PlotStyle->{ Dashing[{0.01}]}, PlotPoints->50 ]; dsol = NDSolve[ Join[ { q''[t]+q'[t]*res/ind+ q[t]/(ind*cap)==0}, {q[0]==q0, q'[0]==i0}], q[t], {t, tmin, tmax}]//Flatten p2 = Plot[ {q[t]/.dsol}, {t, tmin, tmax}, AxesLabel->{"t", "q"}, PlotPoints->50 ]; Show[p1, p2]

29

30 Nonlinearity : Rectifier's Output Clear["Global`*"] w= 2.0; tmin = 0; tmax = 6; eps = 1.1; v[t_]:= Sin[w*t] Plot[ v[t], {t, tmin, tmax}, PlotLabel -> "Input Signal", AxesLabel->{"t", "v"}] Plot[ v[t]+eps*v[t]^2, {t, tmin, tmax}, PlotLabel -> "Output Signal", AxesLabel->{"t", "v"}]

31

32 Nonlinear Circuit

33 r = 100.0; k = 1.39*10^(-23); t = 300; q = 1.6*10^(-19); i0 = 10^(-10); v1= 15.0; FindRoot[{(v1-v2)/r == i0*(E^(q*v2/(k*t))-1)}, {v2, 0.5}] v1= 15.1; FindRoot[{(v1-v2)/r == i0*(E^(q*v2/(k*t))-1)}, {v2, 0.5}] {v2 -> 0.549695} {v2 -> 0.549874}

34 Resonance in Driven LC Circuit

35 Eqns. for time dependent Voltage

36 Steady State for w Clear["Global`*"] dsol = Solve[{v1*E^(I w t)-v2*E^(I w t)== i0*r*E^(I w t), i0== i1+i2, c*D[v2*E^(I w t), t]==i1*E^(I w t), l*D[i2*E^(I w t), t]==v2*E^(I w t)}, {v2, i0, i1, i2}] Simplify[dsol] c = 10^(-6); l = 10^(-3); v1=1; Plot[Release[Table[Abs[v2]/.dsol[[1]]/.r->10^n, {n,2,4,0.5}]], {w, 20000, 40000}, PlotRange -> {0,1}]

37

38

39 Thank You


Download ppt "MATHEMATICA – Computer Simulation R.C. Verma Physics Department Punjabi University Patiala – 147 002 PART IX- Computer Simulation RC - Circuit LR-Circuit."

Similar presentations


Ads by Google