← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2550: 1. Add detailed docs for plot.saveDataTxt

 

------------------------------------------------------------
revno: 2550
committer: Václav Šmilauer <eu@xxxxxxxx>
branch nick: trunk
timestamp: Mon 2010-11-15 17:31:43 +0100
message:
  1. Add detailed docs for plot.saveDataTxt 
  2. Do not add dissipated energy if zero in Law2_ScGeom_FrictPhys_CundallStrack 
  3. Set friction to zero in scripts/test/energy.py
modified:
  SConstruct
  pkg/dem/ElasticContactLaw.cpp
  py/plot.py
  scripts/test/energy.py


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

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'SConstruct'
--- SConstruct	2010-11-12 09:48:58 +0000
+++ SConstruct	2010-11-15 16:31:43 +0000
@@ -1,4 +1,4 @@
-#!/usr/bin/scons
+#!/usr/bin/scon
 # coding: UTF-8
 # vim:syntax=python:
 
@@ -111,7 +111,7 @@
 	('CXXFLAGS','Additional compiler flags for compilation (like -march=core2).',None,None,Split),
 	('march','Architecture to use with -march=... when optimizing','native',None,None),
 	BoolVariable('mono','[experimental] Build only one shared library and make all other files (python objects, for instance) only be symlinks.',0),
-	('execCheck','Name of the main script that should be installed; if the current one differs, an erro is raised (do not use directly, only intended for --rebuild',None),
+	('execCheck','Name of the main script that should be installed; if the current one differs, an error is raised (do not use directly, only intended for --rebuild',None),
 	('defThreads','Default number of OpenMP threads to run with, unless overridden with -j. Keep unset (negative) to default to using all cores.',-1),
 	#('SHLINK','Linker for shared objects','g++'),
 	('SHCCFLAGS','Additional compiler flags for linking (for plugins).',None,None,Split),

=== modified file 'pkg/dem/ElasticContactLaw.cpp'
--- pkg/dem/ElasticContactLaw.cpp	2010-11-07 11:46:20 +0000
+++ pkg/dem/ElasticContactLaw.cpp	2010-11-15 16:31:43 +0000
@@ -80,7 +80,8 @@
 			Vector3r trialForce=shearForce;//store prev force for definition of plastic slip
 			//define the plastic work input and increment the total plastic energy dissipated
 			shearForce *= ratio;
-			scene->energy->add(((1/phys->ks)*(trialForce-shearForce))/*plastic disp*/ .dot(shearForce)/*active force*/,"plastDissip",plastDissipIx,/*reset*/false);
+			Real dissip=((1/phys->ks)*(trialForce-shearForce))/*plastic disp*/ .dot(shearForce)/*active force*/;
+			if(dissip>0) scene->energy->add(dissip,"plastDissip",plastDissipIx,/*reset*/false);
 		}
 		// compute elastic energy as well
 		scene->energy->add(0.5*(phys->normalForce.squaredNorm()/phys->kn+phys->shearForce.squaredNorm()/phys->ks),"elastPotential",elastPotentialIx,/*reset at every timestep*/true);

=== modified file 'py/plot.py'
--- py/plot.py	2010-11-13 21:11:39 +0000
+++ py/plot.py	2010-11-15 16:31:43 +0000
@@ -278,6 +278,25 @@
 		else: return figs
 
 def saveDataTxt(fileName,vars=None):
+	"""Save plot data into a (optionally compressed) text file. The first line contains a comment (starting with ``#``) giving variable name for each of the columns. This format is suitable for being loaded for further processing (outside yade) with ``numpy.genfromtxt`` function, which recognizes those variable names (creating numpy array with named entries) and handles decompression transparently.
+
+	>>> from yade import plot
+	>>> plot.reset()
+	>>> plot.addData(a=1,b=11,c=21,d=31)  # add some data here
+	>>> plot.addData(a=2,b=12,c=22,d=32)
+	>>> plot.data=={'a':[1,2],'b':[11,12],'c':[21,22],'d':[31, 32]} # cannot check output directly, since dict ordering is random and doctest would fail
+	True
+	>>> plot.saveDataTxt('/tmp/dataFile.txt.bz2',vars=('a','b','c'))
+	>>> import numpy
+	>>> d=numpy.genfromtxt('/tmp/dataFile.txt.bz2',dtype=None,names=True)
+	>>> d['a']
+	array([1, 2])
+	>>> d['b']
+	array([11, 12])
+
+	:param fileName: file to save data to; if it ends with ``.bz2`` / ``.gz``, the file will be compressed using bzip2 / gzip. 
+	:param vars: Sequence (tuple/list/set) of variable names to be saved. If ``None`` (default), all variables in :yref:`yade.plot.plot` are saved.
+	"""
 	import bz2,gzip
 	if not vars:
 		vars=data.keys(); vars.sort()

=== modified file 'scripts/test/energy.py'
--- scripts/test/energy.py	2010-11-13 21:11:39 +0000
+++ scripts/test/energy.py	2010-11-15 16:31:43 +0000
@@ -9,7 +9,7 @@
 O.engines=[
 	ForceResetter(),
 	InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Wall_Aabb()]),
-	InteractionLoop([Ig2_Sphere_Sphere_ScGeom(),Ig2_Wall_Sphere_ScGeom()],[Ip2_FrictMat_FrictMat_FrictPhys()],[Law2_ScGeom_FrictPhys_CundallStrack()]),
+	InteractionLoop([Ig2_Sphere_Sphere_ScGeom(),Ig2_Wall_Sphere_ScGeom()],[Ip2_FrictMat_FrictMat_FrictPhys(frictAngle=0)],[Law2_ScGeom_FrictPhys_CundallStrack()]),
 	GravityEngine(gravity=(0,0,-9.81)),
 	NewtonIntegrator(damping=0.),
 	PyRunner(iterPeriod=10,command='addPlotData()'),
@@ -29,7 +29,7 @@
 #
 # (unfortunately even if we were changing plot.plots periodically,
 # plots would not pick up changes in plot.plots during live plotting)
-O.run(200,True)  
+O.run(400,True)  
 plot.plots={'i':['total',]+O.energy.keys()}
 plot.plot(subPlots=True)