-
-
Save rhettallain/d14734a3eae8efcc43f6 to your computer and use it in GitHub Desktop.
Discharging a capacitor with constant power
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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