Any way to make my code run Faster

Asked by veerawat

first question :

i try to run my code but i got a little bit problem that i's very slow

Do you have any way to make it run faster

this is my code :

 from yade import pack
import matplotlib.pyplot as plt

idSteel=O.materials.append(FrictMat(young=210e9,poisson=.25,frictionAngle=.8,label="steel"))

O.materials.append(FrictMat(young=3e9,poisson=0.3,frictionAngle=radians(30),density=2600,label='spheres'))

# create rectangular box from boxes (maybe there is some library function, but I did not find it quickly)
cx,cy,cz = 6.3,6.3,6.3 # center of the box
dx,dy,dz = 7.5,7.5,7.5 # half-dimensions of the box
t = 0.25 # half-thickness of walls
left = box((cx-dx-t+1.2,cy+1.2,cz),(t,dy+2*t,cz),fixed=True,wire=True,material="steel")
right = box((cx+dx+t+1.2,cy+1.2,cz),(t,dy+2*t,cz),fixed=True,wire=True,material="steel")
front = box((cx+1.2,cy-dy-t+1.2,cz),(dx,t,cz),fixed=True,wire=True,material="steel")
back = box((cx+1.2,cy+dy+t+1.2,cz),(dx,t,cz),fixed=True,wire=True,material="steel")
bottom = box((cx+1.2,cy+1.2,cz-dz-t+1.2),(dx+2*t,dy+2*t,t),fixed=True,wire=True,material="steel")

left2 = box((cx-dx-t+1.2,cy+1.2,cz*2+2.7),(t,dy+2*t,2.7),fixed=True,wire=True,material="steel")
right2 = box((cx+dx+t+1.2,cy+1.2,cz*2+2.7),(t,dy+2*t,2.7),fixed=True,wire=True,material="steel")
front2 = box((cx+1.2,cy-dy-t+1.2,cz*2+2.7),(dx,t,2.7),fixed=True,wire=True,material="steel")
back2 = box((cx+1.2,cy+dy+t+1.2,cz*2+2.7),(dx,t,2.7),fixed=True,wire=True,material="steel")

top2 = box((cx+1.2,cy+1.2,18+t),(dx,dy,t),fixed=True,material="steel")

psdSizes,psdCumm=[0.0075,0.015,0.0425,.085,.2,.475],[0.,0.195,0.3145,0.6952,.9828,1.]
sp=pack.SpherePack()
# generate randomly spheres with uniform radius distribution
sp.makeCloud((0,0,0),(15,15,1.5),psdSizes=psdSizes,psdCumm=psdCumm,num=10000,seed=1)
# add the sphere pack to the simulation
sp.toSimulation(material='spheres')

Boxids=O.bodies.append((left,right,back,front,left2,right2,back2,front2,bottom))

O.engines=[
   ForceResetter(),
   InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()]),
   InteractionLoop(
      [Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
      [Ip2_FrictMat_FrictMat_FrictPhys()],
      [Law2_ScGeom_FrictPhys_CundallStrack()]
   ),
   NewtonIntegrator(gravity=(0,0,-9.81),damping=0.4),
   #PyRunner(command='addsphere()',iterPeriod=1000,label='adds'),

]
O.dt=0.001

Question information

Language:
English Edit question
Status:
Expired
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hello,

> O.dt=0.001

what is the value of PWaveTimeStep()?

How many cores do you use?

Please use timing module [1] and provide output of timing.stats()

cheers
Jan

[1] https://yade-dem.org/doc/yade.timing.html

Revision history for this message
veerawat (suesan) said :
#2

dear jan,

>what is the value of PWaveTimeStep()?

PWaveTimeStep 3.5589305925e-05

>How many cores do you use?
sorry sir i am the begginer

what is cores and How can i know how many do i use ?

Revision history for this message
Jan Stránský (honzik) said :
#3

> PWaveTimeStep 3.5589305925e-05
> O.dt=0.001

increasing time step is one option to make the running faster, but it is not a good idea to increase it above critical time step -> the simulation would become unstable and meaningless

>How many cores do you use?

you can run Yade in parallel using -j option (see yade --help), e.g.
yade -j 4 your_script.py
will use 4 cores and (normally) the execution should be almost 4 times faster (BUT depending on simulation itself)

waiting for the timing.stats

cheers
Jan

Revision history for this message
veerawat (suesan) said :
#4

Dear jan,

thanks

i try to use -j4 my_scrip.py

but it still take 1 or 2 days to simulation. Do you have other ways to make my code runing Faster ?

Revision history for this message
veerawat (suesan) said :
#5

Dear jan,

thanks

i try to use -j4 my_scrip.py

but it still take 1 or 2 days to simulation. Do you have other ways to make my code runing Faster ?

Revision history for this message
veerawat (suesan) said :
#6

Dear jan,

thanks

i try to use -j4 my_scrip.py

but it still take 1 or 2 days to simulation. Do you have other ways to make my code runing Faster ?

Revision history for this message
Jan Stránský (honzik) said :
#7

> Please use timing module [1] and provide output of timing.stats()

Revision history for this message
Launchpad Janitor (janitor) said :
#8

This question was expired because it remained in the 'Needs information' state without activity for the last 15 days.