4.4 Tests

In this section, we will carry out some numerical experiments with a PDE application based on the toolkit just described.

The ``code'', i.e. the set of components, properly configured and connected is in PDE_STUDENT_SRC/components/tests/example1.rc; (see also Appendix B). Note that the connection between the RHSCombiner and Reaction is commented out.

The Driver has been designed with a parameter port (part of the CCA specification) which allows you to change some of the basic simulation parameters without changing the code. In example1.rc, the application is configured to take 2000 time steps of size dt = 1.0 x 10-4 .

We will now integrate forward in time and try to view the output of the code.

  1. $ cd $PDE_STUDENT_SRC/components

  2. In developing the PDE toolkit, we've added a user ``test'' to the build system, as described in Section 3.6. This allows us to easily run the application with the command

    $ make USER_TESTS=example1.rc example1.rc

    The simulation takes a few moments to execute, but at the end of the output from your make command, you should see messages similar to:

    Test script: /san/homedirs/bernhold/tutorial-src/obj/pde/components/tests/example1.rc
    SUCCESS:
    ==> Test passed, go command(s) executed successfully (see /san/homedirs/bernhold/tutorial-src/obj/pde/components/tests/example1.rc.log).
    

  3. While the build scripts are designed to check and report whether or not the test completed successfully, it is a good idea to double check the log file until you become confident with the CCA and the particular application.

    Notice that the messages from the build system indicate where the log of the test is located (in this case $PDE_STUDENT_SRC/components/tests/example1.rc.log). Edit it, and jump to the bottom to confirm that it appears to have executed correctly.

    What you're seeing in this log is the output of the Ccaffeine session in which the application was run. So you see the stdout and stderr streams from the application and from Ccaffeine itself.

    A message that is repeated throughout the log hints at an interesting point about the CCA that we haven't discussed yet:

    !Info: Requested uses port dump in component RHSCombiner is not connected.
    
    (and similarly for the reaction port). A CCA component can use and provide whatever ports it wants, and use them in whatever way it considers appropriate. For example, a component may consider some port connections as ``optional'' - to be used if the port is connected, but if there is no connection, the component can do its job in some other way. In this case, the RHSCombiner component can use a NamedPatchPort (which it refers to as dump) to expose internal data for debugging or visualization purposes. But if it is not connected, the component skips those logging activities.

  4. The application has also left us some more interesting and informative output in the directory in which we ran it ($PDE_STUDENT_SRC/components). You should see files with names like driver.ex1.step.1100.out.0,4.1 which were dumped every 100 time steps by the application. These files are designed to be viewed using gnuplot (other visualization components are under development).

    Image noteNote

    If you're working remotely from the machine where you are running Ccaffeine , you'll need to have an X11 server on your local machine in order to view the simulation results using gnuplot. Linux/unix and Mac users may need to make sure that the X11 protocol is being tunneled through their ssh connection (see Appendix D.2). Windows users will need to run an X11 server (unfortunately, we have no documentation for that yet).

    Let's gnuplot and then use it to explore the simulation output a little:

    $ gnuplot

    1. We've created an input file for gnuplot that sets up a reasonable way to view the output from this application. To load it, type  load 'tests/show.gp' at the ``gnuplot>'' prompt. You should see two ``hot spots'' which were part of the initial conditions given for this run.

    2. To view other time steps (for example step 1500), enter a command like  splot 'driver.ex1.step.1500.out' u 1:2:4 at the ``gnuplot>'' prompt. Notice that the hot spots diffuse away over time.

      The triplet 1:2:4 at the end of the command line above tells gnuplot to use columns 1, 2, and 4 of the data file. The data file contains five columns of numbers: x , y , $ \phi_{{0}}^{}$ (temperature), $ \phi_{{1}}^{}$ (reactant), and $ \phi_{{2}}^{}$ (product). So you can view other fields by changing the final element of the triplet.

  5. Now we will run another simulation by modifying the parameters in $PDE_STUDENT_SRC/components/tests/example1.rc and re-running the simulation as in Step 2. Use the procedures of Step 4 to view the results.

    Try changing the time step dt. Note that Changing the time step without corresponding changes to the mesh resolutions (parameters NX and NY) will cause the time integration algorithm to become unstable at some point, giving incorrect results. For example, with dt set to 102 instead of 10-4 , the system will rapidly become unstable, and you will see the boundaries of the regions of high reactant concentration ( \bgroup\color{black}$ \phi_{{1}}^{}$\egroup ) become jagged instead of smooth, and may cease to be simply connected. Also, to minimum and maximum values of \bgroup\color{black}$ \phi_{{1}}^{}$\egroup will grow without bound with time.

  6. Finally, we will modify the application itself. Once again, edit $PDE_STUDENT_SRC/components/tests/example1.rc. First, restore the Driver parameters to their original values (see Appendix B if you've forgotten them). The uncomment the line that connects the RHSCombiner to the Reaction component. This changes the simulation from a pure diffusion problem to a reaction-diffusion problem. If you run this experiment and view the output, you should see traveling waves as shown in Fig. 4.3.

    Figure 4.3: Traveling wave solution at t = 0, 700$ \Delta$t , 1200 $ \Delta$t and 1600$ \Delta$t , where $ \Delta$t is 10-4 (Step 6
    Image hp_tw_ic Image hp_tw_t700
    Image hp_tw_t1200 Image hp_tw_t1600

2010-08-11