← Back to team overview

yade-dev team mailing list archive

Move a wall and plot (force, displacement) in a Python simulation

 


Hi all,

If anyone can help me on Python. I have modified the script in Python to generate a cylindrical packing written by Vaclav. I added with the facet, a wall at top (execute the attached file) in order to realize a uniaxial compaction.

 Now, i need :
1) define this wall (the last facet in my simulation) like a dynamic body. ==> b['isDynamic']=True. What is b? It is not a number !!! 2) give a translation velocity at this wall. What is the Python line to give a velocity at a body ? 3) plot the applied forces on this wall according to wall displacement.

Thank you for your replies.

JF





49.26801101,59.94282821,5.80499847,5.805
77.14994284,64.9995042,5.80499796,5.805
46.47217878,76.2143138,5.80498822,5.805
65.46252129,76.89966003,5.80495756,5.805
24.87411609,68.53131329,5.80499366,5.805
30.33384773,25.68900419,5.80499796,5.805
47.10257685,18.80565182,5.80499183,5.805
56.5080584,69.50982377,5.80499465,5.805
43.04991349,80.31580439,16.11313848,5.805
80.66965718,44.88274678,5.80497416,5.805
39.824205,66.6960953,5.8049964,5.805
76.70626199,33.96091537,5.80498707,5.805
60.81427353,58.72795917,5.80498419,5.805
22.75098637,34.49197629,5.8049975,5.805
43.16475884,40.53891863,5.80499796,5.805
33.36616093,36.13711254,10.20996001,5.805
18.89735627,46.31773059,5.80499729,5.805
31.33247943,58.77885881,5.80498547,5.805
54.55050208,33.26171171,5.8049628,5.805
30.59457732,46.51527538,5.80495985,5.805
40.86228221,51.93434406,5.80499027,5.805
41.44457673,29.05706017,5.80496314,5.805
58.65673097,19.94302694,5.80499786,5.805
62.94363557,47.84876188,9.25475806,5.805
71.79792034,54.51906027,5.80499661,5.805
51.86446301,48.22704241,5.80499029,5.805
19.75056733,57.97179512,5.80499102,5.805
34.90810857,77.24599155,5.80498921,5.805
65.51934146,37.06651892,5.80498048,5.805
69.02801434,25.25249367,5.80499525,5.805
35.36329771,44.17649195,22.83492403,9.295
53.19280511,40.72773141,18.85965666,9.295
67.96639335,53.36386352,49.85959574,9.295
58.75681668,49.7795486,34.11397915,9.295
67.08536006,66.80421452,16.91612734,9.295
35.95223964,26.14479406,27.31812229,9.295
27.45087015,42.95946942,39.61289783,9.295
31.72063549,70.78216671,19.07408578,9.295
34.5801464,27.16180545,46.33564173,9.295
45.46121568,59.3845768,42.86374844,9.295
50.53560932,33.18890506,37.38606398,9.295
54.35859994,77.02929631,25.80799349,9.295
45.70089927,77.2655036,47.94341255,9.295
73.10187476,41.44896565,18.41241993,9.295
77.40989654,50.40575711,34.1224438,9.295
23.12816228,57.09272637,28.33667514,9.295
53.78273964,22.44870005,22.56404912,9.295
31.55409302,70.6577285,37.85415029,9.295
68.44374152,29.31384338,31.70258483,9.295
68.90419887,70.01493167,35.13620007,9.295
62.79551984,25.37181282,48.96949016,9.295
62.68640691,52.6541619,19.82045588,5.805
80.80975596,53.91377978,13.09968976,5.805
20.71992184,60.96715697,42.73108877,5.805
43.85777711,46.53666333,35.09393414,5.805
55.82506772,80.49974069,11.18556496,5.805
45.75536558,18.95552074,40.35389554,5.805
67.81273295,24.35373719,17.31618172,5.805
40.94458587,59.45295182,14.80909062,5.805
78.57858161,62.09791964,43.60598207,5.805
19.18578372,44.29355503,21.30935027,5.805
33.69102442,46.99540849,52.75754149,5.805
48.43623649,68.29075257,14.06039524,5.805
41.23475847,41.73901494,45.65648043,5.805
23.85806389,35.36079828,27.06849382,5.805
58.54352466,79.84402137,40.04083274,5.805
24.6558541,51.7544149,14.2946536,5.805
38.59115605,20.79511675,13.44631619,5.805
31.41995981,75.0258815,52.30791222,5.805
39.70279548,79.36625614,28.59293572,5.805
47.9397285,54.3516887,22.70711872,5.805
25.24025328,30.74178107,16.50694527,5.805
68.31938462,40.76242839,41.54760415,5.805
52.13078159,62.61230745,29.70635675,5.805
37.95680245,59.0745142,26.28876613,5.805
58.15325429,41.96976004,47.0233904,5.805
80.24481474,42.74077351,46.81973668,5.805
75.65217878,32.30516862,44.62931629,5.805
65.96463479,76.60375362,48.40105471,5.805
23.97435898,52.90735442,50.42786185,5.805
57.59811042,68.43816284,45.02033544,5.805
79.32456615,60.17130417,22.76559206,5.805
58.20249471,62.5848717,37.29020554,3.91
64.28092256,79.66758309,15.89589844,3.91
24.68525059,28.42191364,33.81748234,3.91
79.62387539,35.38311352,28.16131536,3.91
22.95781662,30.63374359,41.11653469,3.91
75.49159451,70.82560948,46.5520241,3.91
57.94091438,81.96943727,49.50131334,3.91
49.78923191,45.25947041,42.68855326,3.91
61.08494541,27.98400228,10.68636185,3.91
81.87630453,58.30289453,51.91886549,3.91
49.40739724,26.76485267,10.8764904,3.91
44.95989206,17.15441255,30.84051361,3.91
60.79384499,18.63968647,33.0858482,3.91
20.68973374,65.4670791,14.01977508,3.91
54.58235876,54.97498352,12.24389989,3.91
38.57407103,37.40117524,33.70497642,3.91
71.97676812,54.53988313,17.09562978,3.91
17.06426175,45.60271684,30.69905006,3.91
78.20199754,37.308297,35.6060672,3.91
82.76347377,53.5418048,45.77904839,3.91
43.57174424,65.80115301,22.09281855,3.91
53.3002825,16.96458491,34.56670351,3.91
34.21181043,52.73127813,12.84184447,3.91
17.92802582,58.49149219,16.22580199,3.91
18.41676729,39.6203586,12.82607029,3.91
31.97554227,57.59017619,18.54645552,3.91
16.79429241,50.56999396,37.91310788,3.91
71.61172265,40.524092,50.68461275,3.91
67.40783192,77.94159954,24.00320534,3.91
75.66202349,29.1386037,14.17374427,3.91
47.01525768,52.01529566,13.32267294,3.91
26.87756294,36.7061682,51.22924687,3.91
79.57325505,35.27968169,53.00539269,3.91
34.85484667,56.26244018,50.08380533,3.91
70.28794768,34.28084974,55.20367728,3.91
52.14493517,54.58216739,53.19025704,3.91
42.9971055,17.5101624,49.55629537,3.91
73.36049297,73.18959809,53.69501804,3.91
51.06222992,31.24957979,50.43725969,3.91
56.60862601,60.09966096,49.90618523,3.91
47.73927978,48.26445356,49.6109928,3.91
17.77682833,41.84431496,49.30680241,3.91
55.05977344,51.17388169,46.71396838,3.91
30.10171437,59.51941711,44.79681827,3.91
22.89533432,69.03260614,47.69065863,3.91
37.1311738,67.31771568,49.34817071,3.91
75.28391087,65.36168349,52.14262154,3.91
49.43703487,38.89857781,50.01948419,3.91
56.33902698,35.64810731,54.17367069,3.91
44.03686201,33.88570352,52.63895382,3.91
41.96698228,52.05686555,53.27849761,3.91
80.66814255,50.48792638,52.66641444,3.91
16.8118767,48.59516337,45.47962168,3.91
36.3443293,52.37670316,33.13861873,3.91
74.89884993,28.22392905,53.41323346,3.91
51.56972114,66.27819497,52.32610611,3.91
53.97016088,47.04225762,54.17550338,3.91
64.55613134,39.43187877,53.87492631,3.91
20.42998429,34.78335836,47.24378188,3.91
68.83986949,66.38295915,47.83173692,3.91
63.26192945,68.43587385,52.91352059,3.91
49.72619262,24.09415049,47.57942235,3.91
52.92681341,16.92787831,46.58608727,3.91
32.49613596,57.48819952,37.63488437,3.91
76.21278546,44.69089771,55.44069828,3.91
57.61537369,74.27353921,52.78752976,3.91
37.07746502,37.92567648,53.56575249,3.91
44.70856858,43.08818266,54.6283037,3.91


