Skip to content

Instantly share code, notes, and snippets.

@scottralph
Created February 11, 2022 14: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 scottralph/285a2a6d8822f070874b52de0da1a926 to your computer and use it in GitHub Desktop.
Save scottralph/285a2a6d8822f070874b52de0da1a926 to your computer and use it in GitHub Desktop.
Charging of a RC Circuit
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import math
fig = plt.figure()
ax = plt.axes()
ax.set_xlim([0,4])
ax.set_ylim([0,1])
xs = np.array([x/1000.0 for x in range(0,4001)])
ys = np.array([1.0 - math.exp(-x) for x in xs])
ax.plot(xs, ys)
y1 = 1.0-math.exp(-1.0)
lx = [0.0, 1.0, 1.0]
ly = [y1, y1, 0]
plt.plot(lx,ly)
plt.title('Charging of a Capacitor')
plt.xlabel('Time (Tau)')
plt.ylabel('Voltage (Vc)')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment