Skip to content

Instantly share code, notes, and snippets.

@rhettallain rhettallain/capacitor_discharge.py Secret
Last active Dec 17, 2015

Embed
What would you like to do?
Discharging a capacitor with constant power
from pylab import *
C=1200.
V=6.
Q=C*V
P=0.5
R=V**2/P
I=V/R
t=0
dt=10.
vp=[]
tp=[]
rp=[]
while V>2.5:
V=Q/C
R=V**2/P
I=V/R
Q=Q-I*dt
vp=vp+[V]
tp=tp+[t]
rp=rp+[R]
t=t+dt
#print(V)
plot(tp,rp, linewidth=3)
print(t)
print(V)
print(Q)
#plot(tp,rp, linewidth=3)
grid(True)
xlabel('Time [s]')
ylabel('Potential Difference for Capacitor [Volts]')
show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.