Warp can be run interactively or non-interactively from an installation of Warp with the python scripts and compiled source code making up Warp properly linked with python. In this section we assume that Warp has been installed and properly linked with python 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 really 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. When information in the How To's are adequately understood, example input scripts provided on this site 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 load 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. In documentation following this subsection, the python prompt ">>>" will subsequently be dropped for brevity, but the shell prompt "%" will generally be used for clarity. 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:More information on the x-y plotting commands above can be found in Basic Plotting.
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:
Executing the script
creates a cgm output file plot.000.cgm containing the plot in the directory which python is run and after the commands in plot.py are executed, the user in remains in interactive control of Warp via the open python interface. More commands can be entered or python can then be quit, as usual, by [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 if the script is run successively.
Alternatively, the x-y plot script could also be interactively run by opening python and reading in the commands via the python command execfile() using:
Such procedures can be useful for reading in code to debug.
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 on execution of plot.py and subsequent Warp commands cannot be entered. Such commands can be submitted in batch mode with the specific synatax depending on the operating system used.
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.
Warp accepts several command line arguments, as described here.
User specified command line arguments can be setup 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.