Although Garfield can be run in batch mode, it is easier to run it from a workstation or graphics terminal. You should be able to issue any combinations of commands without causing core dumps, abends etc. (please contact me if this nevertheless happens !).
A simple example to start with:
& CELL plane x -1 plane y -1 rows S 5 * i i 1000*i& FIELD plot surf V, contour V
More elaborate examples examples of the use of Garfield can be found on WWW.
The program is structured in a set of so-called sections (cell, gas, magnetic, optimise, field, drift and signal) that each contain a set of instructions performing certain tasks. The cell section e.g. will read the cell description, the field section offers facilities for plotting the field etc. The sections are headed by a line starting with an ampersand (&), &CELL and &FIELD start sections in the above example. You may insert one or more blanks between the & and the section name.
There is one special header: &STOP (or &QUIT or &EXIT if you prefer) which will stop program execution. End-Of-File on input will have the same effect.
The instructions within the sections are free format lines. Input files can be both fixed and variable record length. The maximum record length is large, about 500 characters.
An ellipsis (...) at the end of one physical line indicates that the instruction continues on the next. There can be only 1 instruction per input line.
The first word on each line is the command proper. The other words can be viewed as a set of parameters, with sometimes a value assigned to them.
The elements on the input are separated from each other by a blanc ( ), a comma (,), a colon (:) or an equal sign (=). There is no difference in meaning between these separators. You may if you wish place several between the words.
Case is irrelevant in commands. Strings of which the case matters, such as file names on Unix systems and also in identifiers, should be delimited by double quotes.
Here is an example of a cell description:
&CELL plane x=10, V=1000 plane x -10 ... V 1000 periodicity y 3 rows S * * 0 0 5000cell-identifier "Test cell"
The words PLANE, PERIODICITY, ROWS and CELL-IDENTIFIER are the commands. The command "PLANE" has two arguments with a value for each. You may if you wish invert their order without affecting the meaning of the command:
PLANE V=1000 X=10
This is true in general - exceptions are explicitly stated. PLANE, like most commands, can have more arguments. If no value is given, defaults are used for these, if a meaningful default is available.
The ROWS command has a slighly different syntax from the rest: apart from having arguments of its own (not shown in the example), it is followed by a series of lines (1 in this example) that contain the actual data. The end of the list is signaled by a blank line. There is one more such command in the cell section (SOLIDS) and there are also a few commands of this type in the gas section (CLUSTER and TABLE).
Nearly all words in the input may be abbreviated to some extent in each of the 'segments':
E-MOST-PROBABLE & CELL PLANE E-MOST-PROB &CELL PLAN E-M-PROB &C PL
Garfield does not pretend to be programmable, but Do_loops and conditional execution of statements (If_lines and If_blocks) exist. For clarity, all control statements are shown with initial capital in the documentation. Here is an example:
Global ok False Until ok Do Say "Please enter an integer number" Parse Terminal n If n<0 Then Say "The number you entered, {n}, is negative." Iterate Elseif entier(n)#n Then Say "The number you entered, {n}, is not an integer" Iterate Endif Global fac=1 For i From 1 To n Do Global fac=fac*i Enddo Say "Factorial of {n} is {fac}." Global ok True Enddo
A large collection of procedures, mainly in the areas of field and drift line calculation, are available - and they are more and more widely used. They are described under Call.
After a little practice, you should become aware of the utility commands. They can be used to change the graphics settings, to issue commands to the shell (Aegis, DCL, Unix or VM/CMS), to take input from and to output data to files etc.
Character | Description | Example |
---|---|---|
&
| Start of a new section | & CELL
|
!
| graphics commands | ! REP DR-L POLYL-COL RED
|
%
| dataset commands | % DIR TEST.DAT
|
<
| input from a file | < CELL.INPUT
|
>
| output to a file | > OUTPUT.LIS
|
>>
| recording of terminal input | >> record.dat
|
$
| shell commands | $ SHOW TIME
|
*
| comment line | * Modified DC1 cell
|
?
| Enter the help facility | ? &OPTIMISE SET
|
@
| algebra commands | @
|
Some characters have a special meaning when used inside commands:
Character | Description | Example |
---|---|---|
*
| Default value | AREA * -2 * 2
|
*
| Wildcard | GET CELL.DAT PL*
|
@
| Enter the algebra editor | PLOT CONT @ HIST E
|
\
| Escape character | \{abc\}
|
...
| Continuation lines | PLANE X ...
|
{ ... }
| Formula evaluation | Say "Two x pi={2*pi}"
|
[ ... ]
| Matrix indexing | Global a=b[2;]
|
' ... '
| Keep string together | get 'cell lib d'
|
" ... "
| Like '' but preserve case | get "/cell/lib/dc1"
|
` ... `
| Algebra string delimiters | Parse Input . `phi=` phi
|
Examples:
Global a=cos(2*pi/3) Call print(1+2*(3+4))
Example:
Global a=number(b[3;3])
Curly brackets must not be used in control statements.
Example:
Global argon=80 Global co2=20 Global gas_file=`Ar`/string(argon)/`CO2`/string(co2) Call inquire_file(gas_file) If exist Then get {gas_file} Else magboltz argon {argon} co2 {co2} heed argon {argon} co2 {co2} add mobility 1.5e-6 write {gas_file} Endif
Please note that curly brackets are used only in the GET, WRITE, MAGBOLTZ and HEED statements - these are commands, not control statements. Curly brackets are not used when the global variable GAS_FILE is used as argument of the INQUIRE_FILE procedure. Similarly, EXIST is not enclosed in curly brackets in the If-condition. When ARGON and CO2 are used without brackets in the Global statement, but with curly brackets in MAGBOLTZ and Heed.
Examples:
Say "Hello, how are you doing ?" arrival dataset "arrival.dat"
Example:
Call threshold_crossing(1,-0.02,`rising,linear`,n,t1,t2) If 'n=0' Then Say "Warning: No crossing found." Iterate Endif
The condition of If_lines and If_blocks must be a single word which must moreover be in upper case. In the example, an equal sign is used in the condition. Since equal signs are treated like commas and blanks, the condition without quotes would be read as 2 words: "n" and "0". We could also have typed:
If "N=0" Then
Example:
Global argon=80 Global co2=20 Global gas_file=`Ar`/string(argon)/`CO2`/string(co2)
A file name is contructed from the percentages of Ar and CO2.
Text strings, such as formulae, that should not be broken up but which contain a word separator, should be put between single or double quotes. The string is converted to upper case when single quotes are used, while the case is preserved with double quotes.
Please contact the author in case of trouble and if you need further information, have suggestions for extensions etc. In case you suspect a bug, send the following:
A common source of problems is the use of a manual that is out of date. As a rule, it is better to consult the help file via WWW for up to date information concerning the commands:
http://consult.cern.ch/writeup/garfield/cnl for modifications http://consult.cern.ch/writeup/garfield/examples for examples http://consult.cern.ch/writeup/garfield/files for the files http://consult.cern.ch/writeup/garfield/help for help
Magboltz is the work of Steve Biagi.
Most of Garfield has been written by Rob Veenhof (referred to as 'I' or 'me' in the documentation). The best way to contact me is by electronic mail.
If you prefer more traditional means:
Rob Veenhof Rob Veenhof CERN / PPE-division 2, Rue du Reculet CH-1211 Geneve 23 F-01630 St Genis-Pouilly Suisse France tel: + 41 22 7671156 tel: + 33 4 50421784
A prompt response can not be guaranteed because maintaining this program is not part of my regular work, but I do my best.
For technical questions and remarks about the control-C mechanism and other typical Vax features, please contact Carlo Mekenkamp directly (cmekenkamp@vx8000.nl).
G.A. Erskine contributed key ideas but he should not be called in case of problems. Please contact me in case of questions about his parts (theta functions, polygone mappings).
Since then, the program has grown enormously:
In 1984 the program had a length of 5000 lines. In 1999 the main program (excluding Magboltz and Heed) counts 114000 lines (4.4 Mb).
Dimension | Input unit | Internal unit |
---|---|---|
angle | degree | radian |
B field | user has the choice | 100 G |
charge | electron charge | 1.6e-19 C |
current | micro Ampere | 1e-18 A |
energy | eV [Garfield] or MeV [Heed] | eV or MeV |
length | centimeter | cm |
potential | Volt | V |
pressure | user has the choice | Torr |
temperature | user has the choice | K |
time | micro second | micro sec |
weight | grams | g |
wire charge | - | 1/V |
When the input unit is shown as "user has the choice", then the quantity can, on input, be followed by a unit of the users choice. If no unit is indicated, then internal units are assumed.
To convert the wire charge into the more usual units of C/cm, one should multiply the charge obtained from procedures such as GET_WIRE_DATA with 2 pi epsilon0, approximately 5.56e-13 F/cm. The wire charge shown in the table printed in response to the CELL-PRINT option and the PRINT-CELL command includes this conversion factor.
http://consult.cern.ch/writeup/garfield/files
Executables at CERN can be found on AFS in the PaRC area, and also in the author's private area:
/afs/cern.ch/project/parc/bin/garfield /afs/cern.ch/user/r/rjd/Garfield/Files/garfield
Formatted on 15/01/01 at 23:07.