← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2559: 1. HarmonicMotionEngine is added with example.

 

------------------------------------------------------------
revno: 2559
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2010-11-18 16:00:08 +0100
message:
  1. HarmonicMotionEngine is added with example.
modified:
  examples/regular-sphere-pack/regular-sphere-pack.py
  pkg/common/TranslationEngine.cpp
  pkg/common/TranslationEngine.hpp


--
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 'examples/regular-sphere-pack/regular-sphere-pack.py'
--- examples/regular-sphere-pack/regular-sphere-pack.py	2010-10-29 10:12:44 +0000
+++ examples/regular-sphere-pack/regular-sphere-pack.py	2010-11-18 15:00:08 +0000
@@ -69,11 +69,17 @@
 O.bodies.append(ymport.gengeoFile('regular-sphere-pack-LSMGenGeo.geo',shift=Vector3(-7.0,-7.0,-5.9),scale=1.0,orientation=oriBody,color=(1,0,1),**kw))
 
 # spheresToFile saves coordinates and radii of all spheres of the simulation into the text file
-#print "Saved into the OutFile " + str (export.text("OutFile")) + " spheres";
+print "Saved into the OutFile " + str (export.text("OutFile")) + " spheres";
 
 # spheresFromFile function imports coordinates and radiuses of all spheres of the simulation into the text file
 O.bodies.append(ymport.text('regular-sphere-pack-FromFile',shift=Vector3(6.0,6.0,-2.9),scale=0.7,color=(1,1,1),**kw))
 
+#Demonstration of HarmonicMotionEngine
+O.bodies.append(pack.regularHexa(pack.inSphere((-10,5,-5),1.5),radius=rad*2.0,gap=gap,color=(0.2,0.5,0.9),material=0))
+O.bodies.append(utils.facetBox((-10,5,-5),(2,2,2),wallMask=15,**kwMeshes))
+vibrationPlate = O.bodies.append(utils.facetBox((-10,5,-5),(2,2,2),wallMask=16,**kwBoxes))
+
+
 try:
 	from yade import qt
 	qt.Controller()
@@ -95,7 +101,8 @@
 		angularVelocity=10.0,
 		rotationAxis=[0,0,1],
 		rotateAroundZero=1,
-		zeroPoint=[6.0,6.0,0.0])
+		zeroPoint=[6.0,6.0,0.0]),
+	HarmonicMotionEngine(A=[0,0,0.5], w=[0,0,80.0], fi = [0.0,0.0,pi], ids = vibrationPlate)
 ]
 # we don't care about physical accuracy here, (over)critical step is fine as long as the simulation doesn't explode
 O.dt=utils.PWaveTimeStep()

=== modified file 'pkg/common/TranslationEngine.cpp'
--- pkg/common/TranslationEngine.cpp	2010-10-13 16:23:08 +0000
+++ pkg/common/TranslationEngine.cpp	2010-11-18 15:00:08 +0000
@@ -20,4 +20,17 @@
 	}
 }
 
-YADE_PLUGIN((TranslationEngine));
+void HarmonicMotionEngine::action(){
+	const Real& dt=scene->dt;
+	const Real& time=scene->time;
+	FOREACH(Body::id_t id,ids){
+		assert(id<(Body::id_t)scene->bodies->size());
+		Body* b=Body::byId(id,scene).get();
+		if(!b) continue;
+		Vector3r velocity = ((((w*time + fi).cwise().sin())*(-1.0)).cwise()*A).cwise()*w;
+		b->state->pos+=dt*velocity;
+		b->state->vel=velocity;
+	}
+}
+
+YADE_PLUGIN((TranslationEngine)(HarmonicMotionEngine));

=== modified file 'pkg/common/TranslationEngine.hpp'
--- pkg/common/TranslationEngine.hpp	2010-11-07 11:46:20 +0000
+++ pkg/common/TranslationEngine.hpp	2010-11-18 15:00:08 +0000
@@ -21,6 +21,18 @@
 		((Vector3r,translationAxis,,,"Direction [Vector3]"))
 	);
 };
+
+class HarmonicMotionEngine : public TranslationEngine {
+	public:
+		virtual void action();
+	YADE_CLASS_BASE_DOC_ATTRS(HarmonicMotionEngine,TranslationEngine,"This engine implements the harmonic oscillation of bodies. http://en.wikipedia.org/wiki/Simple_harmonic_motion#Dynamics_of_simple_harmonic_motion";,
+		((Vector3r,A,Vector3r::Zero(),,"Amplitude [m]"))
+		((Vector3r,w,Vector3r::Zero(),,"Angular frequency [hertz]"))
+		((Vector3r,fi,Vector3r::Zero(),,"Initial phase [radians]"))
+	);
+};
+
 REGISTER_SERIALIZABLE(TranslationEngine);
+REGISTER_SERIALIZABLE(HarmonicMotionEngine);