Skip to content

Instantly share code, notes, and snippets.

@mick001
Created August 28, 2015 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mick001/52466504274e255a7720 to your computer and use it in GitHub Desktop.
Save mick001/52466504274e255a7720 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('ggplot')
c = 100 * 10**(-6)
v = 5
r = 2000
t = np.linspace(0,1,1000)
q = c*v*(1-np.exp((-1/(r*c))*t))
i = (v/r)*np.exp((-1/(r*c))*t)
plt.plot([0,t[-1]],[c*v,c*v],label='Charge peak')
plt.plot(t,q,label='Charge of the capacitor (C)')
plt.plot(t,i,label='Current (A)')
print('Tau',1/(r*c))
print('Peak current (A)',v/r)
plt.xlabel('Time (s)')
plt.title('RC circuit')
plt.legend()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment