With the advent of v7.0 of Xppaut, it is now possible to dynamically create graphics and export the results to image files during a batch run or using the command line interface. In this tutorial we will show how to use Snifflib's Xppaut interface to publish a flipbook style animation to the web. For the purposes of this demonstration we'll be using a Groovy script, but you can use similar syntax in your own JAVA or MATLAB programs (Note: To review these various approaches see Basic Usage).
To get started, be sure you have Groovy installed on your system and that you have placed a copy of the lastest Snifflib library (.jar) into your ~/.groovy/lib folder. Then, open groovyConsole and enter the following commands.
import com.mockturtlesolutions.snifflib.datatypes.DblMatrix;
import com.mockturtlesolutions.snifflib.xppauttools.database.*;
import com.mockturtlesolutions.snifflib.vistools.ImageStack;
import java.io.File;
//Change this path to suit your username & system.
myodefile = new File("/home/jdoe/lecar.ode");
myode = new XppOdeDOM(myodefile);
extracmds = new String("-silent -quiet 1 -mkplot -plotfmt svg -ncdraw 1 -dfdraw 3");
iapp = DblMatrix.span(0.0,0.5,10);
images = new ImageStack();
for (int k=0;k<iapp.getN();k++)
{
myode.setXppParameter("iapp",iapp.getDoubleAt(k).doubleValue());
result = myode.execXpp(extracmds);
images.addImageFile(result.getOdeFile().getAbsolutePath()+".svg");
}
//Change this path to suit your username & system.
images.writeAsJavascriptHTML(new File("/home/jdoe/lecar_anim"));
View the resulting animation here. (Note: May appear slowly in some browsers.)
In the above code, the line
extracmds = new String("-silent -quiet 1 -mkplot -plotfmt svg -ncdraw 1 -dfdraw 3");
tells Xppaut to export graphics and that the exported file format should be SVG. (Note: The other currently supported option is ps which produces postscript.) Nullclines will also be automatically determined (if possible) and a direction field representation generated. The possible options for dfdraw and their meanings are
The number (density) of the direction field can be controlled by setting the dfgrid @-option in lecar.ode file or, more permanently, in your .xpprc file.
The above code also uses the ImageStack class to progressively build-up the flipbook of images and then to finally publish an HTML+Javascript web page containing the animation.