Advertisement
lingran

Ep code

Sep 17th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1. E=O.energy['plastDissip']
  2. e=0
  3. energy=open('energy.txt','w')
  4. for k in range (0,100):
  5.     a=open('state_1.txt','w')
  6.     b=open('state_2.txt','w')
  7.     for i in O.interactions:
  8.           Ft=i.phys.shearForce
  9.           a.write('%d %d %f %f %f\n' %(i.id1,i.id2,Ft[0],Ft[1],Ft[2]))
  10.  
  11.     a.close()    
  12.  
  13.     O.step()
  14.  
  15.     for i in O.interactions:
  16.         Ftt=i.phys.shearForce
  17.         du=i.geom.shearInc
  18.         kt=i.phys.ks
  19.         Fn=i.phys.normalForce
  20.         maxFs=Fn.norm()*i.phys.tangensOfFrictionAngle
  21.         b.write('%d %d %f %f %f %f %f %f %f %f\n' %(i.id1,i.id2,Ftt[0],Ftt[1],Ftt[2],maxFs,du[0],du[1],du[2],kt))
  22.    
  23.    
  24.     b.close()
  25.    
  26.     x = numpy.loadtxt('state_1.txt')
  27.     y = numpy.loadtxt('state_2.txt')
  28.    
  29.     for i in range (0,len(y)):
  30.         Ftt=Vector3(y[i][2],y[i][3],y[i][4])
  31.         maxFs=y[i][5]
  32.         du=Vector3(y[i][6],y[i][7],y[i][8])
  33.         kt=y[i][9]
  34.         Ft=Vector3(0,0,0)
  35.         for j in range (0,len(x)):
  36.             if y[i][0]==x[j][0] and y[i][1]==x[j][1]:
  37.                 Ft=Vector3(x[j][2],x[j][3],x[j][4])
  38.         Ftc=Ft-kt*du
  39.         if Ftc.norm()> maxFs:
  40.                 #Ftt=Ftt/Ftt.norm()*maxFs
  41.                 due=-(Ftt-Ft)/kt
  42.                 #e+=Ftt.norm()*(du.norm()-due.norm())
  43.                 e+=Ftt.norm()*(du-due).norm()
  44.     energy.write('%f %f %f\n'%(O.time,e,O.energy['plastDissip']-E))
  45.  
  46.  
  47. energy.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement