Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168734
Image: ubuntu2004
def v_C(bigV, R, L, C, v0, i0): ''' Plot the capacitor voltage over time in a series RLC circuit. ''' t = var('t') #seconds v = function('v',t) DE = L*C*diff(v, t,2) + R*C*diff(v, t) + v == bigV #the differential equation governing the system vdot0 = i0/C #initial dv/dt, derived from q==CV and i==dq/dt IC = [0, v0, vdot0] #initial conditions: [t0, v(t0), dv(t0)/dt] vPlot = plot(desolve(DE, [v,t], IC),(t,0,1e-3)) ''' Portray the amplitude decay envelope ''' a = R/2/L #1/second (damping factor) A0 = sqrt((v0-bigV)^2 + L*C*vdot0^2) #initial amplitude envelope = A0 * e^(-a*t) envelopePlot = plot([bigV + envelope, bigV - envelope], (t,0,1e-3), linestyle="--", rgbcolor=(.3,.5,.3)) ''' Put it all together in one combined graphics object ''' return (vPlot + envelopePlot)
@interact def plotter(bigV = slider(range(-3,4),default=0,label = '$Driving\ voltage\ (V)\ \\sim\ road\ height\ (Y)$')\ , R = slider([10^i for i in range(-2,5)],default=10,label = '$Resistance\ (R)\ \\sim\ friction\ (b)$')\ , L = slider([10^i for i in range(-6,1)],default = 10^-3, label="$Inductance\ (L)\ \\sim\ mass\ (m)$")\ , C = slider([10^i for i in range(-10,-3)],default = 10^-7, label="$Capacitance\ (C)\ \\sim\ spring\ constant\ (k)$")\ , v0 = slider(range(-3,4),default=1,label = '$Initial\ capacitor\ voltage\ (v_{C}(0))\ \\sim\ initial\ displacement\ (y(0))$')\ , vdot0 = slider([i/100 for i in range(-3,4)],default=0,label = '$Initial\ current\ i(0)\ \\sim\ initial\ velocity\ (y\'(0))$')): show(v_C(bigV,R,L,C,v0,vdot0), figsize=[10,4], axes_labels=['$t\ \\mathrm{seconds}$','$v_{C}(t)\ \\mathrm{volts}\ \\sim\ y(t)\ \\mathrm{meters}$'])
Driving\ voltage\ (V)\ \sim\ road\ height\ (Y) 
Resistance\ (R)\ \sim\ friction\ (b) 
Inductance\ (L)\ \sim\ mass\ (m) 
Capacitance\ (C)\ \sim\ spring\ constant\ (k) 
Initial\ capacitor\ voltage\ (v_{C}(0))\ \sim\ initial\ displacement\ (y(0)) 
Initial\ current\ i(0)\ \sim\ initial\ velocity\ (y'(0)) 
[removed]
[removed]
[removed]
[removed]