Commits

Mike Graham committed d5b2694

Trying to use new version of MF to make movies.

  • Participants
  • Parent commits 80530f3

Comments (0)

Files changed (2)

File nanocontact/post.py

 from itertools import chain, izip
 import math
 
+from mech.fusion import swf
+from mech.fusion.swf import SwfData
 import numpy
 
 def dissipated_energy(u, h, P_r, k_r, radius, time):
 
 
 def movie(filename, t, r, h, h0=None, rlim=None, hlim=None, duration=10):
-    from mech.fusion.swf import SwfData
-
     #XXX: reflection is done ugly. Improve it, maybe to use sprites.
 
     if rlim is None:
     #movie.setRate(rate)
     #movie.setDimension(xdim, ydim)
     for h_row, h0_row in izip(hs.T, h0s.T):
-        shape = movie.new_shape()
+        to_be_removed = []
+
+        shape = swf.new_shape()
         shape.graphics.lineStyle(3)
         _draw_all_reflected(shape, xs, h_row, xdim)
+        to_be_removed.append(movie.place(shape))
 
         if h0 is not None:
-            undeformed = movie.new_shape()
+            undeformed = swf.new_shape()
             undeformed.graphics.lineStyle(3)
             _draw_all_reflected(undeformed, xs, h0_row, xdim)
+            to_be_removed.append(movie.place(undeformed))
 
         movie.next_frame()
+        
+        for placed_shape in to_be_removed:
+            placed_shape.remove()
 
     with open(filename, 'wb') as f:
         f.write(movie.serialize())

File scripts/example.py

 profile = utils.rounded_cone(radius, 60, 5 * nm)
 
 # Time steps and rigid separation
-numsteps = 32
+numsteps = 64
 time = numpy.linspace(0, 1 * sec, numsteps)
 h0 = utils.constant_rate_h0(farthest=100 * nm,
                             closest=-50 * nm,
 except RuntimeError as e:
     print e
 
+print "DONE!"
+
 print sim.dissipated_energy()
 
 sim.make_movie('rabbit')