| 271 | [[CollapsibleStart(Script for following collapse of uniform sphere)]] |
| 272 | This script adjusts the window bounds to zoom in on a region at the same rate the region collapses (assuming it follows the solution for a uniform density sphere undergoing free fall collapse) |
| 273 | {{{ |
| 274 | r_0=60 # Initial radius of view (usually 150% of clump radius is good) |
| 275 | r_min=8 # Radius to stop shrinking at (32*levels(MaxLevel)%dx) |
| 276 | singular_time=.66 #t_ff using clump density in computational units (or by eye) |
| 277 | center=(240,240) #Clump location in computational units |
| 278 | starting_frame=0 #Frame to start from |
| 279 | final_frame=63 #Frame to stop at |
| 280 | my_dir = "/grassdata/johannjc/scrambler_111007/modules/Problem/Images/2D" #directory for movie output |
| 281 | movie_name = "ZoomingRhoTestwSinksA" #base name for movie |
| 282 | |
| 283 | |
| 284 | # ~~~~~~~~~~~~~~~~~ Output file attributes... ~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 285 | OldSaveWindowAtts = SaveWindowAttributes() |
| 286 | SaveWindowAtts = SaveWindowAttributes() |
| 287 | SaveWindowAtts.outputToCurrentDirectory = 0 |
| 288 | SaveWindowAtts.outputDirectory = my_dir |
| 289 | SaveWindowAtts.fileName = movie_name |
| 290 | SaveWindowAtts.family = 0 |
| 291 | SaveWindowAtts.format = SaveWindowAtts.PNG #BMP, CURVE, JPEG, OBJ, PNG, POSTSCRIPT, PPM, RGB, STL, TIFF, ULTRA, VTK |
| 292 | SaveWindowAtts.width = 1024 |
| 293 | SaveWindowAtts.height = 1024 |
| 294 | SaveWindowAtts.screenCapture = 1 |
| 295 | SaveWindowAtts.saveTiled = 1 |
| 296 | SaveWindowAtts.quality = 80 |
| 297 | SaveWindowAtts.progressive = 0 |
| 298 | SaveWindowAtts.binary = 0 |
| 299 | SaveWindowAtts.stereo = 0 |
| 300 | SaveWindowAtts.compression = SaveWindowAtts.PackBits |
| 301 | GlobalAtts = GetGlobalAttributes() |
| 302 | |
| 303 | |
| 304 | a=GetView2D() |
| 305 | from math import * |
| 306 | for state in range(starting_frame, final_frame): |
| 307 | Query('Time') #Get current database time |
| 308 | tratio=min(GetQueryOutputValue()/singular_time*1.0,1.0) # Calculate t/t_ff |
| 309 | rratio=.7178*sqrt(1-tratio**2)+.3068*(1-tratio**2)-.01842 # Approximate fit to free fall radius ratio |
| 310 | r=max(r_min,r_0*rratio) # Scale current radius based on rratio keeping it > r_min |
| 311 | a.windowCoords=(center[0]-r, center[0]+r, center[1]-r, center[1]+r) # Set window coords to encompass clump circle |
| 312 | for wins in GlobalAtts.windows: #In case there are multiple windows |
| 313 | SetActiveWindow(wins) |
| 314 | SetTimeSliderState(state) |
| 315 | SetView2D(a) |
| 316 | SaveWindowAtts.fileName = movie_name + "%(frame)04d" % {'frame':state} |
| 317 | SetSaveWindowAttributes(SaveWindowAtts) |
| 318 | SaveWindow() |
| 319 | ClearCache("localhost") |
| 320 | SetSaveWindowAttributes(OldSaveWindowAtts) |
| 321 | }}} |
| 322 | |