Guest User

Untitled

a guest
Oct 17th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. class Cap():
  2.     def __init__(self,res1,cap1,source):
  3.         self.res1 = res1
  4. #        self.res2 = res2
  5.         self.cap1 = cap1
  6. #        self.cap2 = cap2
  7.         self.vsrc = source
  8.     def charge(self,vc_init):
  9.         t=np.linspace(0.,1,1000,endpoint=False)
  10.         vc = np.zeros(len(t))
  11.         if vc_init is None:
  12.             vc[1]=0
  13.         else:
  14.             vc[1]=vc_init
  15.         for i in range(len(t)):
  16.             vc_ = vc[i]
  17.             ir1= (self.vsrc-vc_)/self.res1
  18.             vc[i+1]=vc[i] + (ir1*i)/self.cap1
  19. #            if sinput <=treshhold:
  20. #                break
  21.         print 'vc=', vc
  22.         print len(vc)
  23.         print  len(t)
  24. #        print 'z=',z
  25.         return vc
Advertisement
Add Comment
Please, Sign In to add comment