Changes between Initial Version and Version 1 of ProgressInfo

May 17, 2012, 10:43:52 PM (6 years ago)

initial page


  • ProgressInfo

    v1 v1  
     1== Progress Info: A Proposal ==
     3Rappture has a simple function for reporting progress during simulation.  For example, in C language, the call would be:
     5rpUtilsProgress(25, "Solving sparse matrix...");
     7This brings up a progress bar showing ''25%'' and the message ''Solving sparse matrix...'' beneath it.  Your program should call this again and again during a long simulation to update the percentage and the message displayed to the user.
     9Users of some simulators need to see more than a simple status message.  For example, suppose a simulator spends a while trying to achieve convergence for an initial solution, and then computes solutions at a series of time points.  During the initial solution, the user might want to see a plot of convergence, so if the solution is wandering, the simulation can be aborted.  After the initial solution, the user may want to see a plot for each time point, or perhaps a 2D image at each time point, to get a feeling of how the simulation is progressing.
     11These advanced scenarios could be handled by defining Rappture objects within a {{{<progress>}}} section of the {{{tool.xml}}} file:
     13<?xml version="1.0"?>
     18  <phase id="init">
     19    <curve id="converge">
     20      <about><label>Convergence of Initial Solution</label></about>
     21      <xaxis><label>Iteration</label></xaxis>
     22      <yaxis><label>Error</label><scale>log</scale></yaxis>
     23    </curve>
     24  </phase>
     25  <phase id="solve">
     26    <image id="2D">
     27      <about><label>2D Solution</label></about>
     28    </image>
     29  </phase>
     34This example has two phases of progress.  The first phase is used during the initial solution and shows a plot of error (on a log scale) versus iteration number.  The second phase is used when computing solutions at each time point and it shows a 2D image of the solution for each time point.
     36Progress would be reported within the simulation program as follows:
     38import Rappture
     39import sys
     41# open the XML file containing the run parameters
     42driver = Rappture.library(sys.argv[1])
     44Tstr = driver.get('input.number(temperature).current')
     45T = Rappture.Units.convert(Tstr, to="K", units="off")
     48# phase 1 - initial solution
     49iter = 0
     50while !converged:
     51 the computation...
     52    Rappture.Utils.progressData(driver, 'progress.phase(init).curve(convergence).component.xy', '%d %g\n' % (iter,err), op='append');
     54# phase 2 - solution for each time point
     55t = 0.0
     56while t < tmax:
     57 the computation...
     58    str = Rappture.encoding.encode(imgdata)
     59    Rappture.Utils.progressData(driver, 'progress.phase(solve).image(2D).current', str, op='overwrite');
     60    Rappture.Utils.progress(t/tmax*100, 'Solving at t = %g' % t);
     66When data is sent to a particular phase, it appears on the screen.  Note that separate {{{progress()}}} calls can be used in addition to the {{{progressData()}}} calls to indicate overall progress.