← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2561: 1. HarmonicMotionEngine update.

 

------------------------------------------------------------
revno: 2561
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: trunk
timestamp: Fri 2010-11-19 10:10:54 +0100
message:
  1. HarmonicMotionEngine update.
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-11-18 15:00:08 +0000
+++ examples/regular-sphere-pack/regular-sphere-pack.py	2010-11-19 09:10:54 +0000
@@ -102,7 +102,7 @@
 		rotationAxis=[0,0,1],
 		rotateAroundZero=1,
 		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)
+	HarmonicMotionEngine(A=[0,0,0.5], f=[0,0,50.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-11-18 15:00:08 +0000
+++ pkg/common/TranslationEngine.cpp	2010-11-19 09:10:54 +0000
@@ -23,13 +23,16 @@
 void HarmonicMotionEngine::action(){
 	const Real& dt=scene->dt;
 	const Real& time=scene->time;
+	Vector3r w = f*2.0*Mathr::PI; 			//Angular frequency
+	Vector3r velocity = ((((w*time + fi).cwise().sin())*(-1.0)).cwise()*A).cwise()*w; //Linear velocity at current 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->vel=velocity;
 		b->state->pos+=dt*velocity;
-		b->state->vel=velocity;
 	}
 }
 

=== modified file 'pkg/common/TranslationEngine.hpp'
--- pkg/common/TranslationEngine.hpp	2010-11-18 15:00:08 +0000
+++ pkg/common/TranslationEngine.hpp	2010-11-19 09:10:54 +0000
@@ -25,10 +25,10 @@
 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";,
+	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 ; please, set dynamic=False for bodies, droven by this engine, otherwise amplitude will be 2x more, than awaited.",
 		((Vector3r,A,Vector3r::Zero(),,"Amplitude [m]"))
-		((Vector3r,w,Vector3r::Zero(),,"Angular frequency [hertz]"))
-		((Vector3r,fi,Vector3r::Zero(),,"Initial phase [radians]"))
+		((Vector3r,f,Vector3r::Zero(),,"Frequency [hertz]"))
+		((Vector3r,fi,Vector3r(Mathr::PI/2.0, Mathr::PI/2.0, Mathr::PI/2.0),,"Initial phase [radians]. By default, the body oscillates around initial position."))
 	);
 };