Version 1 (modified by hudson, 14 years ago) (diff) |
---|
ANUGA Checkpoints
Since ANUGA may take a long time to run a simulation, it can be prudent to save off the partial results at different stages of execution in case of hardware failure or power loss.
cPickle Method
Many people have requested restore point functionality in ANUGA to deal with interruptions to a running script. Python already has the ability to save state to a file using the cPickle module.
You can use code like this in your application to implement restore points:
import cPickle start_time = 0.0 if use_restore_point is True: print 'resuming from restore point...' domain = cPickle.load(open('domain_pickle.txt')) start_time = domain.time else: # do your normal domain initialisation here for restorepoint in range(start_time, 10): # evolve domain in small chunks, regularly pickling a restore point for t in domain.evolve(yieldstep=0.1, finaltime=restorepoint): pass print 'saving restore point...' cPickle.dump(domain, open('domain_pickle.txt', 'w'))
use_cache Method
ANUGA also has inbuilt caching functionality. You can set the use_cache = True parameter on many functions, and the results of the operation will be stored on disk for the next time the same operation is executed.