Advertisement
Guest User

make_wall.py

a guest
Nov 9th, 2020
460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.96 KB | None | 0 0
  1. import math
  2. D=1     #Diameter if drum
  3. L=0.5       #length of drum
  4. Dpart=0.02  #particle diameter
  5. DENS=2800   #particle density
  6. z=0.0       #initial z-position
  7. id=1        #particle id-counter
  8. type=1      #atom types need to start from 1
  9.  
  10. content=""
  11. #do some math ..
  12. for i in xrange(0,2*int(L/Dpart)+1):
  13.  for a in xrange(0,360,1):
  14.     rad=a/180.0*math.pi
  15.     x=math.sin(rad)*D/2.
  16.     y=math.cos(rad)*D/2.
  17.     #atom-ID atom-type diameter density x y z
  18.     content+="%d %d %f %f %f %f %f\n" % (id,type,Dpart,DENS,x,y,z)
  19.     id+=1
  20.  z+=Dpart/2.
  21. N=(id-2)
  22.  
  23. header="LIGGGHTS data file made by Richti83 Wall Generator\n\n"
  24. header+="%d atoms\n\n" % (id-2)#N_particle=ID-2
  25. header+="2 atom types\n\n"
  26. header+="%f %f xlo xhi\n" % (-(D+Dpart)/2.,(D+Dpart)/2.)
  27. header+="%f %f ylo yhi\n" % (-(L+Dpart/2.),(L+Dpart/2.))
  28. header+="%f %f zlo zhi\n" % (-(D+Dpart)/2,(D+Dpart)/2.)
  29. header+="\n"
  30. header+="Atoms\n"
  31. #print content
  32. #print string
  33. fo = open("wall.pour", "wb")
  34. fo.write(header);
  35. fo.write(content)
  36. fo.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement