← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-pkg/yade/git-trunk] Rev 3687: Tutorial examples: remove all deprecated 'utils.' and GravityEngine in the example scripts

 

------------------------------------------------------------
revno: 3687
committer: Raphael Maurin <raph_maurin@xxxxxxxxxxx>
timestamp: Tue 2015-06-16 17:31:20 +0200
message:
  Tutorial examples: remove all deprecated 'utils.' and GravityEngine in the example scripts
modified:
  doc/sphinx/tutorial/01-bouncing-sphere.py
  doc/sphinx/tutorial/02-gravity-deposition.py
  doc/sphinx/tutorial/03-oedometric-test.py
  doc/sphinx/tutorial/04-periodic-simple-shear.py
  doc/sphinx/tutorial/05-3d-postprocessing.py
  doc/sphinx/tutorial/06-periodic-triaxial-test.py


--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'doc/sphinx/tutorial/01-bouncing-sphere.py'
--- doc/sphinx/tutorial/01-bouncing-sphere.py	2011-01-20 16:35:46 +0000
+++ doc/sphinx/tutorial/01-bouncing-sphere.py	2015-06-16 15:31:20 +0000
@@ -7,9 +7,9 @@
 # they the default material (utils.defaultMat)
 O.bodies.append([
 	# fixed: particle's position in space will not change (support)
-	utils.sphere(center=(0,0,0),radius=.5,fixed=True),
+	sphere(center=(0,0,0),radius=.5,fixed=True),
 	# this particles is free, subject to dynamics
-	utils.sphere((0,0,2),.5)
+	sphere((0,0,2),.5)
 ])
 
 # FUNCTIONAL COMPONENTS
@@ -23,16 +23,14 @@
 		[Ip2_FrictMat_FrictMat_FrictPhys()], # collision "physics"
 		[Law2_L3Geom_FrictPhys_ElPerfPl()]   # contact law -- apply forces
 	),
-	# apply gravity force to particles
-	GravityEngine(gravity=(0,0,-9.81)),
-	# damping: numerical dissipation of energy
-	NewtonIntegrator(damping=0.1)
+	# Apply gravity force to particles. damping: numerical dissipation of energy.
+	NewtonIntegrator(gravity=(0,0,-9.81),damping=0.1)
 ]
 
 # set timestep to a fraction of the critical timestep
 # the fraction is very small, so that the simulation is not too fast
 # and the motion can be observed
-O.dt=.5e-4*utils.PWaveTimeStep()
+O.dt=.5e-4*PWaveTimeStep()
 
 # save the simulation, so that it can be reloaded later, for experimentation
 O.saveTmp()

=== modified file 'doc/sphinx/tutorial/02-gravity-deposition.py'
--- doc/sphinx/tutorial/02-gravity-deposition.py	2011-05-03 15:04:37 +0000
+++ doc/sphinx/tutorial/02-gravity-deposition.py	2015-06-16 15:31:20 +0000
@@ -6,7 +6,7 @@
 from yade import pack, plot
 
 # create rectangular box from facets
-O.bodies.append(utils.geom.facetBox((.5,.5,.5),(.5,.5,.5),wallMask=31))
+O.bodies.append(geom.facetBox((.5,.5,.5),(.5,.5,.5),wallMask=31))
 
 # create empty sphere packing
 # sphere packing is not equivalent to particles in simulation, it contains only the pure geometry
@@ -25,14 +25,13 @@
 		[Ip2_FrictMat_FrictMat_FrictPhys()],
 		[Law2_L3Geom_FrictPhys_ElPerfPl()]
 	),
-	GravityEngine(gravity=(0,0,-9.81)),
-	NewtonIntegrator(damping=0.4),
+	NewtonIntegrator(gravity=(0,0,-9.81),damping=0.4),
 	# call the checkUnbalanced function (defined below) every 2 seconds
 	PyRunner(command='checkUnbalanced()',realPeriod=2),
 	# call the addPlotData function every 200 steps
 	PyRunner(command='addPlotData()',iterPeriod=100)
 ]
-O.dt=.5*utils.PWaveTimeStep()
+O.dt=.5*PWaveTimeStep()
 
 # enable energy tracking; any simulation parts supporting it
 # can create and update arbitrary energy types, which can be
@@ -43,7 +42,7 @@
 # is considered stabilized, therefore we stop collected
 # data history and stop
 def checkUnbalanced():
-	if utils.unbalancedForce()<.05:
+	if unbalancedForce()<.05:
 		O.pause()
 		plot.saveDataTxt('bbb.txt.bz2')
 		# plot.saveGnuplot('bbb') is also possible
@@ -52,7 +51,7 @@
 def addPlotData():
 	# each item is given a names, by which it can be the unsed in plot.plots
 	# the **O.energy converts dictionary-like O.energy to plot.addData arguments
-	plot.addData(i=O.iter,unbalanced=utils.unbalancedForce(),**O.energy)
+	plot.addData(i=O.iter,unbalanced=unbalancedForce(),**O.energy)
 
 # define how to plot data: 'i' (step number) on the x-axis, unbalanced force
 # on the left y-axis, all energies on the right y-axis

=== modified file 'doc/sphinx/tutorial/03-oedometric-test.py'
--- doc/sphinx/tutorial/03-oedometric-test.py	2011-05-03 15:04:37 +0000
+++ doc/sphinx/tutorial/03-oedometric-test.py	2015-06-16 15:31:20 +0000
@@ -3,7 +3,7 @@
 
 # The components of the batch are:
 # 1. table with parameters, one set of parameters per line (ccc.table)
-# 2. utils.readParamsFromTable which reads respective line from the parameter file
+# 2. readParamsFromTable which reads respective line from the parameter file
 # 3. the simulation muse be run using yade-batch, not yade
 #
 # $ yade-batch --job-threads=1 03-oedometric-test.table 03-oedometric-test.py
@@ -11,13 +11,13 @@
 
 # load parameters from file if run in batch
 # default values are used if not run from batch
-utils.readParamsFromTable(rMean=.05,rRelFuzz=.3,maxLoad=1e6,minLoad=1e4)
+readParamsFromTable(rMean=.05,rRelFuzz=.3,maxLoad=1e6,minLoad=1e4)
 # make rMean, rRelFuzz, maxLoad accessible directly as variables later
 from yade.params.table import *
 
 # create box with free top, and ceate loose packing inside the box
 from yade import pack, plot
-O.bodies.append(utils.geom.facetBox((.5,.5,.5),(.5,.5,.5),wallMask=31))
+O.bodies.append(geom.facetBox((.5,.5,.5),(.5,.5,.5),wallMask=31))
 sp=pack.SpherePack()
 sp.makeCloud((0,0,0),(1,1,1),rMean=rMean,rRelFuzz=rRelFuzz)
 sp.toSimulation()
@@ -32,13 +32,12 @@
 		[Ip2_FrictMat_FrictMat_FrictPhys()],
 		[Law2_L3Geom_FrictPhys_ElPerfPl()]
 	),
-	GravityEngine(gravity=(0,0,-9.81)),
-	NewtonIntegrator(damping=0.5),
+	NewtonIntegrator(gravity=(0,0,-9.81),damping=0.5),
 	# the label creates an automatic variable referring to this engine
 	# we use it below to change its attributes from the functions called
 	PyRunner(command='checkUnbalanced()',realPeriod=2,label='checker'),
 ]
-O.dt=.5*utils.PWaveTimeStep()
+O.dt=.5*PWaveTimeStep()
 
 # the following checkUnbalanced, unloadPlate and stopUnloading functions are all called by the 'checker'
 # (the last engine) one after another; this sequence defines progression of different stages of the
@@ -51,10 +50,10 @@
 	# at the very start, unbalanced force can be low as there is only few contacts, but it does not mean the packing is stable
 	if O.iter<5000: return 
 	# the rest will be run only if unbalanced is < .1 (stabilized packing)
-	if utils.unbalancedForce()>.1: return 
+	if unbalancedForce()>.1: return 
 	# add plate at the position on the top of the packing
 	# the maximum finds the z-coordinate of the top of the topmost particle
-	O.bodies.append(utils.wall(max([b.state.pos[2]+b.shape.radius for b in O.bodies if isinstance(b.shape,Sphere)]),axis=2,sense=-1))
+	O.bodies.append(wall(max([b.state.pos[2]+b.shape.radius for b in O.bodies if isinstance(b.shape,Sphere)]),axis=2,sense=-1))
 	global plate        # without this line, the plate variable would only exist inside this function
 	plate=O.bodies[-1]  # the last particles is the plate
 	# Wall objects are "fixed" by default, i.e. not subject to forces
@@ -85,7 +84,7 @@
 	if not isinstance(O.bodies[-1].shape,Wall):
 		plot.addData(); return
 	Fz=O.forces.f(plate.id)[2]
-	plot.addData(Fz=Fz,w=plate.state.pos[2]-plate.state.refPos[2],unbalanced=utils.unbalancedForce(),i=O.iter)
+	plot.addData(Fz=Fz,w=plate.state.pos[2]-plate.state.refPos[2],unbalanced=unbalancedForce(),i=O.iter)
 
 # besides unbalanced force evolution, also plot the displacement-force diagram
 plot.plots={'i':('unbalanced',),'w':('Fz',)}
@@ -94,6 +93,6 @@
 O.run()
 # when running with yade-batch, the script must not finish until the simulation is done fully
 # this command will wait for that (has no influence in the non-batch mode)
-utils.waitIfBatch()
+waitIfBatch()
 
 

=== modified file 'doc/sphinx/tutorial/04-periodic-simple-shear.py'
--- doc/sphinx/tutorial/04-periodic-simple-shear.py	2011-01-29 22:47:18 +0000
+++ doc/sphinx/tutorial/04-periodic-simple-shear.py	2015-06-16 15:31:20 +0000
@@ -54,7 +54,7 @@
 ]
 
 # set the integration timestep to be 1/2 of the "critical" timestep
-O.dt=.5*utils.PWaveTimeStep()
+O.dt=.5*PWaveTimeStep()
 
 # prescribe isotropic normal deformation (constant strain rate)
 # of the periodic cell
@@ -67,7 +67,7 @@
 def checkStress():
 	# stress tensor as the sum of normal and shear contributions
 	# Matrix3.Zero is the intial value for sum(...)
-	stress=sum(utils.normalShearStressTensors(),Matrix3.Zero)
+	stress=sum(normalShearStressTensors(),Matrix3.Zero)
 	print 'mean stress',stress.trace()/3.
 	# if mean stress is below (bigger in absolute value) limitMeanStress, start shearing
 	if stress.trace()/3.<limitMeanStress:
@@ -106,13 +106,13 @@
 # called periodically to store data history
 def addData():
 	# get the stress tensor (as 3x3 matrix)
-	stress=sum(utils.normalShearStressTensors(),Matrix3.Zero)
+	stress=sum(normalShearStressTensors(),Matrix3.Zero)
 	# give names to values we are interested in and save them
 	plot.addData(exz=O.cell.trsf[0,2],szz=stress[2,2],sxz=stress[0,2],tanPhi=stress[0,2]/stress[2,2],i=O.iter)
 	# color particles based on rotation amount
 	for b in O.bodies:
 		# rot() gives rotation vector between reference and current position
-		b.shape.color=utils.scalarOnColorScale(b.state.rot().norm(),0,pi/2.)
+		b.shape.color=scalarOnColorScale(b.state.rot().norm(),0,pi/2.)
 
 # define what to plot (3 plots in total)
 ## exz(i), [left y axis, separate by None:] szz(i), sxz(i)

=== modified file 'doc/sphinx/tutorial/05-3d-postprocessing.py'
--- doc/sphinx/tutorial/05-3d-postprocessing.py	2011-01-20 16:35:46 +0000
+++ doc/sphinx/tutorial/05-3d-postprocessing.py	2015-06-16 15:31:20 +0000
@@ -1,7 +1,7 @@
 # demonstrate 3d postprocessing with yade
 #
 # 1. qt.SnapshotEngine saves images of the 3d view as it appears on the screen periodically
-#    utils.makeVideo is then used to make real movie from those images
+#    makeVideo is then used to make real movie from those images
 # 2. VTKRecorder saves data in files which can be opened with Paraview
 #    see the User's manual for an intro to Paraview
 
@@ -28,7 +28,7 @@
 	# this engine will be called after 20000 steps, only once
 	PyRunner(command='finish()',iterPeriod=20000)
 ]
-O.dt=.5*utils.PWaveTimeStep()
+O.dt=.5*PWaveTimeStep()
 
 # prescribe constant-strain deformation of the cell
 O.cell.velGrad=Matrix3(-.1,0,0, 0,-.1,0, 0,0,-.1)
@@ -40,7 +40,7 @@
 def finish():
 	# snapshot is label of qt.SnapshotEngine
 	# the 'snapshots' attribute contains list of all saved files
-	utils.makeVideo(snapshot.snapshots,'3d.mpeg',fps=10,bps=10000)
+	makeVideo(snapshot.snapshots,'3d.mpeg',fps=10,bps=10000)
 	O.pause()
 
 # set parameters of the renderer, to show network chains rather than particles

=== modified file 'doc/sphinx/tutorial/06-periodic-triaxial-test.py'
--- doc/sphinx/tutorial/06-periodic-triaxial-test.py	2015-01-09 00:11:14 +0000
+++ doc/sphinx/tutorial/06-periodic-triaxial-test.py	2015-06-16 15:31:20 +0000
@@ -66,10 +66,10 @@
 	NewtonIntegrator(damping=.2),
 	PyRunner(command='addPlotData()',iterPeriod=100),
 ]
-O.dt=.5*utils.PWaveTimeStep()
+O.dt=.5*PWaveTimeStep()
 
 def addPlotData():
-	plot.addData(unbalanced=utils.unbalancedForce(),i=O.iter,
+	plot.addData(unbalanced=unbalancedForce(),i=O.iter,
 		sxx=triax.stress[0],syy=triax.stress[1],szz=triax.stress[2],
 		exx=triax.strain[0],eyy=triax.strain[1],ezz=triax.strain[2],
 		# save all available energy data