Warp can be run interactively or non-interactively from the same installation. In this section we assume that Warp has been installed as described in the Installation How To. In addition to specific Warp functions and variables used to setup and describe the problem which are detailed in the code documentation, the full programming power of python with efficient numerical extensions provided by NumPy are available for use in setting up simulations and the graphics package pygist is available for formulating diagnostics. Extensive documentation for python, NumPy, and pygist can be found online (see linked web pages above) and are not covered here. Basic functions of pygist within the context it is employed in Warp are outlined in Basic Plotting.
In subsections below we first cover Interactive Runs and Non-Interactive Runs of Warp in the serial mode using a simple example "simulation" to create an x-y plot. The examples in these two subsections are not simulations but they provide a simple way to understand how to execute the code and obtain documentation. Next, the subsection Warp Simulation Script Outline provides a basic organizational schematic of a typical Warp simulation script. Details of simulation script elements are provided in the various How To's on this site. There are example input scripts provided on this site that can be adapted to simulate a wide variety of problems. Finally, the subsection Command Line Arguments covers passing run options into Warp.
First execute python in a terminal window and import Warp within python.
Subsequent commands can then be entered in python to describe and advance a simulation by setting and using Warp variables and functions described in other How To's. Basic information on Warp commands can be obtained by executing the documentation function:
provide more information on fortran subroutines accessible via python and python scripts. Further information on a particular Warp variable, linked fortran function name(), or python script name.py can be found by:
For documentation on python scripts and linked fortran functions, the quotes are often not necessary. More information can be obtained on a python script name.py by:
Commands making up a Warp simulation are often saved in a script file created with a text editor to be read into Warp. Examples of scripts used to generate Warp simulations can be found in Example simulation scripts. Here, we illustrate how the basic procedure can be carried out several ways with a simple example "runs" to produce an x-y plot. This example also helps illustrate how Warp diagnostic plots made in a run are typically saved. First, consider a run making an x-y plot with gist graphics via the commands in a file plot.py containing the following lines:
More information on the x-y plotting commands above can be found in Basic Plotting.
Executing the script
creates a cgm output file plot.000.cgm containing the plot in the directory which python is run. Because of the "-i" option, after the commands in plot.py are executed, the Python prompt is given, allowing further operations. More commands can be entered or python can then be quit with [ctrl-d] to terminate the run. The file plot.000.cgm contains the x-y plot frame which can be viewed with a cgm viewer as explained in Basic Plotting. 000 is an automatically generated output number which is incremented by one from the last value each time the script is run.
The same simple x-y plot script plot.py described above in the subsection Interactive Runs can be executed non-interactively by:
In this case the python process will terminate after execution of plot.py. Such commands can be submitted in batch mode with the specific synatax depending on the operating system used.
Warp Simulation Script Outline
Details of simulation setup vary widely since Warp python scripts and linked source code modules can be applied with tremendous flexibility to a wide range of problems. Even a common physical problem can be described by a broad range of setup approaches and numerical procedures within Warp. Details of simulation components are provided in the various How To's (see sidebar) on this site. Several example simulation scripts are provided to provide a template for a range of simulations. These can be adapted to specific problems using information in the How To's. If necessary, members of the Warp development team can be contacted for advice.
Below we functionally outline a basic 3D simulation script saved in a file, say script.py which can be created an modified with a standard text editor:
Details can differ significantly and there is no strict order that must be adhered to.
This script can be run interactively
as described in the previous subsections.
Several types of runs are possible including 3D, r-z, transverse x-y slide, and envelope simulations. Details of the setup may vary for each class of run. For example, for other than envelope model runs, an appropriate field solver and spatial mesh must be setup. In many cases, different classes of runs are possible to carry out with minimal modifications between 3D, r-z, and x-y slice simulations. An appropriate package() call must be made before the code is generated:
Usually, outside of the envelope solver, only one call to generate() can be made within a single Warp run. Usually when a r-z run is done, the w3d package is used: the particles are moved in 3D and an r-z axisymmetric field solver and mesh is setup for the particle deposition and fieldsolve. Warp also has several other packages not listed here to keep the discussion simple.
Command Line Arguments
Warp accepts several command line arguments, as described here.
User specified command line arguments can be added by defining them at the top of the input file before importing warp. For example, the following sets up the command line argument myarg:
The specified value can then be accessed in the input file after importing warp.
Then, Warp can be started with the defined command line option.
See the optparse module for a full description of the add_option command - there is much flexibility.