repeat scripts cause the problem? how to solve

Asked by De zhang

Dear everybody
 I repeat a scripts lot to debugger program. I use the 'from yade import qt,plot,utils,polyhedra_utils,ymport,export,pack' modules, as several times I run the program, the last time I run the script, the yade show that:
 TCP python prompt on localhost:9000, auth cookie 'edkcsy'
XMLRPC info provider on http://localhost:21000
Running script Myprogram.py
Traceback (most recent call last):
    File "/usr/bin/yadedaily", line 182, in runScript
       execfile(script,globals())
  File "Myprogram.py", line 165

^
SytaxErrorL invalid syntax

I check the program, its script is same as before but some parameters were changed, it could be run before but not read now. What's the problem of this? Is the global parameter can't be use many times?

Question information

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

Hello,

as the error says, there is a syntax error in your script

> script is same as before but some parameters were changed

so the script is NOT the same :-) I **guess** the change was such that the syntax is not valid any more.

To get a good answer, please provide a MWE [1] or the script itself.
cheers
Jan

[1] https://yade-dem.org/wiki/Howtoask

Revision history for this message
De zhang (dzlearnyade) said :
#2

Thank you! Jan~
     My friend and I checked the scripts each line and find that a bracket was missing in one line (x_x||) for my careless. But there is another problem for loading process. I want to use a plate to apply a 'sin' load on a ballast sample. Then, the script was simply shows as :

###the process
from yade import qt,plot,utils,polyhedra_utils,ymport,export,pack

#materials define
 sample = PolyhedraMat()
sample.density=3000
....(omit)
steel = PolyhedraMat()
steel.density = 7850
....(omit)

#shape generation
loadingplate=polyhedra_utils.polyhedra(steel,v=Vesctor(3),fixed=False,color=(0.75,0.75,0.75))
O.bodies.append(loadingplate)

O.bodies.append(utils.wall(0,axis=2,sense=1, material = steel))

ballast_up=polyhedra_utils.fillBox((-0.15,-0.15,0.4), (0.15,0.15,0.7),sample,sizemin=[0.025,0.025,0.025],sizemax=[0.05,0.05,0.05],ratio=[1,1,1],seed=4,mask=1)
...(omit)

#engines
## engines ##
O.engines=[
   ForceResetter(),
   InsertionSortCollider([Bo1_Polyhedra_Aabb(),Bo1_Wall_Aabb(),Bo1_Facet_Aabb()]),
   InteractionLoop(
      [Ig2_Wall_Polyhedra_PolyhedraGeom(), Ig2_Polyhedra_Polyhedra_PolyhedraGeom(), Ig2_Facet_Polyhedra_PolyhedraGeom()],
      [Ip2_PolyhedraMat_PolyhedraMat_PolyhedraPhys(), Ip2_FrictMat_PolyhedraMat_FrictPhys()],
      [Law2_PolyhedraGeom_PolyhedraPhys_Volumetric()], # contact law -- apply forces #Bo1_Cylinder_Aabb()
   ),
   #GravityEngine(gravity=(0,0,-9.81)),
   NewtonIntegrator(damping=0.3,gravity=(0,0,-9.81)),
   PolyhedraSplitter(iterPeriod=1,label='Splitter'), # allow splittering ballast
   PyRunner(command='checkUnbalancedI()',realPeriod=1,label='checker')
]

#O.dt=0.25*polyhedra_utils.PWaveTimeStep()
#O.dt=0.0025*polyhedra_utils.PWaveTimeStep()
O.dt=0.1*polyhedra_utils.PWaveTimeStep()

# loading
def checkUnbalancedI():
 print "iter %d, time elapsed %f, time step %.5e, unbalanced forces = %.5f"%(O.iter, O.realtime, O.dt, utils.unbalancedForce())
 if O.iter<5000: return
 # the rest will be run only if unbalanced is < .1 (stabilized packing)
 if unbalancedForce()>0.1: return
 # start plotting the data now, it was not interesting before
 O.engines=O.engines+[PyRunner(command='addPlotData()',iterPeriod=50)]
 # next time, do not call this function anymore, but the next one (unloadPlate) instead
 checker.command='cyclicloadingI()'

def addPlotData():
    Fz=O.forces.setPermF(O.bodies[0].id,(0,0,-200-100*sin((15/pi)*O.time)))
    W=loadingplate.state.pos[2]-loadingplate.state.refPos[2]
    plot.addData(Fz=Fz,w=W,i=O.iter,unbalanced=unbalancedForce(),**O.energy)

def cyclicloadingI():
    O.forces.setPermF(O.bodies[0].id,(0,0,(0,0,-200-100*sin((15/pi)*O.time))))

#view
qt.Controller()
V = qt.View()

#plot
plot.plots={'i':('unbalanced',),'w':('Fz',)}
plot.plot()

#
O.wait()

######over

The results warning shows
The warn:
ArgumentError: Python argument types in
ForceContainer.setPermF(ForceContainer, int, tuple)
did not match C++ signature:
setPermF(pyForceContainer {lvalue}, long, Eigen::Matrix<double, 3,1, 0, 3,1>)

How to deal this problem? and I search the previous similar problem about 'setPermF' module, you provide the 'addF' module. Moreover, I read the 'InterpolatingDirectedForceEngine' and was it fit for 'sin' loading? What's the difference between them and is there the priority of them?

Thanks again for your help~ I follow and adore your papers on the researchgate net~

Revision history for this message
De zhang (dzlearnyade) said :
#3

Thank you! Jan~
     The simple process was added on the above comment, and I have another questions about the plot.
###
line1 def addPlotData():
line 2 Fz=O.forces.setPermF(O.bodies[0].id,(0,0,-200-100*sin((15/pi)*O.time)))
line3 W=loadingplate.state.pos[2]-loadingplate.state.refPos[2]
line4 plot.addData(Fz=Fz,w=W,i=O.iter,unbalanced=unbalancedForce(),**O.energy)

I want to plot the loading force vs the displacement of sample, I can't understand about 'loadingplate.state.refPos[2]' in the line3 .

Thanks again~

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

Hello,

> O.forces.setPermF(O.bodies[0].id,(0,0,(0,0,-200-100*sin((15/pi)*O.time))))
> ...
> ForceContainer.setPermF(ForceContainer, int, tuple)
> did not match C++ signature:
> setPermF(pyForceContainer {lvalue}, long, Eigen::Matrix<double, 3,1, 0, 3,1>)

the force set has to be Vector3. For convenience, yade automatically converts tuples and lists of the form [number,number,number] to Vector3, but here you pass not valid data
(0,0,(0,0,-200-100*sin((15/pi)*O.time)))) = (0, 0, (0, 0, someNumber) ) = (number,number,tuple)
as a force

cheers
Jan

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

> line3 W=loadingplate.state.pos[2]-loadingplate.state.refPos[2]

loadingplate.state.pos is current position of loadingplate
loadingplate.state.refPos is initial position of loadingplate
loadingplate.state.pos - loadingplate.state.refPos is therefore displacement of loadingplate. Using the index pos[2] and refPos[2] you evaluates only displacement in z direction
Jan

Revision history for this message
De zhang (dzlearnyade) said :
#6

Thanks Jan Stránský, that solved my question.

Revision history for this message
De zhang (dzlearnyade) said :
#7

Jan~Thanks~ Help me a lot~~Wish having a warm weekend~~