New question #685313 on Yade: https://answers.launchpad.net/yade/+question/685313
Hello, I am using Ubuntu 18.04, and Yade 2019-08-08.git-775ae74 I slightely changed https://.../script-session1.py and now get a syntax error in PyRunner line as follows: ehsan@ehsan:~/Desktop/mycodes/3axtst$ /home/ehsan/yade/install/bin/yade-2019-08-08.git-775ae74 3axtst.py Welcome to Yade 2019-08-08.git-775ae74 Using python version: 3.6.8 (default, Oct 7 2019, 12:59:55) [GCC 8.3.0] TCP python prompt on localhost:9000, auth cookie `sukesd' XMLRPC info provider on http://localhost:21000 Running script 3axtst.py Traceback (most recent call last): File "/home/ehsan/yade/install/bin/yade-2019-08-08.git-775ae74", line 336, in runScript execfile(script,globals()) File "/usr/lib/python3/dist-packages/past/builtins/misc.py", line 81, in execfile code = compile(source, filename, "exec") File "3axtst.py", line 87 PyRunner(iterPeriod=20,command='history()',label='recorder'), ^ SyntaxError: invalid syntax [[ ^L clears screen, ^U kills line. F12 controller, F11 3D view (press "h" in 3D view for help), F10 both, F9 generator, F8 plot. ]] In [1]: *************************** Reading wiki and he source code, I can't find the problem. Would you help me with that please? Also, please let me know if the code has any other problem. *************************** My code: ############################################################################################################################ ######### TRIAXIAL PROBLEM, Y IS THE VERTICAL AXIS, X IS THE RIGHT AXIS, Z IS THE FRONT AXIS ######### ############################################################################################################################ import numpy as np import math from yade import pack, plot, qt, export, utils from datetime import datetime from yade.params import table ###################################################### ######### DEFINING VARIABLES ######### nRead=readParamsFromTable( num_spheres=1500, # number of spheres compFricDegree = 30, # contact friction during the confining phase key='_triax_base_', # put you simulation's name here unknownOk=True ) num_spheres=table.num_spheres # number of spheres key=table.key targetPorosity = 0.43 #the porosity we want for the packing compFricDegree = table.compFricDegree # initial contact friction during the confining phase (will be decreased during the REFD compaction process) finalFricDegree = 30 # contact friction during the deviatoric loading rate=-0.02 # loading rate (strain rate) damp=0.2 # damping coefficient stabilityThreshold=0.01 # we test unbalancedForce against this value in different loops (see below) young=15e6 # contact stiffness poisson=0.4 mn,mx=Vector3(0,0,0),Vector3(10,10,10) # corners of the initial packing sigmaIso=-50e3 # confining pressure ###################################################### ######### DEFINING MATERIALS ######### O.materials.append(FrictMat(young=young,poisson=poisson,frictionAngle=radians(compFricDegree),density=2600,label='spheres')) # particles(spheres) O.materials.append(FrictMat(young=young,poisson=poisson,frictionAngle=0,density=0,label='frictionlesswalls')) # walls(plates) #################################################### ######### DEFINING PACKING ######### walls=aabbWalls([mn,mx],thickness=0,material='frictionlesswalls') # create walls around the packing wallIds=O.bodies.append(walls) # assigning walls to O.bodies sp=pack.SpherePack() # generating a random loose particles packing, an empty cloud which contains only geometrical information clumps=False # Rigid aggregate of bodies, turn this true for the same example with clumps if clumps: volume = (mx[0]-mn[0])*(mx[1]-mn[1])*(mx[2]-mn[2]) # volume of the box given by minCorner and maxCorner (specimen) mean_rad = pow(0.09*volume/num_spheres,0.3333) # approximate mean radius of the future dense packing for latter use c1=pack.SpherePack([((-0.2*mean_rad,0,0),0.5*mean_rad),((0.2*mean_rad,0,0),0.5*mean_rad)]) # define a unique clump type (we could have many, see clumpCloud documentation) sp.makeClumpCloud(mn,mx,[c1],periodic=False) # generate positions, put spheres with defined radius inside box given by corners mn and mx sp.toSimulation(material='spheres') # input positions in the simulation, create particles and add them to the simulation O.bodies.updateClumpProperties() # get more accurate clump masses/volumes/inertia else: sp.makeCloud(mn,mx,-1,0.3333,num_spheres,False, 0.95,seed=1) #"seed" make the "random" generation always the same O.bodies.append([sphere(center,rad,material='spheres') for center,rad in sp]) #or alternatively (higher level function doing exactly the same): #sp.toSimulation(material='spheres') ########################################################## ######### DEFINING TRIAXIAL TEST ######### triax=TriaxialStressController( # TriaxialStressController will be used to control stress and strain. It controls particles size and plates positions. maxMultiplier=1.+2e4/young, # spheres growing factor (fast growth) finalMaxMultiplier=1.+2e3/young, # spheres growing factor (slow growth) thickness = 0, stressMask = 7, internalCompaction=False # If true the confining pressure is generated by growing particles ) #################################################### ######### DEFINING ENGINES ######### newton=NewtonIntegrator(damping=damp) 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()] ), GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=100,timestepSafetyCoefficient=0.8), # will use the global stiffness of each body to determine an optimal timestep triax, TriaxialStateRecorder(iterPeriod=100,file='WallStresses'+table.key), newton PyRunner(iterPeriod=20,command='history()',label='recorder'), PyRunner(command='checkUnbalanced()',realPeriod=2) ] Gl1_Sphere.stripes=True # Display spheres with different colors for seeing rotations better if nRead==0: yade.qt.Controller(), yade.qt.View() ############################################################### ######### APPLYING CONFINING PRESSURE ######### triax.goal1=triax.goal2=triax.goal3=sigmaIso # the value of (isotropic) confining stress defines the target stress to be applied in all three directions ############################################################### ######### APPLYING CONFINING PRESSURE ######### # We will reach a prescribed value of porosity with the REFD algorithm #import sys #this is only for the flush() below #while triax.porosity>targetPorosity: #compFricDegree = 0.95*compFricDegree # decrease friction value #setContactFriction(radians(compFricDegree)) # apply compFricDegree to all the bodies and contacts #print "\r Friction: ",compFricDegree," porosity:",triax.porosity, #sys.stdout.flush() ## while we run steps, triax will tend to grow particles as the packing ## keeps shrinking as a consequence of decreasing friction. Consequently ## porosity will decrease #O.run(500,1) #O.save('compactedState'+key+'.yade.gz') #print "### Compacted state saved ###" ###################################################### ######### DEVIATORIC LOADING ######### triax.internalCompaction=False # turn internal compaction off to keep particles sizes constant #setContactFriction(radians(finalFricDegree)) # change contact friction (remember that decreasing it would generate instantaneous instabilities) triax.stressMask = 5 # set stress control on x and z, we will impose strain rate on y, now goal2 is the target strain rate triax.goal2=rate # now goal2 is the target strain rate triax.goal1=sigmaIso # we defined the lateral stresses during the test, here the same sigmaIso as for the initial confinement triax.goal3=sigmaIso # we defined the lateral stresses during the test, here the same sigmaIso as for the initial confinement ##Save temporary state in live memory. This state will be reloaded from the interface with the "reload" button. O.saveTmp() ######################################################## ######### RECORD AND PLOT DATA ######### qt.View() def checkUnbalanced(): if unbalancedForce()<.05: O.pause() plot.saveDataTxt('bbb.txt.bz2') def history(): # a function to save variables plot.addData(e11=-triax.strain[0], e22=-triax.strain[1], e33=-triax.strain[2], ev=-triax.strain[0]-triax.strain[1]-triax.strain[2], s11=-triax.stress(triax.wall_right_id)[0], s22=-triax.stress(triax.wall_top_id)[1], s33=-triax.stress(triax.wall_front_id)[2], i=O.iter,unbalanced=unbalancedForce() #,**O.energy,Etot=O.energy.total() ) O.run(5000,True) plot.plots={'e22':('s11','s22','s33'),'e22':('ev')} # the traditional triaxial curves would be more like this plot.labels={'s11':'$\sigma_{11}$' , 's22':'$\sigma_{22}$' , 's33':'$\sigma_{33}$' , 'e11':'$\epsilon_{11}$' , 'e22':'$\epsilon_{22}$' , 'e33':'$\epsilon_{33}$' , 'ev':'$\epsilon_{V}$'} plot.plot() # display on the screen (doesn't work on VMware image it seems) plot.saveDataTxt('results'+key) # save the data to a text file at the the end of the simulation plot.saveGnuplot('plotScript'+key) # generate a script for gnuplot. Open another terminal and type "gnuplot plotScriptKEY.gnuplot *************************** Thank you for your help. -- You received this question notification because your team yade-users is an answer contact for Yade. _______________________________________________ Mailing list: https://launchpad.net/~yade-users Post to : [email protected] Unsubscribe : https://launchpad.net/~yade-users More help : https://help.launchpad.net/ListHelp