from __future__ import division
from math import *
rCyl=37
hCyl=70
nPoly=20
 
hBox=hCyl/5 
 
phiStep=2*pi/nPoly
 
o=Omega()
 
from yade import utils
for n in range(nPoly):
	phi1,phi2=n*phiStep,(n+1)*phiStep
	def pt(angle,radius,z):
		return radius*sin(angle)+50,radius*cos(angle)+50,z
	a,b,c,d=pt(phi1,rCyl,0),pt(phi2,rCyl,0),pt(phi1,rCyl,hCyl),pt(phi2,rCyl,hCyl)
	o.bodies.append([
		utils.facet([a,b,c]),
		utils.facet([b,c,d])])
o.bodies.append(utils.box([50,50,-.5*hBox],[90,90,.5*hBox]))
 
# I need move these two facets which represents the top_wall
a,b1,c,d=(50-rCyl,50-rCyl,hCyl),(50-rCyl,50+rCyl,hCyl),(50+rCyl,50+rCyl,hCyl),(50+rCyl,50+-rCyl,hCyl)
o.bodies.append([
	utils.facet([a,b1,d]),
	utils.facet([b1,c,d])]) 
 
a,b1,c,d=(50-rCyl,50-rCyl,hCyl),(50-rCyl,50+rCyl,hCyl),(50+rCyl,50+rCyl,hCyl),(50+rCyl,50+-rCyl,hCyl)
o.bodies.append([
	utils.facet([a,b1,d]),
	utils.facet([b1,c,d])]) 
	
	
for b in o.bodies: b['isDynamic']=False
 

	
	
	
	
#rSphere=rCyl/10.
from numpy import arange
import random
		
from pylab import *
fichier = open('fichier2.txt','r')

for ligne in fichier.readlines() : 
	 donnees = map(float,ligne.split(","))

         o.bodies.append(utils.sphere([donnees[0],donnees[1],donnees[2]],donnees[3],wire=False,color=[1,0.5,1]))	
		

 
o.initializers=[
	StandAloneEngine('PhysicalActionContainerInitializer'),
	MetaEngine('BoundingVolumeMetaEngine',[EngineUnit('InteractingSphere2AABB'),EngineUnit('InteractingFacet2AABB'),EngineUnit('MetaInteractingGeometry2AABB')])
	]
o.engines=[
	StandAloneEngine('PhysicalActionContainerReseter'),
	MetaEngine('BoundingVolumeMetaEngine',[
		EngineUnit('InteractingSphere2AABB'),
		EngineUnit('InteractingFacet2AABB'),
		EngineUnit('InteractingBox2AABB'),
		EngineUnit('MetaInteractingGeometry2AABB')
	]),
	StandAloneEngine('PersistentSAPCollider'),
	MetaEngine('InteractionGeometryMetaEngine',[
		EngineUnit('InteractingSphere2InteractingSphere4SpheresContactGeometry'),
		EngineUnit('InteractingFacet2InteractingSphere4SpheresContactGeometry'),
		EngineUnit('InteractingBox2InteractingSphere4SpheresContactGeometry')
	]),
	MetaEngine('InteractionPhysicsMetaEngine',[EngineUnit('SimpleElasticRelationships')]),
	StandAloneEngine('ElasticContactLaw'),
	DeusExMachina('GravityEngine',{'gravity':[0,0,-1e5]}),
	DeusExMachina('NewtonsDampedLaw',{'damping':0.4}),
	#StandAloneEngine('PeriodicPythonRunner',{'command':'uf=utils.unbalancedForce(); print uf;\nif uf<abs(grav["gravity"][2])*1e-9: o.pause()','realLim':2})
 
]
grav=[e for e in o.engines if e.name=='GravityEngine'][0]
o.dt=1e-6
o.stopAtIter=10000 # get some better stability criterion here
o.run()
#
o.wait()
utils.spheresToFile('/tmp/a.spheres')







fichier = open('150_billes.txt','r')

for ligne in fichier.readlines() : 
	 donnees = map(float,ligne.split(","))
         o.bodies.append(utils.sphere([donnees[0],donnees[1],donnees[2]],donnees[3],wire=True,color=[random.random(),random.random(),random.random()]))
 
 

Follow ups