yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #07467
[Branch ~yade-dev/yade/trunk] Rev 2817: better default parameters, use dict(...) to read O.energy.items()
------------------------------------------------------------
revno: 2817
committer: Janek Kozicki <cosurgi@xxxxxxxxxx>
branch nick: yade
timestamp: Fri 2011-04-15 21:57:48 +0200
message:
better default parameters, use dict(...) to read O.energy.items()
modified:
examples/simple-scene/simple-scene-energy-tracking.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 'examples/simple-scene/simple-scene-energy-tracking.py'
--- examples/simple-scene/simple-scene-energy-tracking.py 2011-04-15 19:44:40 +0000
+++ examples/simple-scene/simple-scene-energy-tracking.py 2011-04-15 19:57:48 +0000
@@ -10,9 +10,9 @@
# initial angular velocity
angVel = 3.0
# use two spheres?
-two_spheres = True
+two_spheres = False
# sphere rotating more?
-rotate_in_two_directions = True
+rotate_in_two_directions = False
############################################
##### material #####
@@ -103,12 +103,9 @@
E_pot = 0
if(two_spheres):## for more bodies we better use the energy tracker, because it's tracking all bodies
- assert(O.energy.items()[2][0]=='kinTrans')
- assert(O.energy.items()[1][0]=='kinRot')
- assert(O.energy.items()[0][0]=='gravWork')
- E_kin_translation = O.energy.items()[2][1] # hmmm ... can I read O.energy.items() by names 'kinTrans' instead of by index numbers?
- E_kin_rotation = O.energy.items()[1][1]
- E_pot = O.energy.items()[0][1]
+ E_kin_translation = dict(O.energy.items())['kinTrans']
+ E_kin_rotation = dict(O.energy.items())['kinRot']
+ E_pot = dict(O.energy.items())['gravWork']
else: ## for one sphere we can just calculate, and it will be correct
h=sph.state.pos[2]
@@ -123,8 +120,7 @@
total = normal_Work + shear_Work + E_kin_translation + E_kin_rotation + E_pot
total_plus_damp = 0
if(damping!=0):
- assert(O.energy.items()[3][0]=='nonviscDamp')
- total_plus_damp = total + O.energy.items()[3][1]
+ total_plus_damp = total + dict(O.energy.items())['nonviscDamp']
else:
total_plus_damp = total
plot.addData(