← Back to team overview

yade-dev team mailing list archive

[svn] r1688 - trunk/examples

 

Author: sega
Date: 2009-02-24 12:52:49 +0100 (Tue, 24 Feb 2009)
New Revision: 1688

Modified:
   trunk/examples/STLImporterTest.py
Log:
Convert STLImporterTest to ConstitutiveLaw (SimpleViscoelastic contact model) and NewtonsDampedLaw engine.


Modified: trunk/examples/STLImporterTest.py
===================================================================
--- trunk/examples/STLImporterTest.py	2009-02-24 09:06:00 UTC (rev 1687)
+++ trunk/examples/STLImporterTest.py	2009-02-24 11:52:49 UTC (rev 1688)
@@ -7,26 +7,34 @@
 o=Omega() 
 
 ## PhysicalParameters 
-Young = 15e6
-Poisson = 0.2
+Density=2400
+frictionAngle=radians(35)
+sphereRadius=0.05
+tc = 0.001
+en = 0.3
+es = 0.3
 
 ## Import wall's geometry
-imported = utils.import_stl_geometry('baraban.stl',young=Young,poisson=Poisson)
+p=utils.getViscoelasticFromSpheresInteraction(10e3,tc,en,es)
+imported = utils.import_stl_geometry('baraban.stl',frictionAngle=frictionAngle,physParamsClass="SimpleViscoelasticBodyParameters",physParamsAttr={'kn':p['kn'],'cn':p['cn'],'ks':p['ks'],'cs':p['cs']})
 
 ## Spheres
 sphereRadius = 0.2
-nbSpheres = (10,10,10)
+#nbSpheres = (10,10,10)
+nbSpheres = (5,5,5)
 for i in xrange(nbSpheres[0]):
     for j in xrange(nbSpheres[1]):
-	for k in xrange(nbSpheres[2]):
-	    x = (i*2 - nbSpheres[0])*sphereRadius*1.1
-	    y = j*sphereRadius*2.2
-	    z = (k*2 - nbSpheres[2])*sphereRadius*1.1
-	    o.bodies.append(utils.sphere([x,y,z],sphereRadius,young=Young,poisson=Poisson,density=2400))
-utils.randomizeColors(onlyDynamic=True)
+        for k in xrange(nbSpheres[2]):
+            x = (i*2 - nbSpheres[0])*sphereRadius*1.1
+            y = j*sphereRadius*2.2
+            z = (k*2 - nbSpheres[2])*sphereRadius*1.1
+            s=utils.sphere([x,y,z],sphereRadius,density=Density,frictionAngle=frictionAngle,physParamsClass="SimpleViscoelasticBodyParameters")
+            p=utils.getViscoelasticFromSpheresInteraction(s.phys['mass'],tc,en,es)
+            s.phys['kn'],s.phys['cn'],s.phys['ks'],s.phys['cs']=p['kn'],p['cn'],p['ks'],p['cs']
+            o.bodies.append(s)
 
 ## Timestep 
-o.dt=utils.PWaveTimeStep()
+o.dt=.2*tc
 
 ## Initializers 
 o.initializers=[
@@ -47,36 +55,23 @@
 		EngineUnit('MetaInteractingGeometry2AABB')
 	]),
 	## Using bounding boxes find possible body collisions.
-	StandAloneEngine('SpatialQuickSortCollider'),
+    StandAloneEngine('PersistentSAPCollider'),
 	## Create geometry information about each potential collision.
 	MetaEngine('InteractionGeometryMetaEngine',[
 		EngineUnit('InteractingSphere2InteractingSphere4SpheresContactGeometry'),
 		EngineUnit('InteractingFacet2InteractingSphere4SpheresContactGeometry')
 	]),
 	## Create physical information about the interaction.
-	MetaEngine('InteractionPhysicsMetaEngine',[EngineUnit('MacroMicroElasticRelationships')]),
-	## "Solver" of the contact
-	StandAloneEngine('ElasticContactLaw'),
+	MetaEngine('InteractionPhysicsMetaEngine',[EngineUnit('SimpleViscoelasticRelationships')]),
+    ## Constitutive law
+	MetaEngine('ConstitutiveLawDispatcher',[EngineUnit('Spheres_Viscoelastic_SimpleViscoelasticContactLaw')]),
 	## Apply gravity
 	DeusExMachina('GravityEngine',{'gravity':[0,-9.81,0]}),
-	## Forces acting on bodies are damped to artificially increase energy dissipation in simulation.
-	MetaEngine('PhysicalActionDamper',[
-		EngineUnit('CundallNonViscousForceDamping',{'damping':0.3}),
-		EngineUnit('CundallNonViscousMomentumDamping',{'damping':0.3})
-	]),
-	## Now we have forces and momenta acting on bodies. Newton's law calculates acceleration that corresponds to them.
-	MetaEngine('PhysicalActionApplier',[
-		EngineUnit('NewtonsForceLaw'),
-		EngineUnit('NewtonsMomentumLaw'),
-	]),
-	## Acceleration results in velocity change. Integrating the velocity over dt, position of the body will change.
-	MetaEngine('PhysicalParametersMetaEngine',[EngineUnit('LeapFrogPositionIntegrator')]),
-	## Angular acceleration changes angular velocity, resulting in position and/or orientation change of the body.
-	MetaEngine('PhysicalParametersMetaEngine',[EngineUnit('LeapFrogOrientationIntegrator')]),
+	## Cundall damping must been disabled!
+	DeusExMachina('NewtonsDampedLaw',{'damping':0}),
 	## Apply kinematics to walls
 	DeusExMachina('RotationEngine',{'subscribedBodies':imported,'rotationAxis':[0,0,1],'rotateAroundZero':True,'angularVelocity':0.5}),
 ]
 
-## Save the scene to file, so that it can be loaded later. Supported extension are: .xml, .xml.gz, .xml.bz2.
-o.save('/tmp/a.xml');
+o.saveTmp('init');
 




Follow ups